From a249d85c0e727d8251102e13aa179f64d5f8dbf7 Mon Sep 17 00:00:00 2001 From: kamakshidasan Date: Thu, 22 Dec 2016 15:42:26 +0530 Subject: Rearrange folders --- Queue.js | 2 - blocks/3DSCOPE.svg | 9 - blocks/ANDBLK.svg | 34 - blocks/ASCOPE.svg | 31 - blocks/BACHE.svg | 27 - blocks/BARXY.svg | 23 - blocks/BPLATFORM.svg | 15 - blocks/CCS.svg | 7 - blocks/CLOCK_c.svg | 13 - blocks/CLOCK_f.svg | 12 - blocks/CSCOPXY.svg | 150 - blocks/CSCOPXY3D.svg | 162 - blocks/CVS.svg | 5 - blocks/Capacitor.svg | 10 - blocks/ConstantVoltage.svg | 24 - blocks/CurrentSensor.svg | 37 - blocks/DEADBAND.svg | 6 - blocks/DSCOPE.svg | 39 - blocks/Diode.svg | 7 - blocks/Flowmeter.svg | 37 - blocks/Ground.svg | 7 - blocks/Gyrator.svg | 14 - blocks/HYSTHERESIS.svg | 8 - blocks/INTEGRAL.svg | 14 - blocks/IdealTransformer.svg | 23 - blocks/Inductor.svg | 14 - blocks/NMOS.svg | 69 - blocks/NPN.svg | 51 - blocks/PMOS.svg | 65 - blocks/PNP.svg | 51 - blocks/PRODUCT.svg | 4 - blocks/PULSE_SC.svg | 7 - blocks/PerteDP.svg | 44 - blocks/PotentialSensor.svg | 51 - blocks/PuitP.svg | 44 - blocks/QUANT_f.svg | 6 - blocks/RAMP.svg | 7 - blocks/Resistor.svg | 51 - blocks/SATURATION.svg | 6 - blocks/SINUS_f.svg | 15 - blocks/SQUARE_WAVE_f.svg | 8 - blocks/STEP_FUNCTION.svg | 7 - blocks/SUM.svg | 4 - blocks/SUPER.svg | 49 - blocks/SWITCH.svg | 11 - blocks/SampleCLK.svg | 14 - blocks/Self_Switch_off.svg | 77 - blocks/Self_Switch_on.svg | 73 - blocks/SourceP.svg | 59 - blocks/VanneReglante.svg | 58 - blocks/VariableResistor.svg | 64 - blocks/VirtualCLK0.svg | 13 - blocks/VoltageSensor.svg | 35 - blocks/sawtooth.svg | 6 - chart.js | 133 - combined.js | 11264 ---- composer.json | 1 - config/keyhandler-commons.xml | 23 - css/common.css | 221 - css/explorer.css | 15 - data_structures_correct/ABS_VALUE.js | 29 - data_structures_correct/AFFICH_m.js | 33 - data_structures_correct/ANDBLK.js | 130 - data_structures_correct/ANDLOG_f.js | 50 - data_structures_correct/AUTOMAT.js | 38 - data_structures_correct/BACKLASH.js | 21 - data_structures_correct/BARXY.js | 30 - data_structures_correct/BIGSOM_f.js | 24 - data_structures_correct/BITCLEAR.js | 23 - data_structures_correct/BITSET.js | 24 - data_structures_correct/BOUNCE.js | 51 - data_structures_correct/BOUNCEXY.js | 50 - data_structures_correct/BPLATFORM.js | 34 - data_structures_correct/Bache.js | 46 - data_structures_correct/CANIMXY.js | 36 - data_structures_correct/CANIMXY3D.js | 39 - data_structures_correct/CBLOCK.js | 44 - data_structures_correct/CBLOCK4.js | 27 - data_structures_correct/CCS.js | 58 - data_structures_correct/CEVENTSCOPE.js | 27 - data_structures_correct/CFSCOPE.js | 29 - data_structures_correct/CLINDUMMY_f.js | 20 - data_structures_correct/CLKFROM.js | 20 - data_structures_correct/CLKGOTO.js | 22 - data_structures_correct/CLKGotoTagVisibility.js | 27 - data_structures_correct/CLKINV_f.js | 42 - data_structures_correct/CLKOUTV_f.js | 42 - data_structures_correct/CLKSOMV_f.js | 33 - data_structures_correct/CLKSOM_f.js | 19 - data_structures_correct/CLOCK_c.js | 95 - data_structures_correct/CLR.js | 27 - data_structures_correct/CLSS.js | 30 - data_structures_correct/CMSCOPE.js | 73 - data_structures_correct/CONST.js | 26 - data_structures_correct/CONSTRAINT2_c.js | 27 - data_structures_correct/CONSTRAINT_c.js | 25 - data_structures_correct/CONST_f.js | 25 - data_structures_correct/CONST_m.js | 61 - data_structures_correct/CONVERT.js | 31 - data_structures_correct/COSBLK_f.js | 20 - data_structures_correct/CSCOPE.js | 32 - data_structures_correct/CSCOPXY.js | 37 - data_structures_correct/CSCOPXY3D.js | 36 - data_structures_correct/CUMSUM.js | 35 - data_structures_correct/CURV_f.js | 27 - data_structures_correct/CVS.js | 58 - data_structures_correct/Capacitor.js | 31 - data_structures_correct/ConstantVoltage.js | 32 - data_structures_correct/Counter.js | 28 - data_structures_correct/CurrentSensor.js | 29 - data_structures_correct/DEADBAND.js | 27 - data_structures_correct/DEBUG.js | 18 - data_structures_correct/DELAYV_f.js | 31 - data_structures_correct/DELAY_f.js | 121 - data_structures_correct/DEMUX.js | 28 - data_structures_correct/DEMUX_f.js | 27 - data_structures_correct/DERIV.js | 20 - data_structures_correct/DFLIPFLOP.js | 2016 - data_structures_correct/DIFF_f.js | 24 - data_structures_correct/DLATCH.js | 609 - data_structures_correct/DLR.js | 30 - data_structures_correct/DLRADAPT_f.js | 32 - data_structures_correct/DLSS.js | 30 - data_structures_correct/DOLLAR.js | 27 - data_structures_correct/DOLLAR_f.js | 27 - data_structures_correct/DOLLAR_m.js | 27 - data_structures_correct/Diode.js | 36 - data_structures_correct/EDGETRIGGER.js | 25 - data_structures_correct/EDGE_TRIGGER.js | 114 - data_structures_correct/ENDBLK.js | 106 - data_structures_correct/END_c.js | 24 - data_structures_correct/ESELECT_f.js | 29 - data_structures_correct/EVTDLY_c.js | 49 - data_structures_correct/EVTDLY_f.js | 23 - data_structures_correct/EVTGEN_f.js | 22 - data_structures_correct/EVTVARDLY.js | 25 - data_structures_correct/EXPBLK_m.js | 28 - data_structures_correct/EXTRACT.js | 35 - data_structures_correct/EXTRACTBITS.js | 27 - data_structures_correct/EXTRACTOR.js | 24 - data_structures_correct/EXTTRI.js | 35 - data_structures_correct/Extract_Activation.js | 129 - data_structures_correct/FROM.js | 29 - data_structures_correct/FROMMO.js | 33 - data_structures_correct/FROMWSB.js | 164 - data_structures_correct/Flowmeter.js | 61 - data_structures_correct/GAINBLK.js | 30 - data_structures_correct/GAINBLK_f.js | 26 - data_structures_correct/GAIN_f.js | 26 - data_structures_correct/GENERAL_f.js | 29 - data_structures_correct/GENSIN_f.js | 26 - data_structures_correct/GENSQR_f.js | 25 - data_structures_correct/GOTO.js | 28 - data_structures_correct/GOTOMO.js | 33 - data_structures_correct/GotoTagVisibility.js | 30 - data_structures_correct/GotoTagVisibilityMO.js | 29 - data_structures_correct/Ground.js | 30 - data_structures_correct/Gyrator.js | 57 - data_structures_correct/HALT_f.js | 24 - data_structures_correct/HYSTHERESIS.js | 29 - data_structures_correct/IFTHEL_f.js | 60 - data_structures_correct/INIMPL_f.js | 31 - data_structures_correct/INTEGRAL_f.js | 24 - data_structures_correct/INTEGRAL_m.js | 29 - data_structures_correct/INTMUL.js | 29 - data_structures_correct/INTRP2BLK_f.js | 27 - data_structures_correct/INTRPLBLK_f.js | 26 - data_structures_correct/INVBLK.js | 23 - data_structures_correct/IN_f.js | 52 - data_structures_correct/ISELECT_m.js | 35 - data_structures_correct/IdealTransformer.js | 60 - data_structures_correct/Inductor.js | 34 - data_structures_correct/JKFLIPFLOP.js | 897 - data_structures_correct/LOGBLK_f.js | 25 - data_structures_correct/LOGIC.js | 30 - data_structures_correct/LOGICAL_OP.js | 26 - data_structures_correct/LOOKUP_f.js | 21 - data_structures_correct/MATBKSL.js | 35 - data_structures_correct/MATCATH.js | 35 - data_structures_correct/MATCATV.js | 36 - data_structures_correct/MATDET.js | 36 - data_structures_correct/MATDIAG.js | 35 - data_structures_correct/MATDIV.js | 37 - data_structures_correct/MATEIG.js | 35 - data_structures_correct/MATEXPM.js | 34 - data_structures_correct/MATINV.js | 35 - data_structures_correct/MATLU.js | 35 - data_structures_correct/MATMAGPHI.js | 35 - data_structures_correct/MATMUL.js | 24 - data_structures_correct/MATPINV.js | 36 - data_structures_correct/MATRESH.js | 35 - data_structures_correct/MATSING.js | 36 - data_structures_correct/MATSUM.js | 35 - data_structures_correct/MATTRAN.js | 23 - data_structures_correct/MATZCONJ.js | 35 - data_structures_correct/MATZREIM.js | 34 - data_structures_correct/MAXMIN.js | 23 - data_structures_correct/MAX_f.js | 24 - data_structures_correct/MBLOCK.js | 45 - data_structures_correct/MCLOCK_f.js | 139 - data_structures_correct/MFCLCK_f.js | 50 - data_structures_correct/MIN_f.js | 24 - data_structures_correct/MUX.js | 26 - data_structures_correct/MUX_f.js | 26 - data_structures_correct/M_SWITCH.js | 26 - data_structures_correct/M_freq.js | 24 - data_structures_correct/Modulo_Count.js | 46 - data_structures_correct/NEGTOPOS_f.js | 22 - data_structures_correct/NMOS.js | 40 - data_structures_correct/NPN.js | 56 - data_structures_correct/NRMSOM_f.js | 24 - data_structures_correct/OUTIMPL_f.js | 33 - data_structures_correct/OUT_f.js | 53 - data_structures_correct/OpAmp.js | 34 - data_structures_correct/PDE.js | 24 - data_structures_correct/PID.js | 626 - data_structures_correct/PNP.js | 63 - data_structures_correct/POSTONEG_f.js | 24 - data_structures_correct/POWBLK_f.js | 25 - data_structures_correct/PRODUCT.js | 23 - data_structures_correct/PROD_f.js | 19 - data_structures_correct/PULSE_SC.js | 381 - data_structures_correct/PerteDP.js | 41 - data_structures_correct/PotentialSensor.js | 31 - data_structures_correct/PuitsP.js | 34 - data_structures_correct/QUANT_f.js | 26 - data_structures_correct/RAMP.js | 29 - data_structures_correct/RAND_m.js | 39 - data_structures_correct/RATELIMITER.js | 26 - data_structures_correct/READAU_f.js | 33 - data_structures_correct/READC_f.js | 39 - data_structures_correct/REGISTER.js | 26 - data_structures_correct/REGISTER_f.js | 28 - data_structures_correct/RELATIONALOP.js | 26 - data_structures_correct/RELAY_f.js | 28 - data_structures_correct/RFILE_f.js | 36 - data_structures_correct/RICC.js | 35 - data_structures_correct/ROOTCOEF.js | 35 - data_structures_correct/Resistor.js | 33 - data_structures_correct/SAMPHOLD_m.js | 27 - data_structures_correct/SATURATION.js | 28 - data_structures_correct/SAWTOOTH_f.js | 23 - data_structures_correct/SCALAR2VECTOR.js | 23 - data_structures_correct/SELECT_m.js | 35 - data_structures_correct/SELF_SWITCH.js | 30 - data_structures_correct/SHIFT.js | 30 - data_structures_correct/SIGNUM.js | 25 - data_structures_correct/SINBLK_f.js | 22 - data_structures_correct/SOM_f.js | 24 - data_structures_correct/SQRT.js | 24 - data_structures_correct/SRFLIPFLOP.js | 439 - data_structures_correct/STEP_FUNCTION.js | 79 - data_structures_correct/SUBMAT.js | 38 - data_structures_correct/SUMMATION.js | 25 - data_structures_correct/SUM_f.js | 25 - data_structures_correct/SUPER_f.js | 42 - data_structures_correct/SWITCH2_m.js | 33 - data_structures_correct/SWITCH_f.js | 48 - data_structures_correct/SampleCLK.js | 22 - data_structures_correct/Sigbuilder.js | 272 - data_structures_correct/SineVoltage.js | 38 - data_structures_correct/SourceP.js | 36 - data_structures_correct/Switch.js | 42 - data_structures_correct/TANBLK_f.js | 23 - data_structures_correct/TCLSS.js | 34 - data_structures_correct/TEXT_f.js | 25 - data_structures_correct/TIME_DELAY.js | 28 - data_structures_correct/TIME_f.js | 18 - data_structures_correct/TKSCALE.js | 26 - data_structures_correct/TOWS_c.js | 33 - data_structures_correct/TRASH_f.js | 23 - data_structures_correct/TrigFun.js | 21 - data_structures_correct/VARIABLE_DELAY.js | 28 - data_structures_correct/VVsourceAC.js | 39 - data_structures_correct/VanneReglante.js | 37 - data_structures_correct/VariableResistor.js | 29 - data_structures_correct/VirtualCLK0.js | 22 - data_structures_correct/VoltageSensor.js | 29 - data_structures_correct/VsourceAC.js | 37 - data_structures_correct/WRITEAU_f.js | 31 - data_structures_correct/WRITEC_f.js | 31 - data_structures_correct/ZCROSS_f.js | 29 - data_structures_correct/c_block.js | 33 - data_structures_correct/combine_script.bat | 1 - data_structures_correct/fortran_block.js | 29 - data_structures_correct/freq_div.js | 146 - data_structures_correct/generic_block3.js | 25 - data_structures_correct/scifunc_block_m.js | 43 - dependencies.js | 1497 - details.js | 643 - documentation/servlet.md | 4 - documentation/wires.md | 82 - filenames.php | 27 - finalmodsheet.xsl | 2192 - highcharts/highcharts.js | 347 - history/blocks_xcos/ABS_VALUE.xcos | 37 - history/blocks_xcos/AFFICH_m.xcos | 60 - history/blocks_xcos/ANDBLK.xcos | 1355 - history/blocks_xcos/ANDLOG_f.xcos | 38 - history/blocks_xcos/AUTOMAT.xcos | 66 - history/blocks_xcos/BACKLASH.xcos | 42 - history/blocks_xcos/BARXY.xcos | 51 - history/blocks_xcos/BIGSOM_f.xcos | 43 - history/blocks_xcos/BITCLEAR.xcos | 42 - history/blocks_xcos/BITSET.xcos | 42 - history/blocks_xcos/BOUNCE.xcos | 67 - history/blocks_xcos/BOUNCEXY.xcos | 71 - history/blocks_xcos/BPLATFORM.xcos | 57 - history/blocks_xcos/Bache.xcos | 108 - history/blocks_xcos/CANIMXY.xcos | 67 - history/blocks_xcos/CANIMXY3D.xcos | 88 - history/blocks_xcos/CBLOCK.xcos | 53 - history/blocks_xcos/CBLOCK4.xcos | 58 - history/blocks_xcos/CCS.xcos | 61 - history/blocks_xcos/CEVENTSCOPE.xcos | 49 - history/blocks_xcos/CFSCOPE.xcos | 65 - history/blocks_xcos/CLINDUMMY_f.xcos | 32 - history/blocks_xcos/CLKFROM.xcos | 35 - history/blocks_xcos/CLKGOTO.xcos | 38 - history/blocks_xcos/CLKGotoTagVisibility.xcos | 35 - history/blocks_xcos/CLKINV_f.xcos | 28 - history/blocks_xcos/CLKOUTV_f.xcos | 28 - history/blocks_xcos/CLKSOMV_f.xcos | 41 - history/blocks_xcos/CLOCK_c.xcos | 738 - history/blocks_xcos/CLR.xcos | 46 - history/blocks_xcos/CLSS.xcos | 49 - history/blocks_xcos/CMAT3D.xcos | 125 - history/blocks_xcos/CMATVIEW.xcos | 121 - history/blocks_xcos/CMSCOPE.xcos | 70 - history/blocks_xcos/CONST.xcos | 36 - history/blocks_xcos/CONSTRAINT2_c.xcos | 54 - history/blocks_xcos/CONSTRAINT_c.xcos | 43 - history/blocks_xcos/CONST_f.xcos | 36 - history/blocks_xcos/CONST_m.xcos | 36 - history/blocks_xcos/CONVERT.xcos | 41 - history/blocks_xcos/COSBLK_f.xcos | 35 - history/blocks_xcos/CSCOPE.xcos | 67 - history/blocks_xcos/CSCOPXY.xcos | 67 - history/blocks_xcos/CSCOPXY3D.xcos | 88 - history/blocks_xcos/CUMSUM.xcos | 38 - history/blocks_xcos/CURV_f.xcos | 49 - history/blocks_xcos/CVS.xcos | 61 - history/blocks_xcos/Capacitor.xcos | 76 - history/blocks_xcos/ConstantVoltage.xcos | 66 - history/blocks_xcos/Counter.xcos | 46 - history/blocks_xcos/CurrentSensor.xcos | 60 - history/blocks_xcos/DEADBAND.xcos | 42 - history/blocks_xcos/DEBUG.xcos | 37 - history/blocks_xcos/DELAYV_f.xcos | 66 - history/blocks_xcos/DELAY_f.xcos | 1182 - history/blocks_xcos/DEMUX.xcos | 42 - history/blocks_xcos/DEMUX_f.xcos | 42 - history/blocks_xcos/DERIV.xcos | 35 - history/blocks_xcos/DFLIPFLOP.xcos | 7807 --- history/blocks_xcos/DIFF_f.xcos | 42 - history/blocks_xcos/DLATCH.xcos | 2262 - history/blocks_xcos/DLR.xcos | 49 - history/blocks_xcos/DLRADAPT_f.xcos | 69 - history/blocks_xcos/DLSS.xcos | 52 - history/blocks_xcos/DOLLAR.xcos | 44 - history/blocks_xcos/DOLLAR_f.xcos | 44 - history/blocks_xcos/DOLLAR_m.xcos | 44 - history/blocks_xcos/Diode.xcos | 84 - history/blocks_xcos/EDGE_TRIGGER.xcos | 934 - history/blocks_xcos/ENDBLK.xcos | 340 - history/blocks_xcos/END_c.xcos | 37 - history/blocks_xcos/ESELECT_f.xcos | 45 - history/blocks_xcos/EVTDLY_c.xcos | 41 - history/blocks_xcos/EVTGEN_f.xcos | 34 - history/blocks_xcos/EVTVARDLY.xcos | 40 - history/blocks_xcos/EXPBLK_m.xcos | 39 - history/blocks_xcos/EXPRESSION.xcos | 63 - history/blocks_xcos/EXTRACT.xcos | 44 - history/blocks_xcos/EXTRACTBITS.xcos | 42 - history/blocks_xcos/EXTRACTOR.xcos | 39 - history/blocks_xcos/EXTTRI.xcos | 38 - history/blocks_xcos/Extract_Activation.xcos | 950 - history/blocks_xcos/FROM.xcos | 41 - history/blocks_xcos/FROMMO.xcos | 38 - history/blocks_xcos/FROMWSB.xcos | 571 - history/blocks_xcos/Flowmeter.xcos | 71 - history/blocks_xcos/GAINBLK.xcos | 39 - history/blocks_xcos/GAINBLK_f.xcos | 39 - history/blocks_xcos/GAIN_f.xcos | 41 - history/blocks_xcos/GENERAL_f.xcos | 43 - history/blocks_xcos/GENSIN_f.xcos | 40 - history/blocks_xcos/GENSQR_f.xcos | 40 - history/blocks_xcos/GOTO.xcos | 38 - history/blocks_xcos/GOTOMO.xcos | 41 - history/blocks_xcos/GotoTagVisibility.xcos | 35 - history/blocks_xcos/GotoTagVisibilityMO.xcos | 35 - history/blocks_xcos/Ground.xcos | 54 - history/blocks_xcos/Gyrator.xcos | 80 - history/blocks_xcos/HALT_f.xcos | 39 - history/blocks_xcos/HYSTHERESIS.xcos | 46 - history/blocks_xcos/IFTHEL_f.xcos | 44 - history/blocks_xcos/INIMPL_f.xcos | 47 - history/blocks_xcos/INTEGRAL_f.xcos | 40 - history/blocks_xcos/INTEGRAL_m.xcos | 44 - history/blocks_xcos/INTMUL.xcos | 43 - history/blocks_xcos/INTRP2BLK_f.xcos | 54 - history/blocks_xcos/INTRPLBLK_f.xcos | 43 - history/blocks_xcos/INVBLK.xcos | 37 - history/blocks_xcos/IN_f.xcos | 28 - history/blocks_xcos/ISELECT_m.xcos | 51 - history/blocks_xcos/IdealTransformer.xcos | 75 - history/blocks_xcos/Inductor.xcos | 66 - history/blocks_xcos/JKFLIPFLOP.xcos | 3446 -- history/blocks_xcos/LOGBLK_f.xcos | 39 - history/blocks_xcos/LOGIC.xcos | 51 - history/blocks_xcos/LOGICAL_OP.xcos | 43 - history/blocks_xcos/LOOKUP_f.xcos | 44 - history/blocks_xcos/MATBKSL.xcos | 40 - history/blocks_xcos/MATCATH.xcos | 40 - history/blocks_xcos/MATCATV.xcos | 40 - history/blocks_xcos/MATDET.xcos | 37 - history/blocks_xcos/MATDIAG.xcos | 37 - history/blocks_xcos/MATDIV.xcos | 40 - history/blocks_xcos/MATEIG.xcos | 38 - history/blocks_xcos/MATEXPM.xcos | 37 - history/blocks_xcos/MATINV.xcos | 37 - history/blocks_xcos/MATLU.xcos | 40 - history/blocks_xcos/MATMAGPHI.xcos | 40 - history/blocks_xcos/MATMUL.xcos | 42 - history/blocks_xcos/MATPINV.xcos | 37 - history/blocks_xcos/MATRESH.xcos | 39 - history/blocks_xcos/MATSING.xcos | 38 - history/blocks_xcos/MATSUM.xcos | 38 - history/blocks_xcos/MATTRAN.xcos | 37 - history/blocks_xcos/MATZCONJ.xcos | 35 - history/blocks_xcos/MATZREIM.xcos | 40 - history/blocks_xcos/MAXMIN.xcos | 41 - history/blocks_xcos/MAX_f.xcos | 41 - history/blocks_xcos/MBLOCK.xcos | 116 - history/blocks_xcos/MCLOCK_f.xcos | 1389 - history/blocks_xcos/MFCLCK_f.xcos | 48 - history/blocks_xcos/MIN_f.xcos | 41 - history/blocks_xcos/MUX.xcos | 42 - history/blocks_xcos/MUX_f.xcos | 42 - history/blocks_xcos/M_SWITCH.xcos | 48 - history/blocks_xcos/M_freq.xcos | 65 - history/blocks_xcos/Modulo_Count.xcos | 43 - history/blocks_xcos/NEGTOPOS_f.xcos | 40 - history/blocks_xcos/NMOS.xcos | 94 - history/blocks_xcos/NPN.xcos | 151 - history/blocks_xcos/NRMSOM_f.xcos | 40 - history/blocks_xcos/OUTIMPL_f.xcos | 47 - history/blocks_xcos/OUT_f.xcos | 28 - history/blocks_xcos/OpAmp.xcos | 60 - history/blocks_xcos/PDE.xcos | 244 - history/blocks_xcos/PID.xcos | 2403 - history/blocks_xcos/PMOS.xcos | 94 - history/blocks_xcos/PNP.xcos | 151 - history/blocks_xcos/POSTONEG_f.xcos | 40 - history/blocks_xcos/POWBLK_f.xcos | 39 - history/blocks_xcos/PRODUCT.xcos | 43 - history/blocks_xcos/PROD_f.xcos | 39 - history/blocks_xcos/PULSE_SC.xcos | 1370 - history/blocks_xcos/PerteDP.xcos | 84 - history/blocks_xcos/PotentialSensor.xcos | 58 - history/blocks_xcos/PuitsP.xcos | 71 - history/blocks_xcos/QUANT_f.xcos | 42 - history/blocks_xcos/RAMP.xcos | 40 - history/blocks_xcos/RAND_m.xcos | 50 - history/blocks_xcos/RATELIMITER.xcos | 41 - history/blocks_xcos/READAU_f.xcos | 82 - history/blocks_xcos/READC_f.xcos | 84 - history/blocks_xcos/REGISTER.xcos | 52 - history/blocks_xcos/RELATIONALOP.xcos | 43 - history/blocks_xcos/RELAY_f.xcos | 50 - history/blocks_xcos/RFILE_f.xcos | 72 - history/blocks_xcos/RICC.xcos | 47 - history/blocks_xcos/ROOTCOEF.xcos | 38 - history/blocks_xcos/Resistor.xcos | 66 - history/blocks_xcos/SAMPHOLD_m.xcos | 40 - history/blocks_xcos/SATURATION.xcos | 42 - history/blocks_xcos/SAWTOOTH_f.xcos | 40 - history/blocks_xcos/SCALAR2VECTOR.xcos | 37 - history/blocks_xcos/SELECT_m.xcos | 51 - history/blocks_xcos/SELF_SWITCH.xcos | 946 - history/blocks_xcos/SHIFT.xcos | 42 - history/blocks_xcos/SIGNUM.xcos | 37 - history/blocks_xcos/SINBLK_f.xcos | 37 - history/blocks_xcos/SOM_f.xcos | 48 - history/blocks_xcos/SQRT.xcos | 37 - history/blocks_xcos/SRFLIPFLOP.xcos | 1681 - history/blocks_xcos/STEP_FUNCTION.xcos | 1118 - history/blocks_xcos/SUBMAT.xcos | 46 - history/blocks_xcos/SUMMATION.xcos | 43 - history/blocks_xcos/SUM_f.xcos | 43 - history/blocks_xcos/SUPER_f.xcos | 493 - history/blocks_xcos/SWITCH2_m.xcos | 50 - history/blocks_xcos/SWITCH_f.xcos | 43 - history/blocks_xcos/SampleCLK.xcos | 38 - history/blocks_xcos/Sigbuilder.xcos | 992 - history/blocks_xcos/SineVoltage.xcos | 90 - history/blocks_xcos/SourceP.xcos | 71 - history/blocks_xcos/Switch.xcos | 72 - history/blocks_xcos/TANBLK_f.xcos | 37 - history/blocks_xcos/TCLSS.xcos | 55 - history/blocks_xcos/TEXT_f.xcos | 34 - history/blocks_xcos/TIME_DELAY.xcos | 44 - history/blocks_xcos/TIME_f.xcos | 32 - history/blocks_xcos/TKSCALE.xcos | 43 - history/blocks_xcos/TOWS_c.xcos | 43 - history/blocks_xcos/TRASH_f.xcos | 37 - history/blocks_xcos/TrigFun.xcos | 37 - history/blocks_xcos/VARIABLE_DELAY.xcos | 47 - history/blocks_xcos/VVsourceAC.xcos | 70 - history/blocks_xcos/VanneReglante.xcos | 72 - history/blocks_xcos/VariableResistor.xcos | 60 - history/blocks_xcos/VirtualCLK0.xcos | 32 - history/blocks_xcos/VoltageSensor.xcos | 61 - history/blocks_xcos/VsourceAC.xcos | 72 - history/blocks_xcos/WFILE_f.xcos | 69 - history/blocks_xcos/WRITEAU_f.xcos | 63 - history/blocks_xcos/WRITEC_f.xcos | 59 - history/blocks_xcos/ZCROSS_f.xcos | 42 - history/blocks_xcos/c_block.xcos | 44 - history/blocks_xcos/fortran_block.xcos | 47 - history/blocks_xcos/freq_div.xcos | 1165 - history/blocks_xcos/generic_block3.xcos | 55 - history/blocks_xcos/scifunc_block_m.xcos | 72 - history/data_structures/ABS_VALUE.js | 20 - history/data_structures/AFFICH_m.js | 33 - history/data_structures/ANDBLK.js | 75 - history/data_structures/ANDLOG_f.js | 15 - history/data_structures/AUTOMAT.js | 40 - history/data_structures/BACKLASH.js | 18 - history/data_structures/BARXY.js | 27 - history/data_structures/BIGSOM_f.js | 19 - history/data_structures/BITCLEAR.js | 21 - history/data_structures/BITSET.js | 21 - history/data_structures/BOUNCE.js | 17 - history/data_structures/BOUNCEXY.js | 43 - history/data_structures/BPLATFORM.js | 32 - history/data_structures/Bache.js | 50 - history/data_structures/CANIMXY.js | 43 - history/data_structures/CANIMXY3D.js | 43 - history/data_structures/CBLOCK.js | 48 - history/data_structures/CBLOCK4.js | 39 - history/data_structures/CCS.js | 30 - history/data_structures/CEVENTSCOPE.js | 29 - history/data_structures/CFSCOPE.js | 33 - history/data_structures/CLINDUMMY_f.js | 16 - history/data_structures/CLKFROM.js | 16 - history/data_structures/CLKGOTO.js | 17 - history/data_structures/CLKGotoTagVisibility.js | 23 - history/data_structures/CLKINV_f.js | 19 - history/data_structures/CLKOUTV_f.js | 17 - history/data_structures/CLKSOMV_f.js | 15 - history/data_structures/CLOCK_c.js | 48 - history/data_structures/CLR.js | 28 - history/data_structures/CLSS.js | 32 - history/data_structures/CMAT3D.js | 35 - history/data_structures/CMATVIEW.js | 32 - history/data_structures/CMSCOPE.js | 42 - history/data_structures/CONST.js | 19 - history/data_structures/CONSTRAINT2_c.js | 24 - history/data_structures/CONSTRAINT_c.js | 20 - history/data_structures/CONST_f.js | 19 - history/data_structures/CONST_m.js | 22 - history/data_structures/CONVERT.js | 24 - history/data_structures/COSBLK_f.js | 16 - history/data_structures/CSCOPE.js | 35 - history/data_structures/CSCOPXY.js | 40 - history/data_structures/CSCOPXY3D.js | 42 - history/data_structures/CUMSUM.js | 31 - history/data_structures/CURV_f.js | 28 - history/data_structures/CVS.js | 30 - history/data_structures/Capacitor.js | 28 - history/data_structures/ConstantVoltage.js | 27 - history/data_structures/Counter.js | 25 - history/data_structures/CurrentSensor.js | 24 - history/data_structures/DEADBAND.js | 25 - history/data_structures/DEBUG.js | 13 - history/data_structures/DELAYV_f.js | 29 - history/data_structures/DELAY_f.js | 72 - history/data_structures/DEMUX.js | 20 - history/data_structures/DEMUX_f.js | 20 - history/data_structures/DERIV.js | 16 - history/data_structures/DFLIPFLOP.js | 97 - history/data_structures/DIFF_f.js | 19 - history/data_structures/DLATCH.js | 41 - history/data_structures/DLR.js | 29 - history/data_structures/DLRADAPT_f.js | 33 - history/data_structures/DLSS.js | 29 - history/data_structures/DOLLAR.js | 24 - history/data_structures/DOLLAR_f.js | 24 - history/data_structures/DOLLAR_m.js | 24 - history/data_structures/Diode.js | 34 - history/data_structures/EDGE_TRIGGER.js | 87 - history/data_structures/ENDBLK.js | 13 - history/data_structures/END_c.js | 19 - history/data_structures/ESELECT_f.js | 24 - history/data_structures/EVTDLY_c.js | 22 - history/data_structures/EVTGEN_f.js | 18 - history/data_structures/EVTVARDLY.js | 19 - history/data_structures/EXPBLK_m.js | 25 - history/data_structures/EXPRESSION.js | 28 - history/data_structures/EXTRACT.js | 31 - history/data_structures/EXTRACTBITS.js | 23 - history/data_structures/EXTRACTOR.js | 19 - history/data_structures/EXTTRI.js | 31 - history/data_structures/Extract_Activation.js | 92 - history/data_structures/FROM.js | 23 - history/data_structures/FROMMO.js | 27 - history/data_structures/FROMWSB.js | 15 - history/data_structures/Flowmeter.js | 30 - history/data_structures/GAINBLK.js | 25 - history/data_structures/GAINBLK_f.js | 21 - history/data_structures/GAIN_f.js | 19 - history/data_structures/GENERAL_f.js | 25 - history/data_structures/GENSIN_f.js | 21 - history/data_structures/GENSQR_f.js | 21 - history/data_structures/GOTO.js | 23 - history/data_structures/GOTOMO.js | 27 - history/data_structures/GotoTagVisibility.js | 23 - history/data_structures/GotoTagVisibilityMO.js | 23 - history/data_structures/Ground.js | 23 - history/data_structures/Gyrator.js | 30 - history/data_structures/HALT_f.js | 19 - history/data_structures/HYSTHERESIS.js | 27 - history/data_structures/IFTHEL_f.js | 22 - history/data_structures/INIMPL_f.js | 25 - history/data_structures/INTEGRAL_f.js | 19 - history/data_structures/INTEGRAL_m.js | 26 - history/data_structures/INTMUL.js | 24 - history/data_structures/INTRP2BLK_f.js | 24 - history/data_structures/INTRPLBLK_f.js | 21 - history/data_structures/INVBLK.js | 18 - history/data_structures/IN_f.js | 20 - history/data_structures/ISELECT_m.js | 31 - history/data_structures/IdealTransformer.js | 30 - history/data_structures/Inductor.js | 28 - history/data_structures/JKFLIPFLOP.js | 53 - history/data_structures/LOGBLK_f.js | 21 - history/data_structures/LOGIC.js | 25 - history/data_structures/LOGICAL_OP.js | 23 - history/data_structures/LOOKUP_f.js | 15 - history/data_structures/MATBKSL.js | 31 - history/data_structures/MATCATH.js | 31 - history/data_structures/MATCATV.js | 33 - history/data_structures/MATDET.js | 31 - history/data_structures/MATDIAG.js | 31 - history/data_structures/MATDIV.js | 31 - history/data_structures/MATEIG.js | 31 - history/data_structures/MATEXPM.js | 31 - history/data_structures/MATINV.js | 31 - history/data_structures/MATLU.js | 31 - history/data_structures/MATMAGPHI.js | 31 - history/data_structures/MATMUL.js | 18 - history/data_structures/MATPINV.js | 31 - history/data_structures/MATRESH.js | 31 - history/data_structures/MATSING.js | 31 - history/data_structures/MATSUM.js | 31 - history/data_structures/MATTRAN.js | 17 - history/data_structures/MATZCONJ.js | 31 - history/data_structures/MATZREIM.js | 31 - history/data_structures/MAXMIN.js | 18 - history/data_structures/MAX_f.js | 19 - history/data_structures/MBLOCK.js | 30 - history/data_structures/MCLOCK_f.js | 81 - history/data_structures/MFCLCK_f.js | 24 - history/data_structures/MIN_f.js | 19 - history/data_structures/MUX.js | 19 - history/data_structures/MUX_f.js | 19 - history/data_structures/M_SWITCH.js | 23 - history/data_structures/M_freq.js | 19 - history/data_structures/Modulo_Count.js | 22 - history/data_structures/NEGTOPOS_f.js | 17 - history/data_structures/NMOS.js | 43 - history/data_structures/NPN.js | 30 - history/data_structures/NRMSOM_f.js | 20 - history/data_structures/OUTIMPL_f.js | 25 - history/data_structures/OUT_f.js | 22 - history/data_structures/OpAmp.js | 30 - history/data_structures/PDE.js | 19 - history/data_structures/PID.js | 43 - history/data_structures/PMOS.js | 43 - history/data_structures/PNP.js | 30 - history/data_structures/POSTONEG_f.js | 19 - history/data_structures/POWBLK_f.js | 21 - history/data_structures/PRODUCT.js | 19 - history/data_structures/PROD_f.js | 12 - history/data_structures/PULSE_SC.js | 57 - history/data_structures/PerteDP.js | 40 - history/data_structures/PotentialSensor.js | 23 - history/data_structures/PuitsP.js | 31 - history/data_structures/QUANT_f.js | 22 - history/data_structures/RAMP.js | 27 - history/data_structures/RAND_m.js | 39 - history/data_structures/RATELIMITER.js | 23 - history/data_structures/READAU_f.js | 40 - history/data_structures/READC_f.js | 46 - history/data_structures/REGISTER.js | 20 - history/data_structures/RELATIONALOP.js | 22 - history/data_structures/RELAY_f.js | 25 - history/data_structures/RFILE_f.js | 40 - history/data_structures/RICC.js | 31 - history/data_structures/ROOTCOEF.js | 31 - history/data_structures/Resistor.js | 28 - history/data_structures/SAMPHOLD_m.js | 21 - history/data_structures/SATURATION.js | 25 - history/data_structures/SAWTOOTH_f.js | 17 - history/data_structures/SCALAR2VECTOR.js | 18 - history/data_structures/SELECT_m.js | 31 - history/data_structures/SELF_SWITCH.js | 24 - history/data_structures/SHIFT.js | 26 - history/data_structures/SIGNUM.js | 20 - history/data_structures/SINBLK_f.js | 16 - history/data_structures/SOM_f.js | 19 - history/data_structures/SQRT.js | 19 - history/data_structures/SRFLIPFLOP.js | 44 - history/data_structures/STEP_FUNCTION.js | 57 - history/data_structures/SUBMAT.js | 31 - history/data_structures/SUMMATION.js | 21 - history/data_structures/SUM_f.js | 16 - history/data_structures/SUPER_f.js | 28 - history/data_structures/SWITCH2_m.js | 30 - history/data_structures/SWITCH_f.js | 24 - history/data_structures/SampleCLK.js | 15 - history/data_structures/Sigbuilder.js | 19 - history/data_structures/SineVoltage.js | 36 - history/data_structures/SourceP.js | 33 - history/data_structures/Switch.js | 34 - history/data_structures/TANBLK_f.js | 18 - history/data_structures/TCLSS.js | 27 - history/data_structures/TEXT_f.js | 21 - history/data_structures/TIME_DELAY.js | 26 - history/data_structures/TIME_f.js | 13 - history/data_structures/TKSCALE.js | 23 - history/data_structures/TOWS_c.js | 31 - history/data_structures/TRASH_f.js | 18 - history/data_structures/TrigFun.js | 16 - history/data_structures/VARIABLE_DELAY.js | 26 - history/data_structures/VVsourceAC.js | 30 - history/data_structures/VanneReglante.js | 32 - history/data_structures/VariableResistor.js | 24 - history/data_structures/VirtualCLK0.js | 16 - history/data_structures/VoltageSensor.js | 24 - history/data_structures/VsourceAC.js | 30 - history/data_structures/WFILE_f.js | 30 - history/data_structures/WRITEAU_f.js | 32 - history/data_structures/WRITEC_f.js | 32 - history/data_structures/ZCROSS_f.js | 23 - history/data_structures/c_block.js | 43 - history/data_structures/fortran_block.js | 25 - history/data_structures/freq_div.js | 113 - history/data_structures/generic_block3.js | 23 - history/data_structures/scifunc_block_m.js | 51 - images/ScilabExecute.png | Bin 660 -> 0 bytes images/add.png | Bin 1564 -> 0 bytes images/button.gif | Bin 137 -> 0 bytes images/camera.png | Bin 887 -> 0 bytes images/check.png | Bin 253 -> 0 bytes images/close.gif | Bin 70 -> 0 bytes images/close.png | Bin 1910 -> 0 bytes images/collapsed.gif | Bin 877 -> 0 bytes images/connector.gif | Bin 954 -> 0 bytes images/copy.png | Bin 728 -> 0 bytes images/cut.png | Bin 781 -> 0 bytes images/delete2.png | Bin 914 -> 0 bytes images/dot.gif | Bin 517 -> 0 bytes images/draw-brush.png | Bin 635 -> 0 bytes images/edit.png | Bin 599 -> 0 bytes images/error.gif | Bin 907 -> 0 bytes images/expanded.gif | Bin 878 -> 0 bytes images/export1.png | Bin 857 -> 0 bytes images/fit_to_size.png | Bin 529 -> 0 bytes images/flip.png | Bin 540 -> 0 bytes images/gear.gif | Bin 280 -> 0 bytes images/gradient_background.jpg | Bin 6164 -> 0 bytes images/green-dot.gif | Bin 326 -> 0 bytes images/grid.gif | Bin 58 -> 0 bytes images/group.png | Bin 899 -> 0 bytes images/key.png | Bin 300 -> 0 bytes images/loading.gif | Bin 10132 -> 0 bytes images/maximize.gif | Bin 843 -> 0 bytes images/minimize.gif | Bin 64 -> 0 bytes images/mirror.png | Bin 581 -> 0 bytes images/navigate_minus.png | Bin 485 -> 0 bytes images/navigate_plus.png | Bin 709 -> 0 bytes images/normalize.gif | Bin 845 -> 0 bytes images/paste.png | Bin 783 -> 0 bytes images/plus.png | Bin 236 -> 0 bytes images/point.gif | Bin 55 -> 0 bytes images/press32.png | Bin 2261 -> 0 bytes images/print32.png | Bin 2111 -> 0 bytes images/printer.png | Bin 896 -> 0 bytes images/redo.png | Bin 895 -> 0 bytes images/resize.gif | Bin 74 -> 0 bytes images/rotate.png | Bin 703 -> 0 bytes images/selectall.png | Bin 441 -> 0 bytes images/separator.gif | Bin 146 -> 0 bytes images/setup.png | Bin 440 -> 0 bytes images/sidebar_bg.gif | Bin 80 -> 0 bytes images/spacer.gif | Bin 43 -> 0 bytes images/submenu.gif | Bin 56 -> 0 bytes images/superblock.png | Bin 575 -> 0 bytes images/toolbar_bg.gif | Bin 155 -> 0 bytes images/transparent.gif | Bin 90 -> 0 bytes images/undo.png | Bin 879 -> 0 bytes images/view_1_1.png | Bin 849 -> 0 bytes images/view_1_132.png | Bin 2199 -> 0 bytes images/view_next.png | Bin 918 -> 0 bytes images/view_previous.png | Bin 912 -> 0 bytes images/warning.gif | Bin 276 -> 0 bytes images/warning.png | Bin 425 -> 0 bytes images/window-title.gif | Bin 275 -> 0 bytes images/window.gif | Bin 75 -> 0 bytes images/wires-grid.gif | Bin 50 -> 0 bytes images/zoom_in.png | Bin 858 -> 0 bytes images/zoom_in32.png | Bin 2184 -> 0 bytes images/zoom_out.png | Bin 847 -> 0 bytes images/zoom_out32.png | Bin 2150 -> 0 bytes index.html | 3391 -- jquery/LICENSE.txt | 341 - jquery/README.html | 71 - jquery/farbtastic.css | 51 - jquery/farbtastic.js | 345 - jquery/images/ui-bg_flat_75_ffffff_40x100.png | Bin 178 -> 0 bytes jquery/images/ui-bg_glass_75_e6e6e6_1x400.png | Bin 110 -> 0 bytes jquery/images/ui-icons_888888_256x240.png | Bin 4369 -> 0 bytes jquery/jquery-1.8.2.js | 9440 ---- jquery/jquery-ui.css | 470 - jquery/marker.png | Bin 652 -> 0 bytes jquery/mask.png | Bin 2020 -> 0 bytes jquery/wheel.png | Bin 11733 -> 0 bytes math.js | 53091 ------------------- mxClient.min.js | 1564 - orientation.js | 450 - palettes/ABS_VALUE.png | Bin 859 -> 0 bytes palettes/AFFICH_m.png | Bin 761 -> 0 bytes palettes/ANDBLK.png | Bin 972 -> 0 bytes palettes/ANDLOG_f.png | Bin 1429 -> 0 bytes palettes/AUTOMAT.png | Bin 1535 -> 0 bytes palettes/BACKLASH.png | Bin 1000 -> 0 bytes palettes/BARXY.png | Bin 1970 -> 0 bytes palettes/BIGSOM_f.png | Bin 982 -> 0 bytes palettes/BITCLEAR.png | Bin 1095 -> 0 bytes palettes/BITSET.png | Bin 1019 -> 0 bytes palettes/BOUNCE.png | Bin 1185 -> 0 bytes palettes/BOUNCEXY.png | Bin 1532 -> 0 bytes palettes/BPLATFORM.png | Bin 1140 -> 0 bytes palettes/Bache.png | Bin 1088 -> 0 bytes palettes/CANIMXY.png | Bin 1532 -> 0 bytes palettes/CANIMXY3D.png | Bin 1543 -> 0 bytes palettes/CBLOCK.png | Bin 1183 -> 0 bytes palettes/CBLOCK4.png | Bin 1172 -> 0 bytes palettes/CCS.png | Bin 789 -> 0 bytes palettes/CEVENTSCOPE.png | Bin 2021 -> 0 bytes palettes/CFSCOPE.png | Bin 1943 -> 0 bytes palettes/CLINDUMMY_f.png | Bin 1021 -> 0 bytes palettes/CLKFROM.png | Bin 462 -> 0 bytes palettes/CLKGOTO.png | Bin 465 -> 0 bytes palettes/CLKGotoTagVisibility.png | Bin 1436 -> 0 bytes palettes/CLKINV_f.png | Bin 313 -> 0 bytes palettes/CLKOUTV_f.png | Bin 315 -> 0 bytes palettes/CLKSOMV_f.png | Bin 1081 -> 0 bytes palettes/CLOCK_c.png | Bin 1488 -> 0 bytes palettes/CLR.png | Bin 1024 -> 0 bytes palettes/CLSS.png | Bin 1494 -> 0 bytes palettes/CMAT3D.png | Bin 2385 -> 0 bytes palettes/CMATVIEW.png | Bin 2511 -> 0 bytes palettes/CMSCOPE.png | Bin 2050 -> 0 bytes palettes/CONST.png | Bin 512 -> 0 bytes palettes/CONSTRAINT2_c.png | Bin 975 -> 0 bytes palettes/CONSTRAINT_c.png | Bin 763 -> 0 bytes palettes/CONST_f.png | Bin 512 -> 0 bytes palettes/CONST_m.png | Bin 512 -> 0 bytes palettes/CONVERT.png | Bin 1020 -> 0 bytes palettes/COSBLK_f.png | Bin 863 -> 0 bytes palettes/CSCOPE.png | Bin 2033 -> 0 bytes palettes/CSCOPXY.png | Bin 1481 -> 0 bytes palettes/CSCOPXY3D.png | Bin 1570 -> 0 bytes palettes/CUMSUM.png | Bin 958 -> 0 bytes palettes/CURV_f.png | Bin 829 -> 0 bytes palettes/CVS.png | Bin 752 -> 0 bytes palettes/Capacitor.png | Bin 397 -> 0 bytes palettes/ConstantVoltage.png | Bin 442 -> 0 bytes palettes/Counter.png | Bin 1219 -> 0 bytes palettes/CurrentSensor.png | Bin 2717 -> 0 bytes palettes/DEADBAND.png | Bin 801 -> 0 bytes palettes/DEBUG.png | Bin 805 -> 0 bytes palettes/DELAYV_f.png | Bin 1486 -> 0 bytes palettes/DELAY_f.png | Bin 875 -> 0 bytes palettes/DEMUX.png | Bin 855 -> 0 bytes palettes/DEMUX_f.png | Bin 855 -> 0 bytes palettes/DERIV.png | Bin 778 -> 0 bytes palettes/DFLIPFLOP.png | Bin 1011 -> 0 bytes palettes/DIFF_f.png | Bin 652 -> 0 bytes palettes/DLATCH.png | Bin 1124 -> 0 bytes palettes/DLR.png | Bin 1103 -> 0 bytes palettes/DLRADAPT_f.png | Bin 1323 -> 0 bytes palettes/DLSS.png | Bin 1532 -> 0 bytes palettes/DOLLAR.png | Bin 760 -> 0 bytes palettes/DOLLAR_f.png | Bin 760 -> 0 bytes palettes/DOLLAR_m.png | Bin 760 -> 0 bytes palettes/Diode.png | Bin 564 -> 0 bytes palettes/EDGE_TRIGGER.png | Bin 1115 -> 0 bytes palettes/ENDBLK.png | Bin 591 -> 0 bytes palettes/END_c.png | Bin 726 -> 0 bytes palettes/ESELECT_f.png | Bin 1199 -> 0 bytes palettes/EVTDLY_c.png | Bin 1046 -> 0 bytes palettes/EVTGEN_f.png | Bin 1118 -> 0 bytes palettes/EVTVARDLY.png | Bin 1186 -> 0 bytes palettes/EXPBLK_m.png | Bin 696 -> 0 bytes palettes/EXPRESSION.png | Bin 1128 -> 0 bytes palettes/EXTRACT.png | Bin 1025 -> 0 bytes palettes/EXTRACTBITS.png | Bin 1122 -> 0 bytes palettes/EXTRACTOR.png | Bin 946 -> 0 bytes palettes/EXTTRI.png | Bin 1310 -> 0 bytes palettes/Extract_Activation.png | Bin 1297 -> 0 bytes palettes/FROM.png | Bin 449 -> 0 bytes palettes/FROMMO.png | Bin 398 -> 0 bytes palettes/FROMWSB.png | Bin 918 -> 0 bytes palettes/Flowmeter.png | Bin 2746 -> 0 bytes palettes/GAINBLK.png | Bin 863 -> 0 bytes palettes/GAINBLK_f.png | Bin 863 -> 0 bytes palettes/GAIN_f.png | Bin 863 -> 0 bytes palettes/GENERAL_f.png | Bin 1042 -> 0 bytes palettes/GENSIN_f.png | Bin 1702 -> 0 bytes palettes/GENSQR_f.png | Bin 891 -> 0 bytes palettes/GOTO.png | Bin 444 -> 0 bytes palettes/GOTOMO.png | Bin 400 -> 0 bytes palettes/GotoTagVisibility.png | Bin 1025 -> 0 bytes palettes/GotoTagVisibilityMO.png | Bin 1520 -> 0 bytes palettes/Ground.png | Bin 317 -> 0 bytes palettes/Gyrator.png | Bin 845 -> 0 bytes palettes/HALT_f.png | Bin 675 -> 0 bytes palettes/HYSTHERESIS.png | Bin 830 -> 0 bytes palettes/IFTHEL_f.png | Bin 1374 -> 0 bytes palettes/INIMPL_f.png | Bin 255 -> 0 bytes palettes/INTEGRAL_f.png | Bin 731 -> 0 bytes palettes/INTEGRAL_m.png | Bin 942 -> 0 bytes palettes/INTMUL.png | Bin 809 -> 0 bytes palettes/INTRP2BLK_f.png | Bin 946 -> 0 bytes palettes/INTRPLBLK_f.png | Bin 797 -> 0 bytes palettes/INVBLK.png | Bin 684 -> 0 bytes palettes/IN_f.png | Bin 303 -> 0 bytes palettes/ISELECT_m.png | Bin 1104 -> 0 bytes palettes/IdealTransformer.png | Bin 1036 -> 0 bytes palettes/Inductor.png | Bin 464 -> 0 bytes palettes/JKFLIPFLOP.png | Bin 963 -> 0 bytes palettes/LOGBLK_f.png | Bin 792 -> 0 bytes palettes/LOGIC.png | Bin 1007 -> 0 bytes palettes/LOGICAL_OP.png | Bin 853 -> 0 bytes palettes/LOOKUP_f.png | Bin 2062 -> 0 bytes palettes/MATBKSL.png | Bin 842 -> 0 bytes palettes/MATCATH.png | Bin 1041 -> 0 bytes palettes/MATCATV.png | Bin 1095 -> 0 bytes palettes/MATDET.png | Bin 659 -> 0 bytes palettes/MATDIAG.png | Bin 850 -> 0 bytes palettes/MATDIV.png | Bin 845 -> 0 bytes palettes/MATEIG.png | Bin 684 -> 0 bytes palettes/MATEXPM.png | Bin 822 -> 0 bytes palettes/MATINV.png | Bin 732 -> 0 bytes palettes/MATLU.png | Bin 637 -> 0 bytes palettes/MATMAGPHI.png | Bin 1093 -> 0 bytes palettes/MATMUL.png | Bin 914 -> 0 bytes palettes/MATPINV.png | Bin 777 -> 0 bytes palettes/MATRESH.png | Bin 982 -> 0 bytes palettes/MATSING.png | Bin 846 -> 0 bytes palettes/MATSUM.png | Bin 976 -> 0 bytes palettes/MATTRAN.png | Bin 963 -> 0 bytes palettes/MATZCONJ.png | Bin 860 -> 0 bytes palettes/MATZREIM.png | Bin 970 -> 0 bytes palettes/MAXMIN.png | Bin 861 -> 0 bytes palettes/MAX_f.png | Bin 861 -> 0 bytes palettes/MBLOCK.png | Bin 1288 -> 0 bytes palettes/MCLOCK_f.png | Bin 1202 -> 0 bytes palettes/MFCLCK_f.png | Bin 1168 -> 0 bytes palettes/MIN_f.png | Bin 719 -> 0 bytes palettes/MUX.png | Bin 765 -> 0 bytes palettes/MUX_f.png | Bin 765 -> 0 bytes palettes/M_SWITCH.png | Bin 1567 -> 0 bytes palettes/M_freq.png | Bin 1427 -> 0 bytes palettes/Modulo_Count.png | Bin 1395 -> 0 bytes palettes/NEGTOPOS_f.png | Bin 718 -> 0 bytes palettes/NMOS.png | Bin 751 -> 0 bytes palettes/NPN.png | Bin 745 -> 0 bytes palettes/NRMSOM_f.png | Bin 988 -> 0 bytes palettes/OUTIMPL_f.png | Bin 257 -> 0 bytes palettes/OUT_f.png | Bin 297 -> 0 bytes palettes/OpAmp.png | Bin 1649 -> 0 bytes palettes/PDE.png | Bin 882 -> 0 bytes palettes/PID.png | Bin 682 -> 0 bytes palettes/PMOS.png | Bin 766 -> 0 bytes palettes/PNP.png | Bin 747 -> 0 bytes palettes/POSTONEG_f.png | Bin 722 -> 0 bytes palettes/POWBLK_f.png | Bin 687 -> 0 bytes palettes/PRODUCT.png | Bin 1013 -> 0 bytes palettes/PROD_f.png | Bin 803 -> 0 bytes palettes/PULSE_SC.png | Bin 788 -> 0 bytes palettes/PerteDP.png | Bin 454 -> 0 bytes palettes/PotentialSensor.png | Bin 2578 -> 0 bytes palettes/PuitsP.png | Bin 1079 -> 0 bytes palettes/QUANT_f.png | Bin 759 -> 0 bytes palettes/RAMP.png | Bin 790 -> 0 bytes palettes/RAND_m.png | Bin 1410 -> 0 bytes palettes/RATELIMITER.png | Bin 989 -> 0 bytes palettes/READAU_f.png | Bin 1209 -> 0 bytes palettes/READC_f.png | Bin 1669 -> 0 bytes palettes/REGISTER.png | Bin 1272 -> 0 bytes palettes/RELATIONALOP.png | Bin 670 -> 0 bytes palettes/RELAY_f.png | Bin 1008 -> 0 bytes palettes/RFILE_f.png | Bin 1459 -> 0 bytes palettes/RICC.png | Bin 794 -> 0 bytes palettes/ROOTCOEF.png | Bin 1052 -> 0 bytes palettes/Resistor.png | Bin 505 -> 0 bytes palettes/SAMPHOLD_m.png | Bin 857 -> 0 bytes palettes/SATURATION.png | Bin 785 -> 0 bytes palettes/SAWTOOTH_f.png | Bin 1282 -> 0 bytes palettes/SCALAR2VECTOR.png | Bin 1475 -> 0 bytes palettes/SELECT_m.png | Bin 1111 -> 0 bytes palettes/SELF_SWITCH.png | Bin 1792 -> 0 bytes palettes/SELF_SWITCH_off.png | Bin 1823 -> 0 bytes palettes/SELF_SWITCH_on.png | Bin 1723 -> 0 bytes palettes/SHIFT.png | Bin 1275 -> 0 bytes palettes/SIGNUM.png | Bin 866 -> 0 bytes palettes/SINBLK_f.png | Bin 760 -> 0 bytes palettes/SOM_f.png | Bin 1007 -> 0 bytes palettes/SQRT.png | Bin 896 -> 0 bytes palettes/SRFLIPFLOP.png | Bin 1150 -> 0 bytes palettes/STEP_FUNCTION.png | Bin 645 -> 0 bytes palettes/SUBMAT.png | Bin 1006 -> 0 bytes palettes/SUMMATION.png | Bin 1011 -> 0 bytes palettes/SUM_f.png | Bin 752 -> 0 bytes palettes/SUPER_f.png | Bin 801 -> 0 bytes palettes/SWITCH2_m.png | Bin 1289 -> 0 bytes palettes/SWITCH_f.png | Bin 1244 -> 0 bytes palettes/SampleCLK.png | Bin 1383 -> 0 bytes palettes/Sigbuilder.png | Bin 1315 -> 0 bytes palettes/SineVoltage.png | Bin 1043 -> 0 bytes palettes/SourceP.png | Bin 1209 -> 0 bytes palettes/Switch.png | Bin 881 -> 0 bytes palettes/TANBLK_f.png | Bin 753 -> 0 bytes palettes/TCLSS.png | Bin 1406 -> 0 bytes palettes/TEXT_f.png | Bin 110 -> 0 bytes palettes/TIME_DELAY.png | Bin 1454 -> 0 bytes palettes/TIME_f.png | Bin 1398 -> 0 bytes palettes/TKSCALE.png | Bin 1064 -> 0 bytes palettes/TOWS_c.png | Bin 1646 -> 0 bytes palettes/TRASH_f.png | Bin 846 -> 0 bytes palettes/TrigFun.png | Bin 1018 -> 0 bytes palettes/VARIABLE_DELAY.png | Bin 1290 -> 0 bytes palettes/VVsourceAC.png | Bin 1229 -> 0 bytes palettes/VanneReglante.png | Bin 2132 -> 0 bytes palettes/VariableResistor.png | Bin 1034 -> 0 bytes palettes/VirtualCLK0.png | Bin 1485 -> 0 bytes palettes/VoltageSensor.png | Bin 2731 -> 0 bytes palettes/VsourceAC.png | Bin 1316 -> 0 bytes palettes/WFILE_f.png | Bin 1477 -> 0 bytes palettes/WRITEAU_f.png | Bin 1711 -> 0 bytes palettes/WRITEC_f.png | Bin 1587 -> 0 bytes palettes/ZCROSS_f.png | Bin 909 -> 0 bytes palettes/c_block.png | Bin 1068 -> 0 bytes palettes/fortran_block.png | Bin 1378 -> 0 bytes palettes/freq_div.png | Bin 1415 -> 0 bytes palettes/generic_block3.png | Bin 1439 -> 0 bytes palettes/palettes.xml | 849 - palettes/scifunc_block_m.png | Bin 1325 -> 0 bytes resources/editor.properties | 5 - resources/graph.properties | 11 - setup.js | 57 - styles/Xcos-style.xml | 960 - webapp/Queue.js | 2 + webapp/blocks/3DSCOPE.svg | 9 + webapp/blocks/ANDBLK.svg | 34 + webapp/blocks/ASCOPE.svg | 31 + webapp/blocks/BACHE.svg | 27 + webapp/blocks/BARXY.svg | 23 + webapp/blocks/BPLATFORM.svg | 15 + webapp/blocks/CCS.svg | 7 + webapp/blocks/CLOCK_c.svg | 13 + webapp/blocks/CLOCK_f.svg | 12 + webapp/blocks/CSCOPXY.svg | 150 + webapp/blocks/CSCOPXY3D.svg | 162 + webapp/blocks/CVS.svg | 5 + webapp/blocks/Capacitor.svg | 10 + webapp/blocks/ConstantVoltage.svg | 24 + webapp/blocks/CurrentSensor.svg | 37 + webapp/blocks/DEADBAND.svg | 6 + webapp/blocks/DSCOPE.svg | 39 + webapp/blocks/Diode.svg | 7 + webapp/blocks/Flowmeter.svg | 37 + webapp/blocks/Ground.svg | 7 + webapp/blocks/Gyrator.svg | 14 + webapp/blocks/HYSTHERESIS.svg | 8 + webapp/blocks/INTEGRAL.svg | 14 + webapp/blocks/IdealTransformer.svg | 23 + webapp/blocks/Inductor.svg | 14 + webapp/blocks/NMOS.svg | 69 + webapp/blocks/NPN.svg | 51 + webapp/blocks/PMOS.svg | 65 + webapp/blocks/PNP.svg | 51 + webapp/blocks/PRODUCT.svg | 4 + webapp/blocks/PULSE_SC.svg | 7 + webapp/blocks/PerteDP.svg | 44 + webapp/blocks/PotentialSensor.svg | 51 + webapp/blocks/PuitP.svg | 44 + webapp/blocks/QUANT_f.svg | 6 + webapp/blocks/RAMP.svg | 7 + webapp/blocks/Resistor.svg | 51 + webapp/blocks/SATURATION.svg | 6 + webapp/blocks/SINUS_f.svg | 15 + webapp/blocks/SQUARE_WAVE_f.svg | 8 + webapp/blocks/STEP_FUNCTION.svg | 7 + webapp/blocks/SUM.svg | 4 + webapp/blocks/SUPER.svg | 49 + webapp/blocks/SWITCH.svg | 11 + webapp/blocks/SampleCLK.svg | 14 + webapp/blocks/Self_Switch_off.svg | 77 + webapp/blocks/Self_Switch_on.svg | 73 + webapp/blocks/SourceP.svg | 59 + webapp/blocks/VanneReglante.svg | 58 + webapp/blocks/VariableResistor.svg | 64 + webapp/blocks/VirtualCLK0.svg | 13 + webapp/blocks/VoltageSensor.svg | 35 + webapp/blocks/sawtooth.svg | 6 + webapp/chart.js | 133 + webapp/combined.js | 11264 ++++ webapp/composer.json | 1 + webapp/config/keyhandler-commons.xml | 23 + webapp/css/common.css | 221 + webapp/css/explorer.css | 15 + webapp/data_structures_correct/ABS_VALUE.js | 29 + webapp/data_structures_correct/AFFICH_m.js | 33 + webapp/data_structures_correct/ANDBLK.js | 130 + webapp/data_structures_correct/ANDLOG_f.js | 50 + webapp/data_structures_correct/AUTOMAT.js | 38 + webapp/data_structures_correct/BACKLASH.js | 21 + webapp/data_structures_correct/BARXY.js | 30 + webapp/data_structures_correct/BIGSOM_f.js | 24 + webapp/data_structures_correct/BITCLEAR.js | 23 + webapp/data_structures_correct/BITSET.js | 24 + webapp/data_structures_correct/BOUNCE.js | 51 + webapp/data_structures_correct/BOUNCEXY.js | 50 + webapp/data_structures_correct/BPLATFORM.js | 34 + webapp/data_structures_correct/Bache.js | 46 + webapp/data_structures_correct/CANIMXY.js | 36 + webapp/data_structures_correct/CANIMXY3D.js | 39 + webapp/data_structures_correct/CBLOCK.js | 44 + webapp/data_structures_correct/CBLOCK4.js | 27 + webapp/data_structures_correct/CCS.js | 58 + webapp/data_structures_correct/CEVENTSCOPE.js | 27 + webapp/data_structures_correct/CFSCOPE.js | 29 + webapp/data_structures_correct/CLINDUMMY_f.js | 20 + webapp/data_structures_correct/CLKFROM.js | 20 + webapp/data_structures_correct/CLKGOTO.js | 22 + .../CLKGotoTagVisibility.js | 27 + webapp/data_structures_correct/CLKINV_f.js | 42 + webapp/data_structures_correct/CLKOUTV_f.js | 42 + webapp/data_structures_correct/CLKSOMV_f.js | 33 + webapp/data_structures_correct/CLKSOM_f.js | 19 + webapp/data_structures_correct/CLOCK_c.js | 95 + webapp/data_structures_correct/CLR.js | 27 + webapp/data_structures_correct/CLSS.js | 30 + webapp/data_structures_correct/CMSCOPE.js | 73 + webapp/data_structures_correct/CONST.js | 26 + webapp/data_structures_correct/CONSTRAINT2_c.js | 27 + webapp/data_structures_correct/CONSTRAINT_c.js | 25 + webapp/data_structures_correct/CONST_f.js | 25 + webapp/data_structures_correct/CONST_m.js | 61 + webapp/data_structures_correct/CONVERT.js | 31 + webapp/data_structures_correct/COSBLK_f.js | 20 + webapp/data_structures_correct/CSCOPE.js | 32 + webapp/data_structures_correct/CSCOPXY.js | 37 + webapp/data_structures_correct/CSCOPXY3D.js | 36 + webapp/data_structures_correct/CUMSUM.js | 35 + webapp/data_structures_correct/CURV_f.js | 27 + webapp/data_structures_correct/CVS.js | 58 + webapp/data_structures_correct/Capacitor.js | 31 + webapp/data_structures_correct/ConstantVoltage.js | 32 + webapp/data_structures_correct/Counter.js | 28 + webapp/data_structures_correct/CurrentSensor.js | 29 + webapp/data_structures_correct/DEADBAND.js | 27 + webapp/data_structures_correct/DEBUG.js | 18 + webapp/data_structures_correct/DELAYV_f.js | 31 + webapp/data_structures_correct/DELAY_f.js | 121 + webapp/data_structures_correct/DEMUX.js | 28 + webapp/data_structures_correct/DEMUX_f.js | 27 + webapp/data_structures_correct/DERIV.js | 20 + webapp/data_structures_correct/DFLIPFLOP.js | 2016 + webapp/data_structures_correct/DIFF_f.js | 24 + webapp/data_structures_correct/DLATCH.js | 609 + webapp/data_structures_correct/DLR.js | 30 + webapp/data_structures_correct/DLRADAPT_f.js | 32 + webapp/data_structures_correct/DLSS.js | 30 + webapp/data_structures_correct/DOLLAR.js | 27 + webapp/data_structures_correct/DOLLAR_f.js | 27 + webapp/data_structures_correct/DOLLAR_m.js | 27 + webapp/data_structures_correct/Diode.js | 36 + webapp/data_structures_correct/EDGETRIGGER.js | 25 + webapp/data_structures_correct/EDGE_TRIGGER.js | 114 + webapp/data_structures_correct/ENDBLK.js | 106 + webapp/data_structures_correct/END_c.js | 24 + webapp/data_structures_correct/ESELECT_f.js | 29 + webapp/data_structures_correct/EVTDLY_c.js | 49 + webapp/data_structures_correct/EVTDLY_f.js | 23 + webapp/data_structures_correct/EVTGEN_f.js | 22 + webapp/data_structures_correct/EVTVARDLY.js | 25 + webapp/data_structures_correct/EXPBLK_m.js | 28 + webapp/data_structures_correct/EXTRACT.js | 35 + webapp/data_structures_correct/EXTRACTBITS.js | 27 + webapp/data_structures_correct/EXTRACTOR.js | 24 + webapp/data_structures_correct/EXTTRI.js | 35 + .../data_structures_correct/Extract_Activation.js | 129 + webapp/data_structures_correct/FROM.js | 29 + webapp/data_structures_correct/FROMMO.js | 33 + webapp/data_structures_correct/FROMWSB.js | 164 + webapp/data_structures_correct/Flowmeter.js | 61 + webapp/data_structures_correct/GAINBLK.js | 30 + webapp/data_structures_correct/GAINBLK_f.js | 26 + webapp/data_structures_correct/GAIN_f.js | 26 + webapp/data_structures_correct/GENERAL_f.js | 29 + webapp/data_structures_correct/GENSIN_f.js | 26 + webapp/data_structures_correct/GENSQR_f.js | 25 + webapp/data_structures_correct/GOTO.js | 28 + webapp/data_structures_correct/GOTOMO.js | 33 + .../data_structures_correct/GotoTagVisibility.js | 30 + .../data_structures_correct/GotoTagVisibilityMO.js | 29 + webapp/data_structures_correct/Ground.js | 30 + webapp/data_structures_correct/Gyrator.js | 57 + webapp/data_structures_correct/HALT_f.js | 24 + webapp/data_structures_correct/HYSTHERESIS.js | 29 + webapp/data_structures_correct/IFTHEL_f.js | 60 + webapp/data_structures_correct/INIMPL_f.js | 31 + webapp/data_structures_correct/INTEGRAL_f.js | 24 + webapp/data_structures_correct/INTEGRAL_m.js | 29 + webapp/data_structures_correct/INTMUL.js | 29 + webapp/data_structures_correct/INTRP2BLK_f.js | 27 + webapp/data_structures_correct/INTRPLBLK_f.js | 26 + webapp/data_structures_correct/INVBLK.js | 23 + webapp/data_structures_correct/IN_f.js | 52 + webapp/data_structures_correct/ISELECT_m.js | 35 + webapp/data_structures_correct/IdealTransformer.js | 60 + webapp/data_structures_correct/Inductor.js | 34 + webapp/data_structures_correct/JKFLIPFLOP.js | 897 + webapp/data_structures_correct/LOGBLK_f.js | 25 + webapp/data_structures_correct/LOGIC.js | 30 + webapp/data_structures_correct/LOGICAL_OP.js | 26 + webapp/data_structures_correct/LOOKUP_f.js | 21 + webapp/data_structures_correct/MATBKSL.js | 35 + webapp/data_structures_correct/MATCATH.js | 35 + webapp/data_structures_correct/MATCATV.js | 36 + webapp/data_structures_correct/MATDET.js | 36 + webapp/data_structures_correct/MATDIAG.js | 35 + webapp/data_structures_correct/MATDIV.js | 37 + webapp/data_structures_correct/MATEIG.js | 35 + webapp/data_structures_correct/MATEXPM.js | 34 + webapp/data_structures_correct/MATINV.js | 35 + webapp/data_structures_correct/MATLU.js | 35 + webapp/data_structures_correct/MATMAGPHI.js | 35 + webapp/data_structures_correct/MATMUL.js | 24 + webapp/data_structures_correct/MATPINV.js | 36 + webapp/data_structures_correct/MATRESH.js | 35 + webapp/data_structures_correct/MATSING.js | 36 + webapp/data_structures_correct/MATSUM.js | 35 + webapp/data_structures_correct/MATTRAN.js | 23 + webapp/data_structures_correct/MATZCONJ.js | 35 + webapp/data_structures_correct/MATZREIM.js | 34 + webapp/data_structures_correct/MAXMIN.js | 23 + webapp/data_structures_correct/MAX_f.js | 24 + webapp/data_structures_correct/MBLOCK.js | 45 + webapp/data_structures_correct/MCLOCK_f.js | 139 + webapp/data_structures_correct/MFCLCK_f.js | 50 + webapp/data_structures_correct/MIN_f.js | 24 + webapp/data_structures_correct/MUX.js | 26 + webapp/data_structures_correct/MUX_f.js | 26 + webapp/data_structures_correct/M_SWITCH.js | 26 + webapp/data_structures_correct/M_freq.js | 24 + webapp/data_structures_correct/Modulo_Count.js | 46 + webapp/data_structures_correct/NEGTOPOS_f.js | 22 + webapp/data_structures_correct/NMOS.js | 40 + webapp/data_structures_correct/NPN.js | 56 + webapp/data_structures_correct/NRMSOM_f.js | 24 + webapp/data_structures_correct/OUTIMPL_f.js | 33 + webapp/data_structures_correct/OUT_f.js | 53 + webapp/data_structures_correct/OpAmp.js | 34 + webapp/data_structures_correct/PDE.js | 24 + webapp/data_structures_correct/PID.js | 626 + webapp/data_structures_correct/PNP.js | 63 + webapp/data_structures_correct/POSTONEG_f.js | 24 + webapp/data_structures_correct/POWBLK_f.js | 25 + webapp/data_structures_correct/PRODUCT.js | 23 + webapp/data_structures_correct/PROD_f.js | 19 + webapp/data_structures_correct/PULSE_SC.js | 381 + webapp/data_structures_correct/PerteDP.js | 41 + webapp/data_structures_correct/PotentialSensor.js | 31 + webapp/data_structures_correct/PuitsP.js | 34 + webapp/data_structures_correct/QUANT_f.js | 26 + webapp/data_structures_correct/RAMP.js | 29 + webapp/data_structures_correct/RAND_m.js | 39 + webapp/data_structures_correct/RATELIMITER.js | 26 + webapp/data_structures_correct/READAU_f.js | 33 + webapp/data_structures_correct/READC_f.js | 39 + webapp/data_structures_correct/REGISTER.js | 26 + webapp/data_structures_correct/REGISTER_f.js | 28 + webapp/data_structures_correct/RELATIONALOP.js | 26 + webapp/data_structures_correct/RELAY_f.js | 28 + webapp/data_structures_correct/RFILE_f.js | 36 + webapp/data_structures_correct/RICC.js | 35 + webapp/data_structures_correct/ROOTCOEF.js | 35 + webapp/data_structures_correct/Resistor.js | 33 + webapp/data_structures_correct/SAMPHOLD_m.js | 27 + webapp/data_structures_correct/SATURATION.js | 28 + webapp/data_structures_correct/SAWTOOTH_f.js | 23 + webapp/data_structures_correct/SCALAR2VECTOR.js | 23 + webapp/data_structures_correct/SELECT_m.js | 35 + webapp/data_structures_correct/SELF_SWITCH.js | 30 + webapp/data_structures_correct/SHIFT.js | 30 + webapp/data_structures_correct/SIGNUM.js | 25 + webapp/data_structures_correct/SINBLK_f.js | 22 + webapp/data_structures_correct/SOM_f.js | 24 + webapp/data_structures_correct/SQRT.js | 24 + webapp/data_structures_correct/SRFLIPFLOP.js | 439 + webapp/data_structures_correct/STEP_FUNCTION.js | 79 + webapp/data_structures_correct/SUBMAT.js | 38 + webapp/data_structures_correct/SUMMATION.js | 25 + webapp/data_structures_correct/SUM_f.js | 25 + webapp/data_structures_correct/SUPER_f.js | 42 + webapp/data_structures_correct/SWITCH2_m.js | 33 + webapp/data_structures_correct/SWITCH_f.js | 48 + webapp/data_structures_correct/SampleCLK.js | 22 + webapp/data_structures_correct/Sigbuilder.js | 272 + webapp/data_structures_correct/SineVoltage.js | 38 + webapp/data_structures_correct/SourceP.js | 36 + webapp/data_structures_correct/Switch.js | 42 + webapp/data_structures_correct/TANBLK_f.js | 23 + webapp/data_structures_correct/TCLSS.js | 34 + webapp/data_structures_correct/TEXT_f.js | 25 + webapp/data_structures_correct/TIME_DELAY.js | 28 + webapp/data_structures_correct/TIME_f.js | 18 + webapp/data_structures_correct/TKSCALE.js | 26 + webapp/data_structures_correct/TOWS_c.js | 33 + webapp/data_structures_correct/TRASH_f.js | 23 + webapp/data_structures_correct/TrigFun.js | 21 + webapp/data_structures_correct/VARIABLE_DELAY.js | 28 + webapp/data_structures_correct/VVsourceAC.js | 39 + webapp/data_structures_correct/VanneReglante.js | 37 + webapp/data_structures_correct/VariableResistor.js | 29 + webapp/data_structures_correct/VirtualCLK0.js | 22 + webapp/data_structures_correct/VoltageSensor.js | 29 + webapp/data_structures_correct/VsourceAC.js | 37 + webapp/data_structures_correct/WRITEAU_f.js | 31 + webapp/data_structures_correct/WRITEC_f.js | 31 + webapp/data_structures_correct/ZCROSS_f.js | 29 + webapp/data_structures_correct/c_block.js | 33 + webapp/data_structures_correct/combine_script.bat | 1 + webapp/data_structures_correct/fortran_block.js | 29 + webapp/data_structures_correct/freq_div.js | 146 + webapp/data_structures_correct/generic_block3.js | 25 + webapp/data_structures_correct/scifunc_block_m.js | 43 + webapp/dependencies.js | 1497 + webapp/details.js | 643 + webapp/documentation/servlet.md | 4 + webapp/documentation/wires.md | 82 + webapp/filenames.php | 27 + webapp/finalmodsheet.xsl | 2192 + webapp/highcharts/highcharts.js | 347 + webapp/history/blocks_xcos/ABS_VALUE.xcos | 37 + webapp/history/blocks_xcos/AFFICH_m.xcos | 60 + webapp/history/blocks_xcos/ANDBLK.xcos | 1355 + webapp/history/blocks_xcos/ANDLOG_f.xcos | 38 + webapp/history/blocks_xcos/AUTOMAT.xcos | 66 + webapp/history/blocks_xcos/BACKLASH.xcos | 42 + webapp/history/blocks_xcos/BARXY.xcos | 51 + webapp/history/blocks_xcos/BIGSOM_f.xcos | 43 + webapp/history/blocks_xcos/BITCLEAR.xcos | 42 + webapp/history/blocks_xcos/BITSET.xcos | 42 + webapp/history/blocks_xcos/BOUNCE.xcos | 67 + webapp/history/blocks_xcos/BOUNCEXY.xcos | 71 + webapp/history/blocks_xcos/BPLATFORM.xcos | 57 + webapp/history/blocks_xcos/Bache.xcos | 108 + webapp/history/blocks_xcos/CANIMXY.xcos | 67 + webapp/history/blocks_xcos/CANIMXY3D.xcos | 88 + webapp/history/blocks_xcos/CBLOCK.xcos | 53 + webapp/history/blocks_xcos/CBLOCK4.xcos | 58 + webapp/history/blocks_xcos/CCS.xcos | 61 + webapp/history/blocks_xcos/CEVENTSCOPE.xcos | 49 + webapp/history/blocks_xcos/CFSCOPE.xcos | 65 + webapp/history/blocks_xcos/CLINDUMMY_f.xcos | 32 + webapp/history/blocks_xcos/CLKFROM.xcos | 35 + webapp/history/blocks_xcos/CLKGOTO.xcos | 38 + .../history/blocks_xcos/CLKGotoTagVisibility.xcos | 35 + webapp/history/blocks_xcos/CLKINV_f.xcos | 28 + webapp/history/blocks_xcos/CLKOUTV_f.xcos | 28 + webapp/history/blocks_xcos/CLKSOMV_f.xcos | 41 + webapp/history/blocks_xcos/CLOCK_c.xcos | 738 + webapp/history/blocks_xcos/CLR.xcos | 46 + webapp/history/blocks_xcos/CLSS.xcos | 49 + webapp/history/blocks_xcos/CMAT3D.xcos | 125 + webapp/history/blocks_xcos/CMATVIEW.xcos | 121 + webapp/history/blocks_xcos/CMSCOPE.xcos | 70 + webapp/history/blocks_xcos/CONST.xcos | 36 + webapp/history/blocks_xcos/CONSTRAINT2_c.xcos | 54 + webapp/history/blocks_xcos/CONSTRAINT_c.xcos | 43 + webapp/history/blocks_xcos/CONST_f.xcos | 36 + webapp/history/blocks_xcos/CONST_m.xcos | 36 + webapp/history/blocks_xcos/CONVERT.xcos | 41 + webapp/history/blocks_xcos/COSBLK_f.xcos | 35 + webapp/history/blocks_xcos/CSCOPE.xcos | 67 + webapp/history/blocks_xcos/CSCOPXY.xcos | 67 + webapp/history/blocks_xcos/CSCOPXY3D.xcos | 88 + webapp/history/blocks_xcos/CUMSUM.xcos | 38 + webapp/history/blocks_xcos/CURV_f.xcos | 49 + webapp/history/blocks_xcos/CVS.xcos | 61 + webapp/history/blocks_xcos/Capacitor.xcos | 76 + webapp/history/blocks_xcos/ConstantVoltage.xcos | 66 + webapp/history/blocks_xcos/Counter.xcos | 46 + webapp/history/blocks_xcos/CurrentSensor.xcos | 60 + webapp/history/blocks_xcos/DEADBAND.xcos | 42 + webapp/history/blocks_xcos/DEBUG.xcos | 37 + webapp/history/blocks_xcos/DELAYV_f.xcos | 66 + webapp/history/blocks_xcos/DELAY_f.xcos | 1182 + webapp/history/blocks_xcos/DEMUX.xcos | 42 + webapp/history/blocks_xcos/DEMUX_f.xcos | 42 + webapp/history/blocks_xcos/DERIV.xcos | 35 + webapp/history/blocks_xcos/DFLIPFLOP.xcos | 7807 +++ webapp/history/blocks_xcos/DIFF_f.xcos | 42 + webapp/history/blocks_xcos/DLATCH.xcos | 2262 + webapp/history/blocks_xcos/DLR.xcos | 49 + webapp/history/blocks_xcos/DLRADAPT_f.xcos | 69 + webapp/history/blocks_xcos/DLSS.xcos | 52 + webapp/history/blocks_xcos/DOLLAR.xcos | 44 + webapp/history/blocks_xcos/DOLLAR_f.xcos | 44 + webapp/history/blocks_xcos/DOLLAR_m.xcos | 44 + webapp/history/blocks_xcos/Diode.xcos | 84 + webapp/history/blocks_xcos/EDGE_TRIGGER.xcos | 934 + webapp/history/blocks_xcos/ENDBLK.xcos | 340 + webapp/history/blocks_xcos/END_c.xcos | 37 + webapp/history/blocks_xcos/ESELECT_f.xcos | 45 + webapp/history/blocks_xcos/EVTDLY_c.xcos | 41 + webapp/history/blocks_xcos/EVTGEN_f.xcos | 34 + webapp/history/blocks_xcos/EVTVARDLY.xcos | 40 + webapp/history/blocks_xcos/EXPBLK_m.xcos | 39 + webapp/history/blocks_xcos/EXPRESSION.xcos | 63 + webapp/history/blocks_xcos/EXTRACT.xcos | 44 + webapp/history/blocks_xcos/EXTRACTBITS.xcos | 42 + webapp/history/blocks_xcos/EXTRACTOR.xcos | 39 + webapp/history/blocks_xcos/EXTTRI.xcos | 38 + webapp/history/blocks_xcos/Extract_Activation.xcos | 950 + webapp/history/blocks_xcos/FROM.xcos | 41 + webapp/history/blocks_xcos/FROMMO.xcos | 38 + webapp/history/blocks_xcos/FROMWSB.xcos | 571 + webapp/history/blocks_xcos/Flowmeter.xcos | 71 + webapp/history/blocks_xcos/GAINBLK.xcos | 39 + webapp/history/blocks_xcos/GAINBLK_f.xcos | 39 + webapp/history/blocks_xcos/GAIN_f.xcos | 41 + webapp/history/blocks_xcos/GENERAL_f.xcos | 43 + webapp/history/blocks_xcos/GENSIN_f.xcos | 40 + webapp/history/blocks_xcos/GENSQR_f.xcos | 40 + webapp/history/blocks_xcos/GOTO.xcos | 38 + webapp/history/blocks_xcos/GOTOMO.xcos | 41 + webapp/history/blocks_xcos/GotoTagVisibility.xcos | 35 + .../history/blocks_xcos/GotoTagVisibilityMO.xcos | 35 + webapp/history/blocks_xcos/Ground.xcos | 54 + webapp/history/blocks_xcos/Gyrator.xcos | 80 + webapp/history/blocks_xcos/HALT_f.xcos | 39 + webapp/history/blocks_xcos/HYSTHERESIS.xcos | 46 + webapp/history/blocks_xcos/IFTHEL_f.xcos | 44 + webapp/history/blocks_xcos/INIMPL_f.xcos | 47 + webapp/history/blocks_xcos/INTEGRAL_f.xcos | 40 + webapp/history/blocks_xcos/INTEGRAL_m.xcos | 44 + webapp/history/blocks_xcos/INTMUL.xcos | 43 + webapp/history/blocks_xcos/INTRP2BLK_f.xcos | 54 + webapp/history/blocks_xcos/INTRPLBLK_f.xcos | 43 + webapp/history/blocks_xcos/INVBLK.xcos | 37 + webapp/history/blocks_xcos/IN_f.xcos | 28 + webapp/history/blocks_xcos/ISELECT_m.xcos | 51 + webapp/history/blocks_xcos/IdealTransformer.xcos | 75 + webapp/history/blocks_xcos/Inductor.xcos | 66 + webapp/history/blocks_xcos/JKFLIPFLOP.xcos | 3446 ++ webapp/history/blocks_xcos/LOGBLK_f.xcos | 39 + webapp/history/blocks_xcos/LOGIC.xcos | 51 + webapp/history/blocks_xcos/LOGICAL_OP.xcos | 43 + webapp/history/blocks_xcos/LOOKUP_f.xcos | 44 + webapp/history/blocks_xcos/MATBKSL.xcos | 40 + webapp/history/blocks_xcos/MATCATH.xcos | 40 + webapp/history/blocks_xcos/MATCATV.xcos | 40 + webapp/history/blocks_xcos/MATDET.xcos | 37 + webapp/history/blocks_xcos/MATDIAG.xcos | 37 + webapp/history/blocks_xcos/MATDIV.xcos | 40 + webapp/history/blocks_xcos/MATEIG.xcos | 38 + webapp/history/blocks_xcos/MATEXPM.xcos | 37 + webapp/history/blocks_xcos/MATINV.xcos | 37 + webapp/history/blocks_xcos/MATLU.xcos | 40 + webapp/history/blocks_xcos/MATMAGPHI.xcos | 40 + webapp/history/blocks_xcos/MATMUL.xcos | 42 + webapp/history/blocks_xcos/MATPINV.xcos | 37 + webapp/history/blocks_xcos/MATRESH.xcos | 39 + webapp/history/blocks_xcos/MATSING.xcos | 38 + webapp/history/blocks_xcos/MATSUM.xcos | 38 + webapp/history/blocks_xcos/MATTRAN.xcos | 37 + webapp/history/blocks_xcos/MATZCONJ.xcos | 35 + webapp/history/blocks_xcos/MATZREIM.xcos | 40 + webapp/history/blocks_xcos/MAXMIN.xcos | 41 + webapp/history/blocks_xcos/MAX_f.xcos | 41 + webapp/history/blocks_xcos/MBLOCK.xcos | 116 + webapp/history/blocks_xcos/MCLOCK_f.xcos | 1389 + webapp/history/blocks_xcos/MFCLCK_f.xcos | 48 + webapp/history/blocks_xcos/MIN_f.xcos | 41 + webapp/history/blocks_xcos/MUX.xcos | 42 + webapp/history/blocks_xcos/MUX_f.xcos | 42 + webapp/history/blocks_xcos/M_SWITCH.xcos | 48 + webapp/history/blocks_xcos/M_freq.xcos | 65 + webapp/history/blocks_xcos/Modulo_Count.xcos | 43 + webapp/history/blocks_xcos/NEGTOPOS_f.xcos | 40 + webapp/history/blocks_xcos/NMOS.xcos | 94 + webapp/history/blocks_xcos/NPN.xcos | 151 + webapp/history/blocks_xcos/NRMSOM_f.xcos | 40 + webapp/history/blocks_xcos/OUTIMPL_f.xcos | 47 + webapp/history/blocks_xcos/OUT_f.xcos | 28 + webapp/history/blocks_xcos/OpAmp.xcos | 60 + webapp/history/blocks_xcos/PDE.xcos | 244 + webapp/history/blocks_xcos/PID.xcos | 2403 + webapp/history/blocks_xcos/PMOS.xcos | 94 + webapp/history/blocks_xcos/PNP.xcos | 151 + webapp/history/blocks_xcos/POSTONEG_f.xcos | 40 + webapp/history/blocks_xcos/POWBLK_f.xcos | 39 + webapp/history/blocks_xcos/PRODUCT.xcos | 43 + webapp/history/blocks_xcos/PROD_f.xcos | 39 + webapp/history/blocks_xcos/PULSE_SC.xcos | 1370 + webapp/history/blocks_xcos/PerteDP.xcos | 84 + webapp/history/blocks_xcos/PotentialSensor.xcos | 58 + webapp/history/blocks_xcos/PuitsP.xcos | 71 + webapp/history/blocks_xcos/QUANT_f.xcos | 42 + webapp/history/blocks_xcos/RAMP.xcos | 40 + webapp/history/blocks_xcos/RAND_m.xcos | 50 + webapp/history/blocks_xcos/RATELIMITER.xcos | 41 + webapp/history/blocks_xcos/READAU_f.xcos | 82 + webapp/history/blocks_xcos/READC_f.xcos | 84 + webapp/history/blocks_xcos/REGISTER.xcos | 52 + webapp/history/blocks_xcos/RELATIONALOP.xcos | 43 + webapp/history/blocks_xcos/RELAY_f.xcos | 50 + webapp/history/blocks_xcos/RFILE_f.xcos | 72 + webapp/history/blocks_xcos/RICC.xcos | 47 + webapp/history/blocks_xcos/ROOTCOEF.xcos | 38 + webapp/history/blocks_xcos/Resistor.xcos | 66 + webapp/history/blocks_xcos/SAMPHOLD_m.xcos | 40 + webapp/history/blocks_xcos/SATURATION.xcos | 42 + webapp/history/blocks_xcos/SAWTOOTH_f.xcos | 40 + webapp/history/blocks_xcos/SCALAR2VECTOR.xcos | 37 + webapp/history/blocks_xcos/SELECT_m.xcos | 51 + webapp/history/blocks_xcos/SELF_SWITCH.xcos | 946 + webapp/history/blocks_xcos/SHIFT.xcos | 42 + webapp/history/blocks_xcos/SIGNUM.xcos | 37 + webapp/history/blocks_xcos/SINBLK_f.xcos | 37 + webapp/history/blocks_xcos/SOM_f.xcos | 48 + webapp/history/blocks_xcos/SQRT.xcos | 37 + webapp/history/blocks_xcos/SRFLIPFLOP.xcos | 1681 + webapp/history/blocks_xcos/STEP_FUNCTION.xcos | 1118 + webapp/history/blocks_xcos/SUBMAT.xcos | 46 + webapp/history/blocks_xcos/SUMMATION.xcos | 43 + webapp/history/blocks_xcos/SUM_f.xcos | 43 + webapp/history/blocks_xcos/SUPER_f.xcos | 493 + webapp/history/blocks_xcos/SWITCH2_m.xcos | 50 + webapp/history/blocks_xcos/SWITCH_f.xcos | 43 + webapp/history/blocks_xcos/SampleCLK.xcos | 38 + webapp/history/blocks_xcos/Sigbuilder.xcos | 992 + webapp/history/blocks_xcos/SineVoltage.xcos | 90 + webapp/history/blocks_xcos/SourceP.xcos | 71 + webapp/history/blocks_xcos/Switch.xcos | 72 + webapp/history/blocks_xcos/TANBLK_f.xcos | 37 + webapp/history/blocks_xcos/TCLSS.xcos | 55 + webapp/history/blocks_xcos/TEXT_f.xcos | 34 + webapp/history/blocks_xcos/TIME_DELAY.xcos | 44 + webapp/history/blocks_xcos/TIME_f.xcos | 32 + webapp/history/blocks_xcos/TKSCALE.xcos | 43 + webapp/history/blocks_xcos/TOWS_c.xcos | 43 + webapp/history/blocks_xcos/TRASH_f.xcos | 37 + webapp/history/blocks_xcos/TrigFun.xcos | 37 + webapp/history/blocks_xcos/VARIABLE_DELAY.xcos | 47 + webapp/history/blocks_xcos/VVsourceAC.xcos | 70 + webapp/history/blocks_xcos/VanneReglante.xcos | 72 + webapp/history/blocks_xcos/VariableResistor.xcos | 60 + webapp/history/blocks_xcos/VirtualCLK0.xcos | 32 + webapp/history/blocks_xcos/VoltageSensor.xcos | 61 + webapp/history/blocks_xcos/VsourceAC.xcos | 72 + webapp/history/blocks_xcos/WFILE_f.xcos | 69 + webapp/history/blocks_xcos/WRITEAU_f.xcos | 63 + webapp/history/blocks_xcos/WRITEC_f.xcos | 59 + webapp/history/blocks_xcos/ZCROSS_f.xcos | 42 + webapp/history/blocks_xcos/c_block.xcos | 44 + webapp/history/blocks_xcos/fortran_block.xcos | 47 + webapp/history/blocks_xcos/freq_div.xcos | 1165 + webapp/history/blocks_xcos/generic_block3.xcos | 55 + webapp/history/blocks_xcos/scifunc_block_m.xcos | 72 + webapp/history/data_structures/ABS_VALUE.js | 20 + webapp/history/data_structures/AFFICH_m.js | 33 + webapp/history/data_structures/ANDBLK.js | 75 + webapp/history/data_structures/ANDLOG_f.js | 15 + webapp/history/data_structures/AUTOMAT.js | 40 + webapp/history/data_structures/BACKLASH.js | 18 + webapp/history/data_structures/BARXY.js | 27 + webapp/history/data_structures/BIGSOM_f.js | 19 + webapp/history/data_structures/BITCLEAR.js | 21 + webapp/history/data_structures/BITSET.js | 21 + webapp/history/data_structures/BOUNCE.js | 17 + webapp/history/data_structures/BOUNCEXY.js | 43 + webapp/history/data_structures/BPLATFORM.js | 32 + webapp/history/data_structures/Bache.js | 50 + webapp/history/data_structures/CANIMXY.js | 43 + webapp/history/data_structures/CANIMXY3D.js | 43 + webapp/history/data_structures/CBLOCK.js | 48 + webapp/history/data_structures/CBLOCK4.js | 39 + webapp/history/data_structures/CCS.js | 30 + webapp/history/data_structures/CEVENTSCOPE.js | 29 + webapp/history/data_structures/CFSCOPE.js | 33 + webapp/history/data_structures/CLINDUMMY_f.js | 16 + webapp/history/data_structures/CLKFROM.js | 16 + webapp/history/data_structures/CLKGOTO.js | 17 + .../data_structures/CLKGotoTagVisibility.js | 23 + webapp/history/data_structures/CLKINV_f.js | 19 + webapp/history/data_structures/CLKOUTV_f.js | 17 + webapp/history/data_structures/CLKSOMV_f.js | 15 + webapp/history/data_structures/CLOCK_c.js | 48 + webapp/history/data_structures/CLR.js | 28 + webapp/history/data_structures/CLSS.js | 32 + webapp/history/data_structures/CMAT3D.js | 35 + webapp/history/data_structures/CMATVIEW.js | 32 + webapp/history/data_structures/CMSCOPE.js | 42 + webapp/history/data_structures/CONST.js | 19 + webapp/history/data_structures/CONSTRAINT2_c.js | 24 + webapp/history/data_structures/CONSTRAINT_c.js | 20 + webapp/history/data_structures/CONST_f.js | 19 + webapp/history/data_structures/CONST_m.js | 22 + webapp/history/data_structures/CONVERT.js | 24 + webapp/history/data_structures/COSBLK_f.js | 16 + webapp/history/data_structures/CSCOPE.js | 35 + webapp/history/data_structures/CSCOPXY.js | 40 + webapp/history/data_structures/CSCOPXY3D.js | 42 + webapp/history/data_structures/CUMSUM.js | 31 + webapp/history/data_structures/CURV_f.js | 28 + webapp/history/data_structures/CVS.js | 30 + webapp/history/data_structures/Capacitor.js | 28 + webapp/history/data_structures/ConstantVoltage.js | 27 + webapp/history/data_structures/Counter.js | 25 + webapp/history/data_structures/CurrentSensor.js | 24 + webapp/history/data_structures/DEADBAND.js | 25 + webapp/history/data_structures/DEBUG.js | 13 + webapp/history/data_structures/DELAYV_f.js | 29 + webapp/history/data_structures/DELAY_f.js | 72 + webapp/history/data_structures/DEMUX.js | 20 + webapp/history/data_structures/DEMUX_f.js | 20 + webapp/history/data_structures/DERIV.js | 16 + webapp/history/data_structures/DFLIPFLOP.js | 97 + webapp/history/data_structures/DIFF_f.js | 19 + webapp/history/data_structures/DLATCH.js | 41 + webapp/history/data_structures/DLR.js | 29 + webapp/history/data_structures/DLRADAPT_f.js | 33 + webapp/history/data_structures/DLSS.js | 29 + webapp/history/data_structures/DOLLAR.js | 24 + webapp/history/data_structures/DOLLAR_f.js | 24 + webapp/history/data_structures/DOLLAR_m.js | 24 + webapp/history/data_structures/Diode.js | 34 + webapp/history/data_structures/EDGE_TRIGGER.js | 87 + webapp/history/data_structures/ENDBLK.js | 13 + webapp/history/data_structures/END_c.js | 19 + webapp/history/data_structures/ESELECT_f.js | 24 + webapp/history/data_structures/EVTDLY_c.js | 22 + webapp/history/data_structures/EVTGEN_f.js | 18 + webapp/history/data_structures/EVTVARDLY.js | 19 + webapp/history/data_structures/EXPBLK_m.js | 25 + webapp/history/data_structures/EXPRESSION.js | 28 + webapp/history/data_structures/EXTRACT.js | 31 + webapp/history/data_structures/EXTRACTBITS.js | 23 + webapp/history/data_structures/EXTRACTOR.js | 19 + webapp/history/data_structures/EXTTRI.js | 31 + .../history/data_structures/Extract_Activation.js | 92 + webapp/history/data_structures/FROM.js | 23 + webapp/history/data_structures/FROMMO.js | 27 + webapp/history/data_structures/FROMWSB.js | 15 + webapp/history/data_structures/Flowmeter.js | 30 + webapp/history/data_structures/GAINBLK.js | 25 + webapp/history/data_structures/GAINBLK_f.js | 21 + webapp/history/data_structures/GAIN_f.js | 19 + webapp/history/data_structures/GENERAL_f.js | 25 + webapp/history/data_structures/GENSIN_f.js | 21 + webapp/history/data_structures/GENSQR_f.js | 21 + webapp/history/data_structures/GOTO.js | 23 + webapp/history/data_structures/GOTOMO.js | 27 + .../history/data_structures/GotoTagVisibility.js | 23 + .../history/data_structures/GotoTagVisibilityMO.js | 23 + webapp/history/data_structures/Ground.js | 23 + webapp/history/data_structures/Gyrator.js | 30 + webapp/history/data_structures/HALT_f.js | 19 + webapp/history/data_structures/HYSTHERESIS.js | 27 + webapp/history/data_structures/IFTHEL_f.js | 22 + webapp/history/data_structures/INIMPL_f.js | 25 + webapp/history/data_structures/INTEGRAL_f.js | 19 + webapp/history/data_structures/INTEGRAL_m.js | 26 + webapp/history/data_structures/INTMUL.js | 24 + webapp/history/data_structures/INTRP2BLK_f.js | 24 + webapp/history/data_structures/INTRPLBLK_f.js | 21 + webapp/history/data_structures/INVBLK.js | 18 + webapp/history/data_structures/IN_f.js | 20 + webapp/history/data_structures/ISELECT_m.js | 31 + webapp/history/data_structures/IdealTransformer.js | 30 + webapp/history/data_structures/Inductor.js | 28 + webapp/history/data_structures/JKFLIPFLOP.js | 53 + webapp/history/data_structures/LOGBLK_f.js | 21 + webapp/history/data_structures/LOGIC.js | 25 + webapp/history/data_structures/LOGICAL_OP.js | 23 + webapp/history/data_structures/LOOKUP_f.js | 15 + webapp/history/data_structures/MATBKSL.js | 31 + webapp/history/data_structures/MATCATH.js | 31 + webapp/history/data_structures/MATCATV.js | 33 + webapp/history/data_structures/MATDET.js | 31 + webapp/history/data_structures/MATDIAG.js | 31 + webapp/history/data_structures/MATDIV.js | 31 + webapp/history/data_structures/MATEIG.js | 31 + webapp/history/data_structures/MATEXPM.js | 31 + webapp/history/data_structures/MATINV.js | 31 + webapp/history/data_structures/MATLU.js | 31 + webapp/history/data_structures/MATMAGPHI.js | 31 + webapp/history/data_structures/MATMUL.js | 18 + webapp/history/data_structures/MATPINV.js | 31 + webapp/history/data_structures/MATRESH.js | 31 + webapp/history/data_structures/MATSING.js | 31 + webapp/history/data_structures/MATSUM.js | 31 + webapp/history/data_structures/MATTRAN.js | 17 + webapp/history/data_structures/MATZCONJ.js | 31 + webapp/history/data_structures/MATZREIM.js | 31 + webapp/history/data_structures/MAXMIN.js | 18 + webapp/history/data_structures/MAX_f.js | 19 + webapp/history/data_structures/MBLOCK.js | 30 + webapp/history/data_structures/MCLOCK_f.js | 81 + webapp/history/data_structures/MFCLCK_f.js | 24 + webapp/history/data_structures/MIN_f.js | 19 + webapp/history/data_structures/MUX.js | 19 + webapp/history/data_structures/MUX_f.js | 19 + webapp/history/data_structures/M_SWITCH.js | 23 + webapp/history/data_structures/M_freq.js | 19 + webapp/history/data_structures/Modulo_Count.js | 22 + webapp/history/data_structures/NEGTOPOS_f.js | 17 + webapp/history/data_structures/NMOS.js | 43 + webapp/history/data_structures/NPN.js | 30 + webapp/history/data_structures/NRMSOM_f.js | 20 + webapp/history/data_structures/OUTIMPL_f.js | 25 + webapp/history/data_structures/OUT_f.js | 22 + webapp/history/data_structures/OpAmp.js | 30 + webapp/history/data_structures/PDE.js | 19 + webapp/history/data_structures/PID.js | 43 + webapp/history/data_structures/PMOS.js | 43 + webapp/history/data_structures/PNP.js | 30 + webapp/history/data_structures/POSTONEG_f.js | 19 + webapp/history/data_structures/POWBLK_f.js | 21 + webapp/history/data_structures/PRODUCT.js | 19 + webapp/history/data_structures/PROD_f.js | 12 + webapp/history/data_structures/PULSE_SC.js | 57 + webapp/history/data_structures/PerteDP.js | 40 + webapp/history/data_structures/PotentialSensor.js | 23 + webapp/history/data_structures/PuitsP.js | 31 + webapp/history/data_structures/QUANT_f.js | 22 + webapp/history/data_structures/RAMP.js | 27 + webapp/history/data_structures/RAND_m.js | 39 + webapp/history/data_structures/RATELIMITER.js | 23 + webapp/history/data_structures/READAU_f.js | 40 + webapp/history/data_structures/READC_f.js | 46 + webapp/history/data_structures/REGISTER.js | 20 + webapp/history/data_structures/RELATIONALOP.js | 22 + webapp/history/data_structures/RELAY_f.js | 25 + webapp/history/data_structures/RFILE_f.js | 40 + webapp/history/data_structures/RICC.js | 31 + webapp/history/data_structures/ROOTCOEF.js | 31 + webapp/history/data_structures/Resistor.js | 28 + webapp/history/data_structures/SAMPHOLD_m.js | 21 + webapp/history/data_structures/SATURATION.js | 25 + webapp/history/data_structures/SAWTOOTH_f.js | 17 + webapp/history/data_structures/SCALAR2VECTOR.js | 18 + webapp/history/data_structures/SELECT_m.js | 31 + webapp/history/data_structures/SELF_SWITCH.js | 24 + webapp/history/data_structures/SHIFT.js | 26 + webapp/history/data_structures/SIGNUM.js | 20 + webapp/history/data_structures/SINBLK_f.js | 16 + webapp/history/data_structures/SOM_f.js | 19 + webapp/history/data_structures/SQRT.js | 19 + webapp/history/data_structures/SRFLIPFLOP.js | 44 + webapp/history/data_structures/STEP_FUNCTION.js | 57 + webapp/history/data_structures/SUBMAT.js | 31 + webapp/history/data_structures/SUMMATION.js | 21 + webapp/history/data_structures/SUM_f.js | 16 + webapp/history/data_structures/SUPER_f.js | 28 + webapp/history/data_structures/SWITCH2_m.js | 30 + webapp/history/data_structures/SWITCH_f.js | 24 + webapp/history/data_structures/SampleCLK.js | 15 + webapp/history/data_structures/Sigbuilder.js | 19 + webapp/history/data_structures/SineVoltage.js | 36 + webapp/history/data_structures/SourceP.js | 33 + webapp/history/data_structures/Switch.js | 34 + webapp/history/data_structures/TANBLK_f.js | 18 + webapp/history/data_structures/TCLSS.js | 27 + webapp/history/data_structures/TEXT_f.js | 21 + webapp/history/data_structures/TIME_DELAY.js | 26 + webapp/history/data_structures/TIME_f.js | 13 + webapp/history/data_structures/TKSCALE.js | 23 + webapp/history/data_structures/TOWS_c.js | 31 + webapp/history/data_structures/TRASH_f.js | 18 + webapp/history/data_structures/TrigFun.js | 16 + webapp/history/data_structures/VARIABLE_DELAY.js | 26 + webapp/history/data_structures/VVsourceAC.js | 30 + webapp/history/data_structures/VanneReglante.js | 32 + webapp/history/data_structures/VariableResistor.js | 24 + webapp/history/data_structures/VirtualCLK0.js | 16 + webapp/history/data_structures/VoltageSensor.js | 24 + webapp/history/data_structures/VsourceAC.js | 30 + webapp/history/data_structures/WFILE_f.js | 30 + webapp/history/data_structures/WRITEAU_f.js | 32 + webapp/history/data_structures/WRITEC_f.js | 32 + webapp/history/data_structures/ZCROSS_f.js | 23 + webapp/history/data_structures/c_block.js | 43 + webapp/history/data_structures/fortran_block.js | 25 + webapp/history/data_structures/freq_div.js | 113 + webapp/history/data_structures/generic_block3.js | 23 + webapp/history/data_structures/scifunc_block_m.js | 51 + webapp/images/ScilabExecute.png | Bin 0 -> 660 bytes webapp/images/add.png | Bin 0 -> 1564 bytes webapp/images/button.gif | Bin 0 -> 137 bytes webapp/images/camera.png | Bin 0 -> 887 bytes webapp/images/check.png | Bin 0 -> 253 bytes webapp/images/close.gif | Bin 0 -> 70 bytes webapp/images/close.png | Bin 0 -> 1910 bytes webapp/images/collapsed.gif | Bin 0 -> 877 bytes webapp/images/connector.gif | Bin 0 -> 954 bytes webapp/images/copy.png | Bin 0 -> 728 bytes webapp/images/cut.png | Bin 0 -> 781 bytes webapp/images/delete2.png | Bin 0 -> 914 bytes webapp/images/dot.gif | Bin 0 -> 517 bytes webapp/images/draw-brush.png | Bin 0 -> 635 bytes webapp/images/edit.png | Bin 0 -> 599 bytes webapp/images/error.gif | Bin 0 -> 907 bytes webapp/images/expanded.gif | Bin 0 -> 878 bytes webapp/images/export1.png | Bin 0 -> 857 bytes webapp/images/fit_to_size.png | Bin 0 -> 529 bytes webapp/images/flip.png | Bin 0 -> 540 bytes webapp/images/gear.gif | Bin 0 -> 280 bytes webapp/images/gradient_background.jpg | Bin 0 -> 6164 bytes webapp/images/green-dot.gif | Bin 0 -> 326 bytes webapp/images/grid.gif | Bin 0 -> 58 bytes webapp/images/group.png | Bin 0 -> 899 bytes webapp/images/key.png | Bin 0 -> 300 bytes webapp/images/loading.gif | Bin 0 -> 10132 bytes webapp/images/maximize.gif | Bin 0 -> 843 bytes webapp/images/minimize.gif | Bin 0 -> 64 bytes webapp/images/mirror.png | Bin 0 -> 581 bytes webapp/images/navigate_minus.png | Bin 0 -> 485 bytes webapp/images/navigate_plus.png | Bin 0 -> 709 bytes webapp/images/normalize.gif | Bin 0 -> 845 bytes webapp/images/paste.png | Bin 0 -> 783 bytes webapp/images/plus.png | Bin 0 -> 236 bytes webapp/images/point.gif | Bin 0 -> 55 bytes webapp/images/press32.png | Bin 0 -> 2261 bytes webapp/images/print32.png | Bin 0 -> 2111 bytes webapp/images/printer.png | Bin 0 -> 896 bytes webapp/images/redo.png | Bin 0 -> 895 bytes webapp/images/resize.gif | Bin 0 -> 74 bytes webapp/images/rotate.png | Bin 0 -> 703 bytes webapp/images/selectall.png | Bin 0 -> 441 bytes webapp/images/separator.gif | Bin 0 -> 146 bytes webapp/images/setup.png | Bin 0 -> 440 bytes webapp/images/sidebar_bg.gif | Bin 0 -> 80 bytes webapp/images/spacer.gif | Bin 0 -> 43 bytes webapp/images/submenu.gif | Bin 0 -> 56 bytes webapp/images/superblock.png | Bin 0 -> 575 bytes webapp/images/toolbar_bg.gif | Bin 0 -> 155 bytes webapp/images/transparent.gif | Bin 0 -> 90 bytes webapp/images/undo.png | Bin 0 -> 879 bytes webapp/images/view_1_1.png | Bin 0 -> 849 bytes webapp/images/view_1_132.png | Bin 0 -> 2199 bytes webapp/images/view_next.png | Bin 0 -> 918 bytes webapp/images/view_previous.png | Bin 0 -> 912 bytes webapp/images/warning.gif | Bin 0 -> 276 bytes webapp/images/warning.png | Bin 0 -> 425 bytes webapp/images/window-title.gif | Bin 0 -> 275 bytes webapp/images/window.gif | Bin 0 -> 75 bytes webapp/images/wires-grid.gif | Bin 0 -> 50 bytes webapp/images/zoom_in.png | Bin 0 -> 858 bytes webapp/images/zoom_in32.png | Bin 0 -> 2184 bytes webapp/images/zoom_out.png | Bin 0 -> 847 bytes webapp/images/zoom_out32.png | Bin 0 -> 2150 bytes webapp/index.html | 3391 ++ webapp/jquery/LICENSE.txt | 341 + webapp/jquery/README.html | 71 + webapp/jquery/farbtastic.css | 51 + webapp/jquery/farbtastic.js | 345 + .../jquery/images/ui-bg_flat_75_ffffff_40x100.png | Bin 0 -> 178 bytes .../jquery/images/ui-bg_glass_75_e6e6e6_1x400.png | Bin 0 -> 110 bytes webapp/jquery/images/ui-icons_888888_256x240.png | Bin 0 -> 4369 bytes webapp/jquery/jquery-1.8.2.js | 9440 ++++ webapp/jquery/jquery-ui.css | 470 + webapp/jquery/marker.png | Bin 0 -> 652 bytes webapp/jquery/mask.png | Bin 0 -> 2020 bytes webapp/jquery/wheel.png | Bin 0 -> 11733 bytes webapp/math.js | 53091 +++++++++++++++++++ webapp/mxClient.min.js | 1564 + webapp/orientation.js | 450 + webapp/palettes/ABS_VALUE.png | Bin 0 -> 859 bytes webapp/palettes/AFFICH_m.png | Bin 0 -> 761 bytes webapp/palettes/ANDBLK.png | Bin 0 -> 972 bytes webapp/palettes/ANDLOG_f.png | Bin 0 -> 1429 bytes webapp/palettes/AUTOMAT.png | Bin 0 -> 1535 bytes webapp/palettes/BACKLASH.png | Bin 0 -> 1000 bytes webapp/palettes/BARXY.png | Bin 0 -> 1970 bytes webapp/palettes/BIGSOM_f.png | Bin 0 -> 982 bytes webapp/palettes/BITCLEAR.png | Bin 0 -> 1095 bytes webapp/palettes/BITSET.png | Bin 0 -> 1019 bytes webapp/palettes/BOUNCE.png | Bin 0 -> 1185 bytes webapp/palettes/BOUNCEXY.png | Bin 0 -> 1532 bytes webapp/palettes/BPLATFORM.png | Bin 0 -> 1140 bytes webapp/palettes/Bache.png | Bin 0 -> 1088 bytes webapp/palettes/CANIMXY.png | Bin 0 -> 1532 bytes webapp/palettes/CANIMXY3D.png | Bin 0 -> 1543 bytes webapp/palettes/CBLOCK.png | Bin 0 -> 1183 bytes webapp/palettes/CBLOCK4.png | Bin 0 -> 1172 bytes webapp/palettes/CCS.png | Bin 0 -> 789 bytes webapp/palettes/CEVENTSCOPE.png | Bin 0 -> 2021 bytes webapp/palettes/CFSCOPE.png | Bin 0 -> 1943 bytes webapp/palettes/CLINDUMMY_f.png | Bin 0 -> 1021 bytes webapp/palettes/CLKFROM.png | Bin 0 -> 462 bytes webapp/palettes/CLKGOTO.png | Bin 0 -> 465 bytes webapp/palettes/CLKGotoTagVisibility.png | Bin 0 -> 1436 bytes webapp/palettes/CLKINV_f.png | Bin 0 -> 313 bytes webapp/palettes/CLKOUTV_f.png | Bin 0 -> 315 bytes webapp/palettes/CLKSOMV_f.png | Bin 0 -> 1081 bytes webapp/palettes/CLOCK_c.png | Bin 0 -> 1488 bytes webapp/palettes/CLR.png | Bin 0 -> 1024 bytes webapp/palettes/CLSS.png | Bin 0 -> 1494 bytes webapp/palettes/CMAT3D.png | Bin 0 -> 2385 bytes webapp/palettes/CMATVIEW.png | Bin 0 -> 2511 bytes webapp/palettes/CMSCOPE.png | Bin 0 -> 2050 bytes webapp/palettes/CONST.png | Bin 0 -> 512 bytes webapp/palettes/CONSTRAINT2_c.png | Bin 0 -> 975 bytes webapp/palettes/CONSTRAINT_c.png | Bin 0 -> 763 bytes webapp/palettes/CONST_f.png | Bin 0 -> 512 bytes webapp/palettes/CONST_m.png | Bin 0 -> 512 bytes webapp/palettes/CONVERT.png | Bin 0 -> 1020 bytes webapp/palettes/COSBLK_f.png | Bin 0 -> 863 bytes webapp/palettes/CSCOPE.png | Bin 0 -> 2033 bytes webapp/palettes/CSCOPXY.png | Bin 0 -> 1481 bytes webapp/palettes/CSCOPXY3D.png | Bin 0 -> 1570 bytes webapp/palettes/CUMSUM.png | Bin 0 -> 958 bytes webapp/palettes/CURV_f.png | Bin 0 -> 829 bytes webapp/palettes/CVS.png | Bin 0 -> 752 bytes webapp/palettes/Capacitor.png | Bin 0 -> 397 bytes webapp/palettes/ConstantVoltage.png | Bin 0 -> 442 bytes webapp/palettes/Counter.png | Bin 0 -> 1219 bytes webapp/palettes/CurrentSensor.png | Bin 0 -> 2717 bytes webapp/palettes/DEADBAND.png | Bin 0 -> 801 bytes webapp/palettes/DEBUG.png | Bin 0 -> 805 bytes webapp/palettes/DELAYV_f.png | Bin 0 -> 1486 bytes webapp/palettes/DELAY_f.png | Bin 0 -> 875 bytes webapp/palettes/DEMUX.png | Bin 0 -> 855 bytes webapp/palettes/DEMUX_f.png | Bin 0 -> 855 bytes webapp/palettes/DERIV.png | Bin 0 -> 778 bytes webapp/palettes/DFLIPFLOP.png | Bin 0 -> 1011 bytes webapp/palettes/DIFF_f.png | Bin 0 -> 652 bytes webapp/palettes/DLATCH.png | Bin 0 -> 1124 bytes webapp/palettes/DLR.png | Bin 0 -> 1103 bytes webapp/palettes/DLRADAPT_f.png | Bin 0 -> 1323 bytes webapp/palettes/DLSS.png | Bin 0 -> 1532 bytes webapp/palettes/DOLLAR.png | Bin 0 -> 760 bytes webapp/palettes/DOLLAR_f.png | Bin 0 -> 760 bytes webapp/palettes/DOLLAR_m.png | Bin 0 -> 760 bytes webapp/palettes/Diode.png | Bin 0 -> 564 bytes webapp/palettes/EDGE_TRIGGER.png | Bin 0 -> 1115 bytes webapp/palettes/ENDBLK.png | Bin 0 -> 591 bytes webapp/palettes/END_c.png | Bin 0 -> 726 bytes webapp/palettes/ESELECT_f.png | Bin 0 -> 1199 bytes webapp/palettes/EVTDLY_c.png | Bin 0 -> 1046 bytes webapp/palettes/EVTGEN_f.png | Bin 0 -> 1118 bytes webapp/palettes/EVTVARDLY.png | Bin 0 -> 1186 bytes webapp/palettes/EXPBLK_m.png | Bin 0 -> 696 bytes webapp/palettes/EXPRESSION.png | Bin 0 -> 1128 bytes webapp/palettes/EXTRACT.png | Bin 0 -> 1025 bytes webapp/palettes/EXTRACTBITS.png | Bin 0 -> 1122 bytes webapp/palettes/EXTRACTOR.png | Bin 0 -> 946 bytes webapp/palettes/EXTTRI.png | Bin 0 -> 1310 bytes webapp/palettes/Extract_Activation.png | Bin 0 -> 1297 bytes webapp/palettes/FROM.png | Bin 0 -> 449 bytes webapp/palettes/FROMMO.png | Bin 0 -> 398 bytes webapp/palettes/FROMWSB.png | Bin 0 -> 918 bytes webapp/palettes/Flowmeter.png | Bin 0 -> 2746 bytes webapp/palettes/GAINBLK.png | Bin 0 -> 863 bytes webapp/palettes/GAINBLK_f.png | Bin 0 -> 863 bytes webapp/palettes/GAIN_f.png | Bin 0 -> 863 bytes webapp/palettes/GENERAL_f.png | Bin 0 -> 1042 bytes webapp/palettes/GENSIN_f.png | Bin 0 -> 1702 bytes webapp/palettes/GENSQR_f.png | Bin 0 -> 891 bytes webapp/palettes/GOTO.png | Bin 0 -> 444 bytes webapp/palettes/GOTOMO.png | Bin 0 -> 400 bytes webapp/palettes/GotoTagVisibility.png | Bin 0 -> 1025 bytes webapp/palettes/GotoTagVisibilityMO.png | Bin 0 -> 1520 bytes webapp/palettes/Ground.png | Bin 0 -> 317 bytes webapp/palettes/Gyrator.png | Bin 0 -> 845 bytes webapp/palettes/HALT_f.png | Bin 0 -> 675 bytes webapp/palettes/HYSTHERESIS.png | Bin 0 -> 830 bytes webapp/palettes/IFTHEL_f.png | Bin 0 -> 1374 bytes webapp/palettes/INIMPL_f.png | Bin 0 -> 255 bytes webapp/palettes/INTEGRAL_f.png | Bin 0 -> 731 bytes webapp/palettes/INTEGRAL_m.png | Bin 0 -> 942 bytes webapp/palettes/INTMUL.png | Bin 0 -> 809 bytes webapp/palettes/INTRP2BLK_f.png | Bin 0 -> 946 bytes webapp/palettes/INTRPLBLK_f.png | Bin 0 -> 797 bytes webapp/palettes/INVBLK.png | Bin 0 -> 684 bytes webapp/palettes/IN_f.png | Bin 0 -> 303 bytes webapp/palettes/ISELECT_m.png | Bin 0 -> 1104 bytes webapp/palettes/IdealTransformer.png | Bin 0 -> 1036 bytes webapp/palettes/Inductor.png | Bin 0 -> 464 bytes webapp/palettes/JKFLIPFLOP.png | Bin 0 -> 963 bytes webapp/palettes/LOGBLK_f.png | Bin 0 -> 792 bytes webapp/palettes/LOGIC.png | Bin 0 -> 1007 bytes webapp/palettes/LOGICAL_OP.png | Bin 0 -> 853 bytes webapp/palettes/LOOKUP_f.png | Bin 0 -> 2062 bytes webapp/palettes/MATBKSL.png | Bin 0 -> 842 bytes webapp/palettes/MATCATH.png | Bin 0 -> 1041 bytes webapp/palettes/MATCATV.png | Bin 0 -> 1095 bytes webapp/palettes/MATDET.png | Bin 0 -> 659 bytes webapp/palettes/MATDIAG.png | Bin 0 -> 850 bytes webapp/palettes/MATDIV.png | Bin 0 -> 845 bytes webapp/palettes/MATEIG.png | Bin 0 -> 684 bytes webapp/palettes/MATEXPM.png | Bin 0 -> 822 bytes webapp/palettes/MATINV.png | Bin 0 -> 732 bytes webapp/palettes/MATLU.png | Bin 0 -> 637 bytes webapp/palettes/MATMAGPHI.png | Bin 0 -> 1093 bytes webapp/palettes/MATMUL.png | Bin 0 -> 914 bytes webapp/palettes/MATPINV.png | Bin 0 -> 777 bytes webapp/palettes/MATRESH.png | Bin 0 -> 982 bytes webapp/palettes/MATSING.png | Bin 0 -> 846 bytes webapp/palettes/MATSUM.png | Bin 0 -> 976 bytes webapp/palettes/MATTRAN.png | Bin 0 -> 963 bytes webapp/palettes/MATZCONJ.png | Bin 0 -> 860 bytes webapp/palettes/MATZREIM.png | Bin 0 -> 970 bytes webapp/palettes/MAXMIN.png | Bin 0 -> 861 bytes webapp/palettes/MAX_f.png | Bin 0 -> 861 bytes webapp/palettes/MBLOCK.png | Bin 0 -> 1288 bytes webapp/palettes/MCLOCK_f.png | Bin 0 -> 1202 bytes webapp/palettes/MFCLCK_f.png | Bin 0 -> 1168 bytes webapp/palettes/MIN_f.png | Bin 0 -> 719 bytes webapp/palettes/MUX.png | Bin 0 -> 765 bytes webapp/palettes/MUX_f.png | Bin 0 -> 765 bytes webapp/palettes/M_SWITCH.png | Bin 0 -> 1567 bytes webapp/palettes/M_freq.png | Bin 0 -> 1427 bytes webapp/palettes/Modulo_Count.png | Bin 0 -> 1395 bytes webapp/palettes/NEGTOPOS_f.png | Bin 0 -> 718 bytes webapp/palettes/NMOS.png | Bin 0 -> 751 bytes webapp/palettes/NPN.png | Bin 0 -> 745 bytes webapp/palettes/NRMSOM_f.png | Bin 0 -> 988 bytes webapp/palettes/OUTIMPL_f.png | Bin 0 -> 257 bytes webapp/palettes/OUT_f.png | Bin 0 -> 297 bytes webapp/palettes/OpAmp.png | Bin 0 -> 1649 bytes webapp/palettes/PDE.png | Bin 0 -> 882 bytes webapp/palettes/PID.png | Bin 0 -> 682 bytes webapp/palettes/PMOS.png | Bin 0 -> 766 bytes webapp/palettes/PNP.png | Bin 0 -> 747 bytes webapp/palettes/POSTONEG_f.png | Bin 0 -> 722 bytes webapp/palettes/POWBLK_f.png | Bin 0 -> 687 bytes webapp/palettes/PRODUCT.png | Bin 0 -> 1013 bytes webapp/palettes/PROD_f.png | Bin 0 -> 803 bytes webapp/palettes/PULSE_SC.png | Bin 0 -> 788 bytes webapp/palettes/PerteDP.png | Bin 0 -> 454 bytes webapp/palettes/PotentialSensor.png | Bin 0 -> 2578 bytes webapp/palettes/PuitsP.png | Bin 0 -> 1079 bytes webapp/palettes/QUANT_f.png | Bin 0 -> 759 bytes webapp/palettes/RAMP.png | Bin 0 -> 790 bytes webapp/palettes/RAND_m.png | Bin 0 -> 1410 bytes webapp/palettes/RATELIMITER.png | Bin 0 -> 989 bytes webapp/palettes/READAU_f.png | Bin 0 -> 1209 bytes webapp/palettes/READC_f.png | Bin 0 -> 1669 bytes webapp/palettes/REGISTER.png | Bin 0 -> 1272 bytes webapp/palettes/RELATIONALOP.png | Bin 0 -> 670 bytes webapp/palettes/RELAY_f.png | Bin 0 -> 1008 bytes webapp/palettes/RFILE_f.png | Bin 0 -> 1459 bytes webapp/palettes/RICC.png | Bin 0 -> 794 bytes webapp/palettes/ROOTCOEF.png | Bin 0 -> 1052 bytes webapp/palettes/Resistor.png | Bin 0 -> 505 bytes webapp/palettes/SAMPHOLD_m.png | Bin 0 -> 857 bytes webapp/palettes/SATURATION.png | Bin 0 -> 785 bytes webapp/palettes/SAWTOOTH_f.png | Bin 0 -> 1282 bytes webapp/palettes/SCALAR2VECTOR.png | Bin 0 -> 1475 bytes webapp/palettes/SELECT_m.png | Bin 0 -> 1111 bytes webapp/palettes/SELF_SWITCH.png | Bin 0 -> 1792 bytes webapp/palettes/SELF_SWITCH_off.png | Bin 0 -> 1823 bytes webapp/palettes/SELF_SWITCH_on.png | Bin 0 -> 1723 bytes webapp/palettes/SHIFT.png | Bin 0 -> 1275 bytes webapp/palettes/SIGNUM.png | Bin 0 -> 866 bytes webapp/palettes/SINBLK_f.png | Bin 0 -> 760 bytes webapp/palettes/SOM_f.png | Bin 0 -> 1007 bytes webapp/palettes/SQRT.png | Bin 0 -> 896 bytes webapp/palettes/SRFLIPFLOP.png | Bin 0 -> 1150 bytes webapp/palettes/STEP_FUNCTION.png | Bin 0 -> 645 bytes webapp/palettes/SUBMAT.png | Bin 0 -> 1006 bytes webapp/palettes/SUMMATION.png | Bin 0 -> 1011 bytes webapp/palettes/SUM_f.png | Bin 0 -> 752 bytes webapp/palettes/SUPER_f.png | Bin 0 -> 801 bytes webapp/palettes/SWITCH2_m.png | Bin 0 -> 1289 bytes webapp/palettes/SWITCH_f.png | Bin 0 -> 1244 bytes webapp/palettes/SampleCLK.png | Bin 0 -> 1383 bytes webapp/palettes/Sigbuilder.png | Bin 0 -> 1315 bytes webapp/palettes/SineVoltage.png | Bin 0 -> 1043 bytes webapp/palettes/SourceP.png | Bin 0 -> 1209 bytes webapp/palettes/Switch.png | Bin 0 -> 881 bytes webapp/palettes/TANBLK_f.png | Bin 0 -> 753 bytes webapp/palettes/TCLSS.png | Bin 0 -> 1406 bytes webapp/palettes/TEXT_f.png | Bin 0 -> 110 bytes webapp/palettes/TIME_DELAY.png | Bin 0 -> 1454 bytes webapp/palettes/TIME_f.png | Bin 0 -> 1398 bytes webapp/palettes/TKSCALE.png | Bin 0 -> 1064 bytes webapp/palettes/TOWS_c.png | Bin 0 -> 1646 bytes webapp/palettes/TRASH_f.png | Bin 0 -> 846 bytes webapp/palettes/TrigFun.png | Bin 0 -> 1018 bytes webapp/palettes/VARIABLE_DELAY.png | Bin 0 -> 1290 bytes webapp/palettes/VVsourceAC.png | Bin 0 -> 1229 bytes webapp/palettes/VanneReglante.png | Bin 0 -> 2132 bytes webapp/palettes/VariableResistor.png | Bin 0 -> 1034 bytes webapp/palettes/VirtualCLK0.png | Bin 0 -> 1485 bytes webapp/palettes/VoltageSensor.png | Bin 0 -> 2731 bytes webapp/palettes/VsourceAC.png | Bin 0 -> 1316 bytes webapp/palettes/WFILE_f.png | Bin 0 -> 1477 bytes webapp/palettes/WRITEAU_f.png | Bin 0 -> 1711 bytes webapp/palettes/WRITEC_f.png | Bin 0 -> 1587 bytes webapp/palettes/ZCROSS_f.png | Bin 0 -> 909 bytes webapp/palettes/c_block.png | Bin 0 -> 1068 bytes webapp/palettes/fortran_block.png | Bin 0 -> 1378 bytes webapp/palettes/freq_div.png | Bin 0 -> 1415 bytes webapp/palettes/generic_block3.png | Bin 0 -> 1439 bytes webapp/palettes/palettes.xml | 849 + webapp/palettes/scifunc_block_m.png | Bin 0 -> 1325 bytes webapp/resources/editor.properties | 5 + webapp/resources/graph.properties | 11 + webapp/setup.js | 57 + webapp/styles/Xcos-style.xml | 960 + 2134 files changed, 150824 insertions(+), 150824 deletions(-) delete mode 100755 Queue.js delete mode 100644 blocks/3DSCOPE.svg delete mode 100644 blocks/ANDBLK.svg delete mode 100644 blocks/ASCOPE.svg delete mode 100644 blocks/BACHE.svg delete mode 100644 blocks/BARXY.svg delete mode 100644 blocks/BPLATFORM.svg delete mode 100644 blocks/CCS.svg delete mode 100644 blocks/CLOCK_c.svg delete mode 100644 blocks/CLOCK_f.svg delete mode 100644 blocks/CSCOPXY.svg delete mode 100644 blocks/CSCOPXY3D.svg delete mode 100644 blocks/CVS.svg delete mode 100644 blocks/Capacitor.svg delete mode 100644 blocks/ConstantVoltage.svg delete mode 100644 blocks/CurrentSensor.svg delete mode 100644 blocks/DEADBAND.svg delete mode 100644 blocks/DSCOPE.svg delete mode 100644 blocks/Diode.svg delete mode 100644 blocks/Flowmeter.svg delete mode 100644 blocks/Ground.svg delete mode 100644 blocks/Gyrator.svg delete mode 100644 blocks/HYSTHERESIS.svg delete mode 100644 blocks/INTEGRAL.svg delete mode 100644 blocks/IdealTransformer.svg delete mode 100644 blocks/Inductor.svg delete mode 100644 blocks/NMOS.svg delete mode 100644 blocks/NPN.svg delete mode 100644 blocks/PMOS.svg delete mode 100644 blocks/PNP.svg delete mode 100644 blocks/PRODUCT.svg delete mode 100644 blocks/PULSE_SC.svg delete mode 100644 blocks/PerteDP.svg delete mode 100644 blocks/PotentialSensor.svg delete mode 100644 blocks/PuitP.svg delete mode 100644 blocks/QUANT_f.svg delete mode 100644 blocks/RAMP.svg delete mode 100644 blocks/Resistor.svg delete mode 100644 blocks/SATURATION.svg delete mode 100644 blocks/SINUS_f.svg delete mode 100644 blocks/SQUARE_WAVE_f.svg delete mode 100644 blocks/STEP_FUNCTION.svg delete mode 100644 blocks/SUM.svg delete mode 100644 blocks/SUPER.svg delete mode 100644 blocks/SWITCH.svg delete mode 100644 blocks/SampleCLK.svg delete mode 100644 blocks/Self_Switch_off.svg delete mode 100644 blocks/Self_Switch_on.svg delete mode 100644 blocks/SourceP.svg delete mode 100644 blocks/VanneReglante.svg delete mode 100644 blocks/VariableResistor.svg delete mode 100644 blocks/VirtualCLK0.svg delete mode 100644 blocks/VoltageSensor.svg delete mode 100644 blocks/sawtooth.svg delete mode 100755 chart.js delete mode 100644 combined.js delete mode 100644 composer.json delete mode 100644 config/keyhandler-commons.xml delete mode 100644 css/common.css delete mode 100644 css/explorer.css delete mode 100644 data_structures_correct/ABS_VALUE.js delete mode 100644 data_structures_correct/AFFICH_m.js delete mode 100644 data_structures_correct/ANDBLK.js delete mode 100644 data_structures_correct/ANDLOG_f.js delete mode 100644 data_structures_correct/AUTOMAT.js delete mode 100644 data_structures_correct/BACKLASH.js delete mode 100644 data_structures_correct/BARXY.js delete mode 100644 data_structures_correct/BIGSOM_f.js delete mode 100644 data_structures_correct/BITCLEAR.js delete mode 100644 data_structures_correct/BITSET.js delete mode 100644 data_structures_correct/BOUNCE.js delete mode 100644 data_structures_correct/BOUNCEXY.js delete mode 100644 data_structures_correct/BPLATFORM.js delete mode 100644 data_structures_correct/Bache.js delete mode 100644 data_structures_correct/CANIMXY.js delete mode 100644 data_structures_correct/CANIMXY3D.js delete mode 100644 data_structures_correct/CBLOCK.js delete mode 100644 data_structures_correct/CBLOCK4.js delete mode 100644 data_structures_correct/CCS.js delete mode 100644 data_structures_correct/CEVENTSCOPE.js delete mode 100644 data_structures_correct/CFSCOPE.js delete mode 100644 data_structures_correct/CLINDUMMY_f.js delete mode 100644 data_structures_correct/CLKFROM.js delete mode 100644 data_structures_correct/CLKGOTO.js delete mode 100644 data_structures_correct/CLKGotoTagVisibility.js delete mode 100644 data_structures_correct/CLKINV_f.js delete mode 100644 data_structures_correct/CLKOUTV_f.js delete mode 100644 data_structures_correct/CLKSOMV_f.js delete mode 100644 data_structures_correct/CLKSOM_f.js delete mode 100644 data_structures_correct/CLOCK_c.js delete mode 100644 data_structures_correct/CLR.js delete mode 100644 data_structures_correct/CLSS.js delete mode 100644 data_structures_correct/CMSCOPE.js delete mode 100644 data_structures_correct/CONST.js delete mode 100644 data_structures_correct/CONSTRAINT2_c.js delete mode 100644 data_structures_correct/CONSTRAINT_c.js delete mode 100644 data_structures_correct/CONST_f.js delete mode 100644 data_structures_correct/CONST_m.js delete mode 100644 data_structures_correct/CONVERT.js delete mode 100644 data_structures_correct/COSBLK_f.js delete mode 100644 data_structures_correct/CSCOPE.js delete mode 100644 data_structures_correct/CSCOPXY.js delete mode 100644 data_structures_correct/CSCOPXY3D.js delete mode 100644 data_structures_correct/CUMSUM.js delete mode 100644 data_structures_correct/CURV_f.js delete mode 100644 data_structures_correct/CVS.js delete mode 100644 data_structures_correct/Capacitor.js delete mode 100644 data_structures_correct/ConstantVoltage.js delete mode 100644 data_structures_correct/Counter.js delete mode 100644 data_structures_correct/CurrentSensor.js delete mode 100644 data_structures_correct/DEADBAND.js delete mode 100644 data_structures_correct/DEBUG.js delete mode 100644 data_structures_correct/DELAYV_f.js delete mode 100644 data_structures_correct/DELAY_f.js delete mode 100644 data_structures_correct/DEMUX.js delete mode 100644 data_structures_correct/DEMUX_f.js delete mode 100644 data_structures_correct/DERIV.js delete mode 100644 data_structures_correct/DFLIPFLOP.js delete mode 100644 data_structures_correct/DIFF_f.js delete mode 100644 data_structures_correct/DLATCH.js delete mode 100644 data_structures_correct/DLR.js delete mode 100644 data_structures_correct/DLRADAPT_f.js delete mode 100644 data_structures_correct/DLSS.js delete mode 100644 data_structures_correct/DOLLAR.js delete mode 100644 data_structures_correct/DOLLAR_f.js delete mode 100644 data_structures_correct/DOLLAR_m.js delete mode 100644 data_structures_correct/Diode.js delete mode 100644 data_structures_correct/EDGETRIGGER.js delete mode 100644 data_structures_correct/EDGE_TRIGGER.js delete mode 100644 data_structures_correct/ENDBLK.js delete mode 100644 data_structures_correct/END_c.js delete mode 100644 data_structures_correct/ESELECT_f.js delete mode 100644 data_structures_correct/EVTDLY_c.js delete mode 100644 data_structures_correct/EVTDLY_f.js delete mode 100644 data_structures_correct/EVTGEN_f.js delete mode 100644 data_structures_correct/EVTVARDLY.js delete mode 100644 data_structures_correct/EXPBLK_m.js delete mode 100644 data_structures_correct/EXTRACT.js delete mode 100644 data_structures_correct/EXTRACTBITS.js delete mode 100644 data_structures_correct/EXTRACTOR.js delete mode 100644 data_structures_correct/EXTTRI.js delete mode 100644 data_structures_correct/Extract_Activation.js delete mode 100644 data_structures_correct/FROM.js delete mode 100644 data_structures_correct/FROMMO.js delete mode 100644 data_structures_correct/FROMWSB.js delete mode 100644 data_structures_correct/Flowmeter.js delete mode 100644 data_structures_correct/GAINBLK.js delete mode 100644 data_structures_correct/GAINBLK_f.js delete mode 100644 data_structures_correct/GAIN_f.js delete mode 100644 data_structures_correct/GENERAL_f.js delete mode 100644 data_structures_correct/GENSIN_f.js delete mode 100644 data_structures_correct/GENSQR_f.js delete mode 100644 data_structures_correct/GOTO.js delete mode 100644 data_structures_correct/GOTOMO.js delete mode 100644 data_structures_correct/GotoTagVisibility.js delete mode 100644 data_structures_correct/GotoTagVisibilityMO.js delete mode 100644 data_structures_correct/Ground.js delete mode 100644 data_structures_correct/Gyrator.js delete mode 100644 data_structures_correct/HALT_f.js delete mode 100644 data_structures_correct/HYSTHERESIS.js delete mode 100644 data_structures_correct/IFTHEL_f.js delete mode 100644 data_structures_correct/INIMPL_f.js delete mode 100644 data_structures_correct/INTEGRAL_f.js delete mode 100644 data_structures_correct/INTEGRAL_m.js delete mode 100644 data_structures_correct/INTMUL.js delete mode 100644 data_structures_correct/INTRP2BLK_f.js delete mode 100644 data_structures_correct/INTRPLBLK_f.js delete mode 100644 data_structures_correct/INVBLK.js delete mode 100644 data_structures_correct/IN_f.js delete mode 100644 data_structures_correct/ISELECT_m.js delete mode 100644 data_structures_correct/IdealTransformer.js delete mode 100644 data_structures_correct/Inductor.js delete mode 100644 data_structures_correct/JKFLIPFLOP.js delete mode 100644 data_structures_correct/LOGBLK_f.js delete mode 100644 data_structures_correct/LOGIC.js delete mode 100644 data_structures_correct/LOGICAL_OP.js delete mode 100644 data_structures_correct/LOOKUP_f.js delete mode 100644 data_structures_correct/MATBKSL.js delete mode 100644 data_structures_correct/MATCATH.js delete mode 100644 data_structures_correct/MATCATV.js delete mode 100644 data_structures_correct/MATDET.js delete mode 100644 data_structures_correct/MATDIAG.js delete mode 100644 data_structures_correct/MATDIV.js delete mode 100644 data_structures_correct/MATEIG.js delete mode 100644 data_structures_correct/MATEXPM.js delete mode 100644 data_structures_correct/MATINV.js delete mode 100644 data_structures_correct/MATLU.js delete mode 100644 data_structures_correct/MATMAGPHI.js delete mode 100644 data_structures_correct/MATMUL.js delete mode 100644 data_structures_correct/MATPINV.js delete mode 100644 data_structures_correct/MATRESH.js delete mode 100644 data_structures_correct/MATSING.js delete mode 100644 data_structures_correct/MATSUM.js delete mode 100644 data_structures_correct/MATTRAN.js delete mode 100644 data_structures_correct/MATZCONJ.js delete mode 100644 data_structures_correct/MATZREIM.js delete mode 100644 data_structures_correct/MAXMIN.js delete mode 100644 data_structures_correct/MAX_f.js delete mode 100644 data_structures_correct/MBLOCK.js delete mode 100644 data_structures_correct/MCLOCK_f.js delete mode 100644 data_structures_correct/MFCLCK_f.js delete mode 100644 data_structures_correct/MIN_f.js delete mode 100644 data_structures_correct/MUX.js delete mode 100644 data_structures_correct/MUX_f.js delete mode 100644 data_structures_correct/M_SWITCH.js delete mode 100644 data_structures_correct/M_freq.js delete mode 100644 data_structures_correct/Modulo_Count.js delete mode 100644 data_structures_correct/NEGTOPOS_f.js delete mode 100644 data_structures_correct/NMOS.js delete mode 100644 data_structures_correct/NPN.js delete mode 100644 data_structures_correct/NRMSOM_f.js delete mode 100644 data_structures_correct/OUTIMPL_f.js delete mode 100644 data_structures_correct/OUT_f.js delete mode 100644 data_structures_correct/OpAmp.js delete mode 100644 data_structures_correct/PDE.js delete mode 100644 data_structures_correct/PID.js delete mode 100644 data_structures_correct/PNP.js delete mode 100644 data_structures_correct/POSTONEG_f.js delete mode 100644 data_structures_correct/POWBLK_f.js delete mode 100644 data_structures_correct/PRODUCT.js delete mode 100644 data_structures_correct/PROD_f.js delete mode 100644 data_structures_correct/PULSE_SC.js delete mode 100644 data_structures_correct/PerteDP.js delete mode 100644 data_structures_correct/PotentialSensor.js delete mode 100644 data_structures_correct/PuitsP.js delete mode 100644 data_structures_correct/QUANT_f.js delete mode 100644 data_structures_correct/RAMP.js delete mode 100644 data_structures_correct/RAND_m.js delete mode 100644 data_structures_correct/RATELIMITER.js delete mode 100644 data_structures_correct/READAU_f.js delete mode 100644 data_structures_correct/READC_f.js delete mode 100644 data_structures_correct/REGISTER.js delete mode 100644 data_structures_correct/REGISTER_f.js delete mode 100644 data_structures_correct/RELATIONALOP.js delete mode 100644 data_structures_correct/RELAY_f.js delete mode 100644 data_structures_correct/RFILE_f.js delete mode 100644 data_structures_correct/RICC.js delete mode 100644 data_structures_correct/ROOTCOEF.js delete mode 100644 data_structures_correct/Resistor.js delete mode 100644 data_structures_correct/SAMPHOLD_m.js delete mode 100644 data_structures_correct/SATURATION.js delete mode 100644 data_structures_correct/SAWTOOTH_f.js delete mode 100644 data_structures_correct/SCALAR2VECTOR.js delete mode 100644 data_structures_correct/SELECT_m.js delete mode 100644 data_structures_correct/SELF_SWITCH.js delete mode 100644 data_structures_correct/SHIFT.js delete mode 100644 data_structures_correct/SIGNUM.js delete mode 100644 data_structures_correct/SINBLK_f.js delete mode 100644 data_structures_correct/SOM_f.js delete mode 100644 data_structures_correct/SQRT.js delete mode 100644 data_structures_correct/SRFLIPFLOP.js delete mode 100644 data_structures_correct/STEP_FUNCTION.js delete mode 100644 data_structures_correct/SUBMAT.js delete mode 100644 data_structures_correct/SUMMATION.js delete mode 100644 data_structures_correct/SUM_f.js delete mode 100644 data_structures_correct/SUPER_f.js delete mode 100644 data_structures_correct/SWITCH2_m.js delete mode 100644 data_structures_correct/SWITCH_f.js delete mode 100644 data_structures_correct/SampleCLK.js delete mode 100644 data_structures_correct/Sigbuilder.js delete mode 100644 data_structures_correct/SineVoltage.js delete mode 100644 data_structures_correct/SourceP.js delete mode 100644 data_structures_correct/Switch.js delete mode 100644 data_structures_correct/TANBLK_f.js delete mode 100644 data_structures_correct/TCLSS.js delete mode 100644 data_structures_correct/TEXT_f.js delete mode 100644 data_structures_correct/TIME_DELAY.js delete mode 100644 data_structures_correct/TIME_f.js delete mode 100644 data_structures_correct/TKSCALE.js delete mode 100644 data_structures_correct/TOWS_c.js delete mode 100644 data_structures_correct/TRASH_f.js delete mode 100644 data_structures_correct/TrigFun.js delete mode 100644 data_structures_correct/VARIABLE_DELAY.js delete mode 100644 data_structures_correct/VVsourceAC.js delete mode 100644 data_structures_correct/VanneReglante.js delete mode 100644 data_structures_correct/VariableResistor.js delete mode 100644 data_structures_correct/VirtualCLK0.js delete mode 100644 data_structures_correct/VoltageSensor.js delete mode 100644 data_structures_correct/VsourceAC.js delete mode 100644 data_structures_correct/WRITEAU_f.js delete mode 100644 data_structures_correct/WRITEC_f.js delete mode 100644 data_structures_correct/ZCROSS_f.js delete mode 100644 data_structures_correct/c_block.js delete mode 100644 data_structures_correct/combine_script.bat delete mode 100644 data_structures_correct/fortran_block.js delete mode 100644 data_structures_correct/freq_div.js delete mode 100644 data_structures_correct/generic_block3.js delete mode 100644 data_structures_correct/scifunc_block_m.js delete mode 100644 dependencies.js delete mode 100644 details.js delete mode 100644 documentation/servlet.md delete mode 100644 documentation/wires.md delete mode 100644 filenames.php delete mode 100644 finalmodsheet.xsl delete mode 100755 highcharts/highcharts.js delete mode 100644 history/blocks_xcos/ABS_VALUE.xcos delete mode 100644 history/blocks_xcos/AFFICH_m.xcos delete mode 100644 history/blocks_xcos/ANDBLK.xcos delete mode 100644 history/blocks_xcos/ANDLOG_f.xcos delete mode 100644 history/blocks_xcos/AUTOMAT.xcos delete mode 100644 history/blocks_xcos/BACKLASH.xcos delete mode 100644 history/blocks_xcos/BARXY.xcos delete mode 100644 history/blocks_xcos/BIGSOM_f.xcos delete mode 100644 history/blocks_xcos/BITCLEAR.xcos delete mode 100644 history/blocks_xcos/BITSET.xcos delete mode 100644 history/blocks_xcos/BOUNCE.xcos delete mode 100644 history/blocks_xcos/BOUNCEXY.xcos delete mode 100644 history/blocks_xcos/BPLATFORM.xcos delete mode 100644 history/blocks_xcos/Bache.xcos delete mode 100644 history/blocks_xcos/CANIMXY.xcos delete mode 100644 history/blocks_xcos/CANIMXY3D.xcos delete mode 100644 history/blocks_xcos/CBLOCK.xcos delete mode 100644 history/blocks_xcos/CBLOCK4.xcos delete mode 100644 history/blocks_xcos/CCS.xcos delete mode 100644 history/blocks_xcos/CEVENTSCOPE.xcos delete mode 100644 history/blocks_xcos/CFSCOPE.xcos delete mode 100644 history/blocks_xcos/CLINDUMMY_f.xcos delete mode 100644 history/blocks_xcos/CLKFROM.xcos delete mode 100644 history/blocks_xcos/CLKGOTO.xcos delete mode 100644 history/blocks_xcos/CLKGotoTagVisibility.xcos delete mode 100644 history/blocks_xcos/CLKINV_f.xcos delete mode 100644 history/blocks_xcos/CLKOUTV_f.xcos delete mode 100644 history/blocks_xcos/CLKSOMV_f.xcos delete mode 100644 history/blocks_xcos/CLOCK_c.xcos delete mode 100644 history/blocks_xcos/CLR.xcos delete mode 100644 history/blocks_xcos/CLSS.xcos delete mode 100644 history/blocks_xcos/CMAT3D.xcos delete mode 100644 history/blocks_xcos/CMATVIEW.xcos delete mode 100644 history/blocks_xcos/CMSCOPE.xcos delete mode 100644 history/blocks_xcos/CONST.xcos delete mode 100644 history/blocks_xcos/CONSTRAINT2_c.xcos delete mode 100644 history/blocks_xcos/CONSTRAINT_c.xcos delete mode 100644 history/blocks_xcos/CONST_f.xcos delete mode 100644 history/blocks_xcos/CONST_m.xcos delete mode 100644 history/blocks_xcos/CONVERT.xcos delete mode 100644 history/blocks_xcos/COSBLK_f.xcos delete mode 100644 history/blocks_xcos/CSCOPE.xcos delete mode 100644 history/blocks_xcos/CSCOPXY.xcos delete mode 100644 history/blocks_xcos/CSCOPXY3D.xcos delete mode 100644 history/blocks_xcos/CUMSUM.xcos delete mode 100644 history/blocks_xcos/CURV_f.xcos delete mode 100644 history/blocks_xcos/CVS.xcos delete mode 100644 history/blocks_xcos/Capacitor.xcos delete mode 100644 history/blocks_xcos/ConstantVoltage.xcos delete mode 100644 history/blocks_xcos/Counter.xcos delete mode 100644 history/blocks_xcos/CurrentSensor.xcos delete mode 100644 history/blocks_xcos/DEADBAND.xcos delete mode 100644 history/blocks_xcos/DEBUG.xcos delete mode 100644 history/blocks_xcos/DELAYV_f.xcos delete mode 100644 history/blocks_xcos/DELAY_f.xcos delete mode 100644 history/blocks_xcos/DEMUX.xcos delete mode 100644 history/blocks_xcos/DEMUX_f.xcos delete mode 100644 history/blocks_xcos/DERIV.xcos delete mode 100644 history/blocks_xcos/DFLIPFLOP.xcos delete mode 100644 history/blocks_xcos/DIFF_f.xcos delete mode 100644 history/blocks_xcos/DLATCH.xcos delete mode 100644 history/blocks_xcos/DLR.xcos delete mode 100644 history/blocks_xcos/DLRADAPT_f.xcos delete mode 100644 history/blocks_xcos/DLSS.xcos delete mode 100644 history/blocks_xcos/DOLLAR.xcos delete mode 100644 history/blocks_xcos/DOLLAR_f.xcos delete mode 100644 history/blocks_xcos/DOLLAR_m.xcos delete mode 100644 history/blocks_xcos/Diode.xcos delete mode 100644 history/blocks_xcos/EDGE_TRIGGER.xcos delete mode 100644 history/blocks_xcos/ENDBLK.xcos delete mode 100644 history/blocks_xcos/END_c.xcos delete mode 100644 history/blocks_xcos/ESELECT_f.xcos delete mode 100644 history/blocks_xcos/EVTDLY_c.xcos delete mode 100644 history/blocks_xcos/EVTGEN_f.xcos delete mode 100644 history/blocks_xcos/EVTVARDLY.xcos delete mode 100644 history/blocks_xcos/EXPBLK_m.xcos delete mode 100644 history/blocks_xcos/EXPRESSION.xcos delete mode 100644 history/blocks_xcos/EXTRACT.xcos delete mode 100644 history/blocks_xcos/EXTRACTBITS.xcos delete mode 100644 history/blocks_xcos/EXTRACTOR.xcos delete mode 100644 history/blocks_xcos/EXTTRI.xcos delete mode 100644 history/blocks_xcos/Extract_Activation.xcos delete mode 100644 history/blocks_xcos/FROM.xcos delete mode 100644 history/blocks_xcos/FROMMO.xcos delete mode 100644 history/blocks_xcos/FROMWSB.xcos delete mode 100644 history/blocks_xcos/Flowmeter.xcos delete mode 100644 history/blocks_xcos/GAINBLK.xcos delete mode 100644 history/blocks_xcos/GAINBLK_f.xcos delete mode 100644 history/blocks_xcos/GAIN_f.xcos delete mode 100644 history/blocks_xcos/GENERAL_f.xcos delete mode 100644 history/blocks_xcos/GENSIN_f.xcos delete mode 100644 history/blocks_xcos/GENSQR_f.xcos delete mode 100644 history/blocks_xcos/GOTO.xcos delete mode 100644 history/blocks_xcos/GOTOMO.xcos delete mode 100644 history/blocks_xcos/GotoTagVisibility.xcos delete mode 100644 history/blocks_xcos/GotoTagVisibilityMO.xcos delete mode 100644 history/blocks_xcos/Ground.xcos delete mode 100644 history/blocks_xcos/Gyrator.xcos delete mode 100644 history/blocks_xcos/HALT_f.xcos delete mode 100644 history/blocks_xcos/HYSTHERESIS.xcos delete mode 100644 history/blocks_xcos/IFTHEL_f.xcos delete mode 100644 history/blocks_xcos/INIMPL_f.xcos delete mode 100644 history/blocks_xcos/INTEGRAL_f.xcos delete mode 100644 history/blocks_xcos/INTEGRAL_m.xcos delete mode 100644 history/blocks_xcos/INTMUL.xcos delete mode 100644 history/blocks_xcos/INTRP2BLK_f.xcos delete mode 100644 history/blocks_xcos/INTRPLBLK_f.xcos delete mode 100644 history/blocks_xcos/INVBLK.xcos delete mode 100644 history/blocks_xcos/IN_f.xcos delete mode 100644 history/blocks_xcos/ISELECT_m.xcos delete mode 100644 history/blocks_xcos/IdealTransformer.xcos delete mode 100644 history/blocks_xcos/Inductor.xcos delete mode 100644 history/blocks_xcos/JKFLIPFLOP.xcos delete mode 100644 history/blocks_xcos/LOGBLK_f.xcos delete mode 100644 history/blocks_xcos/LOGIC.xcos delete mode 100644 history/blocks_xcos/LOGICAL_OP.xcos delete mode 100644 history/blocks_xcos/LOOKUP_f.xcos delete mode 100644 history/blocks_xcos/MATBKSL.xcos delete mode 100644 history/blocks_xcos/MATCATH.xcos delete mode 100644 history/blocks_xcos/MATCATV.xcos delete mode 100644 history/blocks_xcos/MATDET.xcos delete mode 100644 history/blocks_xcos/MATDIAG.xcos delete mode 100644 history/blocks_xcos/MATDIV.xcos delete mode 100644 history/blocks_xcos/MATEIG.xcos delete mode 100644 history/blocks_xcos/MATEXPM.xcos delete mode 100644 history/blocks_xcos/MATINV.xcos delete mode 100644 history/blocks_xcos/MATLU.xcos delete mode 100644 history/blocks_xcos/MATMAGPHI.xcos delete mode 100644 history/blocks_xcos/MATMUL.xcos delete mode 100644 history/blocks_xcos/MATPINV.xcos delete mode 100644 history/blocks_xcos/MATRESH.xcos delete mode 100644 history/blocks_xcos/MATSING.xcos delete mode 100644 history/blocks_xcos/MATSUM.xcos delete mode 100644 history/blocks_xcos/MATTRAN.xcos delete mode 100644 history/blocks_xcos/MATZCONJ.xcos delete mode 100644 history/blocks_xcos/MATZREIM.xcos delete mode 100644 history/blocks_xcos/MAXMIN.xcos delete mode 100644 history/blocks_xcos/MAX_f.xcos delete mode 100644 history/blocks_xcos/MBLOCK.xcos delete mode 100644 history/blocks_xcos/MCLOCK_f.xcos delete mode 100644 history/blocks_xcos/MFCLCK_f.xcos delete mode 100644 history/blocks_xcos/MIN_f.xcos delete mode 100644 history/blocks_xcos/MUX.xcos delete mode 100644 history/blocks_xcos/MUX_f.xcos delete mode 100644 history/blocks_xcos/M_SWITCH.xcos delete mode 100644 history/blocks_xcos/M_freq.xcos delete mode 100644 history/blocks_xcos/Modulo_Count.xcos delete mode 100644 history/blocks_xcos/NEGTOPOS_f.xcos delete mode 100644 history/blocks_xcos/NMOS.xcos delete mode 100644 history/blocks_xcos/NPN.xcos delete mode 100644 history/blocks_xcos/NRMSOM_f.xcos delete mode 100644 history/blocks_xcos/OUTIMPL_f.xcos delete mode 100644 history/blocks_xcos/OUT_f.xcos delete mode 100644 history/blocks_xcos/OpAmp.xcos delete mode 100644 history/blocks_xcos/PDE.xcos delete mode 100644 history/blocks_xcos/PID.xcos delete mode 100644 history/blocks_xcos/PMOS.xcos delete mode 100644 history/blocks_xcos/PNP.xcos delete mode 100644 history/blocks_xcos/POSTONEG_f.xcos delete mode 100644 history/blocks_xcos/POWBLK_f.xcos delete mode 100644 history/blocks_xcos/PRODUCT.xcos delete mode 100644 history/blocks_xcos/PROD_f.xcos delete mode 100644 history/blocks_xcos/PULSE_SC.xcos delete mode 100644 history/blocks_xcos/PerteDP.xcos delete mode 100644 history/blocks_xcos/PotentialSensor.xcos delete mode 100644 history/blocks_xcos/PuitsP.xcos delete mode 100644 history/blocks_xcos/QUANT_f.xcos delete mode 100644 history/blocks_xcos/RAMP.xcos delete mode 100644 history/blocks_xcos/RAND_m.xcos delete mode 100644 history/blocks_xcos/RATELIMITER.xcos delete mode 100644 history/blocks_xcos/READAU_f.xcos delete mode 100644 history/blocks_xcos/READC_f.xcos delete mode 100644 history/blocks_xcos/REGISTER.xcos delete mode 100644 history/blocks_xcos/RELATIONALOP.xcos delete mode 100644 history/blocks_xcos/RELAY_f.xcos delete mode 100644 history/blocks_xcos/RFILE_f.xcos delete mode 100644 history/blocks_xcos/RICC.xcos delete mode 100644 history/blocks_xcos/ROOTCOEF.xcos delete mode 100644 history/blocks_xcos/Resistor.xcos delete mode 100644 history/blocks_xcos/SAMPHOLD_m.xcos delete mode 100644 history/blocks_xcos/SATURATION.xcos delete mode 100644 history/blocks_xcos/SAWTOOTH_f.xcos delete mode 100644 history/blocks_xcos/SCALAR2VECTOR.xcos delete mode 100644 history/blocks_xcos/SELECT_m.xcos delete mode 100644 history/blocks_xcos/SELF_SWITCH.xcos delete mode 100644 history/blocks_xcos/SHIFT.xcos delete mode 100644 history/blocks_xcos/SIGNUM.xcos delete mode 100644 history/blocks_xcos/SINBLK_f.xcos delete mode 100644 history/blocks_xcos/SOM_f.xcos delete mode 100644 history/blocks_xcos/SQRT.xcos delete mode 100644 history/blocks_xcos/SRFLIPFLOP.xcos delete mode 100644 history/blocks_xcos/STEP_FUNCTION.xcos delete mode 100644 history/blocks_xcos/SUBMAT.xcos delete mode 100644 history/blocks_xcos/SUMMATION.xcos delete mode 100644 history/blocks_xcos/SUM_f.xcos delete mode 100644 history/blocks_xcos/SUPER_f.xcos delete mode 100644 history/blocks_xcos/SWITCH2_m.xcos delete mode 100644 history/blocks_xcos/SWITCH_f.xcos delete mode 100644 history/blocks_xcos/SampleCLK.xcos delete mode 100644 history/blocks_xcos/Sigbuilder.xcos delete mode 100644 history/blocks_xcos/SineVoltage.xcos delete mode 100644 history/blocks_xcos/SourceP.xcos delete mode 100644 history/blocks_xcos/Switch.xcos delete mode 100644 history/blocks_xcos/TANBLK_f.xcos delete mode 100644 history/blocks_xcos/TCLSS.xcos delete mode 100644 history/blocks_xcos/TEXT_f.xcos delete mode 100644 history/blocks_xcos/TIME_DELAY.xcos delete mode 100644 history/blocks_xcos/TIME_f.xcos delete mode 100644 history/blocks_xcos/TKSCALE.xcos delete mode 100644 history/blocks_xcos/TOWS_c.xcos delete mode 100644 history/blocks_xcos/TRASH_f.xcos delete mode 100644 history/blocks_xcos/TrigFun.xcos delete mode 100644 history/blocks_xcos/VARIABLE_DELAY.xcos delete mode 100644 history/blocks_xcos/VVsourceAC.xcos delete mode 100644 history/blocks_xcos/VanneReglante.xcos delete mode 100644 history/blocks_xcos/VariableResistor.xcos delete mode 100644 history/blocks_xcos/VirtualCLK0.xcos delete mode 100644 history/blocks_xcos/VoltageSensor.xcos delete mode 100644 history/blocks_xcos/VsourceAC.xcos delete mode 100644 history/blocks_xcos/WFILE_f.xcos delete mode 100644 history/blocks_xcos/WRITEAU_f.xcos delete mode 100644 history/blocks_xcos/WRITEC_f.xcos delete mode 100644 history/blocks_xcos/ZCROSS_f.xcos delete mode 100644 history/blocks_xcos/c_block.xcos delete mode 100644 history/blocks_xcos/fortran_block.xcos delete mode 100644 history/blocks_xcos/freq_div.xcos delete mode 100644 history/blocks_xcos/generic_block3.xcos delete mode 100644 history/blocks_xcos/scifunc_block_m.xcos delete mode 100644 history/data_structures/ABS_VALUE.js delete mode 100644 history/data_structures/AFFICH_m.js delete mode 100644 history/data_structures/ANDBLK.js delete mode 100644 history/data_structures/ANDLOG_f.js delete mode 100644 history/data_structures/AUTOMAT.js delete mode 100644 history/data_structures/BACKLASH.js delete mode 100644 history/data_structures/BARXY.js delete mode 100644 history/data_structures/BIGSOM_f.js delete mode 100644 history/data_structures/BITCLEAR.js delete mode 100644 history/data_structures/BITSET.js delete mode 100644 history/data_structures/BOUNCE.js delete mode 100644 history/data_structures/BOUNCEXY.js delete mode 100644 history/data_structures/BPLATFORM.js delete mode 100644 history/data_structures/Bache.js delete mode 100644 history/data_structures/CANIMXY.js delete mode 100644 history/data_structures/CANIMXY3D.js delete mode 100644 history/data_structures/CBLOCK.js delete mode 100644 history/data_structures/CBLOCK4.js delete mode 100644 history/data_structures/CCS.js delete mode 100644 history/data_structures/CEVENTSCOPE.js delete mode 100644 history/data_structures/CFSCOPE.js delete mode 100644 history/data_structures/CLINDUMMY_f.js delete mode 100644 history/data_structures/CLKFROM.js delete mode 100644 history/data_structures/CLKGOTO.js delete mode 100644 history/data_structures/CLKGotoTagVisibility.js delete mode 100644 history/data_structures/CLKINV_f.js delete mode 100644 history/data_structures/CLKOUTV_f.js delete mode 100644 history/data_structures/CLKSOMV_f.js delete mode 100644 history/data_structures/CLOCK_c.js delete mode 100644 history/data_structures/CLR.js delete mode 100644 history/data_structures/CLSS.js delete mode 100644 history/data_structures/CMAT3D.js delete mode 100644 history/data_structures/CMATVIEW.js delete mode 100644 history/data_structures/CMSCOPE.js delete mode 100644 history/data_structures/CONST.js delete mode 100644 history/data_structures/CONSTRAINT2_c.js delete mode 100644 history/data_structures/CONSTRAINT_c.js delete mode 100644 history/data_structures/CONST_f.js delete mode 100644 history/data_structures/CONST_m.js delete mode 100644 history/data_structures/CONVERT.js delete mode 100644 history/data_structures/COSBLK_f.js delete mode 100644 history/data_structures/CSCOPE.js delete mode 100644 history/data_structures/CSCOPXY.js delete mode 100644 history/data_structures/CSCOPXY3D.js delete mode 100644 history/data_structures/CUMSUM.js delete mode 100644 history/data_structures/CURV_f.js delete mode 100644 history/data_structures/CVS.js delete mode 100644 history/data_structures/Capacitor.js delete mode 100644 history/data_structures/ConstantVoltage.js delete mode 100644 history/data_structures/Counter.js delete mode 100644 history/data_structures/CurrentSensor.js delete mode 100644 history/data_structures/DEADBAND.js delete mode 100644 history/data_structures/DEBUG.js delete mode 100644 history/data_structures/DELAYV_f.js delete mode 100644 history/data_structures/DELAY_f.js delete mode 100644 history/data_structures/DEMUX.js delete mode 100644 history/data_structures/DEMUX_f.js delete mode 100644 history/data_structures/DERIV.js delete mode 100644 history/data_structures/DFLIPFLOP.js delete mode 100644 history/data_structures/DIFF_f.js delete mode 100644 history/data_structures/DLATCH.js delete mode 100644 history/data_structures/DLR.js delete mode 100644 history/data_structures/DLRADAPT_f.js delete mode 100644 history/data_structures/DLSS.js delete mode 100644 history/data_structures/DOLLAR.js delete mode 100644 history/data_structures/DOLLAR_f.js delete mode 100644 history/data_structures/DOLLAR_m.js delete mode 100644 history/data_structures/Diode.js delete mode 100644 history/data_structures/EDGE_TRIGGER.js delete mode 100644 history/data_structures/ENDBLK.js delete mode 100644 history/data_structures/END_c.js delete mode 100644 history/data_structures/ESELECT_f.js delete mode 100644 history/data_structures/EVTDLY_c.js delete mode 100644 history/data_structures/EVTGEN_f.js delete mode 100644 history/data_structures/EVTVARDLY.js delete mode 100644 history/data_structures/EXPBLK_m.js delete mode 100644 history/data_structures/EXPRESSION.js delete mode 100644 history/data_structures/EXTRACT.js delete mode 100644 history/data_structures/EXTRACTBITS.js delete mode 100644 history/data_structures/EXTRACTOR.js delete mode 100644 history/data_structures/EXTTRI.js delete mode 100644 history/data_structures/Extract_Activation.js delete mode 100644 history/data_structures/FROM.js delete mode 100644 history/data_structures/FROMMO.js delete mode 100644 history/data_structures/FROMWSB.js delete mode 100644 history/data_structures/Flowmeter.js delete mode 100644 history/data_structures/GAINBLK.js delete mode 100644 history/data_structures/GAINBLK_f.js delete mode 100644 history/data_structures/GAIN_f.js delete mode 100644 history/data_structures/GENERAL_f.js delete mode 100644 history/data_structures/GENSIN_f.js delete mode 100644 history/data_structures/GENSQR_f.js delete mode 100644 history/data_structures/GOTO.js delete mode 100644 history/data_structures/GOTOMO.js delete mode 100644 history/data_structures/GotoTagVisibility.js delete mode 100644 history/data_structures/GotoTagVisibilityMO.js delete mode 100644 history/data_structures/Ground.js delete mode 100644 history/data_structures/Gyrator.js delete mode 100644 history/data_structures/HALT_f.js delete mode 100644 history/data_structures/HYSTHERESIS.js delete mode 100644 history/data_structures/IFTHEL_f.js delete mode 100644 history/data_structures/INIMPL_f.js delete mode 100644 history/data_structures/INTEGRAL_f.js delete mode 100644 history/data_structures/INTEGRAL_m.js delete mode 100644 history/data_structures/INTMUL.js delete mode 100644 history/data_structures/INTRP2BLK_f.js delete mode 100644 history/data_structures/INTRPLBLK_f.js delete mode 100644 history/data_structures/INVBLK.js delete mode 100644 history/data_structures/IN_f.js delete mode 100644 history/data_structures/ISELECT_m.js delete mode 100644 history/data_structures/IdealTransformer.js delete mode 100644 history/data_structures/Inductor.js delete mode 100644 history/data_structures/JKFLIPFLOP.js delete mode 100644 history/data_structures/LOGBLK_f.js delete mode 100644 history/data_structures/LOGIC.js delete mode 100644 history/data_structures/LOGICAL_OP.js delete mode 100644 history/data_structures/LOOKUP_f.js delete mode 100644 history/data_structures/MATBKSL.js delete mode 100644 history/data_structures/MATCATH.js delete mode 100644 history/data_structures/MATCATV.js delete mode 100644 history/data_structures/MATDET.js delete mode 100644 history/data_structures/MATDIAG.js delete mode 100644 history/data_structures/MATDIV.js delete mode 100644 history/data_structures/MATEIG.js delete mode 100644 history/data_structures/MATEXPM.js delete mode 100644 history/data_structures/MATINV.js delete mode 100644 history/data_structures/MATLU.js delete mode 100644 history/data_structures/MATMAGPHI.js delete mode 100644 history/data_structures/MATMUL.js delete mode 100644 history/data_structures/MATPINV.js delete mode 100644 history/data_structures/MATRESH.js delete mode 100644 history/data_structures/MATSING.js delete mode 100644 history/data_structures/MATSUM.js delete mode 100644 history/data_structures/MATTRAN.js delete mode 100644 history/data_structures/MATZCONJ.js delete mode 100644 history/data_structures/MATZREIM.js delete mode 100644 history/data_structures/MAXMIN.js delete mode 100644 history/data_structures/MAX_f.js delete mode 100644 history/data_structures/MBLOCK.js delete mode 100644 history/data_structures/MCLOCK_f.js delete mode 100644 history/data_structures/MFCLCK_f.js delete mode 100644 history/data_structures/MIN_f.js delete mode 100644 history/data_structures/MUX.js delete mode 100644 history/data_structures/MUX_f.js delete mode 100644 history/data_structures/M_SWITCH.js delete mode 100644 history/data_structures/M_freq.js delete mode 100644 history/data_structures/Modulo_Count.js delete mode 100644 history/data_structures/NEGTOPOS_f.js delete mode 100644 history/data_structures/NMOS.js delete mode 100644 history/data_structures/NPN.js delete mode 100644 history/data_structures/NRMSOM_f.js delete mode 100644 history/data_structures/OUTIMPL_f.js delete mode 100644 history/data_structures/OUT_f.js delete mode 100644 history/data_structures/OpAmp.js delete mode 100644 history/data_structures/PDE.js delete mode 100644 history/data_structures/PID.js delete mode 100644 history/data_structures/PMOS.js delete mode 100644 history/data_structures/PNP.js delete mode 100644 history/data_structures/POSTONEG_f.js delete mode 100644 history/data_structures/POWBLK_f.js delete mode 100644 history/data_structures/PRODUCT.js delete mode 100644 history/data_structures/PROD_f.js delete mode 100644 history/data_structures/PULSE_SC.js delete mode 100644 history/data_structures/PerteDP.js delete mode 100644 history/data_structures/PotentialSensor.js delete mode 100644 history/data_structures/PuitsP.js delete mode 100644 history/data_structures/QUANT_f.js delete mode 100644 history/data_structures/RAMP.js delete mode 100644 history/data_structures/RAND_m.js delete mode 100644 history/data_structures/RATELIMITER.js delete mode 100644 history/data_structures/READAU_f.js delete mode 100644 history/data_structures/READC_f.js delete mode 100644 history/data_structures/REGISTER.js delete mode 100644 history/data_structures/RELATIONALOP.js delete mode 100644 history/data_structures/RELAY_f.js delete mode 100644 history/data_structures/RFILE_f.js delete mode 100644 history/data_structures/RICC.js delete mode 100644 history/data_structures/ROOTCOEF.js delete mode 100644 history/data_structures/Resistor.js delete mode 100644 history/data_structures/SAMPHOLD_m.js delete mode 100644 history/data_structures/SATURATION.js delete mode 100644 history/data_structures/SAWTOOTH_f.js delete mode 100644 history/data_structures/SCALAR2VECTOR.js delete mode 100644 history/data_structures/SELECT_m.js delete mode 100644 history/data_structures/SELF_SWITCH.js delete mode 100644 history/data_structures/SHIFT.js delete mode 100644 history/data_structures/SIGNUM.js delete mode 100644 history/data_structures/SINBLK_f.js delete mode 100644 history/data_structures/SOM_f.js delete mode 100644 history/data_structures/SQRT.js delete mode 100644 history/data_structures/SRFLIPFLOP.js delete mode 100644 history/data_structures/STEP_FUNCTION.js delete mode 100644 history/data_structures/SUBMAT.js delete mode 100644 history/data_structures/SUMMATION.js delete mode 100644 history/data_structures/SUM_f.js delete mode 100644 history/data_structures/SUPER_f.js delete mode 100644 history/data_structures/SWITCH2_m.js delete mode 100644 history/data_structures/SWITCH_f.js delete mode 100644 history/data_structures/SampleCLK.js delete mode 100644 history/data_structures/Sigbuilder.js delete mode 100644 history/data_structures/SineVoltage.js delete mode 100644 history/data_structures/SourceP.js delete mode 100644 history/data_structures/Switch.js delete mode 100644 history/data_structures/TANBLK_f.js delete mode 100644 history/data_structures/TCLSS.js delete mode 100644 history/data_structures/TEXT_f.js delete mode 100644 history/data_structures/TIME_DELAY.js delete mode 100644 history/data_structures/TIME_f.js delete mode 100644 history/data_structures/TKSCALE.js delete mode 100644 history/data_structures/TOWS_c.js delete mode 100644 history/data_structures/TRASH_f.js delete mode 100644 history/data_structures/TrigFun.js delete mode 100644 history/data_structures/VARIABLE_DELAY.js delete mode 100644 history/data_structures/VVsourceAC.js delete mode 100644 history/data_structures/VanneReglante.js delete mode 100644 history/data_structures/VariableResistor.js delete mode 100644 history/data_structures/VirtualCLK0.js delete mode 100644 history/data_structures/VoltageSensor.js delete mode 100644 history/data_structures/VsourceAC.js delete mode 100644 history/data_structures/WFILE_f.js delete mode 100644 history/data_structures/WRITEAU_f.js delete mode 100644 history/data_structures/WRITEC_f.js delete mode 100644 history/data_structures/ZCROSS_f.js delete mode 100644 history/data_structures/c_block.js delete mode 100644 history/data_structures/fortran_block.js delete mode 100644 history/data_structures/freq_div.js delete mode 100644 history/data_structures/generic_block3.js delete mode 100644 history/data_structures/scifunc_block_m.js delete mode 100644 images/ScilabExecute.png delete mode 100644 images/add.png delete mode 100644 images/button.gif delete mode 100644 images/camera.png delete mode 100644 images/check.png delete mode 100644 images/close.gif delete mode 100644 images/close.png delete mode 100644 images/collapsed.gif delete mode 100644 images/connector.gif delete mode 100644 images/copy.png delete mode 100644 images/cut.png delete mode 100644 images/delete2.png delete mode 100644 images/dot.gif delete mode 100644 images/draw-brush.png delete mode 100644 images/edit.png delete mode 100644 images/error.gif delete mode 100644 images/expanded.gif delete mode 100644 images/export1.png delete mode 100644 images/fit_to_size.png delete mode 100644 images/flip.png delete mode 100644 images/gear.gif delete mode 100644 images/gradient_background.jpg delete mode 100644 images/green-dot.gif delete mode 100644 images/grid.gif delete mode 100644 images/group.png delete mode 100644 images/key.png delete mode 100644 images/loading.gif delete mode 100644 images/maximize.gif delete mode 100644 images/minimize.gif delete mode 100644 images/mirror.png delete mode 100644 images/navigate_minus.png delete mode 100644 images/navigate_plus.png delete mode 100644 images/normalize.gif delete mode 100644 images/paste.png delete mode 100644 images/plus.png delete mode 100644 images/point.gif delete mode 100644 images/press32.png delete mode 100644 images/print32.png delete mode 100644 images/printer.png delete mode 100644 images/redo.png delete mode 100644 images/resize.gif delete mode 100644 images/rotate.png delete mode 100644 images/selectall.png delete mode 100644 images/separator.gif delete mode 100644 images/setup.png delete mode 100644 images/sidebar_bg.gif delete mode 100644 images/spacer.gif delete mode 100644 images/submenu.gif delete mode 100644 images/superblock.png delete mode 100644 images/toolbar_bg.gif delete mode 100644 images/transparent.gif delete mode 100644 images/undo.png delete mode 100644 images/view_1_1.png delete mode 100644 images/view_1_132.png delete mode 100644 images/view_next.png delete mode 100644 images/view_previous.png delete mode 100644 images/warning.gif delete mode 100644 images/warning.png delete mode 100644 images/window-title.gif delete mode 100644 images/window.gif delete mode 100644 images/wires-grid.gif delete mode 100644 images/zoom_in.png delete mode 100644 images/zoom_in32.png delete mode 100644 images/zoom_out.png delete mode 100644 images/zoom_out32.png delete mode 100644 index.html delete mode 100644 jquery/LICENSE.txt delete mode 100644 jquery/README.html delete mode 100644 jquery/farbtastic.css delete mode 100644 jquery/farbtastic.js delete mode 100644 jquery/images/ui-bg_flat_75_ffffff_40x100.png delete mode 100644 jquery/images/ui-bg_glass_75_e6e6e6_1x400.png delete mode 100644 jquery/images/ui-icons_888888_256x240.png delete mode 100644 jquery/jquery-1.8.2.js delete mode 100644 jquery/jquery-ui.css delete mode 100644 jquery/marker.png delete mode 100644 jquery/mask.png delete mode 100644 jquery/wheel.png delete mode 100644 math.js delete mode 100644 mxClient.min.js delete mode 100644 orientation.js delete mode 100644 palettes/ABS_VALUE.png delete mode 100644 palettes/AFFICH_m.png delete mode 100644 palettes/ANDBLK.png delete mode 100644 palettes/ANDLOG_f.png delete mode 100644 palettes/AUTOMAT.png delete mode 100644 palettes/BACKLASH.png delete mode 100644 palettes/BARXY.png delete mode 100644 palettes/BIGSOM_f.png delete mode 100644 palettes/BITCLEAR.png delete mode 100644 palettes/BITSET.png delete mode 100644 palettes/BOUNCE.png delete mode 100644 palettes/BOUNCEXY.png delete mode 100644 palettes/BPLATFORM.png delete mode 100644 palettes/Bache.png delete mode 100644 palettes/CANIMXY.png delete mode 100644 palettes/CANIMXY3D.png delete mode 100644 palettes/CBLOCK.png delete mode 100644 palettes/CBLOCK4.png delete mode 100644 palettes/CCS.png delete mode 100644 palettes/CEVENTSCOPE.png delete mode 100644 palettes/CFSCOPE.png delete mode 100644 palettes/CLINDUMMY_f.png delete mode 100644 palettes/CLKFROM.png delete mode 100644 palettes/CLKGOTO.png delete mode 100644 palettes/CLKGotoTagVisibility.png delete mode 100644 palettes/CLKINV_f.png delete mode 100644 palettes/CLKOUTV_f.png delete mode 100644 palettes/CLKSOMV_f.png delete mode 100644 palettes/CLOCK_c.png delete mode 100644 palettes/CLR.png delete mode 100644 palettes/CLSS.png delete mode 100644 palettes/CMAT3D.png delete mode 100644 palettes/CMATVIEW.png delete mode 100644 palettes/CMSCOPE.png delete mode 100644 palettes/CONST.png delete mode 100644 palettes/CONSTRAINT2_c.png delete mode 100644 palettes/CONSTRAINT_c.png delete mode 100644 palettes/CONST_f.png delete mode 100644 palettes/CONST_m.png delete mode 100644 palettes/CONVERT.png delete mode 100644 palettes/COSBLK_f.png delete mode 100644 palettes/CSCOPE.png delete mode 100644 palettes/CSCOPXY.png delete mode 100644 palettes/CSCOPXY3D.png delete mode 100644 palettes/CUMSUM.png delete mode 100644 palettes/CURV_f.png delete mode 100644 palettes/CVS.png delete mode 100644 palettes/Capacitor.png delete mode 100644 palettes/ConstantVoltage.png delete mode 100644 palettes/Counter.png delete mode 100644 palettes/CurrentSensor.png delete mode 100644 palettes/DEADBAND.png delete mode 100644 palettes/DEBUG.png delete mode 100644 palettes/DELAYV_f.png delete mode 100644 palettes/DELAY_f.png delete mode 100644 palettes/DEMUX.png delete mode 100644 palettes/DEMUX_f.png delete mode 100644 palettes/DERIV.png delete mode 100644 palettes/DFLIPFLOP.png delete mode 100644 palettes/DIFF_f.png delete mode 100644 palettes/DLATCH.png delete mode 100644 palettes/DLR.png delete mode 100644 palettes/DLRADAPT_f.png delete mode 100644 palettes/DLSS.png delete mode 100644 palettes/DOLLAR.png delete mode 100644 palettes/DOLLAR_f.png delete mode 100644 palettes/DOLLAR_m.png delete mode 100644 palettes/Diode.png delete mode 100644 palettes/EDGE_TRIGGER.png delete mode 100644 palettes/ENDBLK.png delete mode 100644 palettes/END_c.png delete mode 100644 palettes/ESELECT_f.png delete mode 100644 palettes/EVTDLY_c.png delete mode 100644 palettes/EVTGEN_f.png delete mode 100644 palettes/EVTVARDLY.png delete mode 100644 palettes/EXPBLK_m.png delete mode 100644 palettes/EXPRESSION.png delete mode 100644 palettes/EXTRACT.png delete mode 100644 palettes/EXTRACTBITS.png delete mode 100644 palettes/EXTRACTOR.png delete mode 100644 palettes/EXTTRI.png delete mode 100644 palettes/Extract_Activation.png delete mode 100644 palettes/FROM.png delete mode 100644 palettes/FROMMO.png delete mode 100644 palettes/FROMWSB.png delete mode 100644 palettes/Flowmeter.png delete mode 100644 palettes/GAINBLK.png delete mode 100644 palettes/GAINBLK_f.png delete mode 100644 palettes/GAIN_f.png delete mode 100644 palettes/GENERAL_f.png delete mode 100644 palettes/GENSIN_f.png delete mode 100644 palettes/GENSQR_f.png delete mode 100644 palettes/GOTO.png delete mode 100644 palettes/GOTOMO.png delete mode 100644 palettes/GotoTagVisibility.png delete mode 100644 palettes/GotoTagVisibilityMO.png delete mode 100644 palettes/Ground.png delete mode 100644 palettes/Gyrator.png delete mode 100644 palettes/HALT_f.png delete mode 100644 palettes/HYSTHERESIS.png delete mode 100644 palettes/IFTHEL_f.png delete mode 100644 palettes/INIMPL_f.png delete mode 100644 palettes/INTEGRAL_f.png delete mode 100644 palettes/INTEGRAL_m.png delete mode 100644 palettes/INTMUL.png delete mode 100644 palettes/INTRP2BLK_f.png delete mode 100644 palettes/INTRPLBLK_f.png delete mode 100644 palettes/INVBLK.png delete mode 100644 palettes/IN_f.png delete mode 100644 palettes/ISELECT_m.png delete mode 100644 palettes/IdealTransformer.png delete mode 100644 palettes/Inductor.png delete mode 100644 palettes/JKFLIPFLOP.png delete mode 100644 palettes/LOGBLK_f.png delete mode 100644 palettes/LOGIC.png delete mode 100644 palettes/LOGICAL_OP.png delete mode 100644 palettes/LOOKUP_f.png delete mode 100644 palettes/MATBKSL.png delete mode 100644 palettes/MATCATH.png delete mode 100644 palettes/MATCATV.png delete mode 100644 palettes/MATDET.png delete mode 100644 palettes/MATDIAG.png delete mode 100644 palettes/MATDIV.png delete mode 100644 palettes/MATEIG.png delete mode 100644 palettes/MATEXPM.png delete mode 100644 palettes/MATINV.png delete mode 100644 palettes/MATLU.png delete mode 100644 palettes/MATMAGPHI.png delete mode 100644 palettes/MATMUL.png delete mode 100644 palettes/MATPINV.png delete mode 100644 palettes/MATRESH.png delete mode 100644 palettes/MATSING.png delete mode 100644 palettes/MATSUM.png delete mode 100644 palettes/MATTRAN.png delete mode 100644 palettes/MATZCONJ.png delete mode 100644 palettes/MATZREIM.png delete mode 100644 palettes/MAXMIN.png delete mode 100644 palettes/MAX_f.png delete mode 100644 palettes/MBLOCK.png delete mode 100644 palettes/MCLOCK_f.png delete mode 100644 palettes/MFCLCK_f.png delete mode 100644 palettes/MIN_f.png delete mode 100644 palettes/MUX.png delete mode 100644 palettes/MUX_f.png delete mode 100644 palettes/M_SWITCH.png delete mode 100644 palettes/M_freq.png delete mode 100644 palettes/Modulo_Count.png delete mode 100644 palettes/NEGTOPOS_f.png delete mode 100644 palettes/NMOS.png delete mode 100644 palettes/NPN.png delete mode 100644 palettes/NRMSOM_f.png delete mode 100644 palettes/OUTIMPL_f.png delete mode 100644 palettes/OUT_f.png delete mode 100644 palettes/OpAmp.png delete mode 100644 palettes/PDE.png delete mode 100644 palettes/PID.png delete mode 100644 palettes/PMOS.png delete mode 100644 palettes/PNP.png delete mode 100644 palettes/POSTONEG_f.png delete mode 100644 palettes/POWBLK_f.png delete mode 100644 palettes/PRODUCT.png delete mode 100644 palettes/PROD_f.png delete mode 100644 palettes/PULSE_SC.png delete mode 100644 palettes/PerteDP.png delete mode 100644 palettes/PotentialSensor.png delete mode 100644 palettes/PuitsP.png delete mode 100644 palettes/QUANT_f.png delete mode 100644 palettes/RAMP.png delete mode 100644 palettes/RAND_m.png delete mode 100644 palettes/RATELIMITER.png delete mode 100644 palettes/READAU_f.png delete mode 100644 palettes/READC_f.png delete mode 100644 palettes/REGISTER.png delete mode 100644 palettes/RELATIONALOP.png delete mode 100644 palettes/RELAY_f.png delete mode 100644 palettes/RFILE_f.png delete mode 100644 palettes/RICC.png delete mode 100644 palettes/ROOTCOEF.png delete mode 100644 palettes/Resistor.png delete mode 100644 palettes/SAMPHOLD_m.png delete mode 100644 palettes/SATURATION.png delete mode 100644 palettes/SAWTOOTH_f.png delete mode 100644 palettes/SCALAR2VECTOR.png delete mode 100644 palettes/SELECT_m.png delete mode 100644 palettes/SELF_SWITCH.png delete mode 100644 palettes/SELF_SWITCH_off.png delete mode 100644 palettes/SELF_SWITCH_on.png delete mode 100644 palettes/SHIFT.png delete mode 100644 palettes/SIGNUM.png delete mode 100644 palettes/SINBLK_f.png delete mode 100644 palettes/SOM_f.png delete mode 100644 palettes/SQRT.png delete mode 100644 palettes/SRFLIPFLOP.png delete mode 100644 palettes/STEP_FUNCTION.png delete mode 100644 palettes/SUBMAT.png delete mode 100644 palettes/SUMMATION.png delete mode 100644 palettes/SUM_f.png delete mode 100644 palettes/SUPER_f.png delete mode 100644 palettes/SWITCH2_m.png delete mode 100644 palettes/SWITCH_f.png delete mode 100644 palettes/SampleCLK.png delete mode 100644 palettes/Sigbuilder.png delete mode 100644 palettes/SineVoltage.png delete mode 100644 palettes/SourceP.png delete mode 100644 palettes/Switch.png delete mode 100644 palettes/TANBLK_f.png delete mode 100644 palettes/TCLSS.png delete mode 100644 palettes/TEXT_f.png delete mode 100644 palettes/TIME_DELAY.png delete mode 100644 palettes/TIME_f.png delete mode 100644 palettes/TKSCALE.png delete mode 100644 palettes/TOWS_c.png delete mode 100644 palettes/TRASH_f.png delete mode 100644 palettes/TrigFun.png delete mode 100644 palettes/VARIABLE_DELAY.png delete mode 100644 palettes/VVsourceAC.png delete mode 100644 palettes/VanneReglante.png delete mode 100644 palettes/VariableResistor.png delete mode 100644 palettes/VirtualCLK0.png delete mode 100644 palettes/VoltageSensor.png delete mode 100644 palettes/VsourceAC.png delete mode 100644 palettes/WFILE_f.png delete mode 100644 palettes/WRITEAU_f.png delete mode 100644 palettes/WRITEC_f.png delete mode 100644 palettes/ZCROSS_f.png delete mode 100644 palettes/c_block.png delete mode 100644 palettes/fortran_block.png delete mode 100644 palettes/freq_div.png delete mode 100644 palettes/generic_block3.png delete mode 100644 palettes/palettes.xml delete mode 100644 palettes/scifunc_block_m.png delete mode 100644 resources/editor.properties delete mode 100644 resources/graph.properties delete mode 100644 setup.js delete mode 100644 styles/Xcos-style.xml create mode 100755 webapp/Queue.js create mode 100644 webapp/blocks/3DSCOPE.svg create mode 100644 webapp/blocks/ANDBLK.svg create mode 100644 webapp/blocks/ASCOPE.svg create mode 100644 webapp/blocks/BACHE.svg create mode 100644 webapp/blocks/BARXY.svg create mode 100644 webapp/blocks/BPLATFORM.svg create mode 100644 webapp/blocks/CCS.svg create mode 100644 webapp/blocks/CLOCK_c.svg create mode 100644 webapp/blocks/CLOCK_f.svg create mode 100644 webapp/blocks/CSCOPXY.svg create mode 100644 webapp/blocks/CSCOPXY3D.svg create mode 100644 webapp/blocks/CVS.svg create mode 100644 webapp/blocks/Capacitor.svg create mode 100644 webapp/blocks/ConstantVoltage.svg create mode 100644 webapp/blocks/CurrentSensor.svg create mode 100644 webapp/blocks/DEADBAND.svg create mode 100644 webapp/blocks/DSCOPE.svg create mode 100644 webapp/blocks/Diode.svg create mode 100644 webapp/blocks/Flowmeter.svg create mode 100644 webapp/blocks/Ground.svg create mode 100644 webapp/blocks/Gyrator.svg create mode 100644 webapp/blocks/HYSTHERESIS.svg create mode 100644 webapp/blocks/INTEGRAL.svg create mode 100644 webapp/blocks/IdealTransformer.svg create mode 100644 webapp/blocks/Inductor.svg create mode 100644 webapp/blocks/NMOS.svg create mode 100644 webapp/blocks/NPN.svg create mode 100644 webapp/blocks/PMOS.svg create mode 100644 webapp/blocks/PNP.svg create mode 100644 webapp/blocks/PRODUCT.svg create mode 100644 webapp/blocks/PULSE_SC.svg create mode 100644 webapp/blocks/PerteDP.svg create mode 100644 webapp/blocks/PotentialSensor.svg create mode 100644 webapp/blocks/PuitP.svg create mode 100644 webapp/blocks/QUANT_f.svg create mode 100644 webapp/blocks/RAMP.svg create mode 100644 webapp/blocks/Resistor.svg create mode 100644 webapp/blocks/SATURATION.svg create mode 100644 webapp/blocks/SINUS_f.svg create mode 100644 webapp/blocks/SQUARE_WAVE_f.svg create mode 100644 webapp/blocks/STEP_FUNCTION.svg create mode 100644 webapp/blocks/SUM.svg create mode 100644 webapp/blocks/SUPER.svg create mode 100644 webapp/blocks/SWITCH.svg create mode 100644 webapp/blocks/SampleCLK.svg create mode 100644 webapp/blocks/Self_Switch_off.svg create mode 100644 webapp/blocks/Self_Switch_on.svg create mode 100644 webapp/blocks/SourceP.svg create mode 100644 webapp/blocks/VanneReglante.svg create mode 100644 webapp/blocks/VariableResistor.svg create mode 100644 webapp/blocks/VirtualCLK0.svg create mode 100644 webapp/blocks/VoltageSensor.svg create mode 100644 webapp/blocks/sawtooth.svg create mode 100755 webapp/chart.js create mode 100644 webapp/combined.js create mode 100644 webapp/composer.json create mode 100644 webapp/config/keyhandler-commons.xml create mode 100644 webapp/css/common.css create mode 100644 webapp/css/explorer.css create mode 100644 webapp/data_structures_correct/ABS_VALUE.js create mode 100644 webapp/data_structures_correct/AFFICH_m.js create mode 100644 webapp/data_structures_correct/ANDBLK.js create mode 100644 webapp/data_structures_correct/ANDLOG_f.js create mode 100644 webapp/data_structures_correct/AUTOMAT.js create mode 100644 webapp/data_structures_correct/BACKLASH.js create mode 100644 webapp/data_structures_correct/BARXY.js create mode 100644 webapp/data_structures_correct/BIGSOM_f.js create mode 100644 webapp/data_structures_correct/BITCLEAR.js create mode 100644 webapp/data_structures_correct/BITSET.js create mode 100644 webapp/data_structures_correct/BOUNCE.js create mode 100644 webapp/data_structures_correct/BOUNCEXY.js create mode 100644 webapp/data_structures_correct/BPLATFORM.js create mode 100644 webapp/data_structures_correct/Bache.js create mode 100644 webapp/data_structures_correct/CANIMXY.js create mode 100644 webapp/data_structures_correct/CANIMXY3D.js create mode 100644 webapp/data_structures_correct/CBLOCK.js create mode 100644 webapp/data_structures_correct/CBLOCK4.js create mode 100644 webapp/data_structures_correct/CCS.js create mode 100644 webapp/data_structures_correct/CEVENTSCOPE.js create mode 100644 webapp/data_structures_correct/CFSCOPE.js create mode 100644 webapp/data_structures_correct/CLINDUMMY_f.js create mode 100644 webapp/data_structures_correct/CLKFROM.js create mode 100644 webapp/data_structures_correct/CLKGOTO.js create mode 100644 webapp/data_structures_correct/CLKGotoTagVisibility.js create mode 100644 webapp/data_structures_correct/CLKINV_f.js create mode 100644 webapp/data_structures_correct/CLKOUTV_f.js create mode 100644 webapp/data_structures_correct/CLKSOMV_f.js create mode 100644 webapp/data_structures_correct/CLKSOM_f.js create mode 100644 webapp/data_structures_correct/CLOCK_c.js create mode 100644 webapp/data_structures_correct/CLR.js create mode 100644 webapp/data_structures_correct/CLSS.js create mode 100644 webapp/data_structures_correct/CMSCOPE.js create mode 100644 webapp/data_structures_correct/CONST.js create mode 100644 webapp/data_structures_correct/CONSTRAINT2_c.js create mode 100644 webapp/data_structures_correct/CONSTRAINT_c.js create mode 100644 webapp/data_structures_correct/CONST_f.js create mode 100644 webapp/data_structures_correct/CONST_m.js create mode 100644 webapp/data_structures_correct/CONVERT.js create mode 100644 webapp/data_structures_correct/COSBLK_f.js create mode 100644 webapp/data_structures_correct/CSCOPE.js create mode 100644 webapp/data_structures_correct/CSCOPXY.js create mode 100644 webapp/data_structures_correct/CSCOPXY3D.js create mode 100644 webapp/data_structures_correct/CUMSUM.js create mode 100644 webapp/data_structures_correct/CURV_f.js create mode 100644 webapp/data_structures_correct/CVS.js create mode 100644 webapp/data_structures_correct/Capacitor.js create mode 100644 webapp/data_structures_correct/ConstantVoltage.js create mode 100644 webapp/data_structures_correct/Counter.js create mode 100644 webapp/data_structures_correct/CurrentSensor.js create mode 100644 webapp/data_structures_correct/DEADBAND.js create mode 100644 webapp/data_structures_correct/DEBUG.js create mode 100644 webapp/data_structures_correct/DELAYV_f.js create mode 100644 webapp/data_structures_correct/DELAY_f.js create mode 100644 webapp/data_structures_correct/DEMUX.js create mode 100644 webapp/data_structures_correct/DEMUX_f.js create mode 100644 webapp/data_structures_correct/DERIV.js create mode 100644 webapp/data_structures_correct/DFLIPFLOP.js create mode 100644 webapp/data_structures_correct/DIFF_f.js create mode 100644 webapp/data_structures_correct/DLATCH.js create mode 100644 webapp/data_structures_correct/DLR.js create mode 100644 webapp/data_structures_correct/DLRADAPT_f.js create mode 100644 webapp/data_structures_correct/DLSS.js create mode 100644 webapp/data_structures_correct/DOLLAR.js create mode 100644 webapp/data_structures_correct/DOLLAR_f.js create mode 100644 webapp/data_structures_correct/DOLLAR_m.js create mode 100644 webapp/data_structures_correct/Diode.js create mode 100644 webapp/data_structures_correct/EDGETRIGGER.js create mode 100644 webapp/data_structures_correct/EDGE_TRIGGER.js create mode 100644 webapp/data_structures_correct/ENDBLK.js create mode 100644 webapp/data_structures_correct/END_c.js create mode 100644 webapp/data_structures_correct/ESELECT_f.js create mode 100644 webapp/data_structures_correct/EVTDLY_c.js create mode 100644 webapp/data_structures_correct/EVTDLY_f.js create mode 100644 webapp/data_structures_correct/EVTGEN_f.js create mode 100644 webapp/data_structures_correct/EVTVARDLY.js create mode 100644 webapp/data_structures_correct/EXPBLK_m.js create mode 100644 webapp/data_structures_correct/EXTRACT.js create mode 100644 webapp/data_structures_correct/EXTRACTBITS.js create mode 100644 webapp/data_structures_correct/EXTRACTOR.js create mode 100644 webapp/data_structures_correct/EXTTRI.js create mode 100644 webapp/data_structures_correct/Extract_Activation.js create mode 100644 webapp/data_structures_correct/FROM.js create mode 100644 webapp/data_structures_correct/FROMMO.js create mode 100644 webapp/data_structures_correct/FROMWSB.js create mode 100644 webapp/data_structures_correct/Flowmeter.js create mode 100644 webapp/data_structures_correct/GAINBLK.js create mode 100644 webapp/data_structures_correct/GAINBLK_f.js create mode 100644 webapp/data_structures_correct/GAIN_f.js create mode 100644 webapp/data_structures_correct/GENERAL_f.js create mode 100644 webapp/data_structures_correct/GENSIN_f.js create mode 100644 webapp/data_structures_correct/GENSQR_f.js create mode 100644 webapp/data_structures_correct/GOTO.js create mode 100644 webapp/data_structures_correct/GOTOMO.js create mode 100644 webapp/data_structures_correct/GotoTagVisibility.js create mode 100644 webapp/data_structures_correct/GotoTagVisibilityMO.js create mode 100644 webapp/data_structures_correct/Ground.js create mode 100644 webapp/data_structures_correct/Gyrator.js create mode 100644 webapp/data_structures_correct/HALT_f.js create mode 100644 webapp/data_structures_correct/HYSTHERESIS.js create mode 100644 webapp/data_structures_correct/IFTHEL_f.js create mode 100644 webapp/data_structures_correct/INIMPL_f.js create mode 100644 webapp/data_structures_correct/INTEGRAL_f.js create mode 100644 webapp/data_structures_correct/INTEGRAL_m.js create mode 100644 webapp/data_structures_correct/INTMUL.js create mode 100644 webapp/data_structures_correct/INTRP2BLK_f.js create mode 100644 webapp/data_structures_correct/INTRPLBLK_f.js create mode 100644 webapp/data_structures_correct/INVBLK.js create mode 100644 webapp/data_structures_correct/IN_f.js create mode 100644 webapp/data_structures_correct/ISELECT_m.js create mode 100644 webapp/data_structures_correct/IdealTransformer.js create mode 100644 webapp/data_structures_correct/Inductor.js create mode 100644 webapp/data_structures_correct/JKFLIPFLOP.js create mode 100644 webapp/data_structures_correct/LOGBLK_f.js create mode 100644 webapp/data_structures_correct/LOGIC.js create mode 100644 webapp/data_structures_correct/LOGICAL_OP.js create mode 100644 webapp/data_structures_correct/LOOKUP_f.js create mode 100644 webapp/data_structures_correct/MATBKSL.js create mode 100644 webapp/data_structures_correct/MATCATH.js create mode 100644 webapp/data_structures_correct/MATCATV.js create mode 100644 webapp/data_structures_correct/MATDET.js create mode 100644 webapp/data_structures_correct/MATDIAG.js create mode 100644 webapp/data_structures_correct/MATDIV.js create mode 100644 webapp/data_structures_correct/MATEIG.js create mode 100644 webapp/data_structures_correct/MATEXPM.js create mode 100644 webapp/data_structures_correct/MATINV.js create mode 100644 webapp/data_structures_correct/MATLU.js create mode 100644 webapp/data_structures_correct/MATMAGPHI.js create mode 100644 webapp/data_structures_correct/MATMUL.js create mode 100644 webapp/data_structures_correct/MATPINV.js create mode 100644 webapp/data_structures_correct/MATRESH.js create mode 100644 webapp/data_structures_correct/MATSING.js create mode 100644 webapp/data_structures_correct/MATSUM.js create mode 100644 webapp/data_structures_correct/MATTRAN.js create mode 100644 webapp/data_structures_correct/MATZCONJ.js create mode 100644 webapp/data_structures_correct/MATZREIM.js create mode 100644 webapp/data_structures_correct/MAXMIN.js create mode 100644 webapp/data_structures_correct/MAX_f.js create mode 100644 webapp/data_structures_correct/MBLOCK.js create mode 100644 webapp/data_structures_correct/MCLOCK_f.js create mode 100644 webapp/data_structures_correct/MFCLCK_f.js create mode 100644 webapp/data_structures_correct/MIN_f.js create mode 100644 webapp/data_structures_correct/MUX.js create mode 100644 webapp/data_structures_correct/MUX_f.js create mode 100644 webapp/data_structures_correct/M_SWITCH.js create mode 100644 webapp/data_structures_correct/M_freq.js create mode 100644 webapp/data_structures_correct/Modulo_Count.js create mode 100644 webapp/data_structures_correct/NEGTOPOS_f.js create mode 100644 webapp/data_structures_correct/NMOS.js create mode 100644 webapp/data_structures_correct/NPN.js create mode 100644 webapp/data_structures_correct/NRMSOM_f.js create mode 100644 webapp/data_structures_correct/OUTIMPL_f.js create mode 100644 webapp/data_structures_correct/OUT_f.js create mode 100644 webapp/data_structures_correct/OpAmp.js create mode 100644 webapp/data_structures_correct/PDE.js create mode 100644 webapp/data_structures_correct/PID.js create mode 100644 webapp/data_structures_correct/PNP.js create mode 100644 webapp/data_structures_correct/POSTONEG_f.js create mode 100644 webapp/data_structures_correct/POWBLK_f.js create mode 100644 webapp/data_structures_correct/PRODUCT.js create mode 100644 webapp/data_structures_correct/PROD_f.js create mode 100644 webapp/data_structures_correct/PULSE_SC.js create mode 100644 webapp/data_structures_correct/PerteDP.js create mode 100644 webapp/data_structures_correct/PotentialSensor.js create mode 100644 webapp/data_structures_correct/PuitsP.js create mode 100644 webapp/data_structures_correct/QUANT_f.js create mode 100644 webapp/data_structures_correct/RAMP.js create mode 100644 webapp/data_structures_correct/RAND_m.js create mode 100644 webapp/data_structures_correct/RATELIMITER.js create mode 100644 webapp/data_structures_correct/READAU_f.js create mode 100644 webapp/data_structures_correct/READC_f.js create mode 100644 webapp/data_structures_correct/REGISTER.js create mode 100644 webapp/data_structures_correct/REGISTER_f.js create mode 100644 webapp/data_structures_correct/RELATIONALOP.js create mode 100644 webapp/data_structures_correct/RELAY_f.js create mode 100644 webapp/data_structures_correct/RFILE_f.js create mode 100644 webapp/data_structures_correct/RICC.js create mode 100644 webapp/data_structures_correct/ROOTCOEF.js create mode 100644 webapp/data_structures_correct/Resistor.js create mode 100644 webapp/data_structures_correct/SAMPHOLD_m.js create mode 100644 webapp/data_structures_correct/SATURATION.js create mode 100644 webapp/data_structures_correct/SAWTOOTH_f.js create mode 100644 webapp/data_structures_correct/SCALAR2VECTOR.js create mode 100644 webapp/data_structures_correct/SELECT_m.js create mode 100644 webapp/data_structures_correct/SELF_SWITCH.js create mode 100644 webapp/data_structures_correct/SHIFT.js create mode 100644 webapp/data_structures_correct/SIGNUM.js create mode 100644 webapp/data_structures_correct/SINBLK_f.js create mode 100644 webapp/data_structures_correct/SOM_f.js create mode 100644 webapp/data_structures_correct/SQRT.js create mode 100644 webapp/data_structures_correct/SRFLIPFLOP.js create mode 100644 webapp/data_structures_correct/STEP_FUNCTION.js create mode 100644 webapp/data_structures_correct/SUBMAT.js create mode 100644 webapp/data_structures_correct/SUMMATION.js create mode 100644 webapp/data_structures_correct/SUM_f.js create mode 100644 webapp/data_structures_correct/SUPER_f.js create mode 100644 webapp/data_structures_correct/SWITCH2_m.js create mode 100644 webapp/data_structures_correct/SWITCH_f.js create mode 100644 webapp/data_structures_correct/SampleCLK.js create mode 100644 webapp/data_structures_correct/Sigbuilder.js create mode 100644 webapp/data_structures_correct/SineVoltage.js create mode 100644 webapp/data_structures_correct/SourceP.js create mode 100644 webapp/data_structures_correct/Switch.js create mode 100644 webapp/data_structures_correct/TANBLK_f.js create mode 100644 webapp/data_structures_correct/TCLSS.js create mode 100644 webapp/data_structures_correct/TEXT_f.js create mode 100644 webapp/data_structures_correct/TIME_DELAY.js create mode 100644 webapp/data_structures_correct/TIME_f.js create mode 100644 webapp/data_structures_correct/TKSCALE.js create mode 100644 webapp/data_structures_correct/TOWS_c.js create mode 100644 webapp/data_structures_correct/TRASH_f.js create mode 100644 webapp/data_structures_correct/TrigFun.js create mode 100644 webapp/data_structures_correct/VARIABLE_DELAY.js create mode 100644 webapp/data_structures_correct/VVsourceAC.js create mode 100644 webapp/data_structures_correct/VanneReglante.js create mode 100644 webapp/data_structures_correct/VariableResistor.js create mode 100644 webapp/data_structures_correct/VirtualCLK0.js create mode 100644 webapp/data_structures_correct/VoltageSensor.js create mode 100644 webapp/data_structures_correct/VsourceAC.js create mode 100644 webapp/data_structures_correct/WRITEAU_f.js create mode 100644 webapp/data_structures_correct/WRITEC_f.js create mode 100644 webapp/data_structures_correct/ZCROSS_f.js create mode 100644 webapp/data_structures_correct/c_block.js create mode 100644 webapp/data_structures_correct/combine_script.bat create mode 100644 webapp/data_structures_correct/fortran_block.js create mode 100644 webapp/data_structures_correct/freq_div.js create mode 100644 webapp/data_structures_correct/generic_block3.js create mode 100644 webapp/data_structures_correct/scifunc_block_m.js create mode 100644 webapp/dependencies.js create mode 100644 webapp/details.js create mode 100644 webapp/documentation/servlet.md create mode 100644 webapp/documentation/wires.md create mode 100644 webapp/filenames.php create mode 100644 webapp/finalmodsheet.xsl create mode 100755 webapp/highcharts/highcharts.js create mode 100644 webapp/history/blocks_xcos/ABS_VALUE.xcos create mode 100644 webapp/history/blocks_xcos/AFFICH_m.xcos create mode 100644 webapp/history/blocks_xcos/ANDBLK.xcos create mode 100644 webapp/history/blocks_xcos/ANDLOG_f.xcos create mode 100644 webapp/history/blocks_xcos/AUTOMAT.xcos create mode 100644 webapp/history/blocks_xcos/BACKLASH.xcos create mode 100644 webapp/history/blocks_xcos/BARXY.xcos create mode 100644 webapp/history/blocks_xcos/BIGSOM_f.xcos create mode 100644 webapp/history/blocks_xcos/BITCLEAR.xcos create mode 100644 webapp/history/blocks_xcos/BITSET.xcos create mode 100644 webapp/history/blocks_xcos/BOUNCE.xcos create mode 100644 webapp/history/blocks_xcos/BOUNCEXY.xcos create mode 100644 webapp/history/blocks_xcos/BPLATFORM.xcos create mode 100644 webapp/history/blocks_xcos/Bache.xcos create mode 100644 webapp/history/blocks_xcos/CANIMXY.xcos create mode 100644 webapp/history/blocks_xcos/CANIMXY3D.xcos create mode 100644 webapp/history/blocks_xcos/CBLOCK.xcos create mode 100644 webapp/history/blocks_xcos/CBLOCK4.xcos create mode 100644 webapp/history/blocks_xcos/CCS.xcos create mode 100644 webapp/history/blocks_xcos/CEVENTSCOPE.xcos create mode 100644 webapp/history/blocks_xcos/CFSCOPE.xcos create mode 100644 webapp/history/blocks_xcos/CLINDUMMY_f.xcos create mode 100644 webapp/history/blocks_xcos/CLKFROM.xcos create mode 100644 webapp/history/blocks_xcos/CLKGOTO.xcos create mode 100644 webapp/history/blocks_xcos/CLKGotoTagVisibility.xcos create mode 100644 webapp/history/blocks_xcos/CLKINV_f.xcos create mode 100644 webapp/history/blocks_xcos/CLKOUTV_f.xcos create mode 100644 webapp/history/blocks_xcos/CLKSOMV_f.xcos create mode 100644 webapp/history/blocks_xcos/CLOCK_c.xcos create mode 100644 webapp/history/blocks_xcos/CLR.xcos create mode 100644 webapp/history/blocks_xcos/CLSS.xcos create mode 100644 webapp/history/blocks_xcos/CMAT3D.xcos create mode 100644 webapp/history/blocks_xcos/CMATVIEW.xcos create mode 100644 webapp/history/blocks_xcos/CMSCOPE.xcos create mode 100644 webapp/history/blocks_xcos/CONST.xcos create mode 100644 webapp/history/blocks_xcos/CONSTRAINT2_c.xcos create mode 100644 webapp/history/blocks_xcos/CONSTRAINT_c.xcos create mode 100644 webapp/history/blocks_xcos/CONST_f.xcos create mode 100644 webapp/history/blocks_xcos/CONST_m.xcos create mode 100644 webapp/history/blocks_xcos/CONVERT.xcos create mode 100644 webapp/history/blocks_xcos/COSBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/CSCOPE.xcos create mode 100644 webapp/history/blocks_xcos/CSCOPXY.xcos create mode 100644 webapp/history/blocks_xcos/CSCOPXY3D.xcos create mode 100644 webapp/history/blocks_xcos/CUMSUM.xcos create mode 100644 webapp/history/blocks_xcos/CURV_f.xcos create mode 100644 webapp/history/blocks_xcos/CVS.xcos create mode 100644 webapp/history/blocks_xcos/Capacitor.xcos create mode 100644 webapp/history/blocks_xcos/ConstantVoltage.xcos create mode 100644 webapp/history/blocks_xcos/Counter.xcos create mode 100644 webapp/history/blocks_xcos/CurrentSensor.xcos create mode 100644 webapp/history/blocks_xcos/DEADBAND.xcos create mode 100644 webapp/history/blocks_xcos/DEBUG.xcos create mode 100644 webapp/history/blocks_xcos/DELAYV_f.xcos create mode 100644 webapp/history/blocks_xcos/DELAY_f.xcos create mode 100644 webapp/history/blocks_xcos/DEMUX.xcos create mode 100644 webapp/history/blocks_xcos/DEMUX_f.xcos create mode 100644 webapp/history/blocks_xcos/DERIV.xcos create mode 100644 webapp/history/blocks_xcos/DFLIPFLOP.xcos create mode 100644 webapp/history/blocks_xcos/DIFF_f.xcos create mode 100644 webapp/history/blocks_xcos/DLATCH.xcos create mode 100644 webapp/history/blocks_xcos/DLR.xcos create mode 100644 webapp/history/blocks_xcos/DLRADAPT_f.xcos create mode 100644 webapp/history/blocks_xcos/DLSS.xcos create mode 100644 webapp/history/blocks_xcos/DOLLAR.xcos create mode 100644 webapp/history/blocks_xcos/DOLLAR_f.xcos create mode 100644 webapp/history/blocks_xcos/DOLLAR_m.xcos create mode 100644 webapp/history/blocks_xcos/Diode.xcos create mode 100644 webapp/history/blocks_xcos/EDGE_TRIGGER.xcos create mode 100644 webapp/history/blocks_xcos/ENDBLK.xcos create mode 100644 webapp/history/blocks_xcos/END_c.xcos create mode 100644 webapp/history/blocks_xcos/ESELECT_f.xcos create mode 100644 webapp/history/blocks_xcos/EVTDLY_c.xcos create mode 100644 webapp/history/blocks_xcos/EVTGEN_f.xcos create mode 100644 webapp/history/blocks_xcos/EVTVARDLY.xcos create mode 100644 webapp/history/blocks_xcos/EXPBLK_m.xcos create mode 100644 webapp/history/blocks_xcos/EXPRESSION.xcos create mode 100644 webapp/history/blocks_xcos/EXTRACT.xcos create mode 100644 webapp/history/blocks_xcos/EXTRACTBITS.xcos create mode 100644 webapp/history/blocks_xcos/EXTRACTOR.xcos create mode 100644 webapp/history/blocks_xcos/EXTTRI.xcos create mode 100644 webapp/history/blocks_xcos/Extract_Activation.xcos create mode 100644 webapp/history/blocks_xcos/FROM.xcos create mode 100644 webapp/history/blocks_xcos/FROMMO.xcos create mode 100644 webapp/history/blocks_xcos/FROMWSB.xcos create mode 100644 webapp/history/blocks_xcos/Flowmeter.xcos create mode 100644 webapp/history/blocks_xcos/GAINBLK.xcos create mode 100644 webapp/history/blocks_xcos/GAINBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/GAIN_f.xcos create mode 100644 webapp/history/blocks_xcos/GENERAL_f.xcos create mode 100644 webapp/history/blocks_xcos/GENSIN_f.xcos create mode 100644 webapp/history/blocks_xcos/GENSQR_f.xcos create mode 100644 webapp/history/blocks_xcos/GOTO.xcos create mode 100644 webapp/history/blocks_xcos/GOTOMO.xcos create mode 100644 webapp/history/blocks_xcos/GotoTagVisibility.xcos create mode 100644 webapp/history/blocks_xcos/GotoTagVisibilityMO.xcos create mode 100644 webapp/history/blocks_xcos/Ground.xcos create mode 100644 webapp/history/blocks_xcos/Gyrator.xcos create mode 100644 webapp/history/blocks_xcos/HALT_f.xcos create mode 100644 webapp/history/blocks_xcos/HYSTHERESIS.xcos create mode 100644 webapp/history/blocks_xcos/IFTHEL_f.xcos create mode 100644 webapp/history/blocks_xcos/INIMPL_f.xcos create mode 100644 webapp/history/blocks_xcos/INTEGRAL_f.xcos create mode 100644 webapp/history/blocks_xcos/INTEGRAL_m.xcos create mode 100644 webapp/history/blocks_xcos/INTMUL.xcos create mode 100644 webapp/history/blocks_xcos/INTRP2BLK_f.xcos create mode 100644 webapp/history/blocks_xcos/INTRPLBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/INVBLK.xcos create mode 100644 webapp/history/blocks_xcos/IN_f.xcos create mode 100644 webapp/history/blocks_xcos/ISELECT_m.xcos create mode 100644 webapp/history/blocks_xcos/IdealTransformer.xcos create mode 100644 webapp/history/blocks_xcos/Inductor.xcos create mode 100644 webapp/history/blocks_xcos/JKFLIPFLOP.xcos create mode 100644 webapp/history/blocks_xcos/LOGBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/LOGIC.xcos create mode 100644 webapp/history/blocks_xcos/LOGICAL_OP.xcos create mode 100644 webapp/history/blocks_xcos/LOOKUP_f.xcos create mode 100644 webapp/history/blocks_xcos/MATBKSL.xcos create mode 100644 webapp/history/blocks_xcos/MATCATH.xcos create mode 100644 webapp/history/blocks_xcos/MATCATV.xcos create mode 100644 webapp/history/blocks_xcos/MATDET.xcos create mode 100644 webapp/history/blocks_xcos/MATDIAG.xcos create mode 100644 webapp/history/blocks_xcos/MATDIV.xcos create mode 100644 webapp/history/blocks_xcos/MATEIG.xcos create mode 100644 webapp/history/blocks_xcos/MATEXPM.xcos create mode 100644 webapp/history/blocks_xcos/MATINV.xcos create mode 100644 webapp/history/blocks_xcos/MATLU.xcos create mode 100644 webapp/history/blocks_xcos/MATMAGPHI.xcos create mode 100644 webapp/history/blocks_xcos/MATMUL.xcos create mode 100644 webapp/history/blocks_xcos/MATPINV.xcos create mode 100644 webapp/history/blocks_xcos/MATRESH.xcos create mode 100644 webapp/history/blocks_xcos/MATSING.xcos create mode 100644 webapp/history/blocks_xcos/MATSUM.xcos create mode 100644 webapp/history/blocks_xcos/MATTRAN.xcos create mode 100644 webapp/history/blocks_xcos/MATZCONJ.xcos create mode 100644 webapp/history/blocks_xcos/MATZREIM.xcos create mode 100644 webapp/history/blocks_xcos/MAXMIN.xcos create mode 100644 webapp/history/blocks_xcos/MAX_f.xcos create mode 100644 webapp/history/blocks_xcos/MBLOCK.xcos create mode 100644 webapp/history/blocks_xcos/MCLOCK_f.xcos create mode 100644 webapp/history/blocks_xcos/MFCLCK_f.xcos create mode 100644 webapp/history/blocks_xcos/MIN_f.xcos create mode 100644 webapp/history/blocks_xcos/MUX.xcos create mode 100644 webapp/history/blocks_xcos/MUX_f.xcos create mode 100644 webapp/history/blocks_xcos/M_SWITCH.xcos create mode 100644 webapp/history/blocks_xcos/M_freq.xcos create mode 100644 webapp/history/blocks_xcos/Modulo_Count.xcos create mode 100644 webapp/history/blocks_xcos/NEGTOPOS_f.xcos create mode 100644 webapp/history/blocks_xcos/NMOS.xcos create mode 100644 webapp/history/blocks_xcos/NPN.xcos create mode 100644 webapp/history/blocks_xcos/NRMSOM_f.xcos create mode 100644 webapp/history/blocks_xcos/OUTIMPL_f.xcos create mode 100644 webapp/history/blocks_xcos/OUT_f.xcos create mode 100644 webapp/history/blocks_xcos/OpAmp.xcos create mode 100644 webapp/history/blocks_xcos/PDE.xcos create mode 100644 webapp/history/blocks_xcos/PID.xcos create mode 100644 webapp/history/blocks_xcos/PMOS.xcos create mode 100644 webapp/history/blocks_xcos/PNP.xcos create mode 100644 webapp/history/blocks_xcos/POSTONEG_f.xcos create mode 100644 webapp/history/blocks_xcos/POWBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/PRODUCT.xcos create mode 100644 webapp/history/blocks_xcos/PROD_f.xcos create mode 100644 webapp/history/blocks_xcos/PULSE_SC.xcos create mode 100644 webapp/history/blocks_xcos/PerteDP.xcos create mode 100644 webapp/history/blocks_xcos/PotentialSensor.xcos create mode 100644 webapp/history/blocks_xcos/PuitsP.xcos create mode 100644 webapp/history/blocks_xcos/QUANT_f.xcos create mode 100644 webapp/history/blocks_xcos/RAMP.xcos create mode 100644 webapp/history/blocks_xcos/RAND_m.xcos create mode 100644 webapp/history/blocks_xcos/RATELIMITER.xcos create mode 100644 webapp/history/blocks_xcos/READAU_f.xcos create mode 100644 webapp/history/blocks_xcos/READC_f.xcos create mode 100644 webapp/history/blocks_xcos/REGISTER.xcos create mode 100644 webapp/history/blocks_xcos/RELATIONALOP.xcos create mode 100644 webapp/history/blocks_xcos/RELAY_f.xcos create mode 100644 webapp/history/blocks_xcos/RFILE_f.xcos create mode 100644 webapp/history/blocks_xcos/RICC.xcos create mode 100644 webapp/history/blocks_xcos/ROOTCOEF.xcos create mode 100644 webapp/history/blocks_xcos/Resistor.xcos create mode 100644 webapp/history/blocks_xcos/SAMPHOLD_m.xcos create mode 100644 webapp/history/blocks_xcos/SATURATION.xcos create mode 100644 webapp/history/blocks_xcos/SAWTOOTH_f.xcos create mode 100644 webapp/history/blocks_xcos/SCALAR2VECTOR.xcos create mode 100644 webapp/history/blocks_xcos/SELECT_m.xcos create mode 100644 webapp/history/blocks_xcos/SELF_SWITCH.xcos create mode 100644 webapp/history/blocks_xcos/SHIFT.xcos create mode 100644 webapp/history/blocks_xcos/SIGNUM.xcos create mode 100644 webapp/history/blocks_xcos/SINBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/SOM_f.xcos create mode 100644 webapp/history/blocks_xcos/SQRT.xcos create mode 100644 webapp/history/blocks_xcos/SRFLIPFLOP.xcos create mode 100644 webapp/history/blocks_xcos/STEP_FUNCTION.xcos create mode 100644 webapp/history/blocks_xcos/SUBMAT.xcos create mode 100644 webapp/history/blocks_xcos/SUMMATION.xcos create mode 100644 webapp/history/blocks_xcos/SUM_f.xcos create mode 100644 webapp/history/blocks_xcos/SUPER_f.xcos create mode 100644 webapp/history/blocks_xcos/SWITCH2_m.xcos create mode 100644 webapp/history/blocks_xcos/SWITCH_f.xcos create mode 100644 webapp/history/blocks_xcos/SampleCLK.xcos create mode 100644 webapp/history/blocks_xcos/Sigbuilder.xcos create mode 100644 webapp/history/blocks_xcos/SineVoltage.xcos create mode 100644 webapp/history/blocks_xcos/SourceP.xcos create mode 100644 webapp/history/blocks_xcos/Switch.xcos create mode 100644 webapp/history/blocks_xcos/TANBLK_f.xcos create mode 100644 webapp/history/blocks_xcos/TCLSS.xcos create mode 100644 webapp/history/blocks_xcos/TEXT_f.xcos create mode 100644 webapp/history/blocks_xcos/TIME_DELAY.xcos create mode 100644 webapp/history/blocks_xcos/TIME_f.xcos create mode 100644 webapp/history/blocks_xcos/TKSCALE.xcos create mode 100644 webapp/history/blocks_xcos/TOWS_c.xcos create mode 100644 webapp/history/blocks_xcos/TRASH_f.xcos create mode 100644 webapp/history/blocks_xcos/TrigFun.xcos create mode 100644 webapp/history/blocks_xcos/VARIABLE_DELAY.xcos create mode 100644 webapp/history/blocks_xcos/VVsourceAC.xcos create mode 100644 webapp/history/blocks_xcos/VanneReglante.xcos create mode 100644 webapp/history/blocks_xcos/VariableResistor.xcos create mode 100644 webapp/history/blocks_xcos/VirtualCLK0.xcos create mode 100644 webapp/history/blocks_xcos/VoltageSensor.xcos create mode 100644 webapp/history/blocks_xcos/VsourceAC.xcos create mode 100644 webapp/history/blocks_xcos/WFILE_f.xcos create mode 100644 webapp/history/blocks_xcos/WRITEAU_f.xcos create mode 100644 webapp/history/blocks_xcos/WRITEC_f.xcos create mode 100644 webapp/history/blocks_xcos/ZCROSS_f.xcos create mode 100644 webapp/history/blocks_xcos/c_block.xcos create mode 100644 webapp/history/blocks_xcos/fortran_block.xcos create mode 100644 webapp/history/blocks_xcos/freq_div.xcos create mode 100644 webapp/history/blocks_xcos/generic_block3.xcos create mode 100644 webapp/history/blocks_xcos/scifunc_block_m.xcos create mode 100644 webapp/history/data_structures/ABS_VALUE.js create mode 100644 webapp/history/data_structures/AFFICH_m.js create mode 100644 webapp/history/data_structures/ANDBLK.js create mode 100644 webapp/history/data_structures/ANDLOG_f.js create mode 100644 webapp/history/data_structures/AUTOMAT.js create mode 100644 webapp/history/data_structures/BACKLASH.js create mode 100644 webapp/history/data_structures/BARXY.js create mode 100644 webapp/history/data_structures/BIGSOM_f.js create mode 100644 webapp/history/data_structures/BITCLEAR.js create mode 100644 webapp/history/data_structures/BITSET.js create mode 100644 webapp/history/data_structures/BOUNCE.js create mode 100644 webapp/history/data_structures/BOUNCEXY.js create mode 100644 webapp/history/data_structures/BPLATFORM.js create mode 100644 webapp/history/data_structures/Bache.js create mode 100644 webapp/history/data_structures/CANIMXY.js create mode 100644 webapp/history/data_structures/CANIMXY3D.js create mode 100644 webapp/history/data_structures/CBLOCK.js create mode 100644 webapp/history/data_structures/CBLOCK4.js create mode 100644 webapp/history/data_structures/CCS.js create mode 100644 webapp/history/data_structures/CEVENTSCOPE.js create mode 100644 webapp/history/data_structures/CFSCOPE.js create mode 100644 webapp/history/data_structures/CLINDUMMY_f.js create mode 100644 webapp/history/data_structures/CLKFROM.js create mode 100644 webapp/history/data_structures/CLKGOTO.js create mode 100644 webapp/history/data_structures/CLKGotoTagVisibility.js create mode 100644 webapp/history/data_structures/CLKINV_f.js create mode 100644 webapp/history/data_structures/CLKOUTV_f.js create mode 100644 webapp/history/data_structures/CLKSOMV_f.js create mode 100644 webapp/history/data_structures/CLOCK_c.js create mode 100644 webapp/history/data_structures/CLR.js create mode 100644 webapp/history/data_structures/CLSS.js create mode 100644 webapp/history/data_structures/CMAT3D.js create mode 100644 webapp/history/data_structures/CMATVIEW.js create mode 100644 webapp/history/data_structures/CMSCOPE.js create mode 100644 webapp/history/data_structures/CONST.js create mode 100644 webapp/history/data_structures/CONSTRAINT2_c.js create mode 100644 webapp/history/data_structures/CONSTRAINT_c.js create mode 100644 webapp/history/data_structures/CONST_f.js create mode 100644 webapp/history/data_structures/CONST_m.js create mode 100644 webapp/history/data_structures/CONVERT.js create mode 100644 webapp/history/data_structures/COSBLK_f.js create mode 100644 webapp/history/data_structures/CSCOPE.js create mode 100644 webapp/history/data_structures/CSCOPXY.js create mode 100644 webapp/history/data_structures/CSCOPXY3D.js create mode 100644 webapp/history/data_structures/CUMSUM.js create mode 100644 webapp/history/data_structures/CURV_f.js create mode 100644 webapp/history/data_structures/CVS.js create mode 100644 webapp/history/data_structures/Capacitor.js create mode 100644 webapp/history/data_structures/ConstantVoltage.js create mode 100644 webapp/history/data_structures/Counter.js create mode 100644 webapp/history/data_structures/CurrentSensor.js create mode 100644 webapp/history/data_structures/DEADBAND.js create mode 100644 webapp/history/data_structures/DEBUG.js create mode 100644 webapp/history/data_structures/DELAYV_f.js create mode 100644 webapp/history/data_structures/DELAY_f.js create mode 100644 webapp/history/data_structures/DEMUX.js create mode 100644 webapp/history/data_structures/DEMUX_f.js create mode 100644 webapp/history/data_structures/DERIV.js create mode 100644 webapp/history/data_structures/DFLIPFLOP.js create mode 100644 webapp/history/data_structures/DIFF_f.js create mode 100644 webapp/history/data_structures/DLATCH.js create mode 100644 webapp/history/data_structures/DLR.js create mode 100644 webapp/history/data_structures/DLRADAPT_f.js create mode 100644 webapp/history/data_structures/DLSS.js create mode 100644 webapp/history/data_structures/DOLLAR.js create mode 100644 webapp/history/data_structures/DOLLAR_f.js create mode 100644 webapp/history/data_structures/DOLLAR_m.js create mode 100644 webapp/history/data_structures/Diode.js create mode 100644 webapp/history/data_structures/EDGE_TRIGGER.js create mode 100644 webapp/history/data_structures/ENDBLK.js create mode 100644 webapp/history/data_structures/END_c.js create mode 100644 webapp/history/data_structures/ESELECT_f.js create mode 100644 webapp/history/data_structures/EVTDLY_c.js create mode 100644 webapp/history/data_structures/EVTGEN_f.js create mode 100644 webapp/history/data_structures/EVTVARDLY.js create mode 100644 webapp/history/data_structures/EXPBLK_m.js create mode 100644 webapp/history/data_structures/EXPRESSION.js create mode 100644 webapp/history/data_structures/EXTRACT.js create mode 100644 webapp/history/data_structures/EXTRACTBITS.js create mode 100644 webapp/history/data_structures/EXTRACTOR.js create mode 100644 webapp/history/data_structures/EXTTRI.js create mode 100644 webapp/history/data_structures/Extract_Activation.js create mode 100644 webapp/history/data_structures/FROM.js create mode 100644 webapp/history/data_structures/FROMMO.js create mode 100644 webapp/history/data_structures/FROMWSB.js create mode 100644 webapp/history/data_structures/Flowmeter.js create mode 100644 webapp/history/data_structures/GAINBLK.js create mode 100644 webapp/history/data_structures/GAINBLK_f.js create mode 100644 webapp/history/data_structures/GAIN_f.js create mode 100644 webapp/history/data_structures/GENERAL_f.js create mode 100644 webapp/history/data_structures/GENSIN_f.js create mode 100644 webapp/history/data_structures/GENSQR_f.js create mode 100644 webapp/history/data_structures/GOTO.js create mode 100644 webapp/history/data_structures/GOTOMO.js create mode 100644 webapp/history/data_structures/GotoTagVisibility.js create mode 100644 webapp/history/data_structures/GotoTagVisibilityMO.js create mode 100644 webapp/history/data_structures/Ground.js create mode 100644 webapp/history/data_structures/Gyrator.js create mode 100644 webapp/history/data_structures/HALT_f.js create mode 100644 webapp/history/data_structures/HYSTHERESIS.js create mode 100644 webapp/history/data_structures/IFTHEL_f.js create mode 100644 webapp/history/data_structures/INIMPL_f.js create mode 100644 webapp/history/data_structures/INTEGRAL_f.js create mode 100644 webapp/history/data_structures/INTEGRAL_m.js create mode 100644 webapp/history/data_structures/INTMUL.js create mode 100644 webapp/history/data_structures/INTRP2BLK_f.js create mode 100644 webapp/history/data_structures/INTRPLBLK_f.js create mode 100644 webapp/history/data_structures/INVBLK.js create mode 100644 webapp/history/data_structures/IN_f.js create mode 100644 webapp/history/data_structures/ISELECT_m.js create mode 100644 webapp/history/data_structures/IdealTransformer.js create mode 100644 webapp/history/data_structures/Inductor.js create mode 100644 webapp/history/data_structures/JKFLIPFLOP.js create mode 100644 webapp/history/data_structures/LOGBLK_f.js create mode 100644 webapp/history/data_structures/LOGIC.js create mode 100644 webapp/history/data_structures/LOGICAL_OP.js create mode 100644 webapp/history/data_structures/LOOKUP_f.js create mode 100644 webapp/history/data_structures/MATBKSL.js create mode 100644 webapp/history/data_structures/MATCATH.js create mode 100644 webapp/history/data_structures/MATCATV.js create mode 100644 webapp/history/data_structures/MATDET.js create mode 100644 webapp/history/data_structures/MATDIAG.js create mode 100644 webapp/history/data_structures/MATDIV.js create mode 100644 webapp/history/data_structures/MATEIG.js create mode 100644 webapp/history/data_structures/MATEXPM.js create mode 100644 webapp/history/data_structures/MATINV.js create mode 100644 webapp/history/data_structures/MATLU.js create mode 100644 webapp/history/data_structures/MATMAGPHI.js create mode 100644 webapp/history/data_structures/MATMUL.js create mode 100644 webapp/history/data_structures/MATPINV.js create mode 100644 webapp/history/data_structures/MATRESH.js create mode 100644 webapp/history/data_structures/MATSING.js create mode 100644 webapp/history/data_structures/MATSUM.js create mode 100644 webapp/history/data_structures/MATTRAN.js create mode 100644 webapp/history/data_structures/MATZCONJ.js create mode 100644 webapp/history/data_structures/MATZREIM.js create mode 100644 webapp/history/data_structures/MAXMIN.js create mode 100644 webapp/history/data_structures/MAX_f.js create mode 100644 webapp/history/data_structures/MBLOCK.js create mode 100644 webapp/history/data_structures/MCLOCK_f.js create mode 100644 webapp/history/data_structures/MFCLCK_f.js create mode 100644 webapp/history/data_structures/MIN_f.js create mode 100644 webapp/history/data_structures/MUX.js create mode 100644 webapp/history/data_structures/MUX_f.js create mode 100644 webapp/history/data_structures/M_SWITCH.js create mode 100644 webapp/history/data_structures/M_freq.js create mode 100644 webapp/history/data_structures/Modulo_Count.js create mode 100644 webapp/history/data_structures/NEGTOPOS_f.js create mode 100644 webapp/history/data_structures/NMOS.js create mode 100644 webapp/history/data_structures/NPN.js create mode 100644 webapp/history/data_structures/NRMSOM_f.js create mode 100644 webapp/history/data_structures/OUTIMPL_f.js create mode 100644 webapp/history/data_structures/OUT_f.js create mode 100644 webapp/history/data_structures/OpAmp.js create mode 100644 webapp/history/data_structures/PDE.js create mode 100644 webapp/history/data_structures/PID.js create mode 100644 webapp/history/data_structures/PMOS.js create mode 100644 webapp/history/data_structures/PNP.js create mode 100644 webapp/history/data_structures/POSTONEG_f.js create mode 100644 webapp/history/data_structures/POWBLK_f.js create mode 100644 webapp/history/data_structures/PRODUCT.js create mode 100644 webapp/history/data_structures/PROD_f.js create mode 100644 webapp/history/data_structures/PULSE_SC.js create mode 100644 webapp/history/data_structures/PerteDP.js create mode 100644 webapp/history/data_structures/PotentialSensor.js create mode 100644 webapp/history/data_structures/PuitsP.js create mode 100644 webapp/history/data_structures/QUANT_f.js create mode 100644 webapp/history/data_structures/RAMP.js create mode 100644 webapp/history/data_structures/RAND_m.js create mode 100644 webapp/history/data_structures/RATELIMITER.js create mode 100644 webapp/history/data_structures/READAU_f.js create mode 100644 webapp/history/data_structures/READC_f.js create mode 100644 webapp/history/data_structures/REGISTER.js create mode 100644 webapp/history/data_structures/RELATIONALOP.js create mode 100644 webapp/history/data_structures/RELAY_f.js create mode 100644 webapp/history/data_structures/RFILE_f.js create mode 100644 webapp/history/data_structures/RICC.js create mode 100644 webapp/history/data_structures/ROOTCOEF.js create mode 100644 webapp/history/data_structures/Resistor.js create mode 100644 webapp/history/data_structures/SAMPHOLD_m.js create mode 100644 webapp/history/data_structures/SATURATION.js create mode 100644 webapp/history/data_structures/SAWTOOTH_f.js create mode 100644 webapp/history/data_structures/SCALAR2VECTOR.js create mode 100644 webapp/history/data_structures/SELECT_m.js create mode 100644 webapp/history/data_structures/SELF_SWITCH.js create mode 100644 webapp/history/data_structures/SHIFT.js create mode 100644 webapp/history/data_structures/SIGNUM.js create mode 100644 webapp/history/data_structures/SINBLK_f.js create mode 100644 webapp/history/data_structures/SOM_f.js create mode 100644 webapp/history/data_structures/SQRT.js create mode 100644 webapp/history/data_structures/SRFLIPFLOP.js create mode 100644 webapp/history/data_structures/STEP_FUNCTION.js create mode 100644 webapp/history/data_structures/SUBMAT.js create mode 100644 webapp/history/data_structures/SUMMATION.js create mode 100644 webapp/history/data_structures/SUM_f.js create mode 100644 webapp/history/data_structures/SUPER_f.js create mode 100644 webapp/history/data_structures/SWITCH2_m.js create mode 100644 webapp/history/data_structures/SWITCH_f.js create mode 100644 webapp/history/data_structures/SampleCLK.js create mode 100644 webapp/history/data_structures/Sigbuilder.js create mode 100644 webapp/history/data_structures/SineVoltage.js create mode 100644 webapp/history/data_structures/SourceP.js create mode 100644 webapp/history/data_structures/Switch.js create mode 100644 webapp/history/data_structures/TANBLK_f.js create mode 100644 webapp/history/data_structures/TCLSS.js create mode 100644 webapp/history/data_structures/TEXT_f.js create mode 100644 webapp/history/data_structures/TIME_DELAY.js create mode 100644 webapp/history/data_structures/TIME_f.js create mode 100644 webapp/history/data_structures/TKSCALE.js create mode 100644 webapp/history/data_structures/TOWS_c.js create mode 100644 webapp/history/data_structures/TRASH_f.js create mode 100644 webapp/history/data_structures/TrigFun.js create mode 100644 webapp/history/data_structures/VARIABLE_DELAY.js create mode 100644 webapp/history/data_structures/VVsourceAC.js create mode 100644 webapp/history/data_structures/VanneReglante.js create mode 100644 webapp/history/data_structures/VariableResistor.js create mode 100644 webapp/history/data_structures/VirtualCLK0.js create mode 100644 webapp/history/data_structures/VoltageSensor.js create mode 100644 webapp/history/data_structures/VsourceAC.js create mode 100644 webapp/history/data_structures/WFILE_f.js create mode 100644 webapp/history/data_structures/WRITEAU_f.js create mode 100644 webapp/history/data_structures/WRITEC_f.js create mode 100644 webapp/history/data_structures/ZCROSS_f.js create mode 100644 webapp/history/data_structures/c_block.js create mode 100644 webapp/history/data_structures/fortran_block.js create mode 100644 webapp/history/data_structures/freq_div.js create mode 100644 webapp/history/data_structures/generic_block3.js create mode 100644 webapp/history/data_structures/scifunc_block_m.js create mode 100644 webapp/images/ScilabExecute.png create mode 100644 webapp/images/add.png create mode 100644 webapp/images/button.gif create mode 100644 webapp/images/camera.png create mode 100644 webapp/images/check.png create mode 100644 webapp/images/close.gif create mode 100644 webapp/images/close.png create mode 100644 webapp/images/collapsed.gif create mode 100644 webapp/images/connector.gif create mode 100644 webapp/images/copy.png create mode 100644 webapp/images/cut.png create mode 100644 webapp/images/delete2.png create mode 100644 webapp/images/dot.gif create mode 100644 webapp/images/draw-brush.png create mode 100644 webapp/images/edit.png create mode 100644 webapp/images/error.gif create mode 100644 webapp/images/expanded.gif create mode 100644 webapp/images/export1.png create mode 100644 webapp/images/fit_to_size.png create mode 100644 webapp/images/flip.png create mode 100644 webapp/images/gear.gif create mode 100644 webapp/images/gradient_background.jpg create mode 100644 webapp/images/green-dot.gif create mode 100644 webapp/images/grid.gif create mode 100644 webapp/images/group.png create mode 100644 webapp/images/key.png create mode 100644 webapp/images/loading.gif create mode 100644 webapp/images/maximize.gif create mode 100644 webapp/images/minimize.gif create mode 100644 webapp/images/mirror.png create mode 100644 webapp/images/navigate_minus.png create mode 100644 webapp/images/navigate_plus.png create mode 100644 webapp/images/normalize.gif create mode 100644 webapp/images/paste.png create mode 100644 webapp/images/plus.png create mode 100644 webapp/images/point.gif create mode 100644 webapp/images/press32.png create mode 100644 webapp/images/print32.png create mode 100644 webapp/images/printer.png create mode 100644 webapp/images/redo.png create mode 100644 webapp/images/resize.gif create mode 100644 webapp/images/rotate.png create mode 100644 webapp/images/selectall.png create mode 100644 webapp/images/separator.gif create mode 100644 webapp/images/setup.png create mode 100644 webapp/images/sidebar_bg.gif create mode 100644 webapp/images/spacer.gif create mode 100644 webapp/images/submenu.gif create mode 100644 webapp/images/superblock.png create mode 100644 webapp/images/toolbar_bg.gif create mode 100644 webapp/images/transparent.gif create mode 100644 webapp/images/undo.png create mode 100644 webapp/images/view_1_1.png create mode 100644 webapp/images/view_1_132.png create mode 100644 webapp/images/view_next.png create mode 100644 webapp/images/view_previous.png create mode 100644 webapp/images/warning.gif create mode 100644 webapp/images/warning.png create mode 100644 webapp/images/window-title.gif create mode 100644 webapp/images/window.gif create mode 100644 webapp/images/wires-grid.gif create mode 100644 webapp/images/zoom_in.png create mode 100644 webapp/images/zoom_in32.png create mode 100644 webapp/images/zoom_out.png create mode 100644 webapp/images/zoom_out32.png create mode 100644 webapp/index.html create mode 100644 webapp/jquery/LICENSE.txt create mode 100644 webapp/jquery/README.html create mode 100644 webapp/jquery/farbtastic.css create mode 100644 webapp/jquery/farbtastic.js create mode 100644 webapp/jquery/images/ui-bg_flat_75_ffffff_40x100.png create mode 100644 webapp/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png create mode 100644 webapp/jquery/images/ui-icons_888888_256x240.png create mode 100644 webapp/jquery/jquery-1.8.2.js create mode 100644 webapp/jquery/jquery-ui.css create mode 100644 webapp/jquery/marker.png create mode 100644 webapp/jquery/mask.png create mode 100644 webapp/jquery/wheel.png create mode 100644 webapp/math.js create mode 100644 webapp/mxClient.min.js create mode 100644 webapp/orientation.js create mode 100644 webapp/palettes/ABS_VALUE.png create mode 100644 webapp/palettes/AFFICH_m.png create mode 100644 webapp/palettes/ANDBLK.png create mode 100644 webapp/palettes/ANDLOG_f.png create mode 100644 webapp/palettes/AUTOMAT.png create mode 100644 webapp/palettes/BACKLASH.png create mode 100644 webapp/palettes/BARXY.png create mode 100644 webapp/palettes/BIGSOM_f.png create mode 100644 webapp/palettes/BITCLEAR.png create mode 100644 webapp/palettes/BITSET.png create mode 100644 webapp/palettes/BOUNCE.png create mode 100644 webapp/palettes/BOUNCEXY.png create mode 100644 webapp/palettes/BPLATFORM.png create mode 100644 webapp/palettes/Bache.png create mode 100644 webapp/palettes/CANIMXY.png create mode 100644 webapp/palettes/CANIMXY3D.png create mode 100644 webapp/palettes/CBLOCK.png create mode 100644 webapp/palettes/CBLOCK4.png create mode 100644 webapp/palettes/CCS.png create mode 100644 webapp/palettes/CEVENTSCOPE.png create mode 100644 webapp/palettes/CFSCOPE.png create mode 100644 webapp/palettes/CLINDUMMY_f.png create mode 100644 webapp/palettes/CLKFROM.png create mode 100644 webapp/palettes/CLKGOTO.png create mode 100644 webapp/palettes/CLKGotoTagVisibility.png create mode 100644 webapp/palettes/CLKINV_f.png create mode 100644 webapp/palettes/CLKOUTV_f.png create mode 100644 webapp/palettes/CLKSOMV_f.png create mode 100644 webapp/palettes/CLOCK_c.png create mode 100644 webapp/palettes/CLR.png create mode 100644 webapp/palettes/CLSS.png create mode 100644 webapp/palettes/CMAT3D.png create mode 100644 webapp/palettes/CMATVIEW.png create mode 100644 webapp/palettes/CMSCOPE.png create mode 100644 webapp/palettes/CONST.png create mode 100644 webapp/palettes/CONSTRAINT2_c.png create mode 100644 webapp/palettes/CONSTRAINT_c.png create mode 100644 webapp/palettes/CONST_f.png create mode 100644 webapp/palettes/CONST_m.png create mode 100644 webapp/palettes/CONVERT.png create mode 100644 webapp/palettes/COSBLK_f.png create mode 100644 webapp/palettes/CSCOPE.png create mode 100644 webapp/palettes/CSCOPXY.png create mode 100644 webapp/palettes/CSCOPXY3D.png create mode 100644 webapp/palettes/CUMSUM.png create mode 100644 webapp/palettes/CURV_f.png create mode 100644 webapp/palettes/CVS.png create mode 100644 webapp/palettes/Capacitor.png create mode 100644 webapp/palettes/ConstantVoltage.png create mode 100644 webapp/palettes/Counter.png create mode 100644 webapp/palettes/CurrentSensor.png create mode 100644 webapp/palettes/DEADBAND.png create mode 100644 webapp/palettes/DEBUG.png create mode 100644 webapp/palettes/DELAYV_f.png create mode 100644 webapp/palettes/DELAY_f.png create mode 100644 webapp/palettes/DEMUX.png create mode 100644 webapp/palettes/DEMUX_f.png create mode 100644 webapp/palettes/DERIV.png create mode 100644 webapp/palettes/DFLIPFLOP.png create mode 100644 webapp/palettes/DIFF_f.png create mode 100644 webapp/palettes/DLATCH.png create mode 100644 webapp/palettes/DLR.png create mode 100644 webapp/palettes/DLRADAPT_f.png create mode 100644 webapp/palettes/DLSS.png create mode 100644 webapp/palettes/DOLLAR.png create mode 100644 webapp/palettes/DOLLAR_f.png create mode 100644 webapp/palettes/DOLLAR_m.png create mode 100644 webapp/palettes/Diode.png create mode 100644 webapp/palettes/EDGE_TRIGGER.png create mode 100644 webapp/palettes/ENDBLK.png create mode 100644 webapp/palettes/END_c.png create mode 100644 webapp/palettes/ESELECT_f.png create mode 100644 webapp/palettes/EVTDLY_c.png create mode 100644 webapp/palettes/EVTGEN_f.png create mode 100644 webapp/palettes/EVTVARDLY.png create mode 100644 webapp/palettes/EXPBLK_m.png create mode 100644 webapp/palettes/EXPRESSION.png create mode 100644 webapp/palettes/EXTRACT.png create mode 100644 webapp/palettes/EXTRACTBITS.png create mode 100644 webapp/palettes/EXTRACTOR.png create mode 100644 webapp/palettes/EXTTRI.png create mode 100644 webapp/palettes/Extract_Activation.png create mode 100644 webapp/palettes/FROM.png create mode 100644 webapp/palettes/FROMMO.png create mode 100644 webapp/palettes/FROMWSB.png create mode 100644 webapp/palettes/Flowmeter.png create mode 100644 webapp/palettes/GAINBLK.png create mode 100644 webapp/palettes/GAINBLK_f.png create mode 100644 webapp/palettes/GAIN_f.png create mode 100644 webapp/palettes/GENERAL_f.png create mode 100644 webapp/palettes/GENSIN_f.png create mode 100644 webapp/palettes/GENSQR_f.png create mode 100644 webapp/palettes/GOTO.png create mode 100644 webapp/palettes/GOTOMO.png create mode 100644 webapp/palettes/GotoTagVisibility.png create mode 100644 webapp/palettes/GotoTagVisibilityMO.png create mode 100644 webapp/palettes/Ground.png create mode 100644 webapp/palettes/Gyrator.png create mode 100644 webapp/palettes/HALT_f.png create mode 100644 webapp/palettes/HYSTHERESIS.png create mode 100644 webapp/palettes/IFTHEL_f.png create mode 100644 webapp/palettes/INIMPL_f.png create mode 100644 webapp/palettes/INTEGRAL_f.png create mode 100644 webapp/palettes/INTEGRAL_m.png create mode 100644 webapp/palettes/INTMUL.png create mode 100644 webapp/palettes/INTRP2BLK_f.png create mode 100644 webapp/palettes/INTRPLBLK_f.png create mode 100644 webapp/palettes/INVBLK.png create mode 100644 webapp/palettes/IN_f.png create mode 100644 webapp/palettes/ISELECT_m.png create mode 100644 webapp/palettes/IdealTransformer.png create mode 100644 webapp/palettes/Inductor.png create mode 100644 webapp/palettes/JKFLIPFLOP.png create mode 100644 webapp/palettes/LOGBLK_f.png create mode 100644 webapp/palettes/LOGIC.png create mode 100644 webapp/palettes/LOGICAL_OP.png create mode 100644 webapp/palettes/LOOKUP_f.png create mode 100644 webapp/palettes/MATBKSL.png create mode 100644 webapp/palettes/MATCATH.png create mode 100644 webapp/palettes/MATCATV.png create mode 100644 webapp/palettes/MATDET.png create mode 100644 webapp/palettes/MATDIAG.png create mode 100644 webapp/palettes/MATDIV.png create mode 100644 webapp/palettes/MATEIG.png create mode 100644 webapp/palettes/MATEXPM.png create mode 100644 webapp/palettes/MATINV.png create mode 100644 webapp/palettes/MATLU.png create mode 100644 webapp/palettes/MATMAGPHI.png create mode 100644 webapp/palettes/MATMUL.png create mode 100644 webapp/palettes/MATPINV.png create mode 100644 webapp/palettes/MATRESH.png create mode 100644 webapp/palettes/MATSING.png create mode 100644 webapp/palettes/MATSUM.png create mode 100644 webapp/palettes/MATTRAN.png create mode 100644 webapp/palettes/MATZCONJ.png create mode 100644 webapp/palettes/MATZREIM.png create mode 100644 webapp/palettes/MAXMIN.png create mode 100644 webapp/palettes/MAX_f.png create mode 100644 webapp/palettes/MBLOCK.png create mode 100644 webapp/palettes/MCLOCK_f.png create mode 100644 webapp/palettes/MFCLCK_f.png create mode 100644 webapp/palettes/MIN_f.png create mode 100644 webapp/palettes/MUX.png create mode 100644 webapp/palettes/MUX_f.png create mode 100644 webapp/palettes/M_SWITCH.png create mode 100644 webapp/palettes/M_freq.png create mode 100644 webapp/palettes/Modulo_Count.png create mode 100644 webapp/palettes/NEGTOPOS_f.png create mode 100644 webapp/palettes/NMOS.png create mode 100644 webapp/palettes/NPN.png create mode 100644 webapp/palettes/NRMSOM_f.png create mode 100644 webapp/palettes/OUTIMPL_f.png create mode 100644 webapp/palettes/OUT_f.png create mode 100644 webapp/palettes/OpAmp.png create mode 100644 webapp/palettes/PDE.png create mode 100644 webapp/palettes/PID.png create mode 100644 webapp/palettes/PMOS.png create mode 100644 webapp/palettes/PNP.png create mode 100644 webapp/palettes/POSTONEG_f.png create mode 100644 webapp/palettes/POWBLK_f.png create mode 100644 webapp/palettes/PRODUCT.png create mode 100644 webapp/palettes/PROD_f.png create mode 100644 webapp/palettes/PULSE_SC.png create mode 100644 webapp/palettes/PerteDP.png create mode 100644 webapp/palettes/PotentialSensor.png create mode 100644 webapp/palettes/PuitsP.png create mode 100644 webapp/palettes/QUANT_f.png create mode 100644 webapp/palettes/RAMP.png create mode 100644 webapp/palettes/RAND_m.png create mode 100644 webapp/palettes/RATELIMITER.png create mode 100644 webapp/palettes/READAU_f.png create mode 100644 webapp/palettes/READC_f.png create mode 100644 webapp/palettes/REGISTER.png create mode 100644 webapp/palettes/RELATIONALOP.png create mode 100644 webapp/palettes/RELAY_f.png create mode 100644 webapp/palettes/RFILE_f.png create mode 100644 webapp/palettes/RICC.png create mode 100644 webapp/palettes/ROOTCOEF.png create mode 100644 webapp/palettes/Resistor.png create mode 100644 webapp/palettes/SAMPHOLD_m.png create mode 100644 webapp/palettes/SATURATION.png create mode 100644 webapp/palettes/SAWTOOTH_f.png create mode 100644 webapp/palettes/SCALAR2VECTOR.png create mode 100644 webapp/palettes/SELECT_m.png create mode 100644 webapp/palettes/SELF_SWITCH.png create mode 100644 webapp/palettes/SELF_SWITCH_off.png create mode 100644 webapp/palettes/SELF_SWITCH_on.png create mode 100644 webapp/palettes/SHIFT.png create mode 100644 webapp/palettes/SIGNUM.png create mode 100644 webapp/palettes/SINBLK_f.png create mode 100644 webapp/palettes/SOM_f.png create mode 100644 webapp/palettes/SQRT.png create mode 100644 webapp/palettes/SRFLIPFLOP.png create mode 100644 webapp/palettes/STEP_FUNCTION.png create mode 100644 webapp/palettes/SUBMAT.png create mode 100644 webapp/palettes/SUMMATION.png create mode 100644 webapp/palettes/SUM_f.png create mode 100644 webapp/palettes/SUPER_f.png create mode 100644 webapp/palettes/SWITCH2_m.png create mode 100644 webapp/palettes/SWITCH_f.png create mode 100644 webapp/palettes/SampleCLK.png create mode 100644 webapp/palettes/Sigbuilder.png create mode 100644 webapp/palettes/SineVoltage.png create mode 100644 webapp/palettes/SourceP.png create mode 100644 webapp/palettes/Switch.png create mode 100644 webapp/palettes/TANBLK_f.png create mode 100644 webapp/palettes/TCLSS.png create mode 100644 webapp/palettes/TEXT_f.png create mode 100644 webapp/palettes/TIME_DELAY.png create mode 100644 webapp/palettes/TIME_f.png create mode 100644 webapp/palettes/TKSCALE.png create mode 100644 webapp/palettes/TOWS_c.png create mode 100644 webapp/palettes/TRASH_f.png create mode 100644 webapp/palettes/TrigFun.png create mode 100644 webapp/palettes/VARIABLE_DELAY.png create mode 100644 webapp/palettes/VVsourceAC.png create mode 100644 webapp/palettes/VanneReglante.png create mode 100644 webapp/palettes/VariableResistor.png create mode 100644 webapp/palettes/VirtualCLK0.png create mode 100644 webapp/palettes/VoltageSensor.png create mode 100644 webapp/palettes/VsourceAC.png create mode 100644 webapp/palettes/WFILE_f.png create mode 100644 webapp/palettes/WRITEAU_f.png create mode 100644 webapp/palettes/WRITEC_f.png create mode 100644 webapp/palettes/ZCROSS_f.png create mode 100644 webapp/palettes/c_block.png create mode 100644 webapp/palettes/fortran_block.png create mode 100644 webapp/palettes/freq_div.png create mode 100644 webapp/palettes/generic_block3.png create mode 100644 webapp/palettes/palettes.xml create mode 100644 webapp/palettes/scifunc_block_m.png create mode 100644 webapp/resources/editor.properties create mode 100644 webapp/resources/graph.properties create mode 100644 webapp/setup.js create mode 100644 webapp/styles/Xcos-style.xml diff --git a/Queue.js b/Queue.js deleted file mode 100755 index 075a103..0000000 --- a/Queue.js +++ /dev/null @@ -1,2 +0,0 @@ -//code.stephenmorley.org -function Queue(){var a=[],b=0;this.getLength=function(){return a.length-b};this.isEmpty=function(){return 0==a.length};this.enqueue=function(b){a.push(b)};this.dequeue=function(){if(0!=a.length){var c=a[b];2*++b>=a.length&&(a=a.slice(b),b=0);return c}};this.peek=function(){return 0 - - - - - - - - diff --git a/blocks/ANDBLK.svg b/blocks/ANDBLK.svg deleted file mode 100644 index c55e06a..0000000 --- a/blocks/ANDBLK.svg +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - diff --git a/blocks/ASCOPE.svg b/blocks/ASCOPE.svg deleted file mode 100644 index bd06723..0000000 --- a/blocks/ASCOPE.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/BACHE.svg b/blocks/BACHE.svg deleted file mode 100644 index af85023..0000000 --- a/blocks/BACHE.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - base scilan - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/BARXY.svg b/blocks/BARXY.svg deleted file mode 100644 index 3bc0b38..0000000 --- a/blocks/BARXY.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/BPLATFORM.svg b/blocks/BPLATFORM.svg deleted file mode 100644 index 734ca36..0000000 --- a/blocks/BPLATFORM.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/blocks/CCS.svg b/blocks/CCS.svg deleted file mode 100644 index dc6c316..0000000 --- a/blocks/CCS.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/CLOCK_c.svg b/blocks/CLOCK_c.svg deleted file mode 100644 index 9ade9ae..0000000 --- a/blocks/CLOCK_c.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/blocks/CLOCK_f.svg b/blocks/CLOCK_f.svg deleted file mode 100644 index cc18ac3..0000000 --- a/blocks/CLOCK_f.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/blocks/CSCOPXY.svg b/blocks/CSCOPXY.svg deleted file mode 100644 index 1caa482..0000000 --- a/blocks/CSCOPXY.svg +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - x - y - diff --git a/blocks/CSCOPXY3D.svg b/blocks/CSCOPXY3D.svg deleted file mode 100644 index 074d43e..0000000 --- a/blocks/CSCOPXY3D.svg +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - x - y - z - diff --git a/blocks/CVS.svg b/blocks/CVS.svg deleted file mode 100644 index 6207fde..0000000 --- a/blocks/CVS.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - + - - - diff --git a/blocks/Capacitor.svg b/blocks/Capacitor.svg deleted file mode 100644 index f39a5c5..0000000 --- a/blocks/Capacitor.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/blocks/ConstantVoltage.svg b/blocks/ConstantVoltage.svg deleted file mode 100644 index a7f7cbd..0000000 --- a/blocks/ConstantVoltage.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/CurrentSensor.svg b/blocks/CurrentSensor.svg deleted file mode 100644 index 4ab49af..0000000 --- a/blocks/CurrentSensor.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A - - - - - - diff --git a/blocks/DEADBAND.svg b/blocks/DEADBAND.svg deleted file mode 100644 index 9a72a73..0000000 --- a/blocks/DEADBAND.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/blocks/DSCOPE.svg b/blocks/DSCOPE.svg deleted file mode 100644 index a489ba7..0000000 --- a/blocks/DSCOPE.svg +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - image/svg+xml - - - - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/Diode.svg b/blocks/Diode.svg deleted file mode 100644 index 773da8b..0000000 --- a/blocks/Diode.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/Flowmeter.svg b/blocks/Flowmeter.svg deleted file mode 100644 index d6e7091..0000000 --- a/blocks/Flowmeter.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Q - - - - - - diff --git a/blocks/Ground.svg b/blocks/Ground.svg deleted file mode 100644 index 44a1b80..0000000 --- a/blocks/Ground.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/Gyrator.svg b/blocks/Gyrator.svg deleted file mode 100644 index 1bf3b88..0000000 --- a/blocks/Gyrator.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/blocks/HYSTHERESIS.svg b/blocks/HYSTHERESIS.svg deleted file mode 100644 index 9f05af1..0000000 --- a/blocks/HYSTHERESIS.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/blocks/INTEGRAL.svg b/blocks/INTEGRAL.svg deleted file mode 100644 index 6d5a898..0000000 --- a/blocks/INTEGRAL.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - diff --git a/blocks/IdealTransformer.svg b/blocks/IdealTransformer.svg deleted file mode 100644 index 362d8ab..0000000 --- a/blocks/IdealTransformer.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - diff --git a/blocks/Inductor.svg b/blocks/Inductor.svg deleted file mode 100644 index f4b5168..0000000 --- a/blocks/Inductor.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - diff --git a/blocks/NMOS.svg b/blocks/NMOS.svg deleted file mode 100644 index b2cd485..0000000 --- a/blocks/NMOS.svg +++ /dev/null @@ -1,69 +0,0 @@ - - - - base scilan - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/NPN.svg b/blocks/NPN.svg deleted file mode 100644 index a8da10e..0000000 --- a/blocks/NPN.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - base scilan - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/PMOS.svg b/blocks/PMOS.svg deleted file mode 100644 index 4a67cad..0000000 --- a/blocks/PMOS.svg +++ /dev/null @@ -1,65 +0,0 @@ - - - - base scilan - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/PNP.svg b/blocks/PNP.svg deleted file mode 100644 index 5c8250b..0000000 --- a/blocks/PNP.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - base scilan - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/PRODUCT.svg b/blocks/PRODUCT.svg deleted file mode 100644 index 2f90302..0000000 --- a/blocks/PRODUCT.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - Π - diff --git a/blocks/PULSE_SC.svg b/blocks/PULSE_SC.svg deleted file mode 100644 index 4648b2c..0000000 --- a/blocks/PULSE_SC.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/PerteDP.svg b/blocks/PerteDP.svg deleted file mode 100644 index ede7c63..0000000 --- a/blocks/PerteDP.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - base scilan - - - - - - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/PotentialSensor.svg b/blocks/PotentialSensor.svg deleted file mode 100644 index fbfc84c..0000000 --- a/blocks/PotentialSensor.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/PuitP.svg b/blocks/PuitP.svg deleted file mode 100644 index 9687763..0000000 --- a/blocks/PuitP.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - image/svg+xml - - - - - base scilan - - - - - - - - - - - - - - - - - P - - - - - - - - - - - - - - - diff --git a/blocks/QUANT_f.svg b/blocks/QUANT_f.svg deleted file mode 100644 index 64a2544..0000000 --- a/blocks/QUANT_f.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/blocks/RAMP.svg b/blocks/RAMP.svg deleted file mode 100644 index 6a25f6b..0000000 --- a/blocks/RAMP.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/Resistor.svg b/blocks/Resistor.svg deleted file mode 100644 index d471e63..0000000 --- a/blocks/Resistor.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - base scilan - - - - - - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/SATURATION.svg b/blocks/SATURATION.svg deleted file mode 100644 index 7cecac1..0000000 --- a/blocks/SATURATION.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/blocks/SINUS_f.svg b/blocks/SINUS_f.svg deleted file mode 100644 index 7437e12..0000000 --- a/blocks/SINUS_f.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/blocks/SQUARE_WAVE_f.svg b/blocks/SQUARE_WAVE_f.svg deleted file mode 100644 index 71a0d6c..0000000 --- a/blocks/SQUARE_WAVE_f.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/blocks/STEP_FUNCTION.svg b/blocks/STEP_FUNCTION.svg deleted file mode 100644 index 464c385..0000000 --- a/blocks/STEP_FUNCTION.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/blocks/SUM.svg b/blocks/SUM.svg deleted file mode 100644 index f76cc1c..0000000 --- a/blocks/SUM.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - Σ - diff --git a/blocks/SUPER.svg b/blocks/SUPER.svg deleted file mode 100644 index 5c05a34..0000000 --- a/blocks/SUPER.svg +++ /dev/null @@ -1,49 +0,0 @@ - - - - base scilan - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/SWITCH.svg b/blocks/SWITCH.svg deleted file mode 100644 index 0344da7..0000000 --- a/blocks/SWITCH.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/blocks/SampleCLK.svg b/blocks/SampleCLK.svg deleted file mode 100644 index 19d7fa0..0000000 --- a/blocks/SampleCLK.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/blocks/Self_Switch_off.svg b/blocks/Self_Switch_off.svg deleted file mode 100644 index df37948..0000000 --- a/blocks/Self_Switch_off.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -off - diff --git a/blocks/Self_Switch_on.svg b/blocks/Self_Switch_on.svg deleted file mode 100644 index 50cd1ba..0000000 --- a/blocks/Self_Switch_on.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -on - diff --git a/blocks/SourceP.svg b/blocks/SourceP.svg deleted file mode 100644 index ff73c6c..0000000 --- a/blocks/SourceP.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - base scilan - - - - - - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - S - - - - - - - - - - - - - - - - diff --git a/blocks/VanneReglante.svg b/blocks/VanneReglante.svg deleted file mode 100644 index 1c4cbb8..0000000 --- a/blocks/VanneReglante.svg +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/VariableResistor.svg b/blocks/VariableResistor.svg deleted file mode 100644 index 5783810..0000000 --- a/blocks/VariableResistor.svg +++ /dev/null @@ -1,64 +0,0 @@ - - - - base scilan - - - - - - - - - - - - - - image/svg+xml - - - - Mathieu Drouet / Take a sip - - - http://www.takeasip.net/ - - base scilan - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blocks/VirtualCLK0.svg b/blocks/VirtualCLK0.svg deleted file mode 100644 index 9ade9ae..0000000 --- a/blocks/VirtualCLK0.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/blocks/VoltageSensor.svg b/blocks/VoltageSensor.svg deleted file mode 100644 index 04ead6b..0000000 --- a/blocks/VoltageSensor.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - V - - - - - diff --git a/blocks/sawtooth.svg b/blocks/sawtooth.svg deleted file mode 100644 index 16e2fc9..0000000 --- a/blocks/sawtooth.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/chart.js b/chart.js deleted file mode 100755 index 5035c64..0000000 --- a/chart.js +++ /dev/null @@ -1,133 +0,0 @@ -var chart_id_list = []; -var points_list = []; -var series_list = []; -var INTERVAL = 10; -var RANGE = 30; -var eventSource; -var clientID; -var interval; -var isDone = false; - -var create_new_chart = function(id){ - // Function to create a new chart - $('#charts').append("
"); - $('#chart-'+id.toString()).highcharts({ - chart: { - type: 'line', - animation: false - }, - title : { - text: 'Figure '+id.toString() - }, - xAxis : { - title: { - text: 'x' - }, - tickInterval: 2 - }, - yAxis : { - title: { - text: 'y' - }, - plotLines: [{ - width: 1, - color: '#808080' - }] - }, - plotOptions : { - marker: { - enabled: false, - } - }, - legend : { - enabled: false - }, - exporting : { - enabled: false - }, - series : [] - }); - chart_id_list.push(id); - points_list.push(new Queue()); - series_list.push([]); -} - -function chart_init(wnd){ - // Start listening to server - chart_reset(); - eventSource = new EventSource("/SendLog?id="+clientID); - eventSource.addEventListener("log", function(event){ - var data = event.data.split(' '); - var figure_id = parseInt(data[2]), - line_id = parseInt(data[6]), - x = parseFloat(data[8]), - y = parseFloat(data[9]), - z = parseFloat(data[10]); - if(chart_id_list.indexOf(figure_id)<0) - create_new_chart(figure_id); - var index = chart_id_list.indexOf(figure_id); - points_list[index].enqueue([line_id,x,y]); - }, false); - // Error - eventSource.addEventListener("ERROR", function(event){ - eventSource.close(); // Close connection - console.log("Error: "+event.data); - chart_reset(); - if(event.data=="Empty diagram") alert(event.data); - else alert("Some Error occured!"); - wnd.destroy(); - isDone = true; - }, false); - // Stop listening - eventSource.addEventListener("DONE", function(event){ - eventSource.close(); // Close connection - console.log("Done"); - isDone = true; - }, false); - - interval = setInterval(function(){ - for(var i=0;i1.5*RANGE) - series.removePoint(0, false); - series.addPoint([x,y], false); - } - // Shift chart axis to display new values - if(x>RANGE) chart.xAxis[0].setExtremes(Math.floor(x-RANGE),Math.floor(x)); - // Draw the chart - chart.redraw(); - } - }, INTERVAL); -} - -function chart_reset(){ - clearInterval(interval); - chart_id_list = []; - points_list = []; - series_list = []; -} \ No newline at end of file diff --git a/combined.js b/combined.js deleted file mode 100644 index 4718352..0000000 --- a/combined.js +++ /dev/null @@ -1,11264 +0,0 @@ -function ABS_VALUE() { - - ABS_VALUE.prototype.define = function ABS_VALUE() { - - this.nu = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["absolute_value"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.out = new ScilabDouble([this.nu]); - model.nzcross = new ScilabDouble([this.nu]); - model.nmode = new ScilabDouble([this.nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ABS_VALUE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["ABS_VALUE"]); - return new BasicBlock(this.x); - - } - - ABS_VALUE.prototype.details = function ABS_VALUE() { - return this.x; - } - -} -function AFFICH_m() { - - AFFICH_m.prototype.define = function AFFICH_m() { - this.font = 1; - this.fontsize = 1; - this.colr = 1; - this.nt = 5; - this.nd = 1; - this.in1 = [1, 1]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["affich2"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1[0]]); - model.in2 = new ScilabDouble([this.in1[1]]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [0], [0], [1], [1], [0], ...zeros(this.in1[0] * this.in1[1], 1)); - model.ipar = new ScilabDouble([this.font], [this.fontsize], [this.colr], [1000], [this.nt], [this.nd], [this.in1[0]]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - model.label = new ScilabString([""]); - var exprs = new ScilabString([sci2exp([parseFloat(...getData(model.in)), parseFloat(...getData(model.in2))])], [this.font.toString()], [this.fontsize.toString()], [this.colr.toString()], [this.nt.toString()], [this.nd.toString()], [(0).toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"AFFICH_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["AFFICH_m"]); - return new AfficheBlock(this.x); - } - - AFFICH_m.prototype.details = function AFFICH_m() { - return this.x; - } -} -function ANDBLK() { - - ANDBLK.prototype.define = function ANDBLK() { - - var andlog = new ANDLOG_f().internal(); - andlog.graphics.orig = new ScilabDouble([194, 133]); - andlog.graphics.sz = new ScilabDouble([60, 60]); - andlog.graphics.flip = new ScilabBoolean([true]); - andlog.graphics.pout = new ScilabDouble([9]); - andlog.graphics.pein = new ScilabDouble([4], [11]); - andlog.model.uid = new ScilabString([count]); - andlog.doc = list(new ScilabString([count++])); - - var input_port1 = new CLKIN_f().internal(); - input_port1.graphics.orig = new ScilabDouble([149, 287]); - input_port1.graphics.sz = new ScilabDouble([20, 20]); - input_port1.graphics.flip = new ScilabBoolean([true]); - input_port1.graphics.exprs = new ScilabString(["1"]); - input_port1.graphics.peout = new ScilabDouble([4]); - input_port1.model.ipar = new ScilabDouble([1]); - input_port1.model.uid = new ScilabString([count]); - input_port1.doc = list(new ScilabString([count++])); - - var output_port = new CLKOUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([450, 83]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([8]); - output_port.model.ipar = new ScilabDouble([1]); - output_port.model.uid = new ScilabString([count]); - output_port.doc = list(new ScilabString([count++])); - - var input_port2 = new CLKIN_f().internal(); - input_port2.graphics.orig = new ScilabDouble([141, 330]); - input_port2.graphics.sz = new ScilabDouble([20, 20]); - input_port2.graphics.flip = new ScilabBoolean([true]); - input_port2.graphics.exprs = new ScilabString(["2"]); - input_port2.graphics.peout = new ScilabDouble([6]); - input_port2.model.ipar = new ScilabDouble([2]); - input_port2.model.uid = new ScilabString([count]); - input_port2.doc = list(new ScilabString([count++])); - - var ifthel = new IFTHEL_f().internal(); - ifthel.graphics.orig = new ScilabDouble([331, 137]); - ifthel.graphics.sz = new ScilabDouble([60, 60]); - ifthel.graphics.flip = new ScilabBoolean([true]); - ifthel.graphics.pin = new ScilabDouble([9]); - ifthel.graphics.pein = new ScilabDouble([12]); - ifthel.graphics.peout = new ScilabDouble([8], [0]); - ifthel.model.uid = new ScilabString([count]); - ifthel.doc = list(new ScilabString([count++])); - - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([234, 275.78348]); - split.graphics.pein = new ScilabDouble([6]); - split.graphics.peout = new ScilabDouble([11], [12]); - split.model.uid = new ScilabString([count]); - split.doc = list(new ScilabString([count++])); - - var diagram = scicos_diagram(); - diagram.objs.push(andlog); - diagram.objs.push(input_port1); - diagram.objs.push(output_port); - diagram.objs.push(input_port2); - diagram.objs.push(ifthel); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([169], [214], [214]), - yy: new ScilabDouble([297], [297], [198.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([161], [234], [234]), - yy: new ScilabDouble([340], [340], [275.78]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([351], [351], [450]), - yy: new ScilabDouble([131.29], [93], [93]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([262.57], [322.43]), - yy: new ScilabDouble([163], [167]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([234], [234]), - yy: new ScilabDouble([275.78], [198.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([1, 2, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([234], [361], [361]), - yy: new ScilabDouble([275.78], [275.78], [202.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([6, 2, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - this.x = scicos_block(); - this.x.gui = new ScilabString(["ANDBLK"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pein = new ScilabDouble([0], [0]); - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtin = new ScilabDouble([1], [1]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - return new BasicBlock(this.x); - } - ANDBLK.prototype.details = function ANDBLK() { - return this.x; - } - -} -function ANDLOG_f() { - - ANDLOG_f.prototype.internal = function ANDLOG_f() { - var model = scicos_model(); - model.sim = new ScilabString(["andlog"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); // null -> 1 - model.evtin = new ScilabDouble([-1], [-1]); // 1, 1 -> -1, -1 - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ANDLOG_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, new ScilabDouble(), gr_i); // 3 -> 80 - - // Style - block.graphics.out_implicit = new ScilabString(["E"]); - // changed - block.graphics.out_label = new ScilabString([""]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.style = new ScilabString(["ANDLOG_f"]); - return block; - } - - ANDLOG_f.prototype.define = function ANDLOG_f() { - var model = scicos_model(); - model.sim = new ScilabString(["andlog"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); // null -> 1 - model.evtin = new ScilabDouble([-1], [-1]); // 1, 1 -> -1, -1 - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ANDLOG_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, new ScilabDouble(), gr_i); // 3 -> 80 - - // Style - this.x.graphics.out_implicit = new ScilabString(["E"]); - // changed - this.x.graphics.out_label = new ScilabString([""]); - this.x.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - this.x.graphics.style = new ScilabString(["ANDLOG_f"]); - return new BasicBlock(this.x); - } - - ANDLOG_f.prototype.details = function ANDLOG() { - return this.x; - } -} -function AUTOMAT() { - - AUTOMAT.prototype.define = function AUTOMAT() { - this.NMode = 2; - this.Minitial = 1; - this.NX = 1; - this.X0 = [0.0]; - this.XP = [[1],[1]]; - this.C1 = [2]; - this.C2 = [1]; - - var exprs = new ScilabString([this.NMode.toString()], [this.Minitial.toString()], [this.NX.toString()], [sci2exp(this.X0)], [sci2exp(this.XP)], [sci2exp(this.C1)], [sci2exp(this.C2)]); - var ipar = new ScilabDouble([this.NMode], [this.Minitial], [this.NX], ...this.XP, this.C1, this.C2); - var rpar = new ScilabDouble(this.X0); - - var model = scicos_model(); - model.sim = list(new ScilabString(["automat"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([2 * this.NX + 1], [2 * this.NX + 1]); - model.out = new ScilabDouble([2], [2 * this.NX]); - model.state = new ScilabDouble(...ones(2 * this.NX, 1)); - model.nzcross = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.evtout = new ScilabDouble([1]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, true]); - model.ipar = ipar; - model.rpar = rpar; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"AUTOMAT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - - } - - AUTOMAT.prototype.details = function AUTOMAT() { - return this.x; - } -} -function Bache() { - - Bache.prototype.define = function Bache() { - this.in1 = 2; - this.out = 3; - - var model = scicos_model(); - model.in = new ScilabDouble(math.transpose(math.range(-1, -this.in1, -1, true))); - model.out = new ScilabDouble(math.transpose(math.range(-1, -this.out, -1, true))); - - this.Patm = 1.013E5; - this.A = 1; - this.ze1 = 40; - this.ze2 = 0; - this.zs1 = 40; - this.zs2 = 0; - this.z0 = 30; - this.T0 = 290; - this.p_rho = 0; - - model.rpar = new ScilabDouble([this.Patm], [this.A], [this.ze1], [this.ze2], [this.zs1], [this.zs2], [this.z0], [this.T0], [this.p_rho]); - model.sim = new ScilabString(["Bache"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Bache"]); - mo.inputs = new ScilabString(["Ce1", "Ce2"]); - mo.outputs = new ScilabString(["Cs1", "Cs2", "yNiveau"]); - mo.parameters = list(new ScilabString(["Patm"], ["A"], ["ze1"], ["ze2"], ["zs1"], ["zs2"], ["z0"], ["T0"], ["p_rho"]), new ScilabDouble([this.Patm], [this.A], [this.ze1], [this.ze2], [this.zs1], [this.zs2], [this.z0], [this.T0], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), '*'), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), '*'), 1)); - - var exprs = new ScilabString([this.Patm.toString()], [this.A.toString()], [this.ze1.toString()], [this.ze2.toString()], [this.zs1.toString()], [this.zs2.toString()], [this.z0.toString()], [this.T0.toString()], [this.p_rho.toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Bache\",sz(1),sz(2));"]); - this.x = new standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"], ["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["I"], ["E"]); - return new BasicBlock(this.x); - } - Bache.prototype.details = function Bache() { - return this.x; - } -} -function BACKLASH() { - BACKLASH.prototype.define = function BACKLASH() { - - var exprs = new ScilabString(["0"], ["1"], ["1"]); - var model = scicos_model(); - model.sim = list(new ScilabString(["backlash"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [1]); - model.nzcross = new ScilabDouble([2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BACKLASH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x) - } - BACKLASH.prototype.details = function BACKLASH() { - return this.x; - } -} -function BARXY() { - - BARXY.prototype.define = function BARXY() { - - var model = scicos_model(); - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - - model.sim = list(new ScilabString(["BARXY_sim"]), new ScilabDouble([5])); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.in = new ScilabDouble([-1], [-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([1]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], []); - this.x.graphics.in_implicit = new ScilabString(["E", , "E"]); - this.x.graphics.out_implicit = new ScilabDouble(); - this.x.graphics.exprs = new ScilabString(["-15"], ["15"], ["-15"], ["15"], ["1"]); - return new BasicBlock(this.x); - } - BARXY.prototype.details = function BARXY() { - return this.x; - } - -} -function BIGSOM_f() { - - BIGSOM_f.prototype.define = function BIGSOM_f() { - this.sgn = [[1],[1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["sum"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BIGSOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["BIGSOM_f"]); - return new BigSom(this.x); - } - BIGSOM_f.prototype.details = function BIGSOM_f() { - return this.x; - } -} -function BITCLEAR() { - BITCLEAR.prototype.define = function BITCLEAR() { - var model = scicos_model(); - model.sim = list(new ScilabString(["bit_clear_32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar = list(int32([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BITCLEAR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - BITCLEAR.prototype.details = function BITCLEAR() { - return this.x; - } -} -function BITSET() { - - BITSET.prototype.define = function BITSET() { - var model = scicos_model(); - model.sim = list(new ScilabString(["bit_set_32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar = list(uint32([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BITSET\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - BITSET.prototype.details = function BITSET() { - return this.x; - } -} -function BOUNCE() { - - BOUNCE.prototype.define = function BOUNCE() { - this.n = 2; - - this.k = 0; - this.ipar = []; - - for (var i = 1; i <= this.n; i++) { - for (var j = i + 1; j <= this.n; j++) { - this.ipar[this.k] = [i]; - this.k++; - this.ipar[this.k] = [j]; - this.k++; - } - } - - this.walls = [[0],[5],[0],[5]]; - this.x1 = [[2],[2.5]]; - this.xd = [[0],[0]]; - this.y1 = [[3],[5]]; - this.yd = [[0],[0]]; - this.g = 9.81; - this.C = 0; - this.rpar1 = ones(this.n, 1); - this.rpar2 = this.rpar1; - this.state = [...math.transpose(this.x1), ...math.transpose(this.xd), ...math.transpose(this.y1), ...math.transpose(this.yd)]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bounce_ball"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.n], [this.n]); - model.state = new ScilabDouble(...colon_operator(this.state)); - model.rpar = new ScilabDouble(...this.rpar1, ...this.rpar2, ...this.walls, [this.g], [this.C]); - model.ipar = new ScilabDouble(...this.ipar); - model.nzcross = new ScilabDouble([this.n * (this.n - 1) / 2 + 4 * this.n]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.rpar1)], [sci2exp(this.rpar2)], [sci2exp(this.walls)], [sci2exp(this.x1)], [sci2exp(this.xd)], [sci2exp(this.y1)], [sci2exp(this.yd)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - - return new BasicBlock(this.x); - } - - BOUNCE.prototype.details = function BOUNCE() { - - return this.x; - } -} -function BOUNCEXY() { - - BOUNCEXY.prototype.define = function BOUNCEXY() { - this.win = -1; - this.imode = 1; - this.clrs = [[1],[2]]; - this.siz = [[1],[1]]; - this.xmin = -5; - this.xmax = 5; - this.ymin = 0; - this.ymax = 15; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bouncexy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - - - this.z = []; - - for (var i = 0; i < size(this.clrs, "*"); i++) { - this.z[6 * (i) + 0] = [0]; - this.z[6 * (i) + 1] = [0]; - this.z[6 * (i) + 2] = [2 * this.siz[i]]; - this.z[6 * (i) + 3] = [2 * this.siz[i]]; - this.z[6 * (i) + 4] = [0.000]; - this.z[6 * (i) + 5] = [64.0 * 360.000]; - - } - - model.dstate = new ScilabDouble(...this.z); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [this.imode], ...colon_operator(this.clrs)); - model.blocktype = new ScilabString("d"); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.clrs)], [sci2exp(this.siz)], [sci2exp(this.win)], [sci2exp(1)], [sci2exp(this.xmin)], [sci2exp(this.xmax)], [sci2exp(this.ymin)], [sci2exp(this.ymax)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCEXY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - BOUNCEXY.prototype.details = function BOUNCEXY() { - - return this.x; - } -} -function BPLATFORM() { - - BPLATFORM.prototype.define = function BPLATFORM() { - - this.plen = 2; - this.csiz = 2; - this.phi = 0; - this.xmin = -5; - this.xmax = 5; - this.ymin = 0; - this.ymax = 15; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bplatform2"]), new ScilabDouble([5])); - model.in = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.plen], [this.csiz], [this.phi], [this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.plen], [this.csiz], [this.phi], [this.xmin], [this.xmax], [this.ymin], [this.ymax]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BPLATFORM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - BPLATFORM.prototype.details = function BPLATFORM() { - - return this.x; - } - -} -function CANIMXY() { - - CANIMXY.prototype.define = function CANIMXY() { - this.win = -1; - this.clrs = -4; - this.N = 2; - this.siz = 1; - this.wpos = [[-1],[-1]]; - this.wdim = [[-1],[-1]]; - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["canimxy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], [this.clrs], [this.siz], [0], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs], [this.siz], [this.win], ["[]"], ["[]"], [this.xmin], [this.xmax], [this.ymin], [this.ymax], [this.N]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CANIMXY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CANIMXY.prototype.details = function CANIMXY() { - return this.x; - } -} -function CANIMXY3D() { - - CANIMXY3D.prototype.define = function CANIMXY3D() { - this.win = -1; - this.N = 2; - this.clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - this.siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - this.wpos = [[-1],[-1]]; - this.wdim = [[-1],[-1]]; - this.param3ds = [[50],[280]]; - this.vec_x = [[-15],[15]]; - this.vec_y = [[-15],[15]]; - this.vec_z = [[-15],[15]]; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["canimxy3d"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.intyp = new ScilabDouble([1], [1], [1]); - model.rpar = new ScilabDouble(...colon_operator(this.vec_x), ...colon_operator(this.vec_y), ...colon_operator(this.vec_z), ...colon_operator(this.param3ds)); - model.ipar = new ScilabDouble([this.win], [8], [this.N], ...colon_operator(this.clrs), ...colon_operator(this.siz), [8], ...colon_operator(this.wpos), ...colon_operator(this.wdim), [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs.toString().replace(/,/g, " ")], [this.siz.toString().replace(/,/g, " ")], [this.win], ["[]"], ["[]"], [this.vec_x.toString().replace(/,/g, " ")], [this.vec_y.toString().replace(/,/g, " ")], [this.vec_z.toString().replace(/,/g, " ")], [this.param3ds.toString().replace(/,/g, " ")], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CANIMXY3D\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CANIMXY3D.prototype.details = function CANIMXY3D() { - return this.x; - } - -} -function Capacitor() { - - Capacitor.prototype.define = function Capacitor() { - - var model = scicos_model(); - var C = 0.01, v = 0; - model.rpar = new ScilabDouble([C],[v]); - model.sim = new ScilabString(["Capacitor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Capacitor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["C", "v"]), list(new ScilabDouble([C]), new ScilabDouble([v])), new ScilabDouble([0, 1])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([C], [v]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Capacitor\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1.1]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Capacitor.prototype.details = function Capacitor() { - return this.x; - } -} -function CBLOCK() { - - CBLOCK.prototype.define = function CBLOCK() { - this.in1 = 1; - this.out = 1; - this.clkin = []; - this.clkout = []; - this.x0 = []; - this.z0 = []; - this.typ = "c"; - this.auto = []; - this.rpar = []; - this.ipar = []; - this.funam = "toto"; - this.ng = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2004])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - model.nzcross = new ScilabDouble([this.ng]); - - var label = list(new ScilabString([this.funam], ["n"], [sci2exp(this.in1)], [sci2exp(this.out)], [sci2exp(this.clkin)], [sci2exp(this.clkout)], [sci2exp(this.x0)], [sci2exp(0)], [sci2exp(this.z0)], [sci2exp(this.rpar)], [sci2exp(this.ipar)], [sci2exp(this.auto)], ["y"], ["n"]), new ScilabDouble()); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CBLOCK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x) - } - - - CBLOCK.prototype.details = function CBLOCK() { - - return this.x; - } -} -function CBLOCK4() { - - CBLOCK4.prototype.define = function CBLOCK4() { - - this.funam = "toto"; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2004])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = list(new ScilabString([this.funam], ["n"], [sci2exp([parseFloat(...getData(model.in)), parseFloat(...getData(model.in2))])], [sci2exp(parseFloat(...getData(model.intyp)))], [sci2exp([parseFloat(...getData(model.out)), parseFloat(...getData(model.out2))])], [sci2exp(parseFloat(...getData(model.outtyp)))], [sci2exp(getData(model.evtin))], [sci2exp(getData(model.evtout))], [sci2exp(getData(model.state))], [sci2exp(getData(model.dstate))], [sci2exp(model.odstate)], [sci2exp(getData(model.rpar))], [sci2exp(getData(model.ipar))], [sci2exp(model.opar)], [sci2exp(parseFloat(...getData(model.nmode)))], [sci2exp(parseFloat(...getData(model.nzcross)))], [sci2exp(getData(model.firing))], ["y"], ["n"]), new ScilabDouble()); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CBLOCK4\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - CBLOCK4.prototype.details = function CBLOCK4() { - return this.x; - } -} -function CCS() { - - CCS.prototype.define = function CCS() { - this.ModelName = "CCS"; - this.PrametersValue = new ScilabDouble(); - this.ParametersName = new ScilabDouble(); - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2,50,1,0],[70,98,2,0],[70,2,-2,0]]; - this.PortName = [["Iin"],["p"],["n"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = this.PrametersValue; - mo.parameters = list(this.ParametersName, this.PrametersValue, new ScilabDouble(...zeros(getData(this.ParametersName)))); - var exprs = new ScilabDouble(); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CCS\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2.1, 3]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - CCS.prototype.details = function CCS() { - return this.x; - } -} -function CEVENTSCOPE() { - - CEVENTSCOPE.prototype.define = function CEVENTSCOPE() { - this.nclock = 1; - this.win = -1; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cevscpe"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.per]); - model.ipar = new ScilabDouble([this.win], [1], this.clrs[this.nclock - 1], ...this.wpos, ...this.wdim); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.nclock)], this.clrs[this.nclock - 1], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.per]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CEVENTSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CEVENTSCOPE.prototype.details = function CEVENTSCOPE() { - return this.x; - } -} -function CFSCOPE() { - - CFSCOPE.prototype.define = function CFSCOPE() { - this.win = -1; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 2; - this.ymin = -15; - this.ymax = 15; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cfscope"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim, [1], [1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [1]); - var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CFSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8])); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80 - this.x.graphics.style = new ScilabString(["CFSCOPE"]); - return new BasicBlock(this.x); - } - CFSCOPE.prototype.details = function CFSCOPE() { - return this.x; - } -} -function CLINDUMMY_f() { - - CLINDUMMY_f.prototype.define = function CLINDUMMY_f() { - this.x0 = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cdummy"]), new ScilabDouble([4])); - model.state = new ScilabDouble([this.x0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLINDUMMY_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - CLINDUMMY_f.prototype.details = function CLINDUMMY_f() { - return this.x; - } -} -function CLKFROM() { - - CLKFROM.prototype.define = function CLKFROM() { - var model = scicos_model(); - model.sim = new ScilabString(["clkfrom"]); - model.evtout = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, new ScilabString([" "])); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x); - } - CLKFROM.prototype.details = function CLKFROM() { - return this.x; - } -}function CLKGOTO() { - - CLKGOTO.prototype.define = function CLKGOTO() { - var model = scicos_model(); - model.sim = new ScilabString(["clkgoto"]); - model.evtin = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.ipar = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, new ScilabString([" "])); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x); - } - - CLKGOTO.prototype.details = function CLKGOTO() { - return this.x; - } -} -function CLKGotoTagVisibility() { - - CLKGotoTagVisibility.prototype.define = function CLKGotoTagVisibility() { - var model = scicos_model(); - model.sim = new ScilabString(["clkgototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKGotoTagVisibility\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CLKGotoTagVisibility.prototype.details = function CLKGotoTagVisibility() { - return this.x; - } -} -function CLKINV_f() { - - CLKINV_f.prototype.define = function CLKINV_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.evtout = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.prt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKINV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - return new EventInBlock(this.x); - } - CLKINV_f.prototype.internal = function CLKINV_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.evtout = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var exprs = new ScilabString([this.prt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKINV_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["CLKINV_f"]); - return block; - } - CLKINV_f.prototype.details = function CLKINV_f() { - return this.x; - } -} -function CLKOUTV_f() { - - CLKOUTV_f.prototype.define = function CLKOUTV_f() { - - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.prt]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, new ScilabString([" "])); - return new EventOutBlock(this.x); - } - - CLKOUTV_f.prototype.internal = function CLKOUTV_f() { - - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([this.prt]); - var block = new standard_define(new ScilabDouble([1, 1]), model, exprs, new ScilabString([" "])); - block.graphics.gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])); - block.graphics.style = new ScilabString(["CLKOUTV_f"]); - return block; - } - - CLKOUTV_f.prototype.details = function CLKOUTV_f() { - return this.x; - } -} -function CLKSOMV_f() { - - CLKSOMV_f.prototype.internal = function CLKSOMV_f() { - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOMV_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return block; - } - - CLKSOMV_f.prototype.define = function CLKSOMV_f() { - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOMV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new RoundBlock(this.x); - } - CLKSOMV_f.prototype.details = function CLKSOMV_f() { - return this.x; - } -} -function CLKSOM_f() { - - CLKSOM_f.prototype.internal = function CLKSOM_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOM_f\",sz(1),sz(2));"]); - var block = standard_define(new ScilabDouble([1, 1]), model, [], gr_i); - block.graphics.style = new ScilabString(["CLKSOM_f"]) - return block; - } -} -function CLOCK_c() { - - CLOCK_c.prototype.get = function CLOCK_c() { - var options = { - dt: ["Period", getData(this.x.model.rpar.objs[1].model.rpar)[0]], - t0: ["Initialisation Time", getData(this.x.model.rpar.objs[1].model.firing)], - }; - return options; - } - - CLOCK_c.prototype.set = function CLOCK_c() { - this.x.model.rpar.objs[1].model.firing = new ScilabDouble([arguments[0]["t0"]]); - this.x.model.rpar.objs[1].model.rpar = new ScilabDouble([arguments[0]["dt"]], [arguments[0]["t0"]]); - this.x.model.rpar.objs[1].graphics.exprs = new ScilabString([arguments[0]["dt"]], [arguments[0]["t0"]]) - return new BasicBlock(this.x); - } - - CLOCK_c.prototype.define = function CLOCK_c() { - var evtdly = new EVTDLY_c().internal(); - evtdly.graphics.orig = new ScilabDouble([320, 232]); - evtdly.graphics.sz = new ScilabDouble([40, 40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1"], ["0.1"]); - evtdly.graphics.pein = new ScilabDouble([6]); - evtdly.graphics.peout = new ScilabDouble([3]); - evtdly.model.rpar = new ScilabDouble([0.1], [0.1]); - evtdly.model.firing = new ScilabDouble([0.1]); - - evtdly.model.uid = new ScilabString([count]); // changed - evtdly.doc = list(new ScilabString([count++])); - evtdly.model.evtin = new ScilabDouble([-1]); - evtdly.model.evtout = new ScilabDouble([-1]); - evtdly.graphics.peout = new ScilabDouble([4]); - - var output_port = new CLKOUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([399, 162]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - - output_port.model.uid = new ScilabString([count]); // changed - output_port.doc = list(new ScilabString([count++])); - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([380.71066, 172]); - split.graphics.pein = new ScilabDouble([3]); - split.graphics.peout = new ScilabDouble([5], [6]); - split.model.uid = new ScilabString([count]); - split.doc = list(new ScilabString([count++])); - split.graphics.pein = new ScilabDouble([4]); // changed - - var diagram = scicos_diagram(); - diagram.objs.push(output_port); - diagram.objs.push(evtdly); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([340], [340], [380.71]), - yy: new ScilabDouble([226.29], [172], [172]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([380.71], [399]), - yy: new ScilabDouble([172], [172]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([380.71], [380.71], [340], [340]), - yy: new ScilabDouble([172], [302], [302], [277.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 2, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - this.x = scicos_block(); - this.x.gui = new ScilabString(["CLOCK_c"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabString([]); - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - return new BasicBlock(this.x); - } - CLOCK_c.prototype.details = function CLOCK_c() { - return this.x; - } -} -function CLR() { - - CLR.prototype.define = function CLR() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(["1"], ["1+s"]); - var gr_i = []; - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CLR.prototype.details = function CLR() { - return this.x; - } -} -function CLSS() { - - CLSS.prototype.define = function CLSS() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([this.A], [this.B], [this.C], [this.D], [this.x0]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CLSS.prototype.details = function CLSS() { - return this.x; - } -} -function CMSCOPE() { - CMSCOPE.prototype.get = function CMSCOPE() { - - var options = { - in1: ["Input ports sizes", this.in1.toString().replace(/,/g, " ")], - clrs: ["Drawing colors (>0) or mark (<0)", this.clrs.toString().replace(/,/g, " ")], - win: ["Output window number (-1 for automatic)", this.win], - wpos: ["Output window position", sci2exp([])], - wdim: ["Output window sizes", sci2exp([])], - ymin: ["Ymin vector", this.ymin.toString().replace(/,/g, " ")], - ymax: ["Ymax vector", this.ymax.toString().replace(/,/g, " ")], - per: ["Refresh period", this.per.toString().replace(/,/g, " ")], - N: ["Buffer size", this.N], - heritance: ["Accept herited events 0/1", 0], - nom: ["Name of Scope (label&Id)", ""] - }; - return options; - } - CMSCOPE.prototype.set = function CMSCOPE() { - this.in1 = inverse(arguments[0]["in1"]); - this.clrs = inverse(arguments[0]["clrs"]); - this.win = parseInt((arguments[0]["win"])); - this.ymin = inverse(arguments[0]["ymin"]); - this.ymax = inverse(arguments[0]["ymax"]); - this.per = inverse(arguments[0]["per"]); - this.N = parseInt((arguments[0]["N"])); - this.heritance = parseInt((arguments[0]["heritance"])); - this.nom = arguments[0]["nom"]; - this.yy = [...transpose(this.ymin), ...transpose(this.ymax)]; - this.period = transpose(this.per); - this.x.model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1],[this.heritance]); - this.x.model.label = new ScilabString([this.nom]); - this.x.model.evtin = new ScilabDouble(...ones(1-this.heritance,1)); - this.x.graphics.id = new ScilabString([this.nom]); - this.x.model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy)); - this.x.graphics.exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]); - return new BasicBlock(this.x); - } - CMSCOPE.prototype.define = function CMSCOPE() { - this.win = -1; - this.in1 = [[1],[1]]; - this.wdim = [[-1],[-1]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 20; - this.ymin = [[-1],[-5]]; - this.ymax = [[1],[5]]; - this.per = [[30],[30]]; - this.yy = [...transpose(this.ymin), ...transpose(this.ymax)]; - this.period = transpose(this.per); - - - var model = scicos_model(); - model.sim = list(new ScilabString(["cmscope"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy)); - model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1]); - - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - var exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]); - var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CMSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8])); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80 - this.x.graphics.style = new ScilabString(["CMSCOPE"]); - return new BasicBlock(this.x); - } - CMSCOPE.prototype.details = function CMSCOPE() { - return this.x; - } -} -function CONST() { - - - CONST.prototype.define = function CONST() { - - this.C = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.C)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONST.prototype.details = function CONST() { - return this.x; - } -} -function ConstantVoltage() { - - ConstantVoltage.prototype.define = function ConstantVoltage() { - this.V = 0.01; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.V]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.sim = new ScilabString(["ConstantVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["ConstantVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["V"]), list(new ScilabDouble([this.V]))); - model.equations = mo; - - var exprs = new ScilabString([this.V]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ConstantVoltage\",sz(1),sz(2));"]); - this.x = standard_define([1.5, 1.1], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - ConstantVoltage.prototype.details = function ConstantVoltage() { - return this.x; - } -} -function CONSTRAINT2_c() { - - CONSTRAINT2_c.prototype.define = function CONSTRAINT2_c() { - this.x0 = 0; - this.xd0 = 0; - this.id = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["constraint_c"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [1]); - model.state = new ScilabDouble([this.x0], [this.xd0]); - model.ipar = new ScilabDouble([this.id]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = list(new ScilabString([sci2exp(this.x0)]), new ScilabString([sci2exp(this.xd0)]), new ScilabString([sci2exp(this.id)])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONSTRAINT2_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CONSTRAINT2_c.prototype.details = function CONSTRAINT2_c() { - return this.x; - } -} - -function CONSTRAINT_c() { - - CONSTRAINT_c.prototype.define = function CONSTRAINT_c() { - - this.x0 = [[0],[0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["constraint_c"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.ipar = new ScilabDouble([0]); - model.state = new ScilabDouble(...this.x0); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONSTRAINT_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CONSTRAINT_c.prototype.details = function CONSTRAINT_c() { - return this.x; - } -} -function CONST_f() { - - CONST_f.prototype.define = function CONST_f() { - this.C = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cstblk"]), new ScilabDouble([1])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.C)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONST_f.prototype.details = function CONST_f() { - - return this.x; - } -} -function CONST_m() { - CONST_m.prototype.get = function CONST_m() { - - var options = { - vec: ["Constant Value", this.c.toString()] - }; - return options; - } - CONST_m.prototype.set = function CONST_m() { - this.c = [parseInt(arguments[0]["vec"])]; - this.displayParameter = this.c; - this.x.model.sim = list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])); - this.x.model.opar = list(new ScilabDouble(this.c)); - this.x.model.rpar = new ScilabDouble(); - this.x.graphics.exprs = new ScilabString([sci2exp(this.c)]); - return new BasicBlock(this.x); - } - CONST_m.prototype.internal = function CONST_m() { - this.c = [1]; - var model = new scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.c.length]); - model.in2 = new ScilabDouble(); - model.out2 = new ScilabDouble([this.c.length]); - model.rpar = new ScilabDouble(this.c); - model.opar = list(); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]); - var exprs = new ScilabString([sci2exp(this.c)]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - block.graphics.style = new ScilabString(["CONST_m"]); - return block; - } - CONST_m.prototype.define = function CONST_m() { - this.c = [1]; - var model = new scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.c.length]); - model.in2 = new ScilabDouble(); - model.out2 = new ScilabDouble([this.c.length]); - model.rpar = new ScilabDouble(this.c); - model.opar = list(); - model.blocktype = new ScilabString(["d"]); - this.displayParameter = [1]; - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]); - var exprs = new ScilabString([sci2exp(this.c)]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - this.x.graphics.style = new ScilabString(["CONST_m"]); - return new BasicBlock(this.x); - } - CONST_m.prototype.details = function CONST_m() { - return this.x; - - } -} -function CONVERT() { - - CONVERT.prototype.define = function CONVERT() { - this.sgn = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["convert"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(3)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONVERT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONVERT.prototype.details = function CONVERT() { - return this.x; - - } - -} -function COSBLK_f() { - - COSBLK_f.prototype.define = function COSBLK_f() { - this.in1 = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["cosblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"COSBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - COSBLK_f.prototype.details = function COSBLK_f() { - return this.x; - } -}function Counter() { - - Counter.prototype.define = function Counter() { - this.minim = 0; - this.maxim = 2; - this.rule = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["counter"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.rule], [this.maxim], [this.minim]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.minim], [this.maxim], [this.rule]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Counter\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - Counter.prototype.details = function Counter() { - return this.x; - } -} -function CSCOPE() { - - CSCOPE.prototype.define = function CSCOPE() { - this.win = -1; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 20; - this.ymin = -15; - this.ymax = 15; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscope"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [0], [""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPE.prototype.details = function CSCOPE() { - return this.x; - } -} -function CSCOPXY() { - - CSCOPXY.prototype.define = function CSCOPXY() { - this.win = -1; - this.clrs = 4; - this.siz = 1; - this.wdim = [[600], [400]]; - this.wpos = [[-1], [-1]]; - this.N = 2; - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscopxy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], [this.clrs], [this.siz], [1], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [sci2exp(this.clrs)], [sci2exp(this.siz)], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.xmin], [this.xmax], [this.ymin], [this.ymax], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPXY.prototype.details = function CSCOPXY() { - return this.x; - } -} - -function CSCOPXY3D() { - - CSCOPXY3D.prototype.define = function CSCOPXY3D() { - this.win = -1; - this.clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - this.siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.N = 2; - this.param3ds = [[50],[280]]; - this.vec_x = [[-15],[15]]; - this.vec_y = [[-15],[15]]; - this.vec_z = [[-15],[15]]; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscopxy3d"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1], [1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.intyp = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.vec_x, ...this.vec_y, ...this.vec_z, ...this.param3ds); - model.ipar = new ScilabDouble([this.win], [8], [this.N], ...this.clrs, ...this.siz, [8], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs.toString().replace(/,/g, " ")], [this.siz.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.vec_x.toString().replace(/,/g, " ")], [this.vec_y.toString().replace(/,/g, " ")], [this.vec_z.toString().replace(/,/g, " ")], [this.param3ds.toString().replace(/,/g, " ")], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPXY3D.prototype.details = function CSCOPXY3D() { - return this.x; - } -} -function CUMSUM() { - - CUMSUM.prototype.define = function CUMSUM() { - var model = scicos_model(); - - this.function_name = "cumsum_m"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CUMSUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - CUMSUM.prototype.details = function CUMSUM() { - return this.x; - } -} -function CurrentSensor() { - - CurrentSensor.prototype.define = function CurrentSensor() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [1]); - model.sim = new ScilabString(["CurrentSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["CurrentSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"], ["i"]); - model.equations = mo; - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CurrentSensor\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 2]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["E"]); - return new BasicBlock(this.x); - } - - CurrentSensor.prototype.details = function CurrentSensor() { - return this.x; - } -} -function CURV_f() { - - CURV_f.prototype.define = function CURV_f() { - this.xx = [[0],[1],[2]]; - this.yy = [[-5],[5],[0]]; - this.rect = [0,-5,2,5]; - this.axisdata = [[2],[10],[2],[10]]; - this.ipar = new ScilabDouble([size(this.xx, 1)], ...this.axisdata); - this.rpar = new ScilabDouble(...this.xx, ...this.yy, this.rect); - - var model = scicos_model(); - model.sim = new ScilabString(["intplt"]); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.xx, ...this.yy, ...colon_operator([this.rect])); - model.ipar = new ScilabDouble([size(this.xx, 1)], ...this.axisdata); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CURV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - CURV_f.prototype.details = function CURV_f() { - return this.x; - } -} -function CVS() { - - CVS.prototype.define = function CVS() { - this.ModelName = "CVS"; - this.PrametersValue = new ScilabDouble(); - this.ParametersName = new ScilabDouble(); - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2,50,1,0],[70,98,2,0],[70,2,-2,0]]; - this.PortName = [["vin"],["p"],["n"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = this.PrametersValue; - mo.parameters = list(this.ParametersName, this.PrametersValue, new ScilabDouble(...zeros(getData(this.ParametersName)))); - var exprs = new ScilabDouble(); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CVS\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2.1, 3]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - CVS.prototype.details = function CVS() { - return this.x; - } -} -function c_block() { - - c_block.prototype.define = function c_block() { - - this.in1 = 1; - this.out = 1; - this.rpar = []; - this.typ = "c"; - this.funam = "toto"; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2001])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = list(new ScilabString([sci2exp(this.in1)], [sci2exp(this.out)], [sci2exp(this.rpar)], [this.funam]), list(new ScilabDouble())); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"c_block\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - c_block.prototype.details = function c_block() { - return this.x; - } -} -function DEADBAND() { - - DEADBAND.prototype.define = function DEADBAND() { - this.minp = -0.5; - this.maxp = 0.5; - this.rpar = new ScilabDouble([this.maxp], [this.minp]); - - var model = scicos_model(); - model.sim = list(new ScilabString(["deadband"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = this.rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp], [...getData(model.nmode).toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEADBAND\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEADBAND.prototype.details = function DEADBAND() { - return this.x; - } -} -function DEBUG() { - - DEBUG.prototype.define = function DEBUG() { - var model = scicos_model(); - model.sim = list(new ScilabString(["%debug_scicos"]), new ScilabDouble([99])); - model.blocktype = new ScilabString(["d"]); - - var exprs = list(new ScilabString([""]), new ScilabString(["xcos_debug_gui(flag,block);"])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEBUG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([8, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEBUG.prototype.details = function DEBUG() { - return this.x; - } -} - -function DELAYV_f() { - - DELAYV_f.prototype.define = function DELAYV_f() { - this.nin = 1; - this.z0 = zeros(11, 1); - this.zz0 = math.subset(this.z0, math.index(math.range(0, math.size(this.z0)[0] - 1), 0)); - this.T = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["delayv"]), new ScilabDouble([1])); - model.in = new ScilabDouble([this.nin], [1]); - model.out = new ScilabDouble([this.nin]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble(...this.z0); - model.rpar = new ScilabDouble([this.T / (size(this.zz0, "*"))]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0, -1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], [this.zz0.toString().replace(/,/g, ";")], [this.T]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DELAYV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DELAYV_f.prototype.details = function DELAYV_f() { - return this.x; - } -} - -function DELAY_f() { - - DELAY_f.prototype.define = function DELAY_f() { - var evtdly = new EVTDLY_f().internal(); - evtdly.graphics.orig = new ScilabDouble([243, 296]); - evtdly.graphics.sz = new ScilabDouble([40, 40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1"], ["0"]); - evtdly.graphics.pein = new ScilabDouble([10]); - evtdly.graphics.peout = new ScilabDouble([7]); - evtdly.model.rpar = new ScilabDouble([0.1]); - evtdly.model.firing = new ScilabDouble([0]); - evtdly.model.uid = new ScilabString([count]); // changed - evtdly.doc = list(new ScilabString([count++])); - evtdly.model.outtyp = new ScilabDouble(); - - var register = new REGISTER_f().internal(); - register.graphics.orig = new ScilabDouble([238, 195]); - register.graphics.sz = new ScilabDouble([50, 50]); - register.graphics.flip = new ScilabBoolean([true]); - register.graphics.exprs = new ScilabString(["0;0;0;0;0;0;0;0;0;0"]); - register.graphics.pin = new ScilabDouble([6]); - register.graphics.pout = new ScilabDouble([5]); - register.graphics.pein = new ScilabDouble([9]); - register.model.uid = new ScilabString([count]); // changed - register.doc = list(new ScilabString([count++])); - register.model.in2 = new ScilabDouble([1]); - register.model.intyp = new ScilabDouble([1]); - register.model.out2 = new ScilabDouble([1]); - - var input_port = new IN_f().internal(); - input_port.graphics.orig = new ScilabDouble([92, 210]); - input_port.graphics.sz = new ScilabDouble([20, 20]); - input_port.graphics.flip = new ScilabBoolean([true]); - input_port.graphics.exprs = new ScilabString(["1"], ["1"]); - input_port.graphics.pout = new ScilabDouble([6]); - input_port.model.ipar = new ScilabDouble([1]); - input_port.model.uid = new ScilabString([count]); // changed - input_port.doc = list(new ScilabString([count++])); - input_port.model.outtyp = new ScilabDouble([-1]); - - var output_port = new OUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([440, 210]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"], ["1"]); - output_port.graphics.pin = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - output_port.model.uid = new ScilabString([count]); // changed - output_port.doc = list(new ScilabString([count++])); - output_port.model.outtyp = new ScilabDouble(); - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([263, 271.2]); - split.graphics.pein = new ScilabDouble([7]); - split.graphics.peout = new ScilabDouble([9], [10]); - split.model.uid = new ScilabString([count]); // changed - split.doc = list(new ScilabString([count++])); - - var diagram = scicos_diagram(); - diagram.objs.push(input_port); - diagram.objs.push(output_port); - diagram.objs.push(register); - diagram.objs.push(evtdly); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([296.6], [440]), - yy: new ScilabDouble([220], [220]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([112], [229.4]), - yy: new ScilabDouble([220], [220]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [263]), - yy: new ScilabDouble([290.3], [271.2]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [263]), - yy: new ScilabDouble([271.2], [250.7]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [308.6], [308.6], [263], [263]), - yy: new ScilabDouble([271.2], [271.2], [367], [367], [341.7]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - - this.x = scicos_block(); - this.x.gui = new ScilabString(["DELAY_f"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - return new BasicBlock(this.x); - } - DELAY_f.prototype.details = function DELAY_f() { - return this.x; - } -}function DEMUX() { - - DEMUX.prototype.define = function DEMUX() { - this.out = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["multiplex"]), new ScilabDouble([4])); - model.in = new ScilabDouble([0]); - - var arr = []; - arr.push(math.range(-1, -this.out, -1, true)._data); - model.out = new ScilabDouble(...math.transpose(arr)); - model.ipar = new ScilabDouble([this.out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEMUX\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - DEMUX.prototype.details = function DEMUX() { - return this.x; - } -} -function DEMUX_f() { - - DEMUX_f.prototype.define = function DEMUX_f() { - this.out = 2; - var arr = []; - arr.push(math.range(-1, -this.out, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["demux"]), new ScilabDouble([1])); - model.in = new ScilabDouble([0]); - model.out = new ScilabDouble(...math.transpose(arr)); - model.ipar = new ScilabDouble([this.out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEMUX_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEMUX_f.prototype.details = function DEMUX_f() { - return this.x; - } -} - -function DERIV() { - - DERIV.prototype.define = function DERIV() { - var model = scicos_model(); - model.sim = list(new ScilabString(["deriv"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DERIV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DERIV.prototype.details = function DERIV() { - return this.x; - } -} -function DFLIPFLOP() { - - DFLIPFLOP.prototype.define = function DFLIPFLOP() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["DFLIPFLOP"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["CONST_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([109.62561, 263.44465]), - sz: new ScilabDouble([20], [20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CONST_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CONST_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0])), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([239.98293, 378.2166]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["1"]), - pin: new ScilabDouble([29]), - pout: new ScilabDouble(), - pein: new ScilabDouble([22]), - peout: new ScilabDouble([16], [44]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([1]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([152.88902, 260.24498]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"], ["1"], ["5"], ["0"]), - pin: new ScilabDouble([11], [39]), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([5], [5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SAMPHOLD_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.72156, 260.24498]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["5"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([33]), - pein: new ScilabDouble([42]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SAMPHOLD_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SAMPHOLD_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([221.46044], [225.15013]), - yy: new ScilabDouble([280.24498], [280.24498]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([138.19704], [140.34523]), - yy: new ScilabDouble([273.44465], [273.49157]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([38, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([373.24106, 309.46812]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["5"], ["5"], ["0"]), - pin: new ScilabDouble([36]), - pout: new ScilabDouble([13]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([5], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([199.48466, 398.2166]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["3"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([9]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([3]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([219.48466], [222.54128]), - yy: new ScilabDouble([408.2166], [408.2166]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([8, 1, 0]), - to: new ScilabDouble([28, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([104.31759, 276.91165]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([11]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([124.31759], [144.31759]), - yy: new ScilabDouble([286.91165], [286.91165]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([457.40928, 320.20131]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([13]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([441.81249], [457.40928]), - yy: new ScilabDouble([329.46812], [330.20131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([7, 1, 0]), - to: new ScilabDouble([12, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([376.4669, 270.83282]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([37]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["Untitled"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabDouble(), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["ANDLOG_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([194, 133]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble([9]), - pein: new ScilabDouble([4], [11]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"ANDLOG_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["ANDLOG_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["andlog"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKIN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([149, 287]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKIN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKIN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([450, 83]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([169], [214], [214]), - yy: new ScilabDouble([297], [297], [198.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1]), - to: new ScilabDouble([1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKIN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([141, 330]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([6]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKIN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKIN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([161], [234], [234]), - yy: new ScilabDouble([340], [340], [275.78]), - thick: new ScilabDouble([0, 0]), - id: new ScilabString(["drawlink"]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1]), - to: new ScilabDouble([10, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([331, 137]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["1"]), - pin: new ScilabDouble([9]), - pout: new ScilabDouble(), - pein: new ScilabDouble([12]), - peout: new ScilabDouble([8], [0]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([1]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([351], [351], [450]), - yy: new ScilabDouble([131.29], [93], [93]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([7, 1]), - to: new ScilabDouble([3, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([262.57], [322.43]), - yy: new ScilabDouble([163], [167]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1]), - to: new ScilabDouble([7, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([234], [275.78348]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([6]), - peout: new ScilabDouble([11], [12]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([false, false, false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([234], [234]), - yy: new ScilabDouble([275.78], [198.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([10, 1]), - to: new ScilabDouble([1, 2]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([234], [361], [361]), - yy: new ScilabDouble([275.78], [275.78], [202.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([10, 2]), - to: new ScilabDouble([7, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["ANDBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.73039, 318.74407]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([19], [16]), - peout: new ScilabDouble([17]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"ANDBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["ANDBLK"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabBoolean([false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([259.98293], [260.39705]), - yy: new ScilabDouble([372.50232], [364.45835]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([15, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.73039], [253.72572]), - yy: new ScilabDouble([313.02978], [309.29537]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([15, 1, 0]), - to: new ScilabDouble([41, 1, 1]) - })); - scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["EDGE_TRIGGER", "./"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([30]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["EDGETRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([288.58631, 257.1131]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([3]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGETRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["EDGETRIGGER"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["edgetrig"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([0]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([388.28869, 247.1131]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"]), - pin: new ScilabDouble([3]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([7], [0]), - gr_i: new ScilabDouble(), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble() - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([357.15774], [362.99107], [379.71726]), - yy: new ScilabDouble([277.1131], [277.1131], [277.1131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([240.01488, 267.1131]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([260.01488], [280.01488]), - yy: new ScilabDouble([277.1131], [277.1131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([398.28869, 181.39881]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([7]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([408.28869], [408.28869]), - yy: new ScilabDouble([241.39881], [211.39881]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["EDGE_TRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([133.90637, 385.342]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([26]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([19]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGE_TRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["EDGE_TRIGGER"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([163.90637], [163.90637], [247.06372]), - yy: new ScilabDouble([379.62771], [364.45835], [364.45835]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([18, 1, 0]), - to: new ScilabDouble([15, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([79.594811, 395.47647]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([23]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["EXTRACT_ACTIVATION", "./"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([30]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([150.65045, 143.82208]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([3], [4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSOMV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([169.82143, 96.146231]), - sz: new ScilabDouble([16.666667, 16.666667]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([3], [4], [0]), - peout: new ScilabDouble([8]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSOMV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSOMV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["sum"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1], [1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([170.65045], [170.65045], [150.04302], [150.04302], [169.82143]), - yy: new ScilabDouble([138.10779], [128.235], [128.235], [104.47956], [104.47956]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([190.65045], [190.65045], [178.15476]), - yy: new ScilabDouble([138.10779], [111.55729], [112.8129]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([102.07902, 163.82208]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([122.07902], [142.07902]), - yy: new ScilabDouble([173.82208], [173.82208]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([168.15476, 38.527183]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([178.15476], [178.15476]), - yy: new ScilabDouble([98.527183], [68.527183]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["Extract_Activation"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([239.82193, 456.57677]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([31]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([22]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"Extract_Activation",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["Extract_Activation"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.82193], [269.98293]), - yy: new ScilabDouble([450.86248], [443.93089]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([21, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([99.594811], [110.25582]), - yy: new ScilabDouble([405.47647], [405.42077]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([20, 1, 0]), - to: new ScilabDouble([25, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SUM_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([200.5252, 469.13173]), - sz: new ScilabDouble([16.666667, 16.666667]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([27], [0], [30]), - pout: new ScilabDouble([31]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SUM_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SUM_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["plusblk"]), new ScilabDouble([2])), - in: new ScilabDouble([-1], [-1], [-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([110.25582], [405.42077]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([23]), - pout: new ScilabDouble([26], [27]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([110.25582], [114.33667], [125.33494]), - yy: new ScilabDouble([405.42077], [405.39945], [405.342]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([25, 1, 0]), - to: new ScilabDouble([18, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([110.25582], [110.25582], [208.85853]), - yy: new ScilabDouble([405.42077], [469.13173], [469.13173]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([25, 2, 0]), - to: new ScilabDouble([24, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([222.54128], [408.2166]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([9]), - pout: new ScilabDouble([29], [30]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([222.54128], [231.4115]), - yy: new ScilabDouble([408.2166], [408.2166]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([28, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([222.54128], [222.54128], [208.85853], [208.85853]), - yy: new ScilabDouble([408.2166], [453.0015], [453.0015], [485.7984]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([28, 2, 0]), - to: new ScilabDouble([24, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([219.57282], [231.2505]), - yy: new ScilabDouble([477.46506], [476.57677]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([24, 1, 0]), - to: new ScilabDouble([21, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SELECT_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([298.86371, 253.57321]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["5"], ["2"], ["1"]), - pin: new ScilabDouble([33], [40]), - pout: new ScilabDouble([34]), - pein: new ScilabDouble([43], [44]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SELECT_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SELECT_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["selector_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([5], [5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([1]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([282.29299], [290.29229]), - yy: new ScilabDouble([280.24498], [280.23987]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([32, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.43514], [357.57328], [357.57328]), - yy: new ScilabDouble([273.57321], [273.57321], [280.83282]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([32, 1, 0]), - to: new ScilabDouble([35, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([357.57328, 280.83282]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([34]), - pout: new ScilabDouble([36], [37]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([357.57328], [357.57328], [364.66964]), - yy: new ScilabDouble([280.83282], [329.46812], [329.46812]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([35, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([357.57328], [376.4669]), - yy: new ScilabDouble([280.83282], [280.83282]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([35, 2, 0]), - to: new ScilabDouble([14, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([140.34523], [273.49157]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([6]), - pout: new ScilabDouble([39], [40]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([140.34523], [144.31759]), - yy: new ScilabDouble([273.49157], [273.57832]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([38, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([140.34523], [140.34523], [290.29229], [290.29229]), - yy: new ScilabDouble([273.49157], [247.70767], [247.70767], [266.90654]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([38, 2, 0]), - to: new ScilabDouble([32, 2, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([253.72572], [309.29537]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([17]), - peout: new ScilabDouble([42], [43]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([false, false, false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.72572], [253.72156]), - yy: new ScilabDouble([309.29537], [305.95927]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([41, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.72572], [312.19705], [312.19705]), - yy: new ScilabDouble([309.29537], [309.29537], [299.28749]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([41, 2, 0]), - to: new ScilabDouble([32, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([279.98293], [279.98293], [325.53038], [325.53038]), - yy: new ScilabDouble([372.50232], [315.89455], [315.89455], [299.28749]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 2, 0]), - to: new ScilabDouble([32, 2, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1], [1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, 1, 1]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = []; - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - DFLIPFLOP.prototype.details = function DFLIPFLOP() { - return this.x; - } -} -function DIFF_f() { - - DIFF_f.prototype.define = function DIFF_f() { - this.x0 = [[0], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["diffblk"]), new ScilabDouble([10001])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble(...this.x0); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.x0[0])], [sci2exp(this.x0[1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DIFF_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DIFF_f.prototype.details = function DIFF_f() { - return this.x; - } -} - -function Diode() { - - Diode.prototype.define = function Diode() { - - this.Ids = 1.e-6; - this.Vt = 0.04; - this.Maxexp = 15; - this.R = 1.e8; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.Ids], [this.Vt], [this.Maxexp], [this.R]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.sim = new ScilabString(["Diode"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Diode"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["Ids", "Vt", "Maxexp", "R"]), list(new ScilabDouble([this.Ids]), new ScilabDouble([this.Vt]), new ScilabDouble([this.Maxexp]), new ScilabDouble([this.R]))); - model.equations = mo; - - var exprs = new ScilabString([this.Ids], [this.Vt], [this.Maxexp], [this.R]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Diode\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 1]), model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Diode.prototype.details = function Diode() { - return this.x; - } -} -function DLR() { - - DLR.prototype.define = function DLR() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dsslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["1"], ["1+z"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLR.prototype.details = function DLR() { - return this.x; - } -} - -function DLRADAPT_f() { - - DLRADAPT_f.prototype.define = function DLRADAPT_f() { - this.p = [[0], [1]]; - this.rn = []; - this.rd = [[math.complex(0.2, 0.8), math.complex(0.2, -0.8)], [math.complex(0.3, 0.7), math.complex(0.3, -0.7)]]; - this.g = [[1], [1]]; - this.last_u = []; - this.last_y = [[0], [0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["dlradp"]); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble(...this.last_y); - model.rpar = new ScilabDouble(...this.p, ...real(colon_operator(this.rd)), ...math.im(colon_operator(this.rd)), ...this.g); - model.ipar = new ScilabDouble([0], [2], [2]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.p)], [sci2exp(this.rn)], [sci2exp(this.rd, 0)], [sci2exp(this.g)], [sci2exp(this.last_u)], [sci2exp(this.last_y)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLRADAPT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLRADAPT_f.prototype.details = function DLRADAPT_f() { - return this.x; - } -} -function DLSS() { - - DLSS.prototype.define = function DLSS() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dsslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.A)], [sci2exp(this.B)], [sci2exp(this.C)], [sci2exp(this.D)], [sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLSS.prototype.details = function DLSS() { - return this.x; - } -} - -function DOLLAR() { - - DOLLAR.prototype.define = function DOLLAR() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR.prototype.details = function DOLLAR() { - return this.x; - } -} - -function DOLLAR_f() { - - DOLLAR_f.prototype.define = function DOLLAR_f() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["dollar"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR_f.prototype.details = function DOLLAR_f() { - return this.x; - } -} - -function DOLLAR_m() { - - DOLLAR_m.prototype.define = function DOLLAR_m() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR_m.prototype.details = function DOLLAR_m() { - return this.x; - } -} - -function EDGETRIGGER() { - - EDGETRIGGER.prototype.internal = function EDGETRIGGER() { - this.edge = 1; - var model = scicos_model(); - model.sim = list(new ScilabString(["edgetrig"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.nzcross = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.edge]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.edge]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"EDGETRIGGER",sz(1),sz(2));"]); - var block = standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["EDGETRIGGER"]); - return block; - } -} -function EDGE_TRIGGER() { - - EDGE_TRIGGER.prototype.define = function EDGE_TRIGGER() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new EDGETRIGGER().internal()); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new IN_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - var model = blk.model; - graphics.orig = new ScilabDouble([60, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"]); - graphics.in_implicit = new ScilabString(["E"]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.in_label = new ScilabString([""]); - graphics.out_label = new ScilabString([""]); - model.ipar = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([5]); - graphics.pout = new ScilabDouble([6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([160, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"], ["0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([7], [0]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([0, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([5]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([170, -60]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([7]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - var lnk = scs_m_1.objs[4]; - lnk.xx = new ScilabDouble([64], [96]); - lnk.yy = new ScilabDouble([-40], [-20]); - lnk.from = new ScilabDouble([3, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[4] = lnk; - - lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([164], [196]); - lnk.yy = new ScilabDouble([-20], [-20]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([220], [220]); - lnk.yy = new ScilabDouble([-44], [-96]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[6] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"EDGE_TRIGGER",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - EDGE_TRIGGER.prototype.details = function EDGE_TRIGGER() { - return this.x; - } -} -function ENDBLK() { - - ENDBLK.prototype.define = function ENDBLK() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["ENDBLK"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["END_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([272.104, 249.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1.000E+08"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"END_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["END_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["scicosexit"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([1.000E+08]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([292.104], [292.104], [261.83733], [261.83733], [292.104], [292.104]), - yy: new ScilabDouble([243.40305], [234.45067], [234.45067], [305.584], [305.584], [294.83162]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"ENDBLK",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - ENDBLK.prototype.details = function ENDBLK() { - return this.x; - } -} -function END_c() { - - END_c.prototype.define = function END_c() { - this.tf = 100000000; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scicosexit"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.firing = new ScilabDouble([this.tf]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.tf]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"END_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - END_c.prototype.details = function END_c() { - return this.x; - } -} - -function ESELECT_f() { - - ESELECT_f.prototype.define = function ESELECT_f() { - this.out = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["eselect"]), new ScilabDouble([-2])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(...ones(this.out, 1)); - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble(...ones(this.out, 1)); - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([0]); - model.nzcross = new ScilabDouble([0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ESELECT_f\",sz(1),sz(2));"]);; - - var exprs = new ScilabString([this.out], [1], [parseInt(getData(model.nmode))]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - ESELECT_f.prototype.details = function ESELECT_f() { - return this.x; - } -} -function EVTDLY_c() { - - EVTDLY_c.prototype.internal = function EVTDLY_c() { - var dt = 0.1; - var ff = 0.0; - var model = scicos_model(); - model.sim = list(new ScilabString(["evtdly4"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([dt], [ff]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([ff]); - model.dep_ut = new ScilabBoolean([false, false]); - // changed - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([dt], [ff]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_c\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3,2 -> 80 - block.graphics.style = new ScilabString(["EVTDLY_c"]); - return block; - - } - - EVTDLY_c.prototype.define = function EVTDLY_c() { - this.dt = 0.1; - this.ff = 0.0; - var model = scicos_model(); - model.sim = list(new ScilabString(["evtdly4"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.dt], [this.ff]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.ff]); - model.dep_ut = new ScilabBoolean([false, false]); - // changed - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([this.dt], [this.ff]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3,2 -> 80 - this.x.graphics.style = new ScilabString(["EVTDLY_c"]); - return new BasicBlock(this.x); - - } - - EVTDLY_c.prototype.details = function EVTDLY_c() { - - return this.x; - } -} -function EVTDLY_f() { - - EVTDLY_f.prototype.internal = function EVTDLY_f() { - this.dt = 0.1; - this.ff = this.dt; - - var model = scicos_model(); - model.sim = new ScilabString(["evtdly"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.dt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.ff]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.dt], [sci2exp(this.ff)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["EVTDLY_f"]); - return block; - } -}function EVTGEN_f() { - - EVTGEN_f.prototype.define = function EVTGEN_f() { - this.tt = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.tt]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.tt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTGEN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EVTGEN_f.prototype.details = function EVTGEN_f() { - return this.x; - } -} -function EVTVARDLY() { - - EVTVARDLY.prototype.define = function EVTVARDLY() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["evtvardly"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([parseInt(getData(model.firing), 10)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTVARDLY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EVTVARDLY.prototype.details = function EVTVARDLY() { - return this.x; - } -} - -function EXPBLK_m() { - - EXPBLK_m.prototype.define = function EXPBLK_m() { - this.in1 = 1; - this.a = math.E; - - var model = scicos_model(); - model.sim = list(new ScilabString(["expblk_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["%e"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXPBLK_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXPBLK_m.prototype.details = function EXPBLK_m() { - return this.x; - } -} -function EXTRACT() { - - EXTRACT.prototype.define = function EXTRACT() { - this.function_name = "extract"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1, 1, 1, 1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp([1])], [sci2exp([1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - EXTRACT.prototype.details = function EXTRACT() { - return this.x; - } -} - -function EXTRACTBITS() { - - EXTRACTBITS.prototype.define = function EXTRACTBITS() { - this.numb = []; - - var model = scicos_model(); - model.sim = list(new ScilabString(["extract_bit_32_UH0"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.ipar = new ScilabDouble([0, ...this.numb]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(1)], [sci2exp(0)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACTBITS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXTRACTBITS.prototype.details = function EXTRACTBITS() { - return this.x; - } -} -function EXTRACTOR() { - - EXTRACTOR.prototype.define = function EXTRACTOR() { - this.ind = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["extractor"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([this.ind]); - - var exprs = new ScilabString([sci2exp(this.ind)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACTOR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXTRACTOR.prototype.details = function EXTRACTOR() { - return this.x; - } -} - -function Extract_Activation() { - - Extract_Activation.prototype.define = function Extract_Activation() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new CLKSOMV_f().internal()); - scs_m_1.objs.push(new IN_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([80, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["0"], ["0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([7]); - graphics.peout = new ScilabDouble([5], [6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - model.outtyp = new ScilabDouble(); - model.evtin = new ScilabDouble([-1], [-1], [-1]); - model.evtout = new ScilabDouble([-1]); - graphics.orig = new ScilabDouble([80, -80]); - graphics.sz = new ScilabDouble([80, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.pein = new ScilabDouble([5], [6], [0]); - graphics.peout = new ScilabDouble([8]); - graphics.style = new ScilabString(["CLKSOMV_f"]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([0, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([7]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - model.outtyp = new ScilabDouble(); - graphics.style = new ScilabString(["CLKOUTV_f"]); - graphics.orig = new ScilabDouble([110, -140]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - graphics.gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CLKOUTV_f\",sz(1),sz(2));"]), new ScilabDouble([8])); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - var lnk = scs_m_1.objs[4]; - lnk.xx = new ScilabDouble([140], [140]); - lnk.yy = new ScilabDouble([-44], [-76]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[4] = lnk; - - lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([160], [160]); - lnk.yy = new ScilabDouble([-44], [-76]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 2, 0]); - lnk.to = new ScilabDouble([2, 2, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([64], [116]); - lnk.yy = new ScilabDouble([-40], [-20]); - lnk.from = new ScilabDouble([3, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[6] = lnk; - - lnk = scs_m_1.objs[7]; - lnk.xx = new ScilabDouble([160], [160]); - lnk.yy = new ScilabDouble([-124], [-176]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[7] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Extract_Activation\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - Extract_Activation.prototype.details = function Extract_Activation() { - return this.x; - } -} -function EXTTRI() { - - EXTTRI.prototype.define = function EXTTRI() { - this.function_name = "extrilz"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTTRI\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - EXTTRI.prototype.details = function EXTTRI() { - return this.x; - } -} - -function Flowmeter() { - - Flowmeter.prototype.define = function Flowmeter() { - this.ModelName = "Flowmeter"; - this.PrametersValue = 1; - this.ParametersName = "Qini"; - - var model = scicos_model(); - - this.Typein = []; - this.Typeout = []; - - this.MI = []; - this.MO = []; - this.P = [[50,105,-1,90],[0,10,2,0],[101,10,-2,0]]; - this.PortName = [["Mesure"],["C1"],["C2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble([this.PrametersValue]); - mo.parameters = list(new ScilabString([this.ParametersName]), new ScilabDouble([this.PrametersValue]), new ScilabDouble(zeros([this.ParametersName]))); - var exprs = new ScilabString(["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Flowmeter\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - Flowmeter.prototype.details = function Flowmeter() { - return this.x; - } -} -function fortran_block() { - - fortran_block.prototype.define = function fortran_block() { - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([1001])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - this.funam = "forty"; - - var label = list(new ScilabString([sci2exp(parseInt(getData(model.in)))], [sci2exp(parseInt(getData(model.out)))], [sci2exp(getData(model.rpar))], [this.funam]), list(new ScilabDouble())); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"fortran_block\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - fortran_block.prototype.details = function fortran_block() { - return this.x; - } -} -function freq_div() { - - freq_div.prototype.define = function freq_div() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new Modulo_Count().internal()); - scs_m_1.objs.push(new CLKINV_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new CLKSPLIT_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - var model = blk.model; - graphics.orig = new ScilabDouble([0, -100]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"], ["3"]); - model.dstate = new ScilabDouble([3]); - model.ipar = new ScilabDouble([3]); - graphics.pout = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([10]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.out_label = new ScilabString([""]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([120, 0]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.peout = new ScilabDouble([6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([130, -160]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([100, -100]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["1"], ["0"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([9]); - graphics.peout = new ScilabDouble([0], [8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - blk = scs_m_1.objs[4]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([127, -33]); - graphics.sz = new ScilabDouble([7, 7]); - graphics.pein = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([9], [10]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[4] = blk; - - var lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([170], [170.5]); - lnk.yy = new ScilabDouble([-44], [-75]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([5, 1, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([104], [136]); - lnk.yy = new ScilabDouble([-100], [-100]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[6] = lnk; - - lnk = scs_m_1.objs[7]; - lnk.xx = new ScilabDouble([180], [180]); - lnk.yy = new ScilabDouble([-124], [-176]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([4, 2, 0]); - lnk.to = new ScilabDouble([3, 1, 1]); - scs_m_1.objs[7] = lnk; - - lnk = scs_m_1.objs[8]; - lnk.xx = new ScilabDouble([170], [170.5]); - lnk.yy = new ScilabDouble([-44], [-75]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([5, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[8] = lnk; - - lnk = scs_m_1.objs[9]; - lnk.xx = new ScilabDouble([169], [170]); - lnk.yy = new ScilabDouble([-90], [-76]); - lnk.xx = new ScilabDouble([0, 30, 1]); - lnk.yy = new ScilabDouble([0, -30, 1]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([5, 2, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[9] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"freq_div",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - freq_div.prototype.details = function freq_div() { - return this.x; - } -} -function FROM() { - - FROM.prototype.define = function FROM() { - - var model = scicos_model(); - model.sim = new ScilabString(["from"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x); - } - FROM.prototype.details = function FROM() { - return this.x; - } -} - -function FROMMO() { - - FROMMO.prototype.define = function FROMMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["frommo"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["frommo"]); - mo.outputs = new ScilabString(["n"]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROMMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - FROMMO.prototype.details = function FROMMO() { - return this.x; - } -} - -function FROMWSB() { - - FROMWSB.prototype.define = function FROMWSB() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["FROMWSB"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["FROMWS_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([260.37067, 261.584]), - sz: new ScilabDouble([70, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["V"], ["1"], ["1"], ["0"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([4]), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"FROMWS_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort"]), - out_label: new ScilabString([""]), - style: new ScilabString(["FROMWS_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["fromws_c"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [-31], [1], [1], [0]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([0]), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([358.9421, 271.584]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([4]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([295.37067], [295.37067], [233.23733], [233.23733], [295.37067], [295.37067]), - yy: new ScilabDouble([255.86971], [223.45067], [223.45067], [337.85067], [337.85067], [307.29829]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([338.9421], [358.9421]), - yy: new ScilabDouble([281.584], [281.584]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROMWSB\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([5, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - FROMWSB.prototype.details = function FROMWSB() { - return this.x; - } -}function GAINBLK() { - - GAINBLK.prototype.define = function GAINBLK() { - this.gain = 1; - this.in1 = -1; - this.out = -1; - this.in2 = -2; - this.out2 = -2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.in2 = new ScilabDouble([this.in2]); - model.out2 = new ScilabDouble([this.out2]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAINBLK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAINBLK.prototype.details = function GAINBLK() { - return this.x; - } -} - -function GAINBLK_f() { - - GAINBLK_f.prototype.define = function GAINBLK_f() { - this.gain = 1; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAINBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAINBLK_f.prototype.details = function GAINBLK_f() { - return this.x; - } -} - -function GAIN_f() { - - GAIN_f.prototype.define = function GAIN_f() { - this.gain = 1; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)], [sci2exp(this.in1)], [sci2exp(this.out)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAIN_f.prototype.details = function GAIN_f() { - return this.x; - } -} - -function GENERAL_f() { - - GENERAL_f.prototype.define = function GENERAL_f() { - var rpar = [[0],[0],[0],[0]]; - - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([this.in1]); - model.in = new ScilabDouble([this.in1]); - model.evtout = new ScilabDouble(...ones(this.out, 1)); - model.rpar = new ScilabDouble([0], [0], [0], [0]); - model.blocktype = new ScilabString(["z"]); - model.firing = -new ScilabDouble(...ones(this.out, 1)); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in1)], [sci2exp(this.out)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENERAL_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - GENERAL_f.prototype.details = function GENERAL_f() { - return this.x; - } -} -function generic_block3() { - - generic_block3.prototype.define = function generic_block3() { - var model = scicos_model(); - this.function_name = "sinblk"; - this.funtyp = 4; - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([this.function_name], [sci2exp(this.funtyp)], [sci2exp([parseInt(getData(model.in)[0]), parseInt(getData(model.in2)[0])])], [sci2exp(parseInt(getData(model.intyp)[0]))], [sci2exp([parseInt(getData(model.out)[0]), parseInt(getData(model.out2)[0])])], [sci2exp(parseInt(getData(model.outtyp)[0]))], [sci2exp(getData(model.evtin))], [sci2exp(getData(model.evtout))], [sci2exp(getData(model.state))], [sci2exp(getData(model.dstate))], [sci2exp(model.odstate)], [sci2exp(getData(model.rpar))], [sci2exp(getData(model.ipar))], [sci2exp(model.opar)], [sci2exp(parseInt(getData(model.nmode)[0]))], [sci2exp(parseInt(getData(model.nzcross)[0]))], [sci2exp(getData(model.firing))], ["y"], ["n"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"generic_block3\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - generic_block3.prototype.details = function generic_block3() { - return this.x; - } -} -function GENSIN_f() { - - GENSIN_f.prototype.define = function GENSIN_f() { - this.rpar = [[1], [1], [0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["gensin"]); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1], [1], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(this.rpar[0], this.rpar[1], this.rpar[2]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENSIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GENSIN_f.prototype.details = function GENSIN_f() { - return this.x; - } -} - -function GENSQR_f() { - - GENSQR_f.prototype.define = function GENSQR_f() { - this.Amplitude = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gensqr"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.Amplitude]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.Amplitude]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENSQR_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GENSQR_f.prototype.details = function GENSQR_f() { - return this.x; - } -} -function GOTO() { - - GOTO.prototype.define = function GOTO() { - var model = scicos_model(); - model.sim = new ScilabString(["goto"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GOTO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x) - } - - GOTO.prototype.details = function GOTO() { - return this.x; - } -} -function GOTOMO() { - - GOTOMO.prototype.define = function GOTOMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["gotomo"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["gotomo"]); - mo.inputs = new ScilabString(["p"]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GOTOMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - GOTOMO.prototype.details = function GOTOMO() { - return this.x; - } -} - -function GotoTagVisibility() { - - GotoTagVisibility.prototype.define = function GotoTagVisibility() { - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GotoTagVisibility\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - GotoTagVisibility.prototype.details = function GotoTagVisibility() { - - return this.x; - } -} -function GotoTagVisibilityMO() { - - GotoTagVisibilityMO.prototype.define = function GotoTagVisibilityMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibilitymo"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GotoTagVisibilityMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GotoTagVisibilityMO.prototype.details = function GotoTagVisibilityMO() { - return this.x; - } -} - -function Ground() { - - Ground.prototype.define = function Ground() { - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.sim = new ScilabString(["Ground"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Ground"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString([""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Ground\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([1, 1]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new GroundBlock(this.x); - } - - Ground.prototype.details = function Ground() { - return this.x; - } -} -function Gyrator() { - - Gyrator.prototype.define = function Gyrator() { - this.ModelName = "Gyrator"; - this.PrametersValue = [[1],[1]]; - this.ParametersName = [["G1"],["G2"]]; - this.model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2.5, 90, 2, 0],[2.5, 10, 2, 0],[97.5, 90, -2, 0],[97.5, 10, -2, 0]]; - this.PortName = [["p1"],["n1"],["p2"],["n2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var model = scicos_model(); - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - console.log(this.MI); - model.rpar = new ScilabDouble(...this.PrametersValue); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...zeros(this.ParametersName))); - var exprs = new ScilabString(["1"], ["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"Gyrator",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(...this.Typein); - this.x.graphics.out_implicit = new ScilabString(...this.Typeout); - return new BasicBlock(this.x); - } - Gyrator.prototype.details = function Gyrator() { - return this.x; - } -} -function HALT_f() { - - HALT_f.prototype.define = function HALT_f() { - this.n = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["hltblk"]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.n]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"HALT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - HALT_f.prototype.details = function HALT_f() { - return this.x; - } -} - -function HYSTHERESIS() { - - HYSTHERESIS.prototype.define = function HYSTHERESIS() { - this.in1 = 1; - this.ipar = 0; - this.nzz = 2; - this.rpar = [[1], [0], [1], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["hystheresis"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.nzcross = new ScilabDouble([this.nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(...this.rpar, [Math.sign(this.nzz)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"HYSTHERESIS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - HYSTHERESIS.prototype.details = function HYSTHERESIS() { - return this.x; - } -} - -function IdealTransformer() { - - IdealTransformer.prototype.define = function IdealTransformer() { - this.ModelName = "IdealTransformer"; - this.PrametersValue = [1]; - this.ParametersName = ["N"]; - - var model = scicos_model(); - - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2.5,90,2,0],[2.5,10,2,0],[97.5,90,-2,0],[97.5,10,-2,0]]; - this.PortName = [["p1"],["n1"],["p2"],["n2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(this.PrametersValue); - mo.parameters = list(new ScilabString(this.ParametersName), new ScilabDouble(this.PrametersValue), new ScilabDouble(zeros(getData(this.ParametersName)))); - var exprs = new ScilabString(["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IdealTransformer\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, list(gr_i), new ScilabDouble([0])); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - IdealTransformer.prototype.details = function IdealTransformer() { - return this.x; - } - -} -function IFTHEL_f() { - - IFTHEL_f.prototype.internal = function IFTHEL_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble(); // changed - model.evtout = new ScilabDouble([-1], [-1]) // 1, 1 -> -1, -1 inverse - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble([-1], [-1]); // inverse - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IFTHEL_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(["1"], ["1"]); // value model.in, model.nmode inverse - - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3 -> 80 - block.graphics.in_implicit = new ScilabString(["E"]); - // changed - block.graphics.in_label = new ScilabString([""]); - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.style = new ScilabString(["IFTHEL_f"]); - return block; - } - - IFTHEL_f.prototype.define = function IFTHEL_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble(); // changed - model.evtout = new ScilabDouble([-1], [-1]) // 1, 1 -> -1, -1 inverse - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble([-1], [-1]); // inverse - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IFTHEL_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(["1"], ["1"]); // value model.in, model.nmode inverse - - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3 -> 80 - this.x.graphics.in_implicit = new ScilabString(["E"]); - // changed - this.x.graphics.in_label = new ScilabString([""]); - this.x.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - this.x.graphics.style = new ScilabString(["IFTHEL_f"]); - return new BasicBlock(this.x); - } - - IFTHEL_f.prototype.details = function IFTHEL_f() { - return this.x; - } -} -function Inductor() { - - Inductor.prototype.define = function Inductor() { - this.L = 1.0E-5; - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.L.toExponential(1)]); - model.sim = new ScilabString(["Inductor"]); - - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Inductor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["L"]), list(new ScilabDouble([this.L.toExponential(1)]))); - model.equations = mo; - - var exprs = new ScilabString([this.L]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Inductor\",sz(1),sz(2));"]); - this.x = standard_define([2, 0.9], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Inductor.prototype.details = function Inductor() { - return this.x; - } -} - -function INIMPL_f() { - - INIMPL_f.prototype.define = function INIMPL_f() { - var model = scicos_model(); - model.sim = new ScilabString(["inimpl"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.blocktype = new ScilabString(["c"]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PORT"]); - mo.outputs = new ScilabString(["n"]); - mo.inputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString(["1"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"INIMPL_f",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - this.implicitInBlock = new ImplicitInBlock(this.x); - this.displayParameter = [this.implicitInBlock.ordering]; - return this.implicitInBlock; - } - INIMPL_f.prototype.details = function INIMPL_f() { - return this.x; - } -} -function INTEGRAL_f() { - - INTEGRAL_f.prototype.define = function INTEGRAL_f() { - this.x0 = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["integr"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTEGRAL_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTEGRAL_f.prototype.details = function INTEGRAL_f() { - return this.x; - } -} - -function INTEGRAL_m() { - - INTEGRAL_m.prototype.define = function INTEGRAL_m() { - this.maxp = 1; - this.minp = -1; - this.rpar = []; - - var model = scicos_model(); - model.state = new ScilabDouble([0]); - model.sim = list(new ScilabString(["integral_func"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([0], [0], [0], [this.maxp], [this.minp]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTEGRAL_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTEGRAL_m.prototype.details = function INTEGRAL_m() { - return this.x; - } -} - -function INTMUL() { - - INTMUL.prototype.define = function INTMUL() { - this.sgn = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["matmul_i32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-2]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.out2 = new ScilabDouble([-3]); - model.intyp = new ScilabDouble([3, 3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTMUL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTMUL.prototype.details = function INTMUL() { - return this.x; - } -} - -function INTRP2BLK_f() { - - INTRP2BLK_f.prototype.define = function INTRP2BLK_f() { - this.a = [[0],[1]]; - this.b = [[0],[1]]; - this.c = [[0,1],[1,2]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["intrp2"]), new ScilabDouble([1])); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.a,...this.b,...colon_operator(this.c)); - model.ipar = new ScilabDouble([2], [2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.a)],[sci2exp(this.b)],[sci2exp(this.c)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTRP2BLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTRP2BLK_f.prototype.details = function INTRP2BLK_f() { - return this.x; - } -} - -function INTRPLBLK_f() { - - INTRPLBLK_f.prototype.define = function INTRPLBLK_f() { - this.a = [[0],[1]]; - - this.b = [[0],[1]]; - - var model = scicos_model(); - model.sim = new ScilabString(["intrpl"]); - model.in = new ScilabDouble(1); - model.out = new ScilabDouble(1); - model.rpar = new ScilabDouble(...this.a, ...this.b); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = new ScilabString([sci2exp(this.a)], [sci2exp(this.b)]); - - var gr_i = ["xstringb(orig(1),orig(2),\"INTRPLBLK_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - INTRPLBLK_f.prototype.details = function INTRPLBLK_f() { - return this.x; - } -} -function INVBLK() { - - INVBLK.prototype.define = function INVBLK() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["invblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INVBLK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INVBLK.prototype.details = function INVBLK() { - return this.x; - } -} - -function IN_f () { - - IN_f.prototype.internal = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["IN_f"]); // changed - block.graphics.out_implicit = new ScilabString(["E"]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.out_label = new ScilabString([""]); - return block; - } - - IN_f.prototype.define = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - - this.explicitInBlock = new ExplicitInBlock(this.x); - this.displayParameter = [this.explicitInBlock.ordering]; - return this.explicitInBlock; - - } - - IN_f.prototype.details = function IN_f() { - return this.x; - } -} -function ISELECT_m() { - - ISELECT_m.prototype.define = function ISELECT_m() { - this.z0 = 1; - this.nout = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["selector_m"]), new ScilabDouble([4])); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-2], [-2]); - model.outtyp = new ScilabDouble([1]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin = new ScilabDouble(...ones(this.nout, 1)); - model.dstate = new ScilabDouble([this.z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(this.nout)], [sci2exp(this.z0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ISELECT_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - ISELECT_m.prototype.details = function ISELECT_m() { - return this.x; - } -} - -function LOGBLK_f() { - - LOGBLK_f.prototype.define = function LOGBLK_f() { - this.in1 = 1; - this.a = Math.E; - - var model = scicos_model(); - model.sim = new ScilabString(["logblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["%e"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - LOGBLK_f.prototype.details = function LOGBLK_f() { - return this.x; - } -} - -function LOGIC() { - - LOGIC.prototype.define = function LOGIC() { - this.mat = [[0],[0],[0],[1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["logic"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.intyp = new ScilabDouble([5, 5]); - model.outtyp = new ScilabDouble([5]); - model.opar = list(int8(...this.mat)); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.mat)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGIC\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - LOGIC.prototype.details = function LOGIC() { - return this.x; - } -} -function LOGICAL_OP() { - - LOGICAL_OP.prototype.define = function LOGICAL_OP() { - this.in1 = [[-1], [-1]]; - this.ipar = 0; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["logicalop"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], [this.ipar]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGICAL_OP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - LOGICAL_OP.prototype.details = function LOGICAL_OP() { - return this.x; - } -} - -function LOOKUP_f() { - - LOOKUP_f.prototype.define = function LOOKUP_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["lookup"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-2], [-1], [1], [2], [-1], [1], [-1], [1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOOKUP_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], gr_i); - return new BasicBlock(this.x); - } - LOOKUP_f.prototype.details = function LOOKUP_f() { - return this.x; - } -} - -function MATBKSL() { - - MATBKSL.prototype.define = function MATBKSL() { - this.function_name = "mat_bksl"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-3]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATBKSL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATBKSL.prototype.details = function MATBKSL() { - return this.x; - } -} - -function MATCATH() { - - MATCATH.prototype.define = function MATCATH() { - this.funtyp = 4; - this.function_name = "mat_cath"; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([0]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(2)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATCATH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATCATH.prototype.details = function MATCATH() { - return this.x; - } -} - -function MATCATV() { - - MATCATV.prototype.define = function MATCATV() { - this.l1 = [[2], [2]]; - this.function_name = "mat_catv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in2 = new ScilabDouble([-1], [-1]); - model.in = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([-1, -1]); - model.out = new ScilabDouble([0]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(2)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATCATV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATCATV.prototype.details = function MATCATV() { - return this.x; - } -} - -function MATDET() { - - MATDET.prototype.define = function MATDET() { - var model = scicos_model(); - - this.function_name = "mat_det"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDET\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATDET.prototype.details = function MATDET() { - return this.x; - } -} -function MATDIAG() { - - MATDIAG.prototype.define = function MATDIAG() { - this.function_name = "mat_diag"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDIAG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATDIAG.prototype.details = function MATDIAG() { - return this.x; - } -} - -function MATDIV() { - - MATDIV.prototype.define = function MATDIV() { - var model = scicos_model(); - - this.function_name = "mat_div"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-2]); - model.in2 = new ScilabDouble([-3], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDIV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATDIV.prototype.details = function MATDIV() { - return this.x; - } - -} -function MATEIG() { - - MATEIG.prototype.define = function MATEIG() { - this.function_name = "mat_vps"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATEIG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATEIG.prototype.details = function MATEIG() { - return this.x; - } -} - -function MATEXPM() { - - MATEXPM.prototype.define = function MATEXPM() { - this.function_name = "mat_expm"; - this.funtyp = 4; - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATEXPM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATEXPM.prototype.details = function MATEXPM() { - return this.x; - } -} - -function MATINV() { - - MATINV.prototype.define = function MATINV() { - this.function_name = "mat_inv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATINV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATINV.prototype.details = function MATINV() { - return this.x; - } -} - -function MATLU() { - - MATLU.prototype.define = function MATLU() { - this.function_name = "mat_lu"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-1], [-1]); - model.outtyp = new ScilabDouble([1, 1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATLU\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATLU.prototype.details = function CSCOPE() { - return this.x; - } -} - -function MATMAGPHI() { - - MATMAGPHI.prototype.define = function MATMAGPHI() { - this.function_name = "matz_abs"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-2], [-2]); - model.outtyp = new ScilabDouble([1, 1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATMAGPHI\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATMAGPHI.prototype.details = function MATMAGPHI() { - return this.x; - } -} - -function MATMUL() { - - MATMUL.prototype.define = function MATMUL() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["matmul_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-2]); - model.in2 = new ScilabDouble([-2], [-3]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-3]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([1]); - - var label = new ScilabString([sci2exp(parseInt(getData(model.ipar)))]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATMUL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATMUL.prototype.details = function MATMUL() { - return this.x; - } -} - -function MATPINV() { - - MATPINV.prototype.define = function MATPINV() { - this.function_name = "mat_pinv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATPINV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATPINV.prototype.details = function MATPINV() { - return this.x; - } -} - -function MATRESH() { - - MATRESH.prototype.define = function MATRESH() { - this.function_name = "mat_reshape"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp([1, 1])], [sci2exp([1, 1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATRESH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATRESH.prototype.details = function MATRESH() { - return this.x; - } -} - -function MATSING() { - - MATSING.prototype.define = function MATSING() { - var model = scicos_model(); - - this.function_name = "mat_sing"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATSING\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATSING.prototype.details = function MATSING() { - return this.x; - } -} -function MATSUM() { - - MATSUM.prototype.define = function MATSUM() { - this.function_name = "mat_sum"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATSUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATSUM.prototype.details = function MATSUM() { - return this.x; - } -} - -function MATTRAN() { - - MATTRAN.prototype.define = function MATTRAN() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["mattran_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATTRAN\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATTRAN.prototype.details = function MATTRAN() { - return this.x; - } -} - -function MATZCONJ() { - - MATZCONJ.prototype.define = function MATZCONJ() { - this.function_name = "matz_conj"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATZCONJ\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATZCONJ.prototype.details = function MATZCONJ() { - return this.x; - } -} - -function MATZREIM() { - MATZREIM.prototype.define = function MATZREIM() { - var model = scicos_model(); - - this.function_name = "matz_reim"; - this.funtyp = new ScilabDouble([4]); - model.sim = list(this.function_name, this.funtyp); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble(-1, -1); - model.out2 = new ScilabDouble(-2, -2); - model.outtyp = new ScilabDouble([1,1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - this.label = sci2exp(new ScilabDouble(1)); - - var gr_i = ["xstringb(orig(1),orig(2),\"MATZREIM\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([3,2]), model, this.label, gr_i); - return new BasicBlock(this.x); - } - - MATZREIM.prototype.details = function MATZREIM() { - return this.x; - } -} -function MAXMIN() { - - MAXMIN.prototype.define = function MAXMIN() { - var model = scicos_model(); - model.sim = list(new ScilabString(["minmax"]), new ScilabDouble([4])); - model.out = new ScilabDouble([1]); - model.in = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([0]); - - var exprs = new ScilabString(...math.transpose([[2, 1, 1]])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MAXMIN\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["MAXMIN;displayedLabel=MAX"]); - return new BasicBlock(this.x); - } - - MAXMIN.prototype.details = function MAXMIN() { - return this.x; - } -} -function MAX_f() { - - MAX_f.prototype.define = function MAX_f() { - this.in = new ScilabDouble([-1]); - - var model = scicos_model(); - model.sim = new ScilabString(["maxblk"]); - model.in = this.in; - model.out = new ScilabDouble(1); - model.dstate = new ScilabDouble([0], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = ["xstringb(orig(1),orig(2),\"MAX_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - MAX_f.prototype.details = function MAX_f() { - return this.x; - } -} -function MBLOCK() { - - MBLOCK.prototype.define = function MBLOCK() { - this.in1 = ["u1"]; - this.intype = ["I"]; - this.out = [["y1"],["y2"]]; - this.outtype = [["I"],["E"]]; - this.param = [["R"],["L"]]; - this.paramv = list(new ScilabDouble([0.1]), new ScilabDouble([0.0001])); - this.pprop = [[0],[0]]; - this.nameF = "generic"; - - var exprs = tlist(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"], new ScilabString(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"]), new ScilabString([sci2exp(this.in1)]), new ScilabString([sci2exp(this.intype)]), new ScilabString([sci2exp(this.out)]), new ScilabString([sci2exp(this.outtype)]), new ScilabString([sci2exp(this.param)]), list(new ScilabString([0.1]), new ScilabString([0.0001])), new ScilabString([sci2exp(this.pprop)]), new ScilabString([this.nameF]), new ScilabDouble()); - - var model = scicos_model(); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - model.rpar = []; - - for (var i = 0; i < this.paramv.length; i++) { - model.rpar.push(getData(this.paramv[i])); - } - - model.rpar = new ScilabDouble(...model.rpar); - var mo = new modelica_function(); - mo.model = new ScilabString([this.nameF]); - mo.parameters = list(new ScilabString(...this.param), this.paramv); - model.sim = list(mo.model, new ScilabDouble([30004])); - mo.inputs = new ScilabString(this.in1); - mo.outputs = new ScilabString(...this.out); - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "r"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "r"), 1)); - model.equations = mo; - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MBLOCK\",sz(1),sz(2));"]); - - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(this.intype); - this.x.graphics.out_implicit = new ScilabString(...this.outtype); - return new BasicBlock(this.x); - } - - MBLOCK.prototype.details = function MBLOCK() { - return this.x; - } -} -function MCLOCK_f() { - - MCLOCK_f.prototype.define = function MCLOCK_f() { - this.nn = 2; - this.dt = 0.1; - var exprs = new ScilabString([this.dt], [this.nn]); - - var mfclck = new MFCLCK_f().internal(); - mfclck.graphics.orig = new ScilabDouble([334, 199]); - mfclck.graphics.sz = new ScilabDouble([40, 40]); - mfclck.graphics.flip = new ScilabBoolean([true]); - mfclck.graphics.exprs = exprs; - mfclck.graphics.pein = new ScilabDouble([12]); - mfclck.graphics.peout = new ScilabDouble([4], [3]); - mfclck.model.rpar = new ScilabDouble([0.1]); - mfclck.model.ipar = new ScilabDouble([this.nn]); - mfclck.model.firing = new ScilabDouble([-1, 0]); - mfclck.model.uid = new ScilabString([count]); - mfclck.doc = list(new ScilabString([count++])); - - var clksom = new CLKSOM_f().internal(); - clksom.graphics.orig = new ScilabDouble([457, 161]); - clksom.graphics.sz = new ScilabDouble([16.666667, 16.666667]); - clksom.graphics.flip = new ScilabBoolean([true]); - clksom.graphics.exprs = new ScilabString(["0.1"], ["0.1"]); - clksom.graphics.pein = new ScilabDouble([4], [9], [0]); - clksom.graphics.peout = new ScilabDouble([5]); - clksom.model.uid = new ScilabString([count]); - clksom.doc = list(new ScilabString([count++])); - - var output_port1 = new CLKOUT_f().internal(); - output_port1.graphics.orig = new ScilabDouble([509, 261]); - output_port1.graphics.sz = new ScilabDouble([20, 20]); - output_port1.graphics.flip = new ScilabBoolean([true]); - output_port1.graphics.exprs = new ScilabString(["1"]); - output_port1.graphics.pein = new ScilabDouble([10]); - output_port1.model.ipar = new ScilabDouble([1]); - output_port1.model.uid = new ScilabString([count]); - output_port1.doc = list(new ScilabString([count++])); - - var output_port2 = new CLKOUT_f().internal(); - output_port2.graphics.orig = new ScilabDouble([509, 142]); - output_port2.graphics.sz = new ScilabDouble([20, 20]); - output_port2.graphics.flip = new ScilabBoolean([true]); - output_port2.graphics.exprs = new ScilabString(["2"]); - output_port2.graphics.pein = new ScilabDouble([13]); - output_port2.model.ipar = new ScilabDouble([2]); - output_port2.model.uid = new ScilabString([count]); - output_port2.doc = list(new ScilabString([count++])); - - var split1 = new CLKSPLIT_f().internal(); - split1.graphics.orig = new ScilabDouble([411.92504, 169.33333]); - split1.graphics.pein = new ScilabDouble([3]); - split1.graphics.peout = new ScilabDouble([9], [10]); - split1.model.uid = new ScilabString([count]); - split1.doc = list(new ScilabString([count++])); - - var split2 = new CLKSPLIT_f().internal(); - split2.graphics.orig = new ScilabDouble([482.45315, 169.33333]); - split2.graphics.pein = new ScilabDouble([5]); - split2.graphics.peout = new ScilabDouble([12], [13]); - split2.model.uid = new ScilabString([count]); - split2.doc = list(new ScilabString([count++])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"MCLOCK_f",sz(1),sz(2));"]); - - var diagram = scicos_diagram(); - diagram.objs.push(mfclck); - diagram.objs.push(clksom); - diagram.objs.push(output_port1); - diagram.objs.push(output_port2); - diagram.objs.push(split1); - diagram.objs.push(split2); - - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([360.7], [360.7], [411.9]), - yy: new ScilabDouble([193.3], [169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([347.3], [347.3], [461.8], [461.8]), - yy: new ScilabDouble([193.3], [155.5], [155.5], [161]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([468.9], [482.5]), - yy: new ScilabDouble([169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([411.9], [457]), - yy: new ScilabDouble([169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([411.9], [411.9], [509]), - yy: new ScilabDouble([169.3], [271], [271]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([482.5], [489.6], [489.6], [354], [354]), - yy: new ScilabDouble([169.3], [169.3], [338.3], [338.3], [244.7]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([482.4], [482.4], [509]), - yy: new ScilabDouble([169.3], [152], [152]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([6, 2, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - - this.x = scicos_block(); - this.x.gui = new ScilabString(["MCLOCK_f"]); - this.x.graphics.sz = new ScilabDouble([3, 2]); - this.x.graphics.gr_i = gr_i; - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1], [1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.rpar = diagram; - this.x.graphics.peout = new ScilabDouble([0], [0]); - return new BasicBlock(this.x); - } - MCLOCK_f.prototype.details = function MCLOCK_f() { - return this.x; - } -} -function MFCLCK_f() { - - MFCLCK_f.prototype.define = function MFCLCK_f() { - this.nn = 2; - this.dt = 0.1; - - var model = scicos_model(); - model.sim = new ScilabString(["mfclck"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.dt]); - model.ipar = new ScilabDouble([this.nn]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1], [0]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.dt], [this.nn]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MFCLCK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MFCLCK_f.prototype.internal = function MFCLCK_f() { - this.nn = 2; - this.dt = 0.1; - - var model = scicos_model(); - model.sim = new ScilabString(["mfclck"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.dt]); - model.ipar = new ScilabDouble([this.nn]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1], [0]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var exprs = new ScilabString([this.dt], [this.nn]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MFCLCK_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["MFCLCK_f"]); - return block; - } - MFCLCK_f.prototype.details = function MFCLCK_f() { - return this.x; - } -} -function MIN_f() { - - MIN_f.prototype.define = function MIN_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["minblk"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MIN_f.prototype.details = function MIN_f() { - return this.x; - } -} - -function Modulo_Count() { - - Modulo_Count.prototype.define = function Modulo_Count() { - this.ini_c = 0; - this.base = 3; - - var model = scicos_model(); - model.sim = list(new ScilabString(["modulo_count"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.ini_c]); - model.ipar = new ScilabDouble([this.base]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.ini_c], [this.base]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Modulo_Count\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - Modulo_Count.prototype.internal = function Modulo_Count() { - this.ini_c = 0; - this.base = 3; - - var model = scicos_model(); - model.sim = list(new ScilabString(["modulo_count"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.ini_c]); - model.ipar = new ScilabDouble([this.base]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.ini_c], [this.base]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Modulo_Count\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["Modulo_Count"]); - return block; - } - Modulo_Count.prototype.details = function Modulo_Count() { - return this.x; - } -} -function MUX() { - - MUX.prototype.define = function MUX() { - this.in1 = 2; - var arr = []; - arr.push(math.range(-1, -this.in1, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["multiplex"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...math.transpose(arr)); - model.out = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.in1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MUX.prototype.details = function MUX() { - return this.x; - } -} - -function MUX_f() { - - MUX_f.prototype.define = function MUX_f() { - this.in1 = 2; - var arr = []; - arr.push(math.range(-1, -this.in1, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["mux"]), new ScilabDouble([1])); - model.in = new ScilabDouble(...math.transpose(arr)); - model.out = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.in1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([0.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MUX_f.prototype.details = function MUX_f() { - return this.x; - } -} - -function M_freq() { - - M_freq.prototype.define = function M_freq() { - var model = scicos_model(); - model.sim = list(new ScilabString(["m_frequ"]), new ScilabDouble([4])); - model.evtout = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.opar = list(new ScilabDouble([1, 1, 0], [1, 1, 1], [1, 3, 2]), new ScilabDouble([1]), new ScilabDouble([0]), new ScilabDouble([0])); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0, -1, -1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp([[1], [2]])], [sci2exp([[0], [0]])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"M_freq\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - M_freq.prototype.details = function M_freq() { - return this.x; - } -} -function M_SWITCH() { - - M_SWITCH.prototype.define = function M_SWITCH() { - this.in1 = [[1], [-1], [-1]]; - this.ipar = [[1], [3]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["mswitch"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(...this.ipar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], ...this.ipar); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"M_SWITCH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - M_SWITCH.prototype.details = function M_SWITCH() { - return this.x; - } -} - -function NEGTOPOS_f() { - - NEGTOPOS_f.prototype.define = function NEGTOPOS_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [0], [-1]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NEGTOPOS_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - NEGTOPOS_f.prototype.details = function NEGTOPOS_f() { - return this.x; - } -} -function NMOS() { - - NMOS.prototype.define = function NMOS() { - this.W = 20.e-6; - this.L = 6.e-6; - this.Beta = 0.041e-3; - this.Vt = 0.8; - this.K2 = 1.144; - this.K5 = 0.7311; - this.dW = -2.5e-6; - this.dL = -1.5e-6; - this.RDS = 1.e+7; - - var model = scicos_model(); - model.sim = new ScilabString(["NMOS"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["NMOS"]); - mo.outputs = new ScilabString(["D"], ["B"], ["S"]); - mo.inputs = new ScilabString(["G"]); - mo.parameters = list(new ScilabString(["W"], ["L"], ["Beta"], ["Vt"], ["K2"], ["K5"], ["dW"], ["dL"], ["RDS"]), new ScilabDouble([this.W], [this.L], [this.Beta], [this.Vt], [this.K2], [this.K5], [this.dW], [this.dL], [this.RDS])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.W], [this.L], [this.Beta], [this.Vt], [this.K2], [this.K5], [this.dW], [this.dL], [this.RDS]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NMOS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["I"], ["I"]); - return new BasicBlock(this.x); - } - NMOS.prototype.details = function NMOS() { - return this.x; - } -} - -function NPN() { - - NPN.prototype.define = function NPN() { - this.ModelName = "NPN"; - this.PrametersValue = [[50], [0.1], [0], [0.02], [1.200e-10], [5.000e-09], [1.000e-12], [4.000e-13], [5.000e-13], [0.8], [0.4], [0.8], [0.333], [1.000e-15], [1.000e-15], [0.02585], [40]]; - this.ParametersName = [["Bf"], ["Br"], ["Is"], ["Vak"], ["Tauf"], ["Taur"], ["Ccs"], ["Cje"], ["Cjc"], ["Phie"], ["Me"], ["Phic"], ["Mc"], ["Gbc"], ["Gbe"], ["Vt"], ["EMinMax"]]; - this.model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[100, 90, -2, 0], [0, 50, 2, 0], [100, 10, -2, 0]]; - this.PortName = [["C"], ["B"], ["E"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var model = scicos_model(); - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(...this.PrametersValue); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...zeros(this.ParametersName))); - var exprs = new ScilabString(["50"], ["0.1"], ["1.e-16"], ["0.02"], ["0.12e-9"], ["5e-9"], ["1e-12"], ["0.4e-12"], ["0.5e-12"], ["0.8"], ["0.4"], ["0.8"], ["0.333"], ["1e-15"], ["1e-15"], ["0.02585"], ["40"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"NPN",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(...this.Typein); - this.x.graphics.out_implicit = new ScilabString(...this.Typeout); - return new BasicBlock(this.x); - } - NPN.prototype.details = function NPN() { - return this.x; - } -} -function NRMSOM_f() { - - NRMSOM_f.prototype.define = function NRMSOM_f() { - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = new ScilabString(["junk"]); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NRMSOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - NRMSOM_f.prototype.details = function NRMSOM_f() { - return this.x; - } -} - -function OpAmp() { - - OpAmp.prototype.define = function OpAmp() { - this.S = []; - this.Z = []; - - var model = scicos_model(); - model.sim = new ScilabString(["OpAmp"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = model.sim; - mo.inputs = new ScilabString(["in_p"], ["in_n"]); - mo.outputs = new ScilabString(["out"]); - mo.parameters = list(new ScilabDouble(), new ScilabDouble()); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - model.rpar = new ScilabDouble(); - - var exprs = new ScilabString(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OpAmp\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 5]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"], ["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - OpAmp.prototype.details = function OpAmp() { - return this.x; - } -} - -function OUTIMPL_f() { - - OUTIMPL_f.prototype.define = function OUTIMPL_f() { - var model = scicos_model(); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - - this.prt = 1; - model.sim = new ScilabString(["outimpl"]); - model.ipar = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PORT"]); - mo.inputs = new ScilabString(["n"]); - mo.outputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString(["1"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"OUTIMPL_f",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - - this.implicitOutBlock = new ImplicitOutBlock(this.x); - this.displayParameter = [this.implicitOutBlock.ordering]; - return this.implicitOutBlock; - } - OUTIMPL_f.prototype.details = function OUTIMPL_f() { - return this.x; - } -} -function OUT_f () { - - OUT_f.prototype.internal = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["OUT_f"]); // changed - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.in_label = new ScilabString([""]); - block.graphics.in_implicit = new ScilabString(["E"]); - return block; - } - - OUT_f.prototype.define = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - this.x.graphics.style = new ScilabString(["OUT_f"]); - - this.explicitOutBlock = new ExplicitOutBlock(this.x); - this.displayParameter = [this.explicitOutBlock.ordering]; - return this.explicitOutBlock; - } - - OUT_f.prototype.details = function OUT_f() { - return this.x; - } -} -function PDE() { - - PDE.prototype.define = function PDE() { - this.params_pde = tlist(["paramspde", "a", "b", "txt_exp", "check_op1", "a1", "b1", "check_op2", "a2", "b2", "check_op3", "a3", "b3", "check_op4", "a4", "b4", "check_op5", "a5", "b5", "check_op6", "a6", "b6", "check_op7", "a7", "b7", "discr_cst", "discr_non_cst", "signe", "rad_automatique", "rad_manuel", "methode", "ord1", "ord2", "ord3", "degre", "nnode", "txt_pas", "CI", "dCI", "CLa", "CLa_exp", "CLb", "CLb_exp", "points"], new ScilabString(["paramspde"], ["a"], ["b"], ["txt_exp"], ["check_op1"], ["a1"], ["b1"], ["check_op2"], ["a2"], ["b2"], ["check_op3"], ["a3"], ["b3"], ["check_op4"], ["a4"], ["b4"], ["check_op5"], ["a5"], ["b5"], ["check_op6"], ["a6"], ["b6"], ["check_op7"], ["a7"], ["b7"], ["discr_cst"], ["discr_non_cst"], ["signe"], ["rad_automatique"], ["rad_manuel"], ["methode"], ["ord1"], ["ord2"], ["ord3"], ["degre"], ["nnode"], ["txt_pas"], ["CI"], ["dCI"], ["CLa"], ["CLa_exp"], ["CLb"], ["CLb_exp"], ["points"]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP1(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP2(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP3(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP4(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP5(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP6(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP7(t)"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString(["0"]), new ScilabString(["IN_CL1(t)"]), new ScilabString(["0"]), new ScilabString(["IN_CL2(t)"]), new ScilabString([""])); - - var model = scicos_model(); - model.state = new ScilabDouble(...zeros(10, 1)); - model.sim = list(new ScilabString(["PDE"]), new ScilabDouble([0])); - model.in = new ScilabDouble([1], [1], [1], [1], [1]); - model.out = new ScilabDouble([10], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var label = list(this.params_pde, new ScilabDouble(), new ScilabString([""])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PDE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - PDE.prototype.details = function PDE() { - return this.x; - } -} - -function PerteDP() { - - PerteDP.prototype.define = function PerteDP() { - this.L = 10; - this.D = 0.2; - this.lambda = 0.03; - this.z1 = 0; - this.z2 = 0; - this.p_rho = 0; - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho]); - model.sim = new ScilabString(["PerteDP"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PerteDP"]); - mo.inputs = new ScilabString(["C1"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters = list(new ScilabString(["L"], ["D"], ["lambda"], ["z1"], ["z2"], ["p_rho"]), new ScilabDouble([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PerteDP\",sz(1),sz(2));"]); - this.x = standard_define([2, 1], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - PerteDP.prototype.details = function PerteDP() { - return this.x; - } - -} - -function PID() { - - PID.prototype.define = function PID() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["PID"]), - tol: new ScilabDouble([0.0001], [0.000001], [1.000E-10], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["INTEGRAL_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([318.304, 183.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"], ["0"], ["1"], ["-1"]), - pin: new ScilabDouble([7]), - pout: new ScilabDouble([9]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"INTEGRAL_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString(["1/s"]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["INTEGRAL_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["integral_func"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble([0]), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString(["1/s"]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SUMMATION"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([387.97067, 172.85067]), - sz: new ScilabDouble([40, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["[1;1;1]"]), - pin: new ScilabDouble([10], [9], [11]), - pout: new ScilabDouble([19]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SUMMATION",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SUMMATION"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["summation"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1], [-1]), - in2: new ScilabDouble([-2], [-2], [-2]), - intyp: new ScilabDouble([1], [1], [1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [1], [1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([321.23733, 235.91733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([17]), - pout: new ScilabDouble([10]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["DERIV"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([319.03733, 135.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([8]), - pout: new ScilabDouble([11]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"DERIV",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString(["s"]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["DERIV"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["deriv"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["x"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString(["s"]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([255.23733, 183.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([13]), - pout: new ScilabDouble([7]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([255.23733, 135.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([14]), - pout: new ScilabDouble([8]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([234.704, 203.11733]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([16]), - pout: new ScilabDouble([16], [17], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.97067, 203.11733]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([21]), - pout: new ScilabDouble([18], [19], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([456.5421, 192.85067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([19]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([193.97067, 193.11733]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([21]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([303.80876], [309.73257]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([303.80876], [310.4659]), - yy: new ScilabDouble([155.45067], [155.45067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([366.87543], [379.39924]), - yy: new ScilabDouble([203.11733], [202.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([369.80876], [379.39924], [379.39924]), - yy: new ScilabDouble([255.91733], [255.91733], [217.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([367.60876], [379.39924], [379.39924]), - yy: new ScilabDouble([155.45067], [155.45067], [187.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([2, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([234.704], [246.6659]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([12, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([234.704], [234.704], [246.6659]), - yy: new ScilabDouble([203.11733], [155.45067], [155.45067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([12, 2, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([233.97067], [234.704]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([15, 1, 0]), - to: new ScilabDouble([12, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([233.97067], [233.97067], [312.6659]), - yy: new ScilabDouble([203.11733], [255.91733], [255.91733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([15, 2, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([436.5421], [456.5421]), - yy: new ScilabDouble([202.85067], [202.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([18, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([213.97067], [233.97067]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([20, 1, 0]), - to: new ScilabDouble([15, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - model.rpar = scs_m; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PID\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - PID.prototype.details = function PID() { - return this.x; - } -} -function PNP() { - - PNP.prototype.define = function PNP() { - this.ModelName = "PNP"; - this.PrametersValue = [[50],[0.1],[0],[0.02],[1.200e-10],[5.000e-09],[1.000e-12],[4.000e-13],[5.000e-13],[0.8],[0.4],[0.8],[0.333],[1.000e-15],[1.000e-15],[0.02585],[40]]; - this.ParametersName = [["Bf"],["Br"],["Is"],["Vak"],["Tauf"],["Taur"],["Ccs"],["Cje"],["Cjc"],["Phie"],["Me"],["Phic"],["Mc"],["Gbc"],["Gbe"],["Vt"],["EMinMax"]]; - - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[100, 90, -2, 0], [0, 50, 2, 0], [100, 10, -2, 0]]; - this.PortName = [["C"], ["B"], ["E"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(...this.PrametersValue); - - var arr = []; - arr.push(zeros(getData(this.ParametersName))); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...math.transpose(arr))); - var exprs = new ScilabString(["50"], ["0.1"], ["1.e-16"], ["0.02"], ["0.12e-9"], ["5e-9"], ["1e-12"], ["0.4e-12"], ["0.5e-12"], ["0.8"], ["0.4"], ["0.8"], ["0.333"], ["1e-15"], ["1e-15"], ["0.02585"], ["40"]); - var gr_i = "xstringb(orig(1),orig(2),\"PNP\",sz(1),sz(2));" - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(...this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(...this.Typeout); - - return new BasicBlock(this.x); - } - - PNP.prototype.details = function PNP() { - return this.x; - } -} -function POSTONEG_f() { - - POSTONEG_f.prototype.define = function POSTONEG_f() { - this.rpar = [[-1], [-1], [-1], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [-1], [0]); - model.blocktype = new ScilabString(["z"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.firing = new ScilabDouble([-1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"POSTONEG_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], gr_i); - return new BasicBlock(this.x); - } - POSTONEG_f.prototype.details = function POSTONEG_f() { - return this.x; - } -} - -function PotentialSensor() { - - PotentialSensor.prototype.define = function PotentialSensor() { - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.sim = new ScilabString(["PotentialSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PotentialSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["v"]); - model.equations = mo; - - var exprs = new ScilabString([""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PotentialSensor\",sz(1),sz(2));"]); - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - return new BasicBlock(this.x); - } - PotentialSensor.prototype.details = function PotentialSensor() { - return this.x; - } -} - -function POWBLK_f() { - - POWBLK_f.prototype.define = function POWBLK_f() { - this.in = 1; - this.a = 1.5; - - var model = scicos_model(); - model.sim = new ScilabString(["powblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.a]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"POWBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - POWBLK_f.prototype.details = function POWBLK_f() { - return this.x; - } -} -function PRODUCT() { - - PRODUCT.prototype.define = function PRODUCT() { - this.sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["product"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"PRODUCT",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - return new Product(this.x); - } - PRODUCT.prototype.details = function PRODUCT() { - return this.x; - } -} -function PROD_f() { - - PROD_f.prototype.define = function PROD_f() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["prod"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - this.x = new standard_define(new ScilabDouble([1, 1]), model, new ScilabDouble(), new ScilabString()); - return new RoundBlock(this.x); - } - PROD_f.prototype.details = function PROD_f() { - return this.x; - } -} - -function PuitsP() { - - PuitsP.prototype.define = function PuitsP() { - this.P0 = 100000; - this.T0 = 290; - this.H0 = 100000; - this.option_temperature = 1; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]); - model.sim = new ScilabString(["Puits"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Puits"]); - mo.inputs = new ScilabString(["C"]); - mo.outputs = new ScilabDouble(); - mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - - var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PuitsP\",sz(1),sz(2));"]); - this.x = standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble(0))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - PuitsP.prototype.details = function PuitsP() { - return this.x; - } -} - -function QUANT_f() { - - QUANT_f.prototype.define = function QUANT_f() { - this.pas = 0.1; - this.meth = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["qzrnd"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.pas]); - model.ipar = new ScilabDouble([this.meth]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.pas], [this.meth]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"QUANT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - QUANT_f.prototype.details = function QUANT_f() { - return this.x; - } -} - -function RAMP() { - - RAMP.prototype.define = function RAMP() { - this.slope = 0; - this.iout = 0; - this.stt = 0; - this.rpar = [[this.slope], [this.stt], [this.iout]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["ramp"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(...this.rpar); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RAMP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RAMP.prototype.details = function RAMP() { - return this.x; - } -} - -function RAND_m() { - - RAND_m.prototype.define = function RAND_m() { - this.a = 0; - this.b = 1; - this.dt = 0; - this.flag = 0; - this.function_name = "rndblk_m"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble([parseInt(Math.random() * 10000000)], [0 * this.a]); - model.rpar = new ScilabDouble([this.a, this.b]); - model.ipar = new ScilabDouble([this.flag]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(1)], [this.flag], [sci2exp([this.a])], [sci2exp([this.b])], [sci2exp([parseInt(getData(model.dstate)[0]), parseInt(Math.random() * 10000000)])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RAND_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RAND_m.prototype.details = function RAND_m() { - return this.x; - } -} - -function RATELIMITER() { - - RATELIMITER.prototype.define = function RATELIMITER() { - this.minp = -1; - this.maxp = 1; - this.rpar = [[this.maxp], [this.minp]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["ratelimiter"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RATELIMITER\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RATELIMITER.prototype.details = function RATELIMITER() { - return this.x; - } -} - -function READAU_f() { - - READAU_f.prototype.define = function READAU_f() { - this.frmt = "uc "; - this.fname = "test.au"; - this.lunit = 0; - this.N = 20; - this.M = 1; - this.tmask = []; - this.swap = 0; - this.offset = 1; - this.outmask = 1; - this.ievt = 0; - this.nout = size(this.outmask, "*"); - var model = scicos_model(); - model.sim = list(new ScilabString(["readau"]), new ScilabDouble([2])); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros(this.N * this.M, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.ievt], [this.N], [this.M], [this.swap], [this.offset], ..._str2code(this.fname), [this.outmask]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.fname], [this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"READAU_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - READAU_f.prototype.details = function READAU_f() { - return this.x; - } -} -function READC_f() { - - READC_f.prototype.define = function READC_f() { - this.frmt = "d "; - this.fname = "foo"; - this.lunit = 0; - this.N = 20; - this.M = 1; - this.rpar = []; - this.tmask = 0; - this.swap = 0; - this.offset = 1; - this.outmask = 1; - this.ievt = 0; - this.nout = size(this.outmask, "*"); - - var ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.ievt], [this.N], [this.M], [this.swap], [this.offset], ..._str2code(this.fname), [this.tmask], [this.outmask]); - - var model = scicos_model(); - model.sim = list(new ScilabString(["readc"]), new ScilabDouble([2])); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros(this.N * this.M, 1)); - model.ipar = ipar; - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["[]"], [this.outmask], [this.fname], [this.frmt], [this.M], [this.N], [this.offset], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"READC_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - READC_f.prototype.details = function READC_f() { - return this.x; - } -} -function REGISTER() { - - REGISTER.prototype.define = function REGISTER() { - this.z0 = new ScilabDouble(...zeros(10, 1)); - - var model = scicos_model(); - model.sim = list(new ScilabString(["delay4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = this.z0; - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(this.z0); - - var gr_i = ["xstringb(orig(1),orig(2),\"REGISTER\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([3,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - - } - - REGISTER.prototype.details = function REGISTER() { - return this.x; - } -} -function REGISTER_f () { - - REGISTER_f.prototype.internal = function REGISTER_f() { - this.z0 = zeros(10,1); - - var model = scicos_model(); - model.sim = new ScilabString(["delay"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate= new ScilabDouble(...this.z0); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([this.z0.toString().replace(/,/g, ";")]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"REGISTER_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([2.5,2.5]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["REGISTER_f"]); - block.graphics.in_implicit = new ScilabString(["E"]); // changed - block.graphics.out_implicit = new ScilabString(["E"]); - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.in_label = new ScilabString([""]); - block.graphics.out_label = new ScilabString([""]); - return block; - } -} -function RELATIONALOP() { - - RELATIONALOP.prototype.define = function RELATIONALOP() { - this.ipar = 2; - this.label = "<"; - - var model = scicos_model(); - model.sim = list(new ScilabString(["relationalop"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.ipar], [0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RELATIONALOP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["fontSize=13;fontStyle=1;displayedLabel=" + label]); - return new BasicBlock(this.x); - } - RELATIONALOP.prototype.details = function RELATIONALOP() { - return this.x; - } -} - -function RELAY_f() { - - RELAY_f.prototype.define = function RELAY_f() { - this.i0 = 0; - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["relay"]), new ScilabDouble([2])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(...ones(this.in1)); - model.dstate = new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, true]); - - var exprs = new ScilabString([this.nin], [this.i0 + 1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RELAY_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RELAY_f.prototype.details = function RELAY_f() { - return this.x; - } -} - -function Resistor() { - - Resistor.prototype.define = function Resistor() { - this.R = 0.01; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.R]); - model.sim = new ScilabString(["resistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Resistor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["R"]), list(new ScilabDouble([this.R]))); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.R]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Resistor\",sz(1),sz(2));"]); - this.x = standard_define([2, 1], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Resistor.prototype.details = function Resistor() { - return this.x; - } -} - -function RFILE_f() { - - RFILE_f.prototype.define = function RFILE_f() { - this.out = 1; - this.nout = this.out; - this.frmt = "(7(e10.3,1x))"; - this.fname = "foo"; - this.lunit = 0; - this.N = 2; - this.rpar = []; - this.tmask = 0; - this.outmask = 1; - - var ipar = new ScilabDouble([this.fname.length], [this.frmt.length], [0], [this.N], ..._str2code(this.fname), ..._str2code(this.frmt), [this.tmask], [this.outmask]); - - var dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros((this.nout) * this.N, 1)); - - var model = scicos_model(); - model.sim = new ScilabString(["readf"]); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.dstate = dstate; - model.ipar = ipar; - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp([])], [sci2exp(this.outmask)], [this.fname], [this.frmt], [this.N], [this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RFILE_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RFILE_f.prototype.details = function RFILE_f() { - return this.x; - } -} -function RICC() { - - RICC.prototype.define = function RICC() { - this.function_name = "ricc_m"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.in2 = new ScilabDouble([-1], [-1], [-1]); - model.intyp = new ScilabDouble([1, 1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1], [1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RICC\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - RICC.prototype.details = function RICC() { - return this.x; - } -} - -function ROOTCOEF() { - - ROOTCOEF.prototype.define = function ROOTCOEF() { - this.function_name = "root_coef"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ROOTCOEF\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - ROOTCOEF.prototype.details = function ROOTCOEF() { - return this.x; - } -} - -function SAMPHOLD_m() { - - SAMPHOLD_m.prototype.define = function SAMPHOLD_m() { - var model = scicos_model(); - model.sim = list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = [sci2exp(1)]; - - var gr_i = ["xstringb(orig(1),orig(2),\"SAMPHOLD_m\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - - } - - SAMPHOLD_m.prototype.details = function SAMPHOLD_m() { - return this.x; - } -} -function SampleCLK() { - - SampleCLK.prototype.define = function SampleCLK() { - - var model = scicos_model(); - model.sim = new ScilabString(["sampleclk"]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1, 0]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, ["xstringb(orig(1),orig(2),\"SampleCLK\",sz(1),sz(2));"]); - return new BasicBlock(this.x); - } - SampleCLK.prototype.details = function SampleCLK() { - return this.x; - } -} - -function SATURATION() { - - SATURATION.prototype.define = function SATURATION() { - this.minp = -1; - this.maxp = 1; - this.rpar = [[this.maxp], [this.minp]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["satur"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp], [parseInt(getData(model.nmode)[0])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SATURATION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SATURATION.prototype.details = function SATURATION() { - return this.x; - } -} - -function SAWTOOTH_f() { - - SAWTOOTH_f.prototype.define = function SAWTOOTH_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sawtth"]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SAWTOOTH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SAWTOOTH_f.prototype.details = function SAWTOOTH_f() { - return this.x; - } -} -function SCALAR2VECTOR() { - - SCALAR2VECTOR.prototype.define = function SCALAR2VECTOR() { - this.nout = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scalar2vector"]), new ScilabDouble([4])); - model.out = new ScilabDouble([this.nout]); - model.in = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nout]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SCALAR2VECTOR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SCALAR2VECTOR.prototype.details = function SCALAR2VECTOR() { - return this.x; - } -} - -function scifunc_block_m() { - - scifunc_block_m.prototype.define = function scifunc_block_m() { - this.in1 = 1; - this.out = 1; - this.clkin = []; - this.clkout = []; - this.x0 = []; - this.z0 = []; - this.typ = "c"; - this.auto = []; - this.rpar = []; - this.it = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scifunc"]), new ScilabDouble([3])); - model.in = new ScilabDouble([this.in1]); - model.in2 = new ScilabDouble([this.in1]); - model.intyp = new ScilabDouble([this.it]); - model.out = new ScilabDouble([this.out]); - model.out2 = new ScilabDouble([this.out]); - model.outtyp = new ScilabDouble([this.it]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.opar = list(); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = list(new ScilabString([sci2exp([this.in1, this.in1])], [sci2exp([this.out, this.out])], [sci2exp(this.clkin)], [sci2exp(this.clkout)], [sci2exp(this.x0)], [sci2exp(this.z0)], [sci2exp(this.rpar)], [sci2exp(this.auto)], [sci2exp(0)]), list(new ScilabString(["y1=sin(u1)"]), new ScilabString([" "]), new ScilabString([" "]), new ScilabString(["y1=sin(u1)"]), new ScilabString([" "]), new ScilabString([" "]), new ScilabString([" "]))); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"scifunc_block_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - scifunc_block_m.prototype.details = function scifunc_block_m() { - return this.x; - } -} -function SELECT_m() { - - SELECT_m.prototype.define = function SELECT_m() { - this.z0 = 1; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["selector_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin = new ScilabDouble(...ones(this.nin, 1)); - model.dstate = new ScilabDouble([this.z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp([this.nin])], [sci2exp([this.z0])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SELECT_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SELECT_m.prototype.details = function SELECT_m() { - return this.x; - } -} - -function SELF_SWITCH() { - - SELF_SWITCH.prototype.define = function SELF_SWITCH() { - this.stateOpen = true; - - this.x = scicos_block(); - this.x.gui = new ScilabString(["SELF_SWITCH"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = genSwitchInnerDiagram(this.stateOpen); - this.x.model.opar = list(new ScilabBoolean([this.stateOpen])); - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - this.x.graphics.style = new ScilabString(["SELF_SWITCH;SELF_SWITCH_OFF"]); - return new BasicBlock(this.x); - } - - SELF_SWITCH.prototype.details = function SELF_SWITCH() { - return this.x; - } -} -function SHIFT() { - - SHIFT.prototype.define = function SHIFT() { - this.sgn = [[0],[0]]; - this.OPER = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["shift_32_LA"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SHIFT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SHIFT.prototype.details = function SHIFT() { - return this.x; - } -} -function Sigbuilder() { - - Sigbuilder.prototype.define = function Sigbuilder() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["Sigbuilder"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CURVE_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([329.63473, 606.18517]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["3"], ["[0,1,2]"], ["[10,20,-30]"], ["y"], ["n"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble([4]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CURVE_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CURVE_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["curve_c"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([0], [1], [2], [10], [20], [-30]), - ipar: new ScilabDouble([3], [3], [1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble([0]), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([349.49528, 565.10704]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([8], [4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([-1], [-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([398.20616, 616.18517]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([339.49528, 505.10704]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.63473], [349.49528]), - yy: new ScilabDouble([600.47089], [565.10704]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.49528], [266.69602], [266.69602], [270.35525], [342.80795], [342.80795], [349.63473]), - yy: new ScilabDouble([565.10704], [565.10704], [680.99483], [680.99483], [680.99483], [651.89946], [651.89946]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 2, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([378.20616], [398.20616]), - yy: new ScilabDouble([626.18517], [626.18517]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.49528], [349.49528]), - yy: new ScilabDouble([565.10704], [535.10704]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Sigbuilder\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - Sigbuilder.prototype.details = function Sigbuilder() { - return this.x; - } -} -function SIGNUM() { - - SIGNUM.prototype.define = function SIGNUM() { - this.nu = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["signum"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.out = new ScilabDouble([this.nu]); - model.nzcross = new ScilabDouble([this.nu]); - model.nmode = new ScilabDouble([this.nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SIGNUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SIGNUM.prototype.details = function SIGNUM() { - return this.x; - } -} - -function SINBLK_f() { - - SINBLK_f.prototype.define = function SINBLK_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sinblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SINBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SINBLK_f.prototype.details = function SINBLK_f() { - return this.x; - } -} - -function SineVoltage() { - - SineVoltage.prototype.define = function SineVoltage() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - this.V = 1; - this.ph = 0; - this.frq = 1; - this.offset = 0; - this.start = 0; - - model.rpar = new ScilabDouble([this.V], [this.ph], [this.frq], [this.offset], [this.start]); - model.sim = new ScilabString(["SineVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["SineVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["V"], ["phase"], ["freqHz"], ["offset"], ["startTime"]), list(new ScilabDouble([this.V]), new ScilabDouble([this.ph]), new ScilabDouble([this.frq]), new ScilabDouble([this.offset]), new ScilabDouble([this.start]))); - model.equations = mo; - - var exprs = new ScilabString([this.V], [this.ph], [this.frq], [this.offset], [this.start]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SineVoltage\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - SineVoltage.prototype.details = function SineVoltage() { - return this.x; - } -} -function SOM_f() { - - SOM_f.prototype.define = function SOM_f() { - this.sgn = [[1], [1], [1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["sum"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SINBLK_f.prototype.details = function SINBLK_f() { - return this.x; - } -} -function SourceP() { - - SourceP.prototype.define = function SourceP() { - var model = scicos_model(); - - this.P0 = 300000; - this.T0 = 290; - this.H0 = 100000; - this.option_temperature = 1; - - model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]); - model.sim = new ScilabString(["Source"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Source"]); - mo.inputs = new ScilabDouble(); - mo.outputs = new ScilabString(["C"]); - mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SourceP\",sz(1),sz(2));"]); - this.x = new standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - SourceP.prototype.details = function SourceP() { - return this.x; - } -} -function SQRT() { - - SQRT.prototype.define = function SQRT() { - var model = scicos_model(); - model.sim = list(new ScilabString(["mat_sqrt"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SQRT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - SQRT.prototype.details = function SQRT() { - return this.x; - } -} -function SRFLIPFLOP() { - - SRFLIPFLOP.prototype.define = function SRFLIPFLOP() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["SRFLIPFLOP"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGIC"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([298.504, 201.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["[0 1;1 0;1 0;1 0;0 1;0 1;0 0;0 0]"], ["1"]), - pin: new ScilabDouble([4], [10], [12]), - pout: new ScilabDouble([3], [8]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGIC",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""], [""]), - style: new ScilabString(["LOGIC"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logic"]), new ScilabDouble([4])), - in: new ScilabDouble([1], [1], [1]), - in2: new ScilabDouble([1], [1], [1]), - intyp: new ScilabDouble([5], [5], [5]), - out: new ScilabDouble([1], [1]), - out2: new ScilabDouble([1], [1]), - outtyp: new ScilabDouble([5], [5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0, 1], [1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 0], [0, 0])), - blocktype: new ScilabString(["c"]), - firing: new ScilabBoolean([false]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["DOLLAR_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([299.23733, 254.25067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([false]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"], ["1"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble([4]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"DOLLAR_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["DOLLAR_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["dollar4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(int8([0])), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([363.03733, 248.584]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([3]), - pout: new ScilabDouble([10], [14], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([367.07543, 204.784]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([8]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([249.93257, 211.45067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([10]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([249.93257, 201.45067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([12]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([383.03733, 238.584]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([14]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.07543], [363.03733], [363.03733]), - yy: new ScilabDouble([228.11733], [228.11733], [248.584]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([290.6659], [272.104], [272.104], [289.93257]), - yy: new ScilabDouble([274.25067], [274.25067], [231.45067], [231.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([363.03733], [363.03733], [344.95162]), - yy: new ScilabDouble([248.584], [274.25067], [274.25067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.07543], [367.07543]), - yy: new ScilabDouble([214.784], [214.784]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.93257], [289.93257]), - yy: new ScilabDouble([221.45067], [221.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([9, 1, 0]), - to: new ScilabDouble([1, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.93257], [289.93257]), - yy: new ScilabDouble([211.45067], [221.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([11, 1, 0]), - to: new ScilabDouble([1, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([363.03733], [383.03733]), - yy: new ScilabDouble([248.584], [248.584]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([13, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, 5]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SRFLIPFLOP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - SRFLIPFLOP.prototype.details = function SRFLIPFLOP() { - return this.x; - } -} -function STEP_FUNCTION() { - - STEP_FUNCTION.prototype.define = function STEP_FUNCTION() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new STEP().internal()); - scs_m_1.objs.push(new OUT_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([0, 0]); - graphics.sz = new ScilabDouble([40, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.pein = new ScilabDouble([4]); - graphics.peout = new ScilabDouble([4]); - graphics.pout = new ScilabDouble([3]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.in_style = new ScilabDouble(); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.in_label = new ScilabDouble(); - graphics.out_label = new ScilabString([""]); - model.evtin = new ScilabDouble([-1]); - model.evtout = new ScilabDouble([-1]); - model.uid = new ScilabString([count]); - blk.graphics = graphics; - blk.model = model; - blk.doc = list(new ScilabString([count++])); - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([80, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([3]); - model.outtyp = new ScilabDouble(); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - var lnk = scs_m_1.objs[2]; - lnk.xx = new ScilabDouble([104], [136]); - lnk.yy = new ScilabDouble([-40], [-60]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[2] = lnk; - - lnk = scs_m_1.objs[3]; - lnk.xx = new ScilabDouble([0], [20], [-20], [-20], [20], [1]); - lnk.yy = new ScilabDouble([0], [-20], [-20], [60], [60], [1]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[3] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"STEP_FUNCTION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabString(), gr_i); - return new BasicBlock(this.x); - } - - STEP_FUNCTION.prototype.details = function STEP_FUNCTION() { - return this.x; - } -} -function SUBMAT() { - - SUBMAT.prototype.define = function SUBMAT() { - var model = scicos_model(); - - this.function_name = new ScilabString(["submat"]); - - this.funtyp = new ScilabDouble([4]); - model.sim = list(this.function_name, this.funtyp); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1], [1], [1], [1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - this.label = new ScilabString([sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUBMAT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2.5, 2]), model, this.label, gr_i); - - return new BasicBlock(this.x); - - } - SUBMAT.prototype.details = function SUBMAT() { - return this.x; - - } -} -function SUMMATION() { - SUMMATION.prototype.define = function SUMMATION() { - this.sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["summation"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2], [-2]); - model.out2 = new ScilabDouble([-2]); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUMMATION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - return new Summation(this.x); - } - - SUMMATION.prototype.details = function SUMMATION() { - return this.x; - } -} -function SUM_f() { - - SUM_f.prototype.define = function SUM_f() { - var model = scicos_model(); - - model.sim = list(new ScilabString(["plusblk"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUM_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(); - - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - - return new RoundBlock(this.x); - - } - - SUM_f.prototype.details = function SUM_f() { - return this.x; - - } -} -function SUPER_f() { - - SUPER_f.prototype.define = function SUPER_f() { - var scs = scicos_diagram(); - scs.props.title = new ScilabString(["Super_Block"]); - - var in1 = new IN_f().internal(); - in1.graphics.orig = new ScilabDouble([40, 40]); - in1.graphics.sz = new ScilabDouble([20, 20]); - in1.graphics.flip = new ScilabBoolean([true]); - in1.graphics.pout = new ScilabDouble([0]); - in1.model.uid = new ScilabString([count]); - in1.doc = list(new ScilabString([count++])); - - var out = new OUT_f().internal(); - out.graphics.orig = new ScilabDouble([240, 40]); - out.graphics.sz = new ScilabDouble([20, 20]); - out.graphics.flip = new ScilabBoolean([true]); - out.graphics.pin = new ScilabDouble([0]); - out.model.outtyp = new ScilabDouble(); - out.model.uid = new ScilabString([count]); - out.doc = list(new ScilabString([count++])); - scs.objs.push(in1); - scs.objs.push(out); - - var model = scicos_model(); - model.sim = new ScilabString(["super"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = scs; - model.blocktype = new ScilabString(["h"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = ["xstringb(orig(1),orig(2),\"SUPER_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new SuperBlock(this.x); - } - - SUPER_f.prototype.details = function SUPER_f() { - return this.x; - } -} -function Switch() { - - Switch.prototype.define = function Switch() { - var model = scicos_model(); - - this.Ron = 0.01; - this.Roff = 1e5; - this.S = [["Ron"], ["Roff"]]; - - var scope = { - Ron: 0.01, - Roff: 1e5 - } - this.Z = math.eval('[ Ron ; Roff ]', scope)._data; - - model.sim = new ScilabString(["Switch"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = model.sim; - mo.inputs = new ScilabString(["p"], ["inp"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(...this.S), new ScilabDouble(...this.Z)); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - model.rpar = new ScilabDouble(...this.Z); - - var exprs = new ScilabString(...this.Z); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Switch\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 2]), model, exprs, list(gr_i, new ScilabDouble(0))); - this.x.graphics.in_implicit = new ScilabString([["I"], ["E"]]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - Switch.prototype.details = function Switch() { - this.x; - } -} -function SWITCH2_m() { - - SWITCH2_m.prototype.define = function SWITCH2_m() { - this.ipar = [0]; - this.nzz = 1; - this.rpar = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["switch2_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [1], [-1]); - model.in2 = new ScilabDouble([-2], [1], [-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble(this.ipar); - model.rpar = new ScilabDouble([this.rpar]); - model.nzcross = new ScilabDouble([this.nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1], this.ipar, [this.rpar], [this.nzz]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH2_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SWITCH2_m.prototype.details = function SWITCH2_m() { - return this.x; - } -} -function SWITCH_f() { - - SWITCH_f.prototype.define = function SWITCH_f() { - this.i0 = 0; - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["switchn"]), new ScilabDouble([2])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, true]); - - var exprs = new ScilabString([this.nin], [this.i0 + 1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SWITCH_f.prototype.internal = function SWITCH_f() { - this.i0 = 0; - this.in1 = [[-1],[-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["switchn"]),new ScilabDouble([2])); - model.in=new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,true]); - - var exprs = new ScilabString([this.nin],[this.i0+1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return block; - } - - SWITCH_f.prototype.details = function SWITCH_f() { - return this.x; - } -} -function TANBLK_f() { - - TANBLK_f.prototype.define = function TANBLK_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["tanblk"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(in1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TANBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TANBLK_f.prototype.details = function TANBLK_f() { - return this.x; - } -} -function TCLSS() { - - TCLSS.prototype.define = function TCLSS() { - this.x0 = 0; - this.A = 0; - this.B = 1; - this.C = 1; - this.D = 0; - this.in1 = 1; - this.nx = size(this.x0, "*"); - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tcslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1], [this.nx]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.A)], [sci2exp(this.B)], [sci2exp(this.C)], [sci2exp(this.D)], [sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TCLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - - TCLSS.prototype.details = function TCLSS() { - return this.x; - } -} -function TEXT_f() { - - TEXT_f.prototype.define = function TEXT_f() { - this.font = 2; - this.siz = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["text"]); - model.rpar = new ScilabString(["Text"]); - model.ipar = new ScilabDouble([this.font], [this.siz]); - - var exprs = ["Text", this.font, this.siz]; - - var graphics = scicos_graphics(); - graphics.orig = new ScilabDouble([0, 0]); - graphics.sz = new ScilabDouble([2, 1]); - graphics.exprs = new ScilabString(exprs); - this.x = mlist(["Text", "graphics", "model", "void", "gui"], new ScilabString(["Text", "graphics", "model", "void", "gui"]), graphics, model, new ScilabString([" "]), new ScilabString(["TEXT_f"])); - return new TextBlock(this.x); - } - - TEXT_f.prototype.details = function TEXT_f() { - return this.x; - } -} -function TIME_DELAY() { - - TIME_DELAY.prototype.define = function TIME_DELAY() { - this.nin = 1; - this.T = 1; - this.init = 0; - this.N = 1024; - - var model = scicos_model(); - model.sim = list(new ScilabString(["time_delay"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nin]); - model.out = new ScilabDouble([this.nin]); - model.rpar = new ScilabDouble([this.T, this.init]); - model.ipar = new ScilabDouble([this.N]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([this.T], [this.init], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TIME_DELAY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TIME_DELAY.prototype.details = function TIME_DELAY() { - return this.x; - } -} -function TIME_f() { - - TIME_f.prototype.define = function TIME_f() { - var model = scicos_model(); - model.sim = new ScilabString(["timblk"]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TIME_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - TIME_f.prototype.details = function TIME_f() { - return this.x; - } -} -function TKSCALE() { - - TKSCALE.prototype.define = function TKSCALE() { - this.a = -10; - this.b = 10; - this.f = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tkscaleblk"]), new ScilabDouble([5])); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.a], [this.b], [this.f]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.a)], [sci2exp(this.b)], [sci2exp(this.f)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TKSCALE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TKSCALE.prototype.details = function TKSCALE() { - return this.x; - } -} -function TOWS_c() { - - TOWS_c.prototype.define = function TOWS_c() { - this.nu = -1; - this.nz = 128; - this.varnam = "A"; - this.herit = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tows_c"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.nz], [this.varnam.length], ascii(this.varnam)); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TOWS_c\",sz(1),sz(2));"]);; - - var exprs = new ScilabString([this.nz], [this.varnam], [this.herit]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TOWS_c.prototype.details = function TOWS_c() { - return this.x; - } -} -function TRASH_f() { - - TRASH_f.prototype.define = function TRASH_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.in = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TRASH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TRASH_f.prototype.details = function TRASH_f() { - return this.x; - } -} -function TrigFun() { - - TrigFun.prototype.define = function TrigFun() { - var model = scicos_model(); - model.sim = list(new ScilabString(["sin_blk"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["sin"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TrigFun\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TrigFun.prototype.details = function TrigFun() { - return this.x; - } -} -function VanneReglante() { - - VanneReglante.prototype.define = function VanneReglante() { - var model = scicos_model(); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - - this.Cvmax = 8005.42; - this.p_rho = 0; - - model.rpar = new ScilabDouble([this.Cvmax], [this.p_rho]); - model.sim = new ScilabString(["VanneReglante"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VanneReglante"]); - mo.inputs = new ScilabString(["C1", "Ouv"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters = list(new ScilabString(["Cvmax"], ["p_rho"]), new ScilabDouble([this.Cvmax], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.Cvmax], [this.p_rho]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VanneReglante\",sz(1),sz(2));"]); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"], ["E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - VanneReglante.prototype.details = function VanneReglante() { - return this.x; - } -} -function VariableResistor() { - - VariableResistor.prototype.define = function VariableResistor() { - var model = scicos_model(); - model.sim = new ScilabString(["VariableResistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VariableResistor"]); - mo.inputs = new ScilabString(["p", "R"]); - mo.outputs = new ScilabString(["n"]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VariableResistor\",sz(1),sz(2));"]);; - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I", "E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - VariableResistor.prototype.details = function VariableResistor() { - return this.x; - } -} -function VARIABLE_DELAY() { - - VARIABLE_DELAY.prototype.define = function VARIABLE_DELAY() { - this.nin = 1; - this.T = 1; - this.init = 0; - this.N = 1024; - - var model = scicos_model(); - model.sim = list(new ScilabString(["variable_delay"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nin], [1]); - model.out = new ScilabDouble([this.nin]); - model.rpar = new ScilabDouble([this.T, this.init]); - model.ipar = new ScilabDouble([this.N]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.T], [this.init], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VARIABLE_DELAY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - VARIABLE_DELAY.prototype.details = function VARIABLE_DELAY() { - return this.x; - } -} -function VirtualCLK0() { - - VirtualCLK0.prototype.define = function VirtualCLK0() { - var model = scicos_model(); - model.sim = new ScilabString(["vrtclk0"]); - model.evtin = new ScilabDouble([1]); - model.opar = list(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabDouble(); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, new ScilabString([" "])); - return new BasicBlock(this.x); - } - - VirtualCLK0.prototype.details = function VirtualCLK0() { - return this.x; - } - -} -function VoltageSensor() { - - VoltageSensor.prototype.define = function VoltageSensor() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [, 1]); - model.sim = new ScilabString(["VoltageSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VoltageSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"], ["v"]); - model.equations = mo; - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VoltageSensor\",sz(1),sz(2));"]);; - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["E"]); - return new VoltageSensorBlock(this.x); - } - - VoltageSensor.prototype.details = function VoltageSensor() { - return this.x; - } -} -function VsourceAC() { - - VsourceAC.prototype.define = function VsourceAC() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - this.VA = 220; - - this.FR = 50; - model.rpar = new ScilabDouble([this.VA], [this.FR]); - model.sim = new ScilabString(["VsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = modelica_function(); - mo.model = new ScilabString(["VsourceAC"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["VA"], ["f"]), list(new ScilabDouble([this.VA]), new ScilabDouble([this.FR]))); - model.equations = mo; - - var exprs = new ScilabString([this.VA], [this.FR]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VsourceAC\",sz(1),sz(2));"]); - - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - return new BasicBlock(this.x); - } - - VsourceAC.prototype.details = function VsourceAC() { - return this.x; - } -} -function VVsourceAC() { - - VVsourceAC.prototype.define = function VVsourceAC() { - var model = scicos_model(); - - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - - this.VA = 220; - this.FR = 50; - - model.rpar = new ScilabDouble([this.FR]); - model.sim = new ScilabString(["VVsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = modelica_function(); - mo.model = new ScilabString(["VVsourceAC"]); - mo.inputs = new ScilabString(["p", "VA"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["f"]), list(new ScilabDouble([this.FR]))); - model.equations = mo; - - var exprs = new ScilabString([this.FR]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VVsourceAC\",sz(1),sz(2));"]); - - - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I", "E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - return new BasicBlock(this.x); - } - - VVsourceAC.prototype.details = function VVsourceAC() { - return this.x; - } -} -function WRITEAU_f() { - - WRITEAU_f.prototype.define = function WRITEAU_f() { - this.in1 = 1; - this.nin = math.sum(this.in1); - this.frmt = "uc "; - this.fname = "/dev/audio"; - this.swap = 0; - this.lunit = 0; - this.N = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["writeau"]), new ScilabDouble([2])); - model.in = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [this.lunit], ...zeros((this.nin + 1) * this.N, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.N], [this.swap], ..._str2code(this.fname)); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"WRITEAU_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - WRITEAU_f.prototype.details = function WRITEAU_f() { - return this.x; - } -} -function WRITEC_f() { - - WRITEC_f.prototype.define = function WRITEC_f() { - this.in = 1; - this.nin = math.sum(this.in); - this.frmt = "c "; - this.fname = "foo"; - this.swap = 0; - this.lunit = 0; - this.N = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["writec"]), new ScilabDouble([2])); - model.in = new ScilabDouble([this.in]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [this.lunit], ...zeros((this.nin + 1) * this.N, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.N], [this.swap], ..._str2code(this.fname)); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in)], [this.fname], [this.frmt], [this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"WRITEC_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - WRITEC_f.prototype.details = function WRITEC_f() { - return this.x; - } -} -function ZCROSS_f() { - - ZCROSS_f.prototype.define = function ZCROSS_f() { - this.rpar = [[-1], [-1], [0], [0]]; - - this.in = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.in = new ScilabDouble([this.in]); - model.nzcross = new ScilabDouble([this.in]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [0], [0]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ZCROSS_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - - return new BasicBlock(this.x); - } - - ZCROSS_f.prototype.details = function ZCROSS_f() { - return this.x; - } -} diff --git a/composer.json b/composer.json deleted file mode 100644 index 0967ef4..0000000 --- a/composer.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/config/keyhandler-commons.xml b/config/keyhandler-commons.xml deleted file mode 100644 index 9d21f45..0000000 --- a/config/keyhandler-commons.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/common.css b/css/common.css deleted file mode 100644 index 82f5e94..0000000 --- a/css/common.css +++ /dev/null @@ -1,221 +0,0 @@ -body { - font-family: Arial; -} - -h1 { - font-size: 18px; -} - -h2 { - font-size: 16px; -} -div.mxRubberband { - position: absolute; - overflow: hidden; - border-style: solid; - border-width: 1px; - border-color: #0000FF; - background: #0077FF; -} -textarea.mxCellEditor { - background: url('../images/transparent.gif'); - border-style: solid; - border-color: black; - border-width: 0; - overflow: auto; -} -div.mxWindow { - -webkit-box-shadow: 3px 3px 12px #C0C0C0; - -moz-box-shadow: 3px 3px 12px #C0C0C0; - box-shadow: 3px 3px 12px #C0C0C0; - background: url('../images/window.gif'); - border-style: outset; - border-width: 1px; - position: absolute; - overflow: hidden; - z-index: 1; -} -table.mxWindow { - border-collapse: collapse; - table-layout: fixed; - font-family: Arial; - font-size: 8pt; -} -td.mxWindowTitle { - background: url('../images/window-title.gif') repeat-x; - text-overflow: ellipsis; - white-space: nowrap; - text-align: center; - font-weight: bold; - overflow: hidden; - height: 13px; - padding: 2px; - padding-top: 4px; - padding-bottom: 6px; - color: black; -} -td.mxWindowPane { - vertical-align: top; - padding: 0px; -} -div.mxWindowPane { - overflow: hidden; -} -td.mxWindowPane td { - font-family: Arial; - font-size: 8pt; -} -td.mxWindowPane input, td.mxWindowPane select, td.mxWindowPane textarea, td.mxWindowPane radio { - border-color: #8C8C8C; - border-style: solid; - border-width: 1px; - font-family: Arial; - font-size: 8pt; - padding: 1px; -} -td.mxWindowPane button { - background: url('../images/button.gif') repeat-x; - font-family: Arial; - font-size: 8pt; - padding: 2px; - float: left; -} -img.mxToolbarItem { - margin-right: 6px; - margin-bottom: 6px; - border-width: 1px; -} -select.mxToolbarCombo { - vertical-align: top; - border-style: inset; - border-width: 2px; -} -div.mxToolbarComboContainer { - padding: 2px; -} -img.mxToolbarMode { - margin: 2px; - margin-right: 4px; - margin-bottom: 4px; - border-width: 0px; -} -img.mxToolbarModeSelected { - margin: 0px; - margin-right: 2px; - margin-bottom: 2px; - border-width: 2px; - border-style: inset; -} -div.mxTooltip { - -webkit-box-shadow: 3px 3px 12px #C0C0C0; - -moz-box-shadow: 3px 3px 12px #C0C0C0; - box-shadow: 3px 3px 12px #C0C0C0; - background: #FFFFCC; - border-style: solid; - border-width: 1px; - border-color: black; - font-family: Arial; - font-size: 8pt; - position: absolute; - cursor: default; - padding: 4px; - color: black; -} -div.mxPopupMenu { - -webkit-box-shadow: 3px 3px 12px #C0C0C0; - -moz-box-shadow: 3px 3px 12px #C0C0C0; - box-shadow: 3px 3px 12px #C0C0C0; - background: url('../images/window.gif'); - position: absolute; - border-style: solid; - border-width: 1px; - border-color: black; - cursor: default; -} -table.mxPopupMenu { - border-collapse: collapse; - margin-top: 1px; - margin-bottom: 1px; -} -tr.mxPopupMenuItem { - color: black; - cursor: default; -} -td.mxPopupMenuItem.disabled { - opacity: 0.2; -} -td.mxPopupMenuItem.disabled { - _filter:alpha(opacity=20) !important; -} -tr.mxPopupMenuItemHover { - background-color: #000066; - color: #FFFFFF; -} -td.mxPopupMenuItem { - padding: 2px 30px 2px 10px; - white-space: nowrap; - font-family: Arial; - font-size: 8pt; -} -td.mxPopupMenuIcon { - background-color: #D0D0D0; - padding: 2px 4px 2px 4px; -} - -/* Properties window - Start */ - -#contentProperties { - border-style: solid; - border-width: 1px; - margin:10px 10px 10px 10px; -} - -#headingProperties { - padding-left:2pc; -} - -#resetButtonProperties{ - float:right; -} - -#formProperties { - margin-right:2pc; - margin-left:2pc; - margin-bottom:2pc; -} - -#colorProperties { - border-style: solid; - border-width: 1px; - margin:10px 10px 10px 10px; -} - -.fieldInput { - float: right; -} - -#descriptionSetContext { - font-size: 14px; -} - -#textareaSetContext { - width:380px; - height: 200px; -} - -#buttonSetContext { - margin-left: 160px; - width: 50px; -} - -.boldButton { - font-weight: bold; -} - -.italicButton { - font-style: italic; -} - -.underlineButton { - text-decoration: underline; -} diff --git a/css/explorer.css b/css/explorer.css deleted file mode 100644 index dfbbd21..0000000 --- a/css/explorer.css +++ /dev/null @@ -1,15 +0,0 @@ -div.mxTooltip { - filter:progid:DXImageTransform.Microsoft.DropShadow(OffX=4, OffY=4, - Color='#A2A2A2', Positive='true') -} -div.mxPopupMenu { - filter:progid:DXImageTransform.Microsoft.DropShadow(OffX=4, OffY=4, - Color='#C0C0C0', Positive='true') -} -div.mxWindow { - filter:progid:DXImageTransform.Microsoft.DropShadow(OffX=4, OffY=4, - Color='#C0C0C0', Positive='true') -} -td.mxWindowTitle { - _height: 23px; -} diff --git a/data_structures_correct/ABS_VALUE.js b/data_structures_correct/ABS_VALUE.js deleted file mode 100644 index bf0b6fb..0000000 --- a/data_structures_correct/ABS_VALUE.js +++ /dev/null @@ -1,29 +0,0 @@ -function ABS_VALUE() { - - ABS_VALUE.prototype.define = function ABS_VALUE() { - - this.nu = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["absolute_value"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.out = new ScilabDouble([this.nu]); - model.nzcross = new ScilabDouble([this.nu]); - model.nmode = new ScilabDouble([this.nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ABS_VALUE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["ABS_VALUE"]); - return new BasicBlock(this.x); - - } - - ABS_VALUE.prototype.details = function ABS_VALUE() { - return this.x; - } - -} diff --git a/data_structures_correct/AFFICH_m.js b/data_structures_correct/AFFICH_m.js deleted file mode 100644 index fe63c41..0000000 --- a/data_structures_correct/AFFICH_m.js +++ /dev/null @@ -1,33 +0,0 @@ -function AFFICH_m() { - - AFFICH_m.prototype.define = function AFFICH_m() { - this.font = 1; - this.fontsize = 1; - this.colr = 1; - this.nt = 5; - this.nd = 1; - this.in1 = [1, 1]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["affich2"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1[0]]); - model.in2 = new ScilabDouble([this.in1[1]]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [0], [0], [1], [1], [0], ...zeros(this.in1[0] * this.in1[1], 1)); - model.ipar = new ScilabDouble([this.font], [this.fontsize], [this.colr], [1000], [this.nt], [this.nd], [this.in1[0]]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - model.label = new ScilabString([""]); - var exprs = new ScilabString([sci2exp([parseFloat(...getData(model.in)), parseFloat(...getData(model.in2))])], [this.font.toString()], [this.fontsize.toString()], [this.colr.toString()], [this.nt.toString()], [this.nd.toString()], [(0).toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"AFFICH_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["AFFICH_m"]); - return new AfficheBlock(this.x); - } - - AFFICH_m.prototype.details = function AFFICH_m() { - return this.x; - } -} diff --git a/data_structures_correct/ANDBLK.js b/data_structures_correct/ANDBLK.js deleted file mode 100644 index 11ea9a0..0000000 --- a/data_structures_correct/ANDBLK.js +++ /dev/null @@ -1,130 +0,0 @@ -function ANDBLK() { - - ANDBLK.prototype.define = function ANDBLK() { - - var andlog = new ANDLOG_f().internal(); - andlog.graphics.orig = new ScilabDouble([194, 133]); - andlog.graphics.sz = new ScilabDouble([60, 60]); - andlog.graphics.flip = new ScilabBoolean([true]); - andlog.graphics.pout = new ScilabDouble([9]); - andlog.graphics.pein = new ScilabDouble([4], [11]); - andlog.model.uid = new ScilabString([count]); - andlog.doc = list(new ScilabString([count++])); - - var input_port1 = new CLKIN_f().internal(); - input_port1.graphics.orig = new ScilabDouble([149, 287]); - input_port1.graphics.sz = new ScilabDouble([20, 20]); - input_port1.graphics.flip = new ScilabBoolean([true]); - input_port1.graphics.exprs = new ScilabString(["1"]); - input_port1.graphics.peout = new ScilabDouble([4]); - input_port1.model.ipar = new ScilabDouble([1]); - input_port1.model.uid = new ScilabString([count]); - input_port1.doc = list(new ScilabString([count++])); - - var output_port = new CLKOUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([450, 83]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([8]); - output_port.model.ipar = new ScilabDouble([1]); - output_port.model.uid = new ScilabString([count]); - output_port.doc = list(new ScilabString([count++])); - - var input_port2 = new CLKIN_f().internal(); - input_port2.graphics.orig = new ScilabDouble([141, 330]); - input_port2.graphics.sz = new ScilabDouble([20, 20]); - input_port2.graphics.flip = new ScilabBoolean([true]); - input_port2.graphics.exprs = new ScilabString(["2"]); - input_port2.graphics.peout = new ScilabDouble([6]); - input_port2.model.ipar = new ScilabDouble([2]); - input_port2.model.uid = new ScilabString([count]); - input_port2.doc = list(new ScilabString([count++])); - - var ifthel = new IFTHEL_f().internal(); - ifthel.graphics.orig = new ScilabDouble([331, 137]); - ifthel.graphics.sz = new ScilabDouble([60, 60]); - ifthel.graphics.flip = new ScilabBoolean([true]); - ifthel.graphics.pin = new ScilabDouble([9]); - ifthel.graphics.pein = new ScilabDouble([12]); - ifthel.graphics.peout = new ScilabDouble([8], [0]); - ifthel.model.uid = new ScilabString([count]); - ifthel.doc = list(new ScilabString([count++])); - - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([234, 275.78348]); - split.graphics.pein = new ScilabDouble([6]); - split.graphics.peout = new ScilabDouble([11], [12]); - split.model.uid = new ScilabString([count]); - split.doc = list(new ScilabString([count++])); - - var diagram = scicos_diagram(); - diagram.objs.push(andlog); - diagram.objs.push(input_port1); - diagram.objs.push(output_port); - diagram.objs.push(input_port2); - diagram.objs.push(ifthel); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([169], [214], [214]), - yy: new ScilabDouble([297], [297], [198.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([161], [234], [234]), - yy: new ScilabDouble([340], [340], [275.78]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([351], [351], [450]), - yy: new ScilabDouble([131.29], [93], [93]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([262.57], [322.43]), - yy: new ScilabDouble([163], [167]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([234], [234]), - yy: new ScilabDouble([275.78], [198.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([1, 2, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([234], [361], [361]), - yy: new ScilabDouble([275.78], [275.78], [202.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([6, 2, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - this.x = scicos_block(); - this.x.gui = new ScilabString(["ANDBLK"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pein = new ScilabDouble([0], [0]); - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtin = new ScilabDouble([1], [1]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - return new BasicBlock(this.x); - } - ANDBLK.prototype.details = function ANDBLK() { - return this.x; - } - -} diff --git a/data_structures_correct/ANDLOG_f.js b/data_structures_correct/ANDLOG_f.js deleted file mode 100644 index a1b0c67..0000000 --- a/data_structures_correct/ANDLOG_f.js +++ /dev/null @@ -1,50 +0,0 @@ -function ANDLOG_f() { - - ANDLOG_f.prototype.internal = function ANDLOG_f() { - var model = scicos_model(); - model.sim = new ScilabString(["andlog"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); // null -> 1 - model.evtin = new ScilabDouble([-1], [-1]); // 1, 1 -> -1, -1 - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ANDLOG_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, new ScilabDouble(), gr_i); // 3 -> 80 - - // Style - block.graphics.out_implicit = new ScilabString(["E"]); - // changed - block.graphics.out_label = new ScilabString([""]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.style = new ScilabString(["ANDLOG_f"]); - return block; - } - - ANDLOG_f.prototype.define = function ANDLOG_f() { - var model = scicos_model(); - model.sim = new ScilabString(["andlog"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); // null -> 1 - model.evtin = new ScilabDouble([-1], [-1]); // 1, 1 -> -1, -1 - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ANDLOG_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, new ScilabDouble(), gr_i); // 3 -> 80 - - // Style - this.x.graphics.out_implicit = new ScilabString(["E"]); - // changed - this.x.graphics.out_label = new ScilabString([""]); - this.x.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - this.x.graphics.style = new ScilabString(["ANDLOG_f"]); - return new BasicBlock(this.x); - } - - ANDLOG_f.prototype.details = function ANDLOG() { - return this.x; - } -} diff --git a/data_structures_correct/AUTOMAT.js b/data_structures_correct/AUTOMAT.js deleted file mode 100644 index cab6287..0000000 --- a/data_structures_correct/AUTOMAT.js +++ /dev/null @@ -1,38 +0,0 @@ -function AUTOMAT() { - - AUTOMAT.prototype.define = function AUTOMAT() { - this.NMode = 2; - this.Minitial = 1; - this.NX = 1; - this.X0 = [0.0]; - this.XP = [[1],[1]]; - this.C1 = [2]; - this.C2 = [1]; - - var exprs = new ScilabString([this.NMode.toString()], [this.Minitial.toString()], [this.NX.toString()], [sci2exp(this.X0)], [sci2exp(this.XP)], [sci2exp(this.C1)], [sci2exp(this.C2)]); - var ipar = new ScilabDouble([this.NMode], [this.Minitial], [this.NX], ...this.XP, this.C1, this.C2); - var rpar = new ScilabDouble(this.X0); - - var model = scicos_model(); - model.sim = list(new ScilabString(["automat"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([2 * this.NX + 1], [2 * this.NX + 1]); - model.out = new ScilabDouble([2], [2 * this.NX]); - model.state = new ScilabDouble(...ones(2 * this.NX, 1)); - model.nzcross = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.evtout = new ScilabDouble([1]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, true]); - model.ipar = ipar; - model.rpar = rpar; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"AUTOMAT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - - } - - AUTOMAT.prototype.details = function AUTOMAT() { - return this.x; - } -} diff --git a/data_structures_correct/BACKLASH.js b/data_structures_correct/BACKLASH.js deleted file mode 100644 index 6ea6f08..0000000 --- a/data_structures_correct/BACKLASH.js +++ /dev/null @@ -1,21 +0,0 @@ -function BACKLASH() { - BACKLASH.prototype.define = function BACKLASH() { - - var exprs = new ScilabString(["0"], ["1"], ["1"]); - var model = scicos_model(); - model.sim = list(new ScilabString(["backlash"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [1]); - model.nzcross = new ScilabDouble([2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BACKLASH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x) - } - BACKLASH.prototype.details = function BACKLASH() { - return this.x; - } -} diff --git a/data_structures_correct/BARXY.js b/data_structures_correct/BARXY.js deleted file mode 100644 index a7ca0f1..0000000 --- a/data_structures_correct/BARXY.js +++ /dev/null @@ -1,30 +0,0 @@ -function BARXY() { - - BARXY.prototype.define = function BARXY() { - - var model = scicos_model(); - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - - model.sim = list(new ScilabString(["BARXY_sim"]), new ScilabDouble([5])); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.in = new ScilabDouble([-1], [-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([1]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], []); - this.x.graphics.in_implicit = new ScilabString(["E", , "E"]); - this.x.graphics.out_implicit = new ScilabDouble(); - this.x.graphics.exprs = new ScilabString(["-15"], ["15"], ["-15"], ["15"], ["1"]); - return new BasicBlock(this.x); - } - BARXY.prototype.details = function BARXY() { - return this.x; - } - -} diff --git a/data_structures_correct/BIGSOM_f.js b/data_structures_correct/BIGSOM_f.js deleted file mode 100644 index 1b896a1..0000000 --- a/data_structures_correct/BIGSOM_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function BIGSOM_f() { - - BIGSOM_f.prototype.define = function BIGSOM_f() { - this.sgn = [[1],[1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["sum"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BIGSOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["BIGSOM_f"]); - return new BigSom(this.x); - } - BIGSOM_f.prototype.details = function BIGSOM_f() { - return this.x; - } -} diff --git a/data_structures_correct/BITCLEAR.js b/data_structures_correct/BITCLEAR.js deleted file mode 100644 index 46ec643..0000000 --- a/data_structures_correct/BITCLEAR.js +++ /dev/null @@ -1,23 +0,0 @@ -function BITCLEAR() { - BITCLEAR.prototype.define = function BITCLEAR() { - var model = scicos_model(); - model.sim = list(new ScilabString(["bit_clear_32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar = list(int32([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BITCLEAR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - BITCLEAR.prototype.details = function BITCLEAR() { - return this.x; - } -} diff --git a/data_structures_correct/BITSET.js b/data_structures_correct/BITSET.js deleted file mode 100644 index bec08ff..0000000 --- a/data_structures_correct/BITSET.js +++ /dev/null @@ -1,24 +0,0 @@ -function BITSET() { - - BITSET.prototype.define = function BITSET() { - var model = scicos_model(); - model.sim = list(new ScilabString(["bit_set_32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar = list(uint32([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BITSET\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - BITSET.prototype.details = function BITSET() { - return this.x; - } -} diff --git a/data_structures_correct/BOUNCE.js b/data_structures_correct/BOUNCE.js deleted file mode 100644 index e63b241..0000000 --- a/data_structures_correct/BOUNCE.js +++ /dev/null @@ -1,51 +0,0 @@ -function BOUNCE() { - - BOUNCE.prototype.define = function BOUNCE() { - this.n = 2; - - this.k = 0; - this.ipar = []; - - for (var i = 1; i <= this.n; i++) { - for (var j = i + 1; j <= this.n; j++) { - this.ipar[this.k] = [i]; - this.k++; - this.ipar[this.k] = [j]; - this.k++; - } - } - - this.walls = [[0],[5],[0],[5]]; - this.x1 = [[2],[2.5]]; - this.xd = [[0],[0]]; - this.y1 = [[3],[5]]; - this.yd = [[0],[0]]; - this.g = 9.81; - this.C = 0; - this.rpar1 = ones(this.n, 1); - this.rpar2 = this.rpar1; - this.state = [...math.transpose(this.x1), ...math.transpose(this.xd), ...math.transpose(this.y1), ...math.transpose(this.yd)]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bounce_ball"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.n], [this.n]); - model.state = new ScilabDouble(...colon_operator(this.state)); - model.rpar = new ScilabDouble(...this.rpar1, ...this.rpar2, ...this.walls, [this.g], [this.C]); - model.ipar = new ScilabDouble(...this.ipar); - model.nzcross = new ScilabDouble([this.n * (this.n - 1) / 2 + 4 * this.n]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.rpar1)], [sci2exp(this.rpar2)], [sci2exp(this.walls)], [sci2exp(this.x1)], [sci2exp(this.xd)], [sci2exp(this.y1)], [sci2exp(this.yd)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - - return new BasicBlock(this.x); - } - - BOUNCE.prototype.details = function BOUNCE() { - - return this.x; - } -} diff --git a/data_structures_correct/BOUNCEXY.js b/data_structures_correct/BOUNCEXY.js deleted file mode 100644 index 1fa2ff2..0000000 --- a/data_structures_correct/BOUNCEXY.js +++ /dev/null @@ -1,50 +0,0 @@ -function BOUNCEXY() { - - BOUNCEXY.prototype.define = function BOUNCEXY() { - this.win = -1; - this.imode = 1; - this.clrs = [[1],[2]]; - this.siz = [[1],[1]]; - this.xmin = -5; - this.xmax = 5; - this.ymin = 0; - this.ymax = 15; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bouncexy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - - - this.z = []; - - for (var i = 0; i < size(this.clrs, "*"); i++) { - this.z[6 * (i) + 0] = [0]; - this.z[6 * (i) + 1] = [0]; - this.z[6 * (i) + 2] = [2 * this.siz[i]]; - this.z[6 * (i) + 3] = [2 * this.siz[i]]; - this.z[6 * (i) + 4] = [0.000]; - this.z[6 * (i) + 5] = [64.0 * 360.000]; - - } - - model.dstate = new ScilabDouble(...this.z); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [this.imode], ...colon_operator(this.clrs)); - model.blocktype = new ScilabString("d"); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.clrs)], [sci2exp(this.siz)], [sci2exp(this.win)], [sci2exp(1)], [sci2exp(this.xmin)], [sci2exp(this.xmax)], [sci2exp(this.ymin)], [sci2exp(this.ymax)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCEXY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - BOUNCEXY.prototype.details = function BOUNCEXY() { - - return this.x; - } -} diff --git a/data_structures_correct/BPLATFORM.js b/data_structures_correct/BPLATFORM.js deleted file mode 100644 index 2470bc1..0000000 --- a/data_structures_correct/BPLATFORM.js +++ /dev/null @@ -1,34 +0,0 @@ -function BPLATFORM() { - - BPLATFORM.prototype.define = function BPLATFORM() { - - this.plen = 2; - this.csiz = 2; - this.phi = 0; - this.xmin = -5; - this.xmax = 5; - this.ymin = 0; - this.ymax = 15; - - var model = scicos_model(); - model.sim = list(new ScilabString(["bplatform2"]), new ScilabDouble([5])); - model.in = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.plen], [this.csiz], [this.phi], [this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.plen], [this.csiz], [this.phi], [this.xmin], [this.xmax], [this.ymin], [this.ymax]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BPLATFORM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - BPLATFORM.prototype.details = function BPLATFORM() { - - return this.x; - } - -} diff --git a/data_structures_correct/Bache.js b/data_structures_correct/Bache.js deleted file mode 100644 index a4ecf43..0000000 --- a/data_structures_correct/Bache.js +++ /dev/null @@ -1,46 +0,0 @@ -function Bache() { - - Bache.prototype.define = function Bache() { - this.in1 = 2; - this.out = 3; - - var model = scicos_model(); - model.in = new ScilabDouble(math.transpose(math.range(-1, -this.in1, -1, true))); - model.out = new ScilabDouble(math.transpose(math.range(-1, -this.out, -1, true))); - - this.Patm = 1.013E5; - this.A = 1; - this.ze1 = 40; - this.ze2 = 0; - this.zs1 = 40; - this.zs2 = 0; - this.z0 = 30; - this.T0 = 290; - this.p_rho = 0; - - model.rpar = new ScilabDouble([this.Patm], [this.A], [this.ze1], [this.ze2], [this.zs1], [this.zs2], [this.z0], [this.T0], [this.p_rho]); - model.sim = new ScilabString(["Bache"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Bache"]); - mo.inputs = new ScilabString(["Ce1", "Ce2"]); - mo.outputs = new ScilabString(["Cs1", "Cs2", "yNiveau"]); - mo.parameters = list(new ScilabString(["Patm"], ["A"], ["ze1"], ["ze2"], ["zs1"], ["zs2"], ["z0"], ["T0"], ["p_rho"]), new ScilabDouble([this.Patm], [this.A], [this.ze1], [this.ze2], [this.zs1], [this.zs2], [this.z0], [this.T0], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), '*'), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), '*'), 1)); - - var exprs = new ScilabString([this.Patm.toString()], [this.A.toString()], [this.ze1.toString()], [this.ze2.toString()], [this.zs1.toString()], [this.zs2.toString()], [this.z0.toString()], [this.T0.toString()], [this.p_rho.toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Bache\",sz(1),sz(2));"]); - this.x = new standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"], ["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["I"], ["E"]); - return new BasicBlock(this.x); - } - Bache.prototype.details = function Bache() { - return this.x; - } -} diff --git a/data_structures_correct/CANIMXY.js b/data_structures_correct/CANIMXY.js deleted file mode 100644 index bdb38f3..0000000 --- a/data_structures_correct/CANIMXY.js +++ /dev/null @@ -1,36 +0,0 @@ -function CANIMXY() { - - CANIMXY.prototype.define = function CANIMXY() { - this.win = -1; - this.clrs = -4; - this.N = 2; - this.siz = 1; - this.wpos = [[-1],[-1]]; - this.wdim = [[-1],[-1]]; - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["canimxy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], [this.clrs], [this.siz], [0], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs], [this.siz], [this.win], ["[]"], ["[]"], [this.xmin], [this.xmax], [this.ymin], [this.ymax], [this.N]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CANIMXY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CANIMXY.prototype.details = function CANIMXY() { - return this.x; - } -} diff --git a/data_structures_correct/CANIMXY3D.js b/data_structures_correct/CANIMXY3D.js deleted file mode 100644 index 0a319e6..0000000 --- a/data_structures_correct/CANIMXY3D.js +++ /dev/null @@ -1,39 +0,0 @@ -function CANIMXY3D() { - - CANIMXY3D.prototype.define = function CANIMXY3D() { - this.win = -1; - this.N = 2; - this.clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - this.siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - this.wpos = [[-1],[-1]]; - this.wdim = [[-1],[-1]]; - this.param3ds = [[50],[280]]; - this.vec_x = [[-15],[15]]; - this.vec_y = [[-15],[15]]; - this.vec_z = [[-15],[15]]; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["canimxy3d"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.intyp = new ScilabDouble([1], [1], [1]); - model.rpar = new ScilabDouble(...colon_operator(this.vec_x), ...colon_operator(this.vec_y), ...colon_operator(this.vec_z), ...colon_operator(this.param3ds)); - model.ipar = new ScilabDouble([this.win], [8], [this.N], ...colon_operator(this.clrs), ...colon_operator(this.siz), [8], ...colon_operator(this.wpos), ...colon_operator(this.wdim), [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs.toString().replace(/,/g, " ")], [this.siz.toString().replace(/,/g, " ")], [this.win], ["[]"], ["[]"], [this.vec_x.toString().replace(/,/g, " ")], [this.vec_y.toString().replace(/,/g, " ")], [this.vec_z.toString().replace(/,/g, " ")], [this.param3ds.toString().replace(/,/g, " ")], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CANIMXY3D\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CANIMXY3D.prototype.details = function CANIMXY3D() { - return this.x; - } - -} diff --git a/data_structures_correct/CBLOCK.js b/data_structures_correct/CBLOCK.js deleted file mode 100644 index 5acb078..0000000 --- a/data_structures_correct/CBLOCK.js +++ /dev/null @@ -1,44 +0,0 @@ -function CBLOCK() { - - CBLOCK.prototype.define = function CBLOCK() { - this.in1 = 1; - this.out = 1; - this.clkin = []; - this.clkout = []; - this.x0 = []; - this.z0 = []; - this.typ = "c"; - this.auto = []; - this.rpar = []; - this.ipar = []; - this.funam = "toto"; - this.ng = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2004])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - model.nzcross = new ScilabDouble([this.ng]); - - var label = list(new ScilabString([this.funam], ["n"], [sci2exp(this.in1)], [sci2exp(this.out)], [sci2exp(this.clkin)], [sci2exp(this.clkout)], [sci2exp(this.x0)], [sci2exp(0)], [sci2exp(this.z0)], [sci2exp(this.rpar)], [sci2exp(this.ipar)], [sci2exp(this.auto)], ["y"], ["n"]), new ScilabDouble()); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CBLOCK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x) - } - - - CBLOCK.prototype.details = function CBLOCK() { - - return this.x; - } -} diff --git a/data_structures_correct/CBLOCK4.js b/data_structures_correct/CBLOCK4.js deleted file mode 100644 index 74688d4..0000000 --- a/data_structures_correct/CBLOCK4.js +++ /dev/null @@ -1,27 +0,0 @@ -function CBLOCK4() { - - CBLOCK4.prototype.define = function CBLOCK4() { - - this.funam = "toto"; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2004])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = list(new ScilabString([this.funam], ["n"], [sci2exp([parseFloat(...getData(model.in)), parseFloat(...getData(model.in2))])], [sci2exp(parseFloat(...getData(model.intyp)))], [sci2exp([parseFloat(...getData(model.out)), parseFloat(...getData(model.out2))])], [sci2exp(parseFloat(...getData(model.outtyp)))], [sci2exp(getData(model.evtin))], [sci2exp(getData(model.evtout))], [sci2exp(getData(model.state))], [sci2exp(getData(model.dstate))], [sci2exp(model.odstate)], [sci2exp(getData(model.rpar))], [sci2exp(getData(model.ipar))], [sci2exp(model.opar)], [sci2exp(parseFloat(...getData(model.nmode)))], [sci2exp(parseFloat(...getData(model.nzcross)))], [sci2exp(getData(model.firing))], ["y"], ["n"]), new ScilabDouble()); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CBLOCK4\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - CBLOCK4.prototype.details = function CBLOCK4() { - return this.x; - } -} diff --git a/data_structures_correct/CCS.js b/data_structures_correct/CCS.js deleted file mode 100644 index d1ca10c..0000000 --- a/data_structures_correct/CCS.js +++ /dev/null @@ -1,58 +0,0 @@ -function CCS() { - - CCS.prototype.define = function CCS() { - this.ModelName = "CCS"; - this.PrametersValue = new ScilabDouble(); - this.ParametersName = new ScilabDouble(); - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2,50,1,0],[70,98,2,0],[70,2,-2,0]]; - this.PortName = [["Iin"],["p"],["n"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = this.PrametersValue; - mo.parameters = list(this.ParametersName, this.PrametersValue, new ScilabDouble(...zeros(getData(this.ParametersName)))); - var exprs = new ScilabDouble(); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CCS\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2.1, 3]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - CCS.prototype.details = function CCS() { - return this.x; - } -} diff --git a/data_structures_correct/CEVENTSCOPE.js b/data_structures_correct/CEVENTSCOPE.js deleted file mode 100644 index 390430b..0000000 --- a/data_structures_correct/CEVENTSCOPE.js +++ /dev/null @@ -1,27 +0,0 @@ -function CEVENTSCOPE() { - - CEVENTSCOPE.prototype.define = function CEVENTSCOPE() { - this.nclock = 1; - this.win = -1; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cevscpe"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.per]); - model.ipar = new ScilabDouble([this.win], [1], this.clrs[this.nclock - 1], ...this.wpos, ...this.wdim); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.nclock)], this.clrs[this.nclock - 1], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.per]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CEVENTSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CEVENTSCOPE.prototype.details = function CEVENTSCOPE() { - return this.x; - } -} diff --git a/data_structures_correct/CFSCOPE.js b/data_structures_correct/CFSCOPE.js deleted file mode 100644 index 7be1e41..0000000 --- a/data_structures_correct/CFSCOPE.js +++ /dev/null @@ -1,29 +0,0 @@ -function CFSCOPE() { - - CFSCOPE.prototype.define = function CFSCOPE() { - this.win = -1; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 2; - this.ymin = -15; - this.ymax = 15; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cfscope"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim, [1], [1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [1]); - var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CFSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8])); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80 - this.x.graphics.style = new ScilabString(["CFSCOPE"]); - return new BasicBlock(this.x); - } - CFSCOPE.prototype.details = function CFSCOPE() { - return this.x; - } -} diff --git a/data_structures_correct/CLINDUMMY_f.js b/data_structures_correct/CLINDUMMY_f.js deleted file mode 100644 index 7167f84..0000000 --- a/data_structures_correct/CLINDUMMY_f.js +++ /dev/null @@ -1,20 +0,0 @@ -function CLINDUMMY_f() { - - CLINDUMMY_f.prototype.define = function CLINDUMMY_f() { - this.x0 = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cdummy"]), new ScilabDouble([4])); - model.state = new ScilabDouble([this.x0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLINDUMMY_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - CLINDUMMY_f.prototype.details = function CLINDUMMY_f() { - return this.x; - } -} diff --git a/data_structures_correct/CLKFROM.js b/data_structures_correct/CLKFROM.js deleted file mode 100644 index eeb78b0..0000000 --- a/data_structures_correct/CLKFROM.js +++ /dev/null @@ -1,20 +0,0 @@ -function CLKFROM() { - - CLKFROM.prototype.define = function CLKFROM() { - var model = scicos_model(); - model.sim = new ScilabString(["clkfrom"]); - model.evtout = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, new ScilabString([" "])); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x); - } - CLKFROM.prototype.details = function CLKFROM() { - return this.x; - } -} \ No newline at end of file diff --git a/data_structures_correct/CLKGOTO.js b/data_structures_correct/CLKGOTO.js deleted file mode 100644 index a91514f..0000000 --- a/data_structures_correct/CLKGOTO.js +++ /dev/null @@ -1,22 +0,0 @@ -function CLKGOTO() { - - CLKGOTO.prototype.define = function CLKGOTO() { - var model = scicos_model(); - model.sim = new ScilabString(["clkgoto"]); - model.evtin = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.ipar = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, new ScilabString([" "])); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x); - } - - CLKGOTO.prototype.details = function CLKGOTO() { - return this.x; - } -} diff --git a/data_structures_correct/CLKGotoTagVisibility.js b/data_structures_correct/CLKGotoTagVisibility.js deleted file mode 100644 index d1b5553..0000000 --- a/data_structures_correct/CLKGotoTagVisibility.js +++ /dev/null @@ -1,27 +0,0 @@ -function CLKGotoTagVisibility() { - - CLKGotoTagVisibility.prototype.define = function CLKGotoTagVisibility() { - var model = scicos_model(); - model.sim = new ScilabString(["clkgototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKGotoTagVisibility\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CLKGotoTagVisibility.prototype.details = function CLKGotoTagVisibility() { - return this.x; - } -} diff --git a/data_structures_correct/CLKINV_f.js b/data_structures_correct/CLKINV_f.js deleted file mode 100644 index 70c142f..0000000 --- a/data_structures_correct/CLKINV_f.js +++ /dev/null @@ -1,42 +0,0 @@ -function CLKINV_f() { - - CLKINV_f.prototype.define = function CLKINV_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.evtout = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.prt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKINV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - return new EventInBlock(this.x); - } - CLKINV_f.prototype.internal = function CLKINV_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.evtout = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var exprs = new ScilabString([this.prt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKINV_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["CLKINV_f"]); - return block; - } - CLKINV_f.prototype.details = function CLKINV_f() { - return this.x; - } -} diff --git a/data_structures_correct/CLKOUTV_f.js b/data_structures_correct/CLKOUTV_f.js deleted file mode 100644 index 5ea67f1..0000000 --- a/data_structures_correct/CLKOUTV_f.js +++ /dev/null @@ -1,42 +0,0 @@ -function CLKOUTV_f() { - - CLKOUTV_f.prototype.define = function CLKOUTV_f() { - - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.prt]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, new ScilabString([" "])); - return new EventOutBlock(this.x); - } - - CLKOUTV_f.prototype.internal = function CLKOUTV_f() { - - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([this.prt]); - var block = new standard_define(new ScilabDouble([1, 1]), model, exprs, new ScilabString([" "])); - block.graphics.gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])); - block.graphics.style = new ScilabString(["CLKOUTV_f"]); - return block; - } - - CLKOUTV_f.prototype.details = function CLKOUTV_f() { - return this.x; - } -} diff --git a/data_structures_correct/CLKSOMV_f.js b/data_structures_correct/CLKSOMV_f.js deleted file mode 100644 index 6729647..0000000 --- a/data_structures_correct/CLKSOMV_f.js +++ /dev/null @@ -1,33 +0,0 @@ -function CLKSOMV_f() { - - CLKSOMV_f.prototype.internal = function CLKSOMV_f() { - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOMV_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return block; - } - - CLKSOMV_f.prototype.define = function CLKSOMV_f() { - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOMV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new RoundBlock(this.x); - } - CLKSOMV_f.prototype.details = function CLKSOMV_f() { - return this.x; - } -} diff --git a/data_structures_correct/CLKSOM_f.js b/data_structures_correct/CLKSOM_f.js deleted file mode 100644 index f67b2a4..0000000 --- a/data_structures_correct/CLKSOM_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function CLKSOM_f() { - - CLKSOM_f.prototype.internal = function CLKSOM_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1], [1], [1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSOM_f\",sz(1),sz(2));"]); - var block = standard_define(new ScilabDouble([1, 1]), model, [], gr_i); - block.graphics.style = new ScilabString(["CLKSOM_f"]) - return block; - } -} diff --git a/data_structures_correct/CLOCK_c.js b/data_structures_correct/CLOCK_c.js deleted file mode 100644 index b6910b2..0000000 --- a/data_structures_correct/CLOCK_c.js +++ /dev/null @@ -1,95 +0,0 @@ -function CLOCK_c() { - - CLOCK_c.prototype.get = function CLOCK_c() { - var options = { - dt: ["Period", getData(this.x.model.rpar.objs[1].model.rpar)[0]], - t0: ["Initialisation Time", getData(this.x.model.rpar.objs[1].model.firing)], - }; - return options; - } - - CLOCK_c.prototype.set = function CLOCK_c() { - this.x.model.rpar.objs[1].model.firing = new ScilabDouble([arguments[0]["t0"]]); - this.x.model.rpar.objs[1].model.rpar = new ScilabDouble([arguments[0]["dt"]], [arguments[0]["t0"]]); - this.x.model.rpar.objs[1].graphics.exprs = new ScilabString([arguments[0]["dt"]], [arguments[0]["t0"]]) - return new BasicBlock(this.x); - } - - CLOCK_c.prototype.define = function CLOCK_c() { - var evtdly = new EVTDLY_c().internal(); - evtdly.graphics.orig = new ScilabDouble([320, 232]); - evtdly.graphics.sz = new ScilabDouble([40, 40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1"], ["0.1"]); - evtdly.graphics.pein = new ScilabDouble([6]); - evtdly.graphics.peout = new ScilabDouble([3]); - evtdly.model.rpar = new ScilabDouble([0.1], [0.1]); - evtdly.model.firing = new ScilabDouble([0.1]); - - evtdly.model.uid = new ScilabString([count]); // changed - evtdly.doc = list(new ScilabString([count++])); - evtdly.model.evtin = new ScilabDouble([-1]); - evtdly.model.evtout = new ScilabDouble([-1]); - evtdly.graphics.peout = new ScilabDouble([4]); - - var output_port = new CLKOUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([399, 162]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - - output_port.model.uid = new ScilabString([count]); // changed - output_port.doc = list(new ScilabString([count++])); - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([380.71066, 172]); - split.graphics.pein = new ScilabDouble([3]); - split.graphics.peout = new ScilabDouble([5], [6]); - split.model.uid = new ScilabString([count]); - split.doc = list(new ScilabString([count++])); - split.graphics.pein = new ScilabDouble([4]); // changed - - var diagram = scicos_diagram(); - diagram.objs.push(output_port); - diagram.objs.push(evtdly); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([340], [340], [380.71]), - yy: new ScilabDouble([226.29], [172], [172]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([380.71], [399]), - yy: new ScilabDouble([172], [172]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([380.71], [380.71], [340], [340]), - yy: new ScilabDouble([172], [302], [302], [277.71]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 2, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - this.x = scicos_block(); - this.x.gui = new ScilabString(["CLOCK_c"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabString([]); - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - return new BasicBlock(this.x); - } - CLOCK_c.prototype.details = function CLOCK_c() { - return this.x; - } -} diff --git a/data_structures_correct/CLR.js b/data_structures_correct/CLR.js deleted file mode 100644 index 24d4380..0000000 --- a/data_structures_correct/CLR.js +++ /dev/null @@ -1,27 +0,0 @@ -function CLR() { - - CLR.prototype.define = function CLR() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(["1"], ["1+s"]); - var gr_i = []; - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CLR.prototype.details = function CLR() { - return this.x; - } -} diff --git a/data_structures_correct/CLSS.js b/data_structures_correct/CLSS.js deleted file mode 100644 index db5bd1b..0000000 --- a/data_structures_correct/CLSS.js +++ /dev/null @@ -1,30 +0,0 @@ -function CLSS() { - - CLSS.prototype.define = function CLSS() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([this.A], [this.B], [this.C], [this.D], [this.x0]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CLSS.prototype.details = function CLSS() { - return this.x; - } -} diff --git a/data_structures_correct/CMSCOPE.js b/data_structures_correct/CMSCOPE.js deleted file mode 100644 index 701771a..0000000 --- a/data_structures_correct/CMSCOPE.js +++ /dev/null @@ -1,73 +0,0 @@ -function CMSCOPE() { - CMSCOPE.prototype.get = function CMSCOPE() { - - var options = { - in1: ["Input ports sizes", this.in1.toString().replace(/,/g, " ")], - clrs: ["Drawing colors (>0) or mark (<0)", this.clrs.toString().replace(/,/g, " ")], - win: ["Output window number (-1 for automatic)", this.win], - wpos: ["Output window position", sci2exp([])], - wdim: ["Output window sizes", sci2exp([])], - ymin: ["Ymin vector", this.ymin.toString().replace(/,/g, " ")], - ymax: ["Ymax vector", this.ymax.toString().replace(/,/g, " ")], - per: ["Refresh period", this.per.toString().replace(/,/g, " ")], - N: ["Buffer size", this.N], - heritance: ["Accept herited events 0/1", 0], - nom: ["Name of Scope (label&Id)", ""] - }; - return options; - } - CMSCOPE.prototype.set = function CMSCOPE() { - this.in1 = inverse(arguments[0]["in1"]); - this.clrs = inverse(arguments[0]["clrs"]); - this.win = parseInt((arguments[0]["win"])); - this.ymin = inverse(arguments[0]["ymin"]); - this.ymax = inverse(arguments[0]["ymax"]); - this.per = inverse(arguments[0]["per"]); - this.N = parseInt((arguments[0]["N"])); - this.heritance = parseInt((arguments[0]["heritance"])); - this.nom = arguments[0]["nom"]; - this.yy = [...transpose(this.ymin), ...transpose(this.ymax)]; - this.period = transpose(this.per); - this.x.model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1],[this.heritance]); - this.x.model.label = new ScilabString([this.nom]); - this.x.model.evtin = new ScilabDouble(...ones(1-this.heritance,1)); - this.x.graphics.id = new ScilabString([this.nom]); - this.x.model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy)); - this.x.graphics.exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]); - return new BasicBlock(this.x); - } - CMSCOPE.prototype.define = function CMSCOPE() { - this.win = -1; - this.in1 = [[1],[1]]; - this.wdim = [[-1],[-1]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 20; - this.ymin = [[-1],[-5]]; - this.ymax = [[1],[5]]; - this.per = [[30],[30]]; - this.yy = [...transpose(this.ymin), ...transpose(this.ymax)]; - this.period = transpose(this.per); - - - var model = scicos_model(); - model.sim = list(new ScilabString(["cmscope"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], ...colon_operator(this.period), ...colon_operator(this.yy)); - model.ipar = new ScilabDouble([this.win], [this.in1.length], [this.N], ...this.wpos, ...this.wdim, ...this.in1, this.clrs[0], this.clrs[1]); - - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - var exprs = new ScilabString([this.in1.toString().replace(/,/g, " ")], [this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp([])], [this.ymin.toString().replace(/,/g, " ")], [this.ymax.toString().replace(/,/g, " ")], [this.per.toString().replace(/,/g, " ")], [this.N], [0], [""]); - var gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CMSCOPE\",sz(1),sz(2));"]), new ScilabDouble([8])); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 2 -> 80 - this.x.graphics.style = new ScilabString(["CMSCOPE"]); - return new BasicBlock(this.x); - } - CMSCOPE.prototype.details = function CMSCOPE() { - return this.x; - } -} diff --git a/data_structures_correct/CONST.js b/data_structures_correct/CONST.js deleted file mode 100644 index 4efcdc8..0000000 --- a/data_structures_correct/CONST.js +++ /dev/null @@ -1,26 +0,0 @@ -function CONST() { - - - CONST.prototype.define = function CONST() { - - this.C = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.C)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONST.prototype.details = function CONST() { - return this.x; - } -} diff --git a/data_structures_correct/CONSTRAINT2_c.js b/data_structures_correct/CONSTRAINT2_c.js deleted file mode 100644 index c853059..0000000 --- a/data_structures_correct/CONSTRAINT2_c.js +++ /dev/null @@ -1,27 +0,0 @@ -function CONSTRAINT2_c() { - - CONSTRAINT2_c.prototype.define = function CONSTRAINT2_c() { - this.x0 = 0; - this.xd0 = 0; - this.id = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["constraint_c"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [1]); - model.state = new ScilabDouble([this.x0], [this.xd0]); - model.ipar = new ScilabDouble([this.id]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = list(new ScilabString([sci2exp(this.x0)]), new ScilabString([sci2exp(this.xd0)]), new ScilabString([sci2exp(this.id)])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONSTRAINT2_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CONSTRAINT2_c.prototype.details = function CONSTRAINT2_c() { - return this.x; - } -} - diff --git a/data_structures_correct/CONSTRAINT_c.js b/data_structures_correct/CONSTRAINT_c.js deleted file mode 100644 index 88b734b..0000000 --- a/data_structures_correct/CONSTRAINT_c.js +++ /dev/null @@ -1,25 +0,0 @@ -function CONSTRAINT_c() { - - CONSTRAINT_c.prototype.define = function CONSTRAINT_c() { - - this.x0 = [[0],[0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["constraint_c"]), new ScilabDouble([10004])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.ipar = new ScilabDouble([0]); - model.state = new ScilabDouble(...this.x0); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONSTRAINT_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CONSTRAINT_c.prototype.details = function CONSTRAINT_c() { - return this.x; - } -} diff --git a/data_structures_correct/CONST_f.js b/data_structures_correct/CONST_f.js deleted file mode 100644 index 8890f0d..0000000 --- a/data_structures_correct/CONST_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function CONST_f() { - - CONST_f.prototype.define = function CONST_f() { - this.C = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cstblk"]), new ScilabDouble([1])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.C)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONST_f.prototype.details = function CONST_f() { - - return this.x; - } -} diff --git a/data_structures_correct/CONST_m.js b/data_structures_correct/CONST_m.js deleted file mode 100644 index 0d6a567..0000000 --- a/data_structures_correct/CONST_m.js +++ /dev/null @@ -1,61 +0,0 @@ -function CONST_m() { - CONST_m.prototype.get = function CONST_m() { - - var options = { - vec: ["Constant Value", this.c.toString()] - }; - return options; - } - CONST_m.prototype.set = function CONST_m() { - this.c = [parseInt(arguments[0]["vec"])]; - this.displayParameter = this.c; - this.x.model.sim = list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])); - this.x.model.opar = list(new ScilabDouble(this.c)); - this.x.model.rpar = new ScilabDouble(); - this.x.graphics.exprs = new ScilabString([sci2exp(this.c)]); - return new BasicBlock(this.x); - } - CONST_m.prototype.internal = function CONST_m() { - this.c = [1]; - var model = new scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.c.length]); - model.in2 = new ScilabDouble(); - model.out2 = new ScilabDouble([this.c.length]); - model.rpar = new ScilabDouble(this.c); - model.opar = list(); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]); - var exprs = new ScilabString([sci2exp(this.c)]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - block.graphics.style = new ScilabString(["CONST_m"]); - return block; - } - CONST_m.prototype.define = function CONST_m() { - this.c = [1]; - var model = new scicos_model(); - model.sim = list(new ScilabString(["cstblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([this.c.length]); - model.in2 = new ScilabDouble(); - model.out2 = new ScilabDouble([this.c.length]); - model.rpar = new ScilabDouble(this.c); - model.opar = list(); - model.blocktype = new ScilabString(["d"]); - this.displayParameter = [1]; - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONST_m\",sz(1),sz(2));"]); - var exprs = new ScilabString([sci2exp(this.c)]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - this.x.graphics.style = new ScilabString(["CONST_m"]); - return new BasicBlock(this.x); - } - CONST_m.prototype.details = function CONST_m() { - return this.x; - - } -} diff --git a/data_structures_correct/CONVERT.js b/data_structures_correct/CONVERT.js deleted file mode 100644 index ab56435..0000000 --- a/data_structures_correct/CONVERT.js +++ /dev/null @@ -1,31 +0,0 @@ -function CONVERT() { - - CONVERT.prototype.define = function CONVERT() { - this.sgn = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["convert"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(3)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CONVERT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - CONVERT.prototype.details = function CONVERT() { - return this.x; - - } - -} diff --git a/data_structures_correct/COSBLK_f.js b/data_structures_correct/COSBLK_f.js deleted file mode 100644 index 4e05648..0000000 --- a/data_structures_correct/COSBLK_f.js +++ /dev/null @@ -1,20 +0,0 @@ -function COSBLK_f() { - - COSBLK_f.prototype.define = function COSBLK_f() { - this.in1 = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["cosblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"COSBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - COSBLK_f.prototype.details = function COSBLK_f() { - return this.x; - } -} \ No newline at end of file diff --git a/data_structures_correct/CSCOPE.js b/data_structures_correct/CSCOPE.js deleted file mode 100644 index 87571d4..0000000 --- a/data_structures_correct/CSCOPE.js +++ /dev/null @@ -1,32 +0,0 @@ -function CSCOPE() { - - CSCOPE.prototype.define = function CSCOPE() { - this.win = -1; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - this.N = 20; - this.ymin = -15; - this.ymax = 15; - this.per = 30; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscope"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0], [this.ymin], [this.ymax], [this.per]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], ...this.clrs, ...this.wpos, ...this.wdim); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.clrs.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.ymin], [this.ymax], [this.per], [this.N], [0], [""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPE.prototype.details = function CSCOPE() { - return this.x; - } -} diff --git a/data_structures_correct/CSCOPXY.js b/data_structures_correct/CSCOPXY.js deleted file mode 100644 index d142617..0000000 --- a/data_structures_correct/CSCOPXY.js +++ /dev/null @@ -1,37 +0,0 @@ -function CSCOPXY() { - - CSCOPXY.prototype.define = function CSCOPXY() { - this.win = -1; - this.clrs = 4; - this.siz = 1; - this.wdim = [[600], [400]]; - this.wpos = [[-1], [-1]]; - this.N = 2; - this.xmin = -15; - this.xmax = 15; - this.ymin = -15; - this.ymax = 15; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscopxy"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.xmin], [this.xmax], [this.ymin], [this.ymax]); - model.ipar = new ScilabDouble([this.win], [1], [this.N], [this.clrs], [this.siz], [1], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [sci2exp(this.clrs)], [sci2exp(this.siz)], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.xmin], [this.xmax], [this.ymin], [this.ymax], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPXY.prototype.details = function CSCOPXY() { - return this.x; - } -} - diff --git a/data_structures_correct/CSCOPXY3D.js b/data_structures_correct/CSCOPXY3D.js deleted file mode 100644 index 5f389a5..0000000 --- a/data_structures_correct/CSCOPXY3D.js +++ /dev/null @@ -1,36 +0,0 @@ -function CSCOPXY3D() { - - CSCOPXY3D.prototype.define = function CSCOPXY3D() { - this.win = -1; - this.clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - this.siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - this.wdim = [[600],[400]]; - this.wpos = [[-1],[-1]]; - this.N = 2; - this.param3ds = [[50],[280]]; - this.vec_x = [[-15],[15]]; - this.vec_y = [[-15],[15]]; - this.vec_z = [[-15],[15]]; - this.nbr_curves = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["cscopxy3d"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1], [1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.intyp = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.vec_x, ...this.vec_y, ...this.vec_z, ...this.param3ds); - model.ipar = new ScilabDouble([this.win], [8], [this.N], ...this.clrs, ...this.siz, [8], ...this.wpos, ...this.wdim, [this.nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.nbr_curves], [this.clrs.toString().replace(/,/g, " ")], [this.siz.toString().replace(/,/g, " ")], [this.win], [sci2exp([])], [sci2exp(this.wdim)], [this.vec_x.toString().replace(/,/g, " ")], [this.vec_y.toString().replace(/,/g, " ")], [this.vec_z.toString().replace(/,/g, " ")], [this.param3ds.toString().replace(/,/g, " ")], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CSCOPE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - CSCOPXY3D.prototype.details = function CSCOPXY3D() { - return this.x; - } -} diff --git a/data_structures_correct/CUMSUM.js b/data_structures_correct/CUMSUM.js deleted file mode 100644 index 8e6a1ae..0000000 --- a/data_structures_correct/CUMSUM.js +++ /dev/null @@ -1,35 +0,0 @@ -function CUMSUM() { - - CUMSUM.prototype.define = function CUMSUM() { - var model = scicos_model(); - - this.function_name = "cumsum_m"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CUMSUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - CUMSUM.prototype.details = function CUMSUM() { - return this.x; - } -} diff --git a/data_structures_correct/CURV_f.js b/data_structures_correct/CURV_f.js deleted file mode 100644 index 598f49e..0000000 --- a/data_structures_correct/CURV_f.js +++ /dev/null @@ -1,27 +0,0 @@ -function CURV_f() { - - CURV_f.prototype.define = function CURV_f() { - this.xx = [[0],[1],[2]]; - this.yy = [[-5],[5],[0]]; - this.rect = [0,-5,2,5]; - this.axisdata = [[2],[10],[2],[10]]; - this.ipar = new ScilabDouble([size(this.xx, 1)], ...this.axisdata); - this.rpar = new ScilabDouble(...this.xx, ...this.yy, this.rect); - - var model = scicos_model(); - model.sim = new ScilabString(["intplt"]); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.xx, ...this.yy, ...colon_operator([this.rect])); - model.ipar = new ScilabDouble([size(this.xx, 1)], ...this.axisdata); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CURV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - CURV_f.prototype.details = function CURV_f() { - return this.x; - } -} diff --git a/data_structures_correct/CVS.js b/data_structures_correct/CVS.js deleted file mode 100644 index e671137..0000000 --- a/data_structures_correct/CVS.js +++ /dev/null @@ -1,58 +0,0 @@ -function CVS() { - - CVS.prototype.define = function CVS() { - this.ModelName = "CVS"; - this.PrametersValue = new ScilabDouble(); - this.ParametersName = new ScilabDouble(); - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2,50,1,0],[70,98,2,0],[70,2,-2,0]]; - this.PortName = [["vin"],["p"],["n"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = this.PrametersValue; - mo.parameters = list(this.ParametersName, this.PrametersValue, new ScilabDouble(...zeros(getData(this.ParametersName)))); - var exprs = new ScilabDouble(); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CVS\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2.1, 3]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - CVS.prototype.details = function CVS() { - return this.x; - } -} diff --git a/data_structures_correct/Capacitor.js b/data_structures_correct/Capacitor.js deleted file mode 100644 index 5efd0d7..0000000 --- a/data_structures_correct/Capacitor.js +++ /dev/null @@ -1,31 +0,0 @@ -function Capacitor() { - - Capacitor.prototype.define = function Capacitor() { - - var model = scicos_model(); - var C = 0.01, v = 0; - model.rpar = new ScilabDouble([C],[v]); - model.sim = new ScilabString(["Capacitor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Capacitor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["C", "v"]), list(new ScilabDouble([C]), new ScilabDouble([v])), new ScilabDouble([0, 1])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([C], [v]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Capacitor\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1.1]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Capacitor.prototype.details = function Capacitor() { - return this.x; - } -} diff --git a/data_structures_correct/ConstantVoltage.js b/data_structures_correct/ConstantVoltage.js deleted file mode 100644 index a79318a..0000000 --- a/data_structures_correct/ConstantVoltage.js +++ /dev/null @@ -1,32 +0,0 @@ -function ConstantVoltage() { - - ConstantVoltage.prototype.define = function ConstantVoltage() { - this.V = 0.01; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.V]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.sim = new ScilabString(["ConstantVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["ConstantVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["V"]), list(new ScilabDouble([this.V]))); - model.equations = mo; - - var exprs = new ScilabString([this.V]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ConstantVoltage\",sz(1),sz(2));"]); - this.x = standard_define([1.5, 1.1], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - ConstantVoltage.prototype.details = function ConstantVoltage() { - return this.x; - } -} diff --git a/data_structures_correct/Counter.js b/data_structures_correct/Counter.js deleted file mode 100644 index c884e95..0000000 --- a/data_structures_correct/Counter.js +++ /dev/null @@ -1,28 +0,0 @@ -function Counter() { - - Counter.prototype.define = function Counter() { - this.minim = 0; - this.maxim = 2; - this.rule = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["counter"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.rule], [this.maxim], [this.minim]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.minim], [this.maxim], [this.rule]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Counter\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - Counter.prototype.details = function Counter() { - return this.x; - } -} diff --git a/data_structures_correct/CurrentSensor.js b/data_structures_correct/CurrentSensor.js deleted file mode 100644 index 4559446..0000000 --- a/data_structures_correct/CurrentSensor.js +++ /dev/null @@ -1,29 +0,0 @@ -function CurrentSensor() { - - CurrentSensor.prototype.define = function CurrentSensor() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [1]); - model.sim = new ScilabString(["CurrentSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["CurrentSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"], ["i"]); - model.equations = mo; - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CurrentSensor\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 2]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["E"]); - return new BasicBlock(this.x); - } - - CurrentSensor.prototype.details = function CurrentSensor() { - return this.x; - } -} diff --git a/data_structures_correct/DEADBAND.js b/data_structures_correct/DEADBAND.js deleted file mode 100644 index 91303b3..0000000 --- a/data_structures_correct/DEADBAND.js +++ /dev/null @@ -1,27 +0,0 @@ -function DEADBAND() { - - DEADBAND.prototype.define = function DEADBAND() { - this.minp = -0.5; - this.maxp = 0.5; - this.rpar = new ScilabDouble([this.maxp], [this.minp]); - - var model = scicos_model(); - model.sim = list(new ScilabString(["deadband"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = this.rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp], [...getData(model.nmode).toString()]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEADBAND\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEADBAND.prototype.details = function DEADBAND() { - return this.x; - } -} diff --git a/data_structures_correct/DEBUG.js b/data_structures_correct/DEBUG.js deleted file mode 100644 index 886305e..0000000 --- a/data_structures_correct/DEBUG.js +++ /dev/null @@ -1,18 +0,0 @@ -function DEBUG() { - - DEBUG.prototype.define = function DEBUG() { - var model = scicos_model(); - model.sim = list(new ScilabString(["%debug_scicos"]), new ScilabDouble([99])); - model.blocktype = new ScilabString(["d"]); - - var exprs = list(new ScilabString([""]), new ScilabString(["xcos_debug_gui(flag,block);"])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEBUG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([8, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEBUG.prototype.details = function DEBUG() { - return this.x; - } -} - diff --git a/data_structures_correct/DELAYV_f.js b/data_structures_correct/DELAYV_f.js deleted file mode 100644 index 3cdfe28..0000000 --- a/data_structures_correct/DELAYV_f.js +++ /dev/null @@ -1,31 +0,0 @@ -function DELAYV_f() { - - DELAYV_f.prototype.define = function DELAYV_f() { - this.nin = 1; - this.z0 = zeros(11, 1); - this.zz0 = math.subset(this.z0, math.index(math.range(0, math.size(this.z0)[0] - 1), 0)); - this.T = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["delayv"]), new ScilabDouble([1])); - model.in = new ScilabDouble([this.nin], [1]); - model.out = new ScilabDouble([this.nin]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble(...this.z0); - model.rpar = new ScilabDouble([this.T / (size(this.zz0, "*"))]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0, -1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], [this.zz0.toString().replace(/,/g, ";")], [this.T]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DELAYV_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DELAYV_f.prototype.details = function DELAYV_f() { - return this.x; - } -} - diff --git a/data_structures_correct/DELAY_f.js b/data_structures_correct/DELAY_f.js deleted file mode 100644 index 650ac12..0000000 --- a/data_structures_correct/DELAY_f.js +++ /dev/null @@ -1,121 +0,0 @@ -function DELAY_f() { - - DELAY_f.prototype.define = function DELAY_f() { - var evtdly = new EVTDLY_f().internal(); - evtdly.graphics.orig = new ScilabDouble([243, 296]); - evtdly.graphics.sz = new ScilabDouble([40, 40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1"], ["0"]); - evtdly.graphics.pein = new ScilabDouble([10]); - evtdly.graphics.peout = new ScilabDouble([7]); - evtdly.model.rpar = new ScilabDouble([0.1]); - evtdly.model.firing = new ScilabDouble([0]); - evtdly.model.uid = new ScilabString([count]); // changed - evtdly.doc = list(new ScilabString([count++])); - evtdly.model.outtyp = new ScilabDouble(); - - var register = new REGISTER_f().internal(); - register.graphics.orig = new ScilabDouble([238, 195]); - register.graphics.sz = new ScilabDouble([50, 50]); - register.graphics.flip = new ScilabBoolean([true]); - register.graphics.exprs = new ScilabString(["0;0;0;0;0;0;0;0;0;0"]); - register.graphics.pin = new ScilabDouble([6]); - register.graphics.pout = new ScilabDouble([5]); - register.graphics.pein = new ScilabDouble([9]); - register.model.uid = new ScilabString([count]); // changed - register.doc = list(new ScilabString([count++])); - register.model.in2 = new ScilabDouble([1]); - register.model.intyp = new ScilabDouble([1]); - register.model.out2 = new ScilabDouble([1]); - - var input_port = new IN_f().internal(); - input_port.graphics.orig = new ScilabDouble([92, 210]); - input_port.graphics.sz = new ScilabDouble([20, 20]); - input_port.graphics.flip = new ScilabBoolean([true]); - input_port.graphics.exprs = new ScilabString(["1"], ["1"]); - input_port.graphics.pout = new ScilabDouble([6]); - input_port.model.ipar = new ScilabDouble([1]); - input_port.model.uid = new ScilabString([count]); // changed - input_port.doc = list(new ScilabString([count++])); - input_port.model.outtyp = new ScilabDouble([-1]); - - var output_port = new OUT_f().internal(); - output_port.graphics.orig = new ScilabDouble([440, 210]); - output_port.graphics.sz = new ScilabDouble([20, 20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"], ["1"]); - output_port.graphics.pin = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - output_port.model.uid = new ScilabString([count]); // changed - output_port.doc = list(new ScilabString([count++])); - output_port.model.outtyp = new ScilabDouble(); - - var split = new CLKSPLIT_f().internal(); - split.graphics.orig = new ScilabDouble([263, 271.2]); - split.graphics.pein = new ScilabDouble([7]); - split.graphics.peout = new ScilabDouble([9], [10]); - split.model.uid = new ScilabString([count]); // changed - split.doc = list(new ScilabString([count++])); - - var diagram = scicos_diagram(); - diagram.objs.push(input_port); - diagram.objs.push(output_port); - diagram.objs.push(register); - diagram.objs.push(evtdly); - diagram.objs.push(split); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([296.6], [440]), - yy: new ScilabDouble([220], [220]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([112], [229.4]), - yy: new ScilabDouble([220], [220]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [263]), - yy: new ScilabDouble([290.3], [271.2]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [263]), - yy: new ScilabDouble([271.2], [250.7]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([263], [308.6], [308.6], [263], [263]), - yy: new ScilabDouble([271.2], [271.2], [367], [367], [341.7]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - - this.x = scicos_block(); - this.x.gui = new ScilabString(["DELAY_f"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = diagram; - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - return new BasicBlock(this.x); - } - DELAY_f.prototype.details = function DELAY_f() { - return this.x; - } -} \ No newline at end of file diff --git a/data_structures_correct/DEMUX.js b/data_structures_correct/DEMUX.js deleted file mode 100644 index 4975c52..0000000 --- a/data_structures_correct/DEMUX.js +++ /dev/null @@ -1,28 +0,0 @@ -function DEMUX() { - - DEMUX.prototype.define = function DEMUX() { - this.out = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["multiplex"]), new ScilabDouble([4])); - model.in = new ScilabDouble([0]); - - var arr = []; - arr.push(math.range(-1, -this.out, -1, true)._data); - model.out = new ScilabDouble(...math.transpose(arr)); - model.ipar = new ScilabDouble([this.out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEMUX\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - DEMUX.prototype.details = function DEMUX() { - return this.x; - } -} diff --git a/data_structures_correct/DEMUX_f.js b/data_structures_correct/DEMUX_f.js deleted file mode 100644 index ed0f26c..0000000 --- a/data_structures_correct/DEMUX_f.js +++ /dev/null @@ -1,27 +0,0 @@ -function DEMUX_f() { - - DEMUX_f.prototype.define = function DEMUX_f() { - this.out = 2; - var arr = []; - arr.push(math.range(-1, -this.out, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["demux"]), new ScilabDouble([1])); - model.in = new ScilabDouble([0]); - model.out = new ScilabDouble(...math.transpose(arr)); - model.ipar = new ScilabDouble([this.out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DEMUX_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DEMUX_f.prototype.details = function DEMUX_f() { - return this.x; - } -} - diff --git a/data_structures_correct/DERIV.js b/data_structures_correct/DERIV.js deleted file mode 100644 index 6fc1796..0000000 --- a/data_structures_correct/DERIV.js +++ /dev/null @@ -1,20 +0,0 @@ -function DERIV() { - - DERIV.prototype.define = function DERIV() { - var model = scicos_model(); - model.sim = list(new ScilabString(["deriv"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DERIV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DERIV.prototype.details = function DERIV() { - return this.x; - } -} diff --git a/data_structures_correct/DFLIPFLOP.js b/data_structures_correct/DFLIPFLOP.js deleted file mode 100644 index d99813e..0000000 --- a/data_structures_correct/DFLIPFLOP.js +++ /dev/null @@ -1,2016 +0,0 @@ -function DFLIPFLOP() { - - DFLIPFLOP.prototype.define = function DFLIPFLOP() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["DFLIPFLOP"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["CONST_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([109.62561, 263.44465]), - sz: new ScilabDouble([20], [20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CONST_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CONST_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0])), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([239.98293, 378.2166]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["1"]), - pin: new ScilabDouble([29]), - pout: new ScilabDouble(), - pein: new ScilabDouble([22]), - peout: new ScilabDouble([16], [44]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([1]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([152.88902, 260.24498]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"], ["1"], ["5"], ["0"]), - pin: new ScilabDouble([11], [39]), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([5], [5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SAMPHOLD_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.72156, 260.24498]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["5"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([33]), - pein: new ScilabDouble([42]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SAMPHOLD_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SAMPHOLD_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([221.46044], [225.15013]), - yy: new ScilabDouble([280.24498], [280.24498]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([138.19704], [140.34523]), - yy: new ScilabDouble([273.44465], [273.49157]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([38, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([373.24106, 309.46812]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["5"], ["5"], ["0"]), - pin: new ScilabDouble([36]), - pout: new ScilabDouble([13]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([5], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([199.48466, 398.2166]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["3"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([9]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([3]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([219.48466], [222.54128]), - yy: new ScilabDouble([408.2166], [408.2166]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([8, 1, 0]), - to: new ScilabDouble([28, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([104.31759, 276.91165]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([11]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([124.31759], [144.31759]), - yy: new ScilabDouble([286.91165], [286.91165]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([457.40928, 320.20131]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([13]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([441.81249], [457.40928]), - yy: new ScilabDouble([329.46812], [330.20131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([7, 1, 0]), - to: new ScilabDouble([12, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([376.4669, 270.83282]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([37]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["Untitled"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabDouble(), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["ANDLOG_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([194, 133]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble([9]), - pein: new ScilabDouble([4], [11]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"ANDLOG_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["ANDLOG_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["andlog"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKIN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([149, 287]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKIN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKIN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([450, 83]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([169], [214], [214]), - yy: new ScilabDouble([297], [297], [198.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1]), - to: new ScilabDouble([1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKIN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([141, 330]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([6]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKIN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKIN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([161], [234], [234]), - yy: new ScilabDouble([340], [340], [275.78]), - thick: new ScilabDouble([0, 0]), - id: new ScilabString(["drawlink"]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([5, 1]), - to: new ScilabDouble([10, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([331, 137]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["1"]), - pin: new ScilabDouble([9]), - pout: new ScilabDouble(), - pein: new ScilabDouble([12]), - peout: new ScilabDouble([8], [0]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([1]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([351], [351], [450]), - yy: new ScilabDouble([131.29], [93], [93]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([7, 1]), - to: new ScilabDouble([3, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([262.57], [322.43]), - yy: new ScilabDouble([163], [167]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1]), - to: new ScilabDouble([7, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([234], [275.78348]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([6]), - peout: new ScilabDouble([11], [12]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([false, false, false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([234], [234]), - yy: new ScilabDouble([275.78], [198.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([10, 1]), - to: new ScilabDouble([1, 2]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([234], [361], [361]), - yy: new ScilabDouble([275.78], [275.78], [202.71]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([10, 2]), - to: new ScilabDouble([7, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["ANDBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.73039, 318.74407]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([19], [16]), - peout: new ScilabDouble([17]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"ANDBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["ANDBLK"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabBoolean([false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([259.98293], [260.39705]), - yy: new ScilabDouble([372.50232], [364.45835]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([15, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.73039], [253.72572]), - yy: new ScilabDouble([313.02978], [309.29537]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([15, 1, 0]), - to: new ScilabDouble([41, 1, 1]) - })); - scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["EDGE_TRIGGER", "./"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([30]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["EDGETRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([288.58631, 257.1131]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([3]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGETRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["EDGETRIGGER"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["edgetrig"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([0]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([388.28869, 247.1131]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"]), - pin: new ScilabDouble([3]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([7], [0]), - gr_i: new ScilabDouble(), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble() - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([357.15774], [362.99107], [379.71726]), - yy: new ScilabDouble([277.1131], [277.1131], [277.1131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([240.01488, 267.1131]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([260.01488], [280.01488]), - yy: new ScilabDouble([277.1131], [277.1131]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([398.28869, 181.39881]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([7]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([408.28869], [408.28869]), - yy: new ScilabDouble([241.39881], [211.39881]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["EDGE_TRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([133.90637, 385.342]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([26]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([19]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGE_TRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["EDGE_TRIGGER"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([163.90637], [163.90637], [247.06372]), - yy: new ScilabDouble([379.62771], [364.45835], [364.45835]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([18, 1, 0]), - to: new ScilabDouble([15, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([79.594811, 395.47647]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([23]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["EXTRACT_ACTIVATION", "./"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([30]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([150.65045, 143.82208]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([3], [4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1, -1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSOMV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([169.82143, 96.146231]), - sz: new ScilabDouble([16.666667, 16.666667]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([3], [4], [0]), - peout: new ScilabDouble([8]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSOMV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSOMV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["sum"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1], [1], [1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([170.65045], [170.65045], [150.04302], [150.04302], [169.82143]), - yy: new ScilabDouble([138.10779], [128.235], [128.235], [104.47956], [104.47956]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([190.65045], [190.65045], [178.15476]), - yy: new ScilabDouble([138.10779], [111.55729], [112.8129]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([102.07902, 163.82208]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([122.07902], [142.07902]), - yy: new ScilabDouble([173.82208], [173.82208]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([168.15476, 38.527183]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([178.15476], [178.15476]), - yy: new ScilabDouble([98.527183], [68.527183]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["Extract_Activation"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([239.82193, 456.57677]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([31]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([22]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"Extract_Activation",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["Extract_Activation"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.82193], [269.98293]), - yy: new ScilabDouble([450.86248], [443.93089]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([21, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([99.594811], [110.25582]), - yy: new ScilabDouble([405.47647], [405.42077]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([20, 1, 0]), - to: new ScilabDouble([25, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SUM_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([200.5252, 469.13173]), - sz: new ScilabDouble([16.666667, 16.666667]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([27], [0], [30]), - pout: new ScilabDouble([31]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SUM_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SUM_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["plusblk"]), new ScilabDouble([2])), - in: new ScilabDouble([-1], [-1], [-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([110.25582], [405.42077]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([23]), - pout: new ScilabDouble([26], [27]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([110.25582], [114.33667], [125.33494]), - yy: new ScilabDouble([405.42077], [405.39945], [405.342]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([25, 1, 0]), - to: new ScilabDouble([18, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([110.25582], [110.25582], [208.85853]), - yy: new ScilabDouble([405.42077], [469.13173], [469.13173]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([25, 2, 0]), - to: new ScilabDouble([24, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([222.54128], [408.2166]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([9]), - pout: new ScilabDouble([29], [30]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([222.54128], [231.4115]), - yy: new ScilabDouble([408.2166], [408.2166]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([28, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([222.54128], [222.54128], [208.85853], [208.85853]), - yy: new ScilabDouble([408.2166], [453.0015], [453.0015], [485.7984]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([28, 2, 0]), - to: new ScilabDouble([24, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([219.57282], [231.2505]), - yy: new ScilabDouble([477.46506], [476.57677]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([24, 1, 0]), - to: new ScilabDouble([21, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SELECT_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([298.86371, 253.57321]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["5"], ["2"], ["1"]), - pin: new ScilabDouble([33], [40]), - pout: new ScilabDouble([34]), - pein: new ScilabDouble([43], [44]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SELECT_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SELECT_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["selector_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([5], [5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([1]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([282.29299], [290.29229]), - yy: new ScilabDouble([280.24498], [280.23987]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([32, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.43514], [357.57328], [357.57328]), - yy: new ScilabDouble([273.57321], [273.57321], [280.83282]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([32, 1, 0]), - to: new ScilabDouble([35, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([357.57328, 280.83282]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([34]), - pout: new ScilabDouble([36], [37]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([357.57328], [357.57328], [364.66964]), - yy: new ScilabDouble([280.83282], [329.46812], [329.46812]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([35, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([357.57328], [376.4669]), - yy: new ScilabDouble([280.83282], [280.83282]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([35, 2, 0]), - to: new ScilabDouble([14, 1, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([140.34523], [273.49157]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([6]), - pout: new ScilabDouble([39], [40]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([140.34523], [144.31759]), - yy: new ScilabDouble([273.49157], [273.57832]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([38, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([140.34523], [140.34523], [290.29229], [290.29229]), - yy: new ScilabDouble([273.49157], [247.70767], [247.70767], [266.90654]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([38, 2, 0]), - to: new ScilabDouble([32, 2, 1]) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([253.72572], [309.29537]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([17]), - peout: new ScilabDouble([42], [43]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([false, false, false]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.72572], [253.72156]), - yy: new ScilabDouble([309.29537], [305.95927]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([41, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.72572], [312.19705], [312.19705]), - yy: new ScilabDouble([309.29537], [309.29537], [299.28749]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([41, 2, 0]), - to: new ScilabDouble([32, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([279.98293], [279.98293], [325.53038], [325.53038]), - yy: new ScilabDouble([372.50232], [315.89455], [315.89455], [299.28749]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 2, 0]), - to: new ScilabDouble([32, 2, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1], [1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, 1, 1]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = []; - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - DFLIPFLOP.prototype.details = function DFLIPFLOP() { - return this.x; - } -} diff --git a/data_structures_correct/DIFF_f.js b/data_structures_correct/DIFF_f.js deleted file mode 100644 index d4da04b..0000000 --- a/data_structures_correct/DIFF_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function DIFF_f() { - - DIFF_f.prototype.define = function DIFF_f() { - this.x0 = [[0], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["diffblk"]), new ScilabDouble([10001])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble(...this.x0); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.x0[0])], [sci2exp(this.x0[1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DIFF_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DIFF_f.prototype.details = function DIFF_f() { - return this.x; - } -} - diff --git a/data_structures_correct/DLATCH.js b/data_structures_correct/DLATCH.js deleted file mode 100644 index 9da0de4..0000000 --- a/data_structures_correct/DLATCH.js +++ /dev/null @@ -1,609 +0,0 @@ -function DLATCH() { - - DLATCH.prototype.define = function DLATCH() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["DLATCH"]), - tol: new ScilabDouble([0.0001], [0.000001], [1.000E-10], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.80])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["CONST_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([109.62561, 263.44465]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([7]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CONST_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CONST_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0])), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.37693, 320.30536]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["1"]), - pin: new ScilabDouble([13]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([6], [0]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1], [-1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([1]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([152.88902, 260.24498]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"], ["1"], ["5"], ["0"]), - pin: new ScilabDouble([15], [7]), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([5], [5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SAMPHOLD_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.72156, 260.24498]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["5"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([9]), - pein: new ScilabDouble([6]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SAMPHOLD_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SAMPHOLD_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([317.46698, 309.46812]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["5"], ["5"], ["0"]), - pin: new ScilabDouble([11]), - pout: new ScilabDouble([17]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([5], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([305.09603, 280.83282]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([9]), - pout: new ScilabDouble([11], [19], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([184.8055, 340.30536]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([13]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([104.31759, 276.91165]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([15]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([406.03841, 319.46812]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([17]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([325.09603, 270.83282]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([19]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([221.46044], [225.15013]), - yy: new ScilabDouble([280.24498], [280.24498]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([253.37693], [253.72156]), - yy: new ScilabDouble([314.59108], [305.95927]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([138.19704], [144.31759]), - yy: new ScilabDouble([273.44465], [273.57832]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([282.29299], [305.09603], [305.09603]), - yy: new ScilabDouble([280.24498], [280.52797], [280.83282]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([10, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([305.09603], [305.09603], [308.89555]), - yy: new ScilabDouble([280.83282], [329.46812], [329.46812]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 1, 0]), - to: new ScilabDouble([8, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([204.8055], [224.8055]), - yy: new ScilabDouble([350.30536], [350.30536]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([12, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([124.31759], [144.31759]), - yy: new ScilabDouble([286.91165], [286.91165]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([14, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([386.03841], [406.03841]), - yy: new ScilabDouble([329.46812], [329.46812]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([8, 1, 0]), - to: new ScilabDouble([16, 1, 1]) - - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([305.09603], [325.09603]), - yy: new ScilabDouble([280.83282], [280.83282]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 2, 0]), - to: new ScilabDouble([18, 1, 1]) - - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, -1]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = new ScilabDouble(); - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - DLATCH.prototype.details = function DLATCH() { - return this.x; - } -} diff --git a/data_structures_correct/DLR.js b/data_structures_correct/DLR.js deleted file mode 100644 index 5a3f557..0000000 --- a/data_structures_correct/DLR.js +++ /dev/null @@ -1,30 +0,0 @@ -function DLR() { - - DLR.prototype.define = function DLR() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dsslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["1"], ["1+z"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLR.prototype.details = function DLR() { - return this.x; - } -} - diff --git a/data_structures_correct/DLRADAPT_f.js b/data_structures_correct/DLRADAPT_f.js deleted file mode 100644 index 8b68940..0000000 --- a/data_structures_correct/DLRADAPT_f.js +++ /dev/null @@ -1,32 +0,0 @@ -function DLRADAPT_f() { - - DLRADAPT_f.prototype.define = function DLRADAPT_f() { - this.p = [[0], [1]]; - this.rn = []; - this.rd = [[math.complex(0.2, 0.8), math.complex(0.2, -0.8)], [math.complex(0.3, 0.7), math.complex(0.3, -0.7)]]; - this.g = [[1], [1]]; - this.last_u = []; - this.last_y = [[0], [0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["dlradp"]); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble(...this.last_y); - model.rpar = new ScilabDouble(...this.p, ...real(colon_operator(this.rd)), ...math.im(colon_operator(this.rd)), ...this.g); - model.ipar = new ScilabDouble([0], [2], [2]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.p)], [sci2exp(this.rn)], [sci2exp(this.rd, 0)], [sci2exp(this.g)], [sci2exp(this.last_u)], [sci2exp(this.last_y)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLRADAPT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLRADAPT_f.prototype.details = function DLRADAPT_f() { - return this.x; - } -} diff --git a/data_structures_correct/DLSS.js b/data_structures_correct/DLSS.js deleted file mode 100644 index 39a6aaf..0000000 --- a/data_structures_correct/DLSS.js +++ /dev/null @@ -1,30 +0,0 @@ -function DLSS() { - - DLSS.prototype.define = function DLSS() { - this.x0 = 0; - this.A = -1; - this.B = 1; - this.C = 1; - this.D = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dsslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.A)], [sci2exp(this.B)], [sci2exp(this.C)], [sci2exp(this.D)], [sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DLSS.prototype.details = function DLSS() { - return this.x; - } -} - diff --git a/data_structures_correct/DOLLAR.js b/data_structures_correct/DOLLAR.js deleted file mode 100644 index 5e6dffb..0000000 --- a/data_structures_correct/DOLLAR.js +++ /dev/null @@ -1,27 +0,0 @@ -function DOLLAR() { - - DOLLAR.prototype.define = function DOLLAR() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR.prototype.details = function DOLLAR() { - return this.x; - } -} - diff --git a/data_structures_correct/DOLLAR_f.js b/data_structures_correct/DOLLAR_f.js deleted file mode 100644 index d4625b7..0000000 --- a/data_structures_correct/DOLLAR_f.js +++ /dev/null @@ -1,27 +0,0 @@ -function DOLLAR_f() { - - DOLLAR_f.prototype.define = function DOLLAR_f() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["dollar"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR_f.prototype.details = function DOLLAR_f() { - return this.x; - } -} - diff --git a/data_structures_correct/DOLLAR_m.js b/data_structures_correct/DOLLAR_m.js deleted file mode 100644 index d39a88f..0000000 --- a/data_structures_correct/DOLLAR_m.js +++ /dev/null @@ -1,27 +0,0 @@ -function DOLLAR_m() { - - DOLLAR_m.prototype.define = function DOLLAR_m() { - this.z = 0; - this.inh = 0; - this.in1 = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1 - this.inh]); - model.dstate = new ScilabDouble([this.z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.z], [this.inh]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - DOLLAR_m.prototype.details = function DOLLAR_m() { - return this.x; - } -} - diff --git a/data_structures_correct/Diode.js b/data_structures_correct/Diode.js deleted file mode 100644 index 8245635..0000000 --- a/data_structures_correct/Diode.js +++ /dev/null @@ -1,36 +0,0 @@ -function Diode() { - - Diode.prototype.define = function Diode() { - - this.Ids = 1.e-6; - this.Vt = 0.04; - this.Maxexp = 15; - this.R = 1.e8; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.Ids], [this.Vt], [this.Maxexp], [this.R]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.sim = new ScilabString(["Diode"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Diode"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["Ids", "Vt", "Maxexp", "R"]), list(new ScilabDouble([this.Ids]), new ScilabDouble([this.Vt]), new ScilabDouble([this.Maxexp]), new ScilabDouble([this.R]))); - model.equations = mo; - - var exprs = new ScilabString([this.Ids], [this.Vt], [this.Maxexp], [this.R]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Diode\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 1]), model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Diode.prototype.details = function Diode() { - return this.x; - } -} diff --git a/data_structures_correct/EDGETRIGGER.js b/data_structures_correct/EDGETRIGGER.js deleted file mode 100644 index 5245267..0000000 --- a/data_structures_correct/EDGETRIGGER.js +++ /dev/null @@ -1,25 +0,0 @@ -function EDGETRIGGER() { - - EDGETRIGGER.prototype.internal = function EDGETRIGGER() { - this.edge = 1; - var model = scicos_model(); - model.sim = list(new ScilabString(["edgetrig"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.nzcross = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.edge]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.edge]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"EDGETRIGGER",sz(1),sz(2));"]); - var block = standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["EDGETRIGGER"]); - return block; - } -} diff --git a/data_structures_correct/EDGE_TRIGGER.js b/data_structures_correct/EDGE_TRIGGER.js deleted file mode 100644 index 20aa23a..0000000 --- a/data_structures_correct/EDGE_TRIGGER.js +++ /dev/null @@ -1,114 +0,0 @@ -function EDGE_TRIGGER() { - - EDGE_TRIGGER.prototype.define = function EDGE_TRIGGER() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new EDGETRIGGER().internal()); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new IN_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - var model = blk.model; - graphics.orig = new ScilabDouble([60, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"]); - graphics.in_implicit = new ScilabString(["E"]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.in_label = new ScilabString([""]); - graphics.out_label = new ScilabString([""]); - model.ipar = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([5]); - graphics.pout = new ScilabDouble([6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([160, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"], ["0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([7], [0]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([0, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([5]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([170, -60]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([7]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - var lnk = scs_m_1.objs[4]; - lnk.xx = new ScilabDouble([64], [96]); - lnk.yy = new ScilabDouble([-40], [-20]); - lnk.from = new ScilabDouble([3, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[4] = lnk; - - lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([164], [196]); - lnk.yy = new ScilabDouble([-20], [-20]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([220], [220]); - lnk.yy = new ScilabDouble([-44], [-96]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[6] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"EDGE_TRIGGER",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - EDGE_TRIGGER.prototype.details = function EDGE_TRIGGER() { - return this.x; - } -} diff --git a/data_structures_correct/ENDBLK.js b/data_structures_correct/ENDBLK.js deleted file mode 100644 index e3ca767..0000000 --- a/data_structures_correct/ENDBLK.js +++ /dev/null @@ -1,106 +0,0 @@ -function ENDBLK() { - - ENDBLK.prototype.define = function ENDBLK() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["ENDBLK"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["END_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([272.104, 249.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1.000E+08"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"END_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["END_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["scicosexit"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([1.000E+08]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([292.104], [292.104], [261.83733], [261.83733], [292.104], [292.104]), - yy: new ScilabDouble([243.40305], [234.45067], [234.45067], [305.584], [305.584], [294.83162]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"ENDBLK",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - ENDBLK.prototype.details = function ENDBLK() { - return this.x; - } -} diff --git a/data_structures_correct/END_c.js b/data_structures_correct/END_c.js deleted file mode 100644 index 37c6f21..0000000 --- a/data_structures_correct/END_c.js +++ /dev/null @@ -1,24 +0,0 @@ -function END_c() { - - END_c.prototype.define = function END_c() { - this.tf = 100000000; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scicosexit"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.firing = new ScilabDouble([this.tf]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.tf]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"END_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - END_c.prototype.details = function END_c() { - return this.x; - } -} - diff --git a/data_structures_correct/ESELECT_f.js b/data_structures_correct/ESELECT_f.js deleted file mode 100644 index dc0ab87..0000000 --- a/data_structures_correct/ESELECT_f.js +++ /dev/null @@ -1,29 +0,0 @@ -function ESELECT_f() { - - ESELECT_f.prototype.define = function ESELECT_f() { - this.out = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["eselect"]), new ScilabDouble([-2])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(...ones(this.out, 1)); - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble(...ones(this.out, 1)); - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([0]); - model.nzcross = new ScilabDouble([0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ESELECT_f\",sz(1),sz(2));"]);; - - var exprs = new ScilabString([this.out], [1], [parseInt(getData(model.nmode))]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - ESELECT_f.prototype.details = function ESELECT_f() { - return this.x; - } -} diff --git a/data_structures_correct/EVTDLY_c.js b/data_structures_correct/EVTDLY_c.js deleted file mode 100644 index 46b336c..0000000 --- a/data_structures_correct/EVTDLY_c.js +++ /dev/null @@ -1,49 +0,0 @@ -function EVTDLY_c() { - - EVTDLY_c.prototype.internal = function EVTDLY_c() { - var dt = 0.1; - var ff = 0.0; - var model = scicos_model(); - model.sim = list(new ScilabString(["evtdly4"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([dt], [ff]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([ff]); - model.dep_ut = new ScilabBoolean([false, false]); - // changed - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([dt], [ff]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_c\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3,2 -> 80 - block.graphics.style = new ScilabString(["EVTDLY_c"]); - return block; - - } - - EVTDLY_c.prototype.define = function EVTDLY_c() { - this.dt = 0.1; - this.ff = 0.0; - var model = scicos_model(); - model.sim = list(new ScilabString(["evtdly4"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.dt], [this.ff]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.ff]); - model.dep_ut = new ScilabBoolean([false, false]); - // changed - model.outtyp = new ScilabDouble(); - var exprs = new ScilabString([this.dt], [this.ff]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_c\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3,2 -> 80 - this.x.graphics.style = new ScilabString(["EVTDLY_c"]); - return new BasicBlock(this.x); - - } - - EVTDLY_c.prototype.details = function EVTDLY_c() { - - return this.x; - } -} diff --git a/data_structures_correct/EVTDLY_f.js b/data_structures_correct/EVTDLY_f.js deleted file mode 100644 index 1bb4e29..0000000 --- a/data_structures_correct/EVTDLY_f.js +++ /dev/null @@ -1,23 +0,0 @@ -function EVTDLY_f() { - - EVTDLY_f.prototype.internal = function EVTDLY_f() { - this.dt = 0.1; - this.ff = this.dt; - - var model = scicos_model(); - model.sim = new ScilabString(["evtdly"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.dt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.ff]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.dt], [sci2exp(this.ff)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTDLY_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["EVTDLY_f"]); - return block; - } -} \ No newline at end of file diff --git a/data_structures_correct/EVTGEN_f.js b/data_structures_correct/EVTGEN_f.js deleted file mode 100644 index ba7197f..0000000 --- a/data_structures_correct/EVTGEN_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function EVTGEN_f() { - - EVTGEN_f.prototype.define = function EVTGEN_f() { - this.tt = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([this.tt]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.tt]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTGEN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EVTGEN_f.prototype.details = function EVTGEN_f() { - return this.x; - } -} diff --git a/data_structures_correct/EVTVARDLY.js b/data_structures_correct/EVTVARDLY.js deleted file mode 100644 index 816c0a5..0000000 --- a/data_structures_correct/EVTVARDLY.js +++ /dev/null @@ -1,25 +0,0 @@ -function EVTVARDLY() { - - EVTVARDLY.prototype.define = function EVTVARDLY() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["evtvardly"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([parseInt(getData(model.firing), 10)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTVARDLY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EVTVARDLY.prototype.details = function EVTVARDLY() { - return this.x; - } -} - diff --git a/data_structures_correct/EXPBLK_m.js b/data_structures_correct/EXPBLK_m.js deleted file mode 100644 index b5cf28b..0000000 --- a/data_structures_correct/EXPBLK_m.js +++ /dev/null @@ -1,28 +0,0 @@ -function EXPBLK_m() { - - EXPBLK_m.prototype.define = function EXPBLK_m() { - this.in1 = 1; - this.a = math.E; - - var model = scicos_model(); - model.sim = list(new ScilabString(["expblk_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["%e"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXPBLK_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXPBLK_m.prototype.details = function EXPBLK_m() { - return this.x; - } -} diff --git a/data_structures_correct/EXTRACT.js b/data_structures_correct/EXTRACT.js deleted file mode 100644 index 387f465..0000000 --- a/data_structures_correct/EXTRACT.js +++ /dev/null @@ -1,35 +0,0 @@ -function EXTRACT() { - - EXTRACT.prototype.define = function EXTRACT() { - this.function_name = "extract"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1, 1, 1, 1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp([1])], [sci2exp([1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - EXTRACT.prototype.details = function EXTRACT() { - return this.x; - } -} - diff --git a/data_structures_correct/EXTRACTBITS.js b/data_structures_correct/EXTRACTBITS.js deleted file mode 100644 index 4f16f21..0000000 --- a/data_structures_correct/EXTRACTBITS.js +++ /dev/null @@ -1,27 +0,0 @@ -function EXTRACTBITS() { - - EXTRACTBITS.prototype.define = function EXTRACTBITS() { - this.numb = []; - - var model = scicos_model(); - model.sim = list(new ScilabString(["extract_bit_32_UH0"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.ipar = new ScilabDouble([0, ...this.numb]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(1)], [sci2exp(0)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACTBITS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXTRACTBITS.prototype.details = function EXTRACTBITS() { - return this.x; - } -} diff --git a/data_structures_correct/EXTRACTOR.js b/data_structures_correct/EXTRACTOR.js deleted file mode 100644 index c8d7a1b..0000000 --- a/data_structures_correct/EXTRACTOR.js +++ /dev/null @@ -1,24 +0,0 @@ -function EXTRACTOR() { - - EXTRACTOR.prototype.define = function EXTRACTOR() { - this.ind = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["extractor"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([this.ind]); - - var exprs = new ScilabString([sci2exp(this.ind)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTRACTOR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - EXTRACTOR.prototype.details = function EXTRACTOR() { - return this.x; - } -} - diff --git a/data_structures_correct/EXTTRI.js b/data_structures_correct/EXTTRI.js deleted file mode 100644 index 96fdb39..0000000 --- a/data_structures_correct/EXTTRI.js +++ /dev/null @@ -1,35 +0,0 @@ -function EXTTRI() { - - EXTTRI.prototype.define = function EXTTRI() { - this.function_name = "extrilz"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EXTTRI\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - EXTTRI.prototype.details = function EXTTRI() { - return this.x; - } -} - diff --git a/data_structures_correct/Extract_Activation.js b/data_structures_correct/Extract_Activation.js deleted file mode 100644 index a13fc27..0000000 --- a/data_structures_correct/Extract_Activation.js +++ /dev/null @@ -1,129 +0,0 @@ -function Extract_Activation() { - - Extract_Activation.prototype.define = function Extract_Activation() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new CLKSOMV_f().internal()); - scs_m_1.objs.push(new IN_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([80, 0]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["0"], ["0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([7]); - graphics.peout = new ScilabDouble([5], [6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - model.outtyp = new ScilabDouble(); - model.evtin = new ScilabDouble([-1], [-1], [-1]); - model.evtout = new ScilabDouble([-1]); - graphics.orig = new ScilabDouble([80, -80]); - graphics.sz = new ScilabDouble([80, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.pein = new ScilabDouble([5], [6], [0]); - graphics.peout = new ScilabDouble([8]); - graphics.style = new ScilabString(["CLKSOMV_f"]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([0, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([7]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - model.outtyp = new ScilabDouble(); - graphics.style = new ScilabString(["CLKOUTV_f"]); - graphics.orig = new ScilabDouble([110, -140]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - graphics.gr_i = list(new ScilabString(["xstringb(orig(1),orig(2),\"CLKOUTV_f\",sz(1),sz(2));"]), new ScilabDouble([8])); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - var lnk = scs_m_1.objs[4]; - lnk.xx = new ScilabDouble([140], [140]); - lnk.yy = new ScilabDouble([-44], [-76]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[4] = lnk; - - lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([160], [160]); - lnk.yy = new ScilabDouble([-44], [-76]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 2, 0]); - lnk.to = new ScilabDouble([2, 2, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([64], [116]); - lnk.yy = new ScilabDouble([-40], [-20]); - lnk.from = new ScilabDouble([3, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[6] = lnk; - - lnk = scs_m_1.objs[7]; - lnk.xx = new ScilabDouble([160], [160]); - lnk.yy = new ScilabDouble([-124], [-176]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[7] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Extract_Activation\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - Extract_Activation.prototype.details = function Extract_Activation() { - return this.x; - } -} diff --git a/data_structures_correct/FROM.js b/data_structures_correct/FROM.js deleted file mode 100644 index f6002b2..0000000 --- a/data_structures_correct/FROM.js +++ /dev/null @@ -1,29 +0,0 @@ -function FROM() { - - FROM.prototype.define = function FROM() { - - var model = scicos_model(); - model.sim = new ScilabString(["from"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x); - } - FROM.prototype.details = function FROM() { - return this.x; - } -} - diff --git a/data_structures_correct/FROMMO.js b/data_structures_correct/FROMMO.js deleted file mode 100644 index 03a6255..0000000 --- a/data_structures_correct/FROMMO.js +++ /dev/null @@ -1,33 +0,0 @@ -function FROMMO() { - - FROMMO.prototype.define = function FROMMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["frommo"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["frommo"]); - mo.outputs = new ScilabString(["n"]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROMMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - FROMMO.prototype.details = function FROMMO() { - return this.x; - } -} - diff --git a/data_structures_correct/FROMWSB.js b/data_structures_correct/FROMWSB.js deleted file mode 100644 index 8ccfebf..0000000 --- a/data_structures_correct/FROMWSB.js +++ /dev/null @@ -1,164 +0,0 @@ -function FROMWSB() { - - FROMWSB.prototype.define = function FROMWSB() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["FROMWSB"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["FROMWS_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([260.37067, 261.584]), - sz: new ScilabDouble([70, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["V"], ["1"], ["1"], ["0"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([4]), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"FROMWS_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort"]), - out_label: new ScilabString([""]), - style: new ScilabString(["FROMWS_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["fromws_c"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [-31], [1], [1], [0]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([0]), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([358.9421, 271.584]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([4]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([295.37067], [295.37067], [233.23733], [233.23733], [295.37067], [295.37067]), - yy: new ScilabDouble([255.86971], [223.45067], [223.45067], [337.85067], [337.85067], [307.29829]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([338.9421], [358.9421]), - yy: new ScilabDouble([281.584], [281.584]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"FROMWSB\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([5, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - FROMWSB.prototype.details = function FROMWSB() { - return this.x; - } -} \ No newline at end of file diff --git a/data_structures_correct/Flowmeter.js b/data_structures_correct/Flowmeter.js deleted file mode 100644 index cf27815..0000000 --- a/data_structures_correct/Flowmeter.js +++ /dev/null @@ -1,61 +0,0 @@ -function Flowmeter() { - - Flowmeter.prototype.define = function Flowmeter() { - this.ModelName = "Flowmeter"; - this.PrametersValue = 1; - this.ParametersName = "Qini"; - - var model = scicos_model(); - - this.Typein = []; - this.Typeout = []; - - this.MI = []; - this.MO = []; - this.P = [[50,105,-1,90],[0,10,2,0],[101,10,-2,0]]; - this.PortName = [["Mesure"],["C1"],["C2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble([this.PrametersValue]); - mo.parameters = list(new ScilabString([this.ParametersName]), new ScilabDouble([this.PrametersValue]), new ScilabDouble(zeros([this.ParametersName]))); - var exprs = new ScilabString(["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Flowmeter\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - Flowmeter.prototype.details = function Flowmeter() { - return this.x; - } -} diff --git a/data_structures_correct/GAINBLK.js b/data_structures_correct/GAINBLK.js deleted file mode 100644 index f4d758e..0000000 --- a/data_structures_correct/GAINBLK.js +++ /dev/null @@ -1,30 +0,0 @@ -function GAINBLK() { - - GAINBLK.prototype.define = function GAINBLK() { - this.gain = 1; - this.in1 = -1; - this.out = -1; - this.in2 = -2; - this.out2 = -2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["gainblk"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.in2 = new ScilabDouble([this.in2]); - model.out2 = new ScilabDouble([this.out2]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAINBLK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAINBLK.prototype.details = function GAINBLK() { - return this.x; - } -} - diff --git a/data_structures_correct/GAINBLK_f.js b/data_structures_correct/GAINBLK_f.js deleted file mode 100644 index 1e0ae00..0000000 --- a/data_structures_correct/GAINBLK_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function GAINBLK_f() { - - GAINBLK_f.prototype.define = function GAINBLK_f() { - this.gain = 1; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAINBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAINBLK_f.prototype.details = function GAINBLK_f() { - return this.x; - } -} - diff --git a/data_structures_correct/GAIN_f.js b/data_structures_correct/GAIN_f.js deleted file mode 100644 index b102bab..0000000 --- a/data_structures_correct/GAIN_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function GAIN_f() { - - GAIN_f.prototype.define = function GAIN_f() { - this.gain = 1; - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.gain)], [sci2exp(this.in1)], [sci2exp(this.out)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GAIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GAIN_f.prototype.details = function GAIN_f() { - return this.x; - } -} - diff --git a/data_structures_correct/GENERAL_f.js b/data_structures_correct/GENERAL_f.js deleted file mode 100644 index 10081f9..0000000 --- a/data_structures_correct/GENERAL_f.js +++ /dev/null @@ -1,29 +0,0 @@ -function GENERAL_f() { - - GENERAL_f.prototype.define = function GENERAL_f() { - var rpar = [[0],[0],[0],[0]]; - - this.in1 = 1; - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([this.in1]); - model.in = new ScilabDouble([this.in1]); - model.evtout = new ScilabDouble(...ones(this.out, 1)); - model.rpar = new ScilabDouble([0], [0], [0], [0]); - model.blocktype = new ScilabString(["z"]); - model.firing = -new ScilabDouble(...ones(this.out, 1)); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in1)], [sci2exp(this.out)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENERAL_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - GENERAL_f.prototype.details = function GENERAL_f() { - return this.x; - } -} diff --git a/data_structures_correct/GENSIN_f.js b/data_structures_correct/GENSIN_f.js deleted file mode 100644 index 66542ea..0000000 --- a/data_structures_correct/GENSIN_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function GENSIN_f() { - - GENSIN_f.prototype.define = function GENSIN_f() { - this.rpar = [[1], [1], [0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["gensin"]); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1], [1], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(this.rpar[0], this.rpar[1], this.rpar[2]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENSIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GENSIN_f.prototype.details = function GENSIN_f() { - return this.x; - } -} - diff --git a/data_structures_correct/GENSQR_f.js b/data_structures_correct/GENSQR_f.js deleted file mode 100644 index 4a48f00..0000000 --- a/data_structures_correct/GENSQR_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function GENSQR_f() { - - GENSQR_f.prototype.define = function GENSQR_f() { - this.Amplitude = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gensqr"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.Amplitude]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.Amplitude]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GENSQR_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GENSQR_f.prototype.details = function GENSQR_f() { - return this.x; - } -} diff --git a/data_structures_correct/GOTO.js b/data_structures_correct/GOTO.js deleted file mode 100644 index 7f0a421..0000000 --- a/data_structures_correct/GOTO.js +++ /dev/null @@ -1,28 +0,0 @@ -function GOTO() { - - GOTO.prototype.define = function GOTO() { - var model = scicos_model(); - model.sim = new ScilabString(["goto"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GOTO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x) - } - - GOTO.prototype.details = function GOTO() { - return this.x; - } -} diff --git a/data_structures_correct/GOTOMO.js b/data_structures_correct/GOTOMO.js deleted file mode 100644 index 244930d..0000000 --- a/data_structures_correct/GOTOMO.js +++ /dev/null @@ -1,33 +0,0 @@ -function GOTOMO() { - - GOTOMO.prototype.define = function GOTOMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["gotomo"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["gotomo"]); - mo.inputs = new ScilabString(["p"]); - - var exprs = new ScilabString(["A"], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GOTOMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 1]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - GOTOMO.prototype.details = function GOTOMO() { - return this.x; - } -} - diff --git a/data_structures_correct/GotoTagVisibility.js b/data_structures_correct/GotoTagVisibility.js deleted file mode 100644 index 61eb71c..0000000 --- a/data_structures_correct/GotoTagVisibility.js +++ /dev/null @@ -1,30 +0,0 @@ -function GotoTagVisibility() { - - GotoTagVisibility.prototype.define = function GotoTagVisibility() { - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GotoTagVisibility\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - GotoTagVisibility.prototype.details = function GotoTagVisibility() { - - return this.x; - } -} diff --git a/data_structures_correct/GotoTagVisibilityMO.js b/data_structures_correct/GotoTagVisibilityMO.js deleted file mode 100644 index 06a4356..0000000 --- a/data_structures_correct/GotoTagVisibilityMO.js +++ /dev/null @@ -1,29 +0,0 @@ -function GotoTagVisibilityMO() { - - GotoTagVisibilityMO.prototype.define = function GotoTagVisibilityMO() { - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibilitymo"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar = list(new ScilabString(["A"])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["A"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"GotoTagVisibilityMO\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - GotoTagVisibilityMO.prototype.details = function GotoTagVisibilityMO() { - return this.x; - } -} - diff --git a/data_structures_correct/Ground.js b/data_structures_correct/Ground.js deleted file mode 100644 index a725eeb..0000000 --- a/data_structures_correct/Ground.js +++ /dev/null @@ -1,30 +0,0 @@ -function Ground() { - - Ground.prototype.define = function Ground() { - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.sim = new ScilabString(["Ground"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Ground"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString([""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Ground\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([1, 1]), model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new GroundBlock(this.x); - } - - Ground.prototype.details = function Ground() { - return this.x; - } -} diff --git a/data_structures_correct/Gyrator.js b/data_structures_correct/Gyrator.js deleted file mode 100644 index bafd0d4..0000000 --- a/data_structures_correct/Gyrator.js +++ /dev/null @@ -1,57 +0,0 @@ -function Gyrator() { - - Gyrator.prototype.define = function Gyrator() { - this.ModelName = "Gyrator"; - this.PrametersValue = [[1],[1]]; - this.ParametersName = [["G1"],["G2"]]; - this.model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2.5, 90, 2, 0],[2.5, 10, 2, 0],[97.5, 90, -2, 0],[97.5, 10, -2, 0]]; - this.PortName = [["p1"],["n1"],["p2"],["n2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var model = scicos_model(); - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - console.log(this.MI); - model.rpar = new ScilabDouble(...this.PrametersValue); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...zeros(this.ParametersName))); - var exprs = new ScilabString(["1"], ["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"Gyrator",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(...this.Typein); - this.x.graphics.out_implicit = new ScilabString(...this.Typeout); - return new BasicBlock(this.x); - } - Gyrator.prototype.details = function Gyrator() { - return this.x; - } -} diff --git a/data_structures_correct/HALT_f.js b/data_structures_correct/HALT_f.js deleted file mode 100644 index 1d51549..0000000 --- a/data_structures_correct/HALT_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function HALT_f() { - - HALT_f.prototype.define = function HALT_f() { - this.n = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["hltblk"]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.n]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"HALT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - HALT_f.prototype.details = function HALT_f() { - return this.x; - } -} - diff --git a/data_structures_correct/HYSTHERESIS.js b/data_structures_correct/HYSTHERESIS.js deleted file mode 100644 index cea39de..0000000 --- a/data_structures_correct/HYSTHERESIS.js +++ /dev/null @@ -1,29 +0,0 @@ -function HYSTHERESIS() { - - HYSTHERESIS.prototype.define = function HYSTHERESIS() { - this.in1 = 1; - this.ipar = 0; - this.nzz = 2; - this.rpar = [[1], [0], [1], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["hystheresis"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.nzcross = new ScilabDouble([this.nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(...this.rpar, [Math.sign(this.nzz)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"HYSTHERESIS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - HYSTHERESIS.prototype.details = function HYSTHERESIS() { - return this.x; - } -} - diff --git a/data_structures_correct/IFTHEL_f.js b/data_structures_correct/IFTHEL_f.js deleted file mode 100644 index 95971dc..0000000 --- a/data_structures_correct/IFTHEL_f.js +++ /dev/null @@ -1,60 +0,0 @@ -function IFTHEL_f() { - - IFTHEL_f.prototype.internal = function IFTHEL_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble(); // changed - model.evtout = new ScilabDouble([-1], [-1]) // 1, 1 -> -1, -1 inverse - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble([-1], [-1]); // inverse - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IFTHEL_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(["1"], ["1"]); // value model.in, model.nmode inverse - - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3 -> 80 - block.graphics.in_implicit = new ScilabString(["E"]); - // changed - block.graphics.in_label = new ScilabString([""]); - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.style = new ScilabString(["IFTHEL_f"]); - return block; - } - - IFTHEL_f.prototype.define = function IFTHEL_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble(); // changed - model.evtout = new ScilabDouble([-1], [-1]) // 1, 1 -> -1, -1 inverse - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble([-1], [-1]); // inverse - model.dep_ut = new ScilabBoolean([true, false]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IFTHEL_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(["1"], ["1"]); // value model.in, model.nmode inverse - - this.x = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 3 -> 80 - this.x.graphics.in_implicit = new ScilabString(["E"]); - // changed - this.x.graphics.in_label = new ScilabString([""]); - this.x.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - this.x.graphics.style = new ScilabString(["IFTHEL_f"]); - return new BasicBlock(this.x); - } - - IFTHEL_f.prototype.details = function IFTHEL_f() { - return this.x; - } -} diff --git a/data_structures_correct/INIMPL_f.js b/data_structures_correct/INIMPL_f.js deleted file mode 100644 index 85bc0f2..0000000 --- a/data_structures_correct/INIMPL_f.js +++ /dev/null @@ -1,31 +0,0 @@ -function INIMPL_f() { - - INIMPL_f.prototype.define = function INIMPL_f() { - var model = scicos_model(); - model.sim = new ScilabString(["inimpl"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false, false]); - model.blocktype = new ScilabString(["c"]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PORT"]); - mo.outputs = new ScilabString(["n"]); - mo.inputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString(["1"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"INIMPL_f",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - this.implicitInBlock = new ImplicitInBlock(this.x); - this.displayParameter = [this.implicitInBlock.ordering]; - return this.implicitInBlock; - } - INIMPL_f.prototype.details = function INIMPL_f() { - return this.x; - } -} diff --git a/data_structures_correct/INTEGRAL_f.js b/data_structures_correct/INTEGRAL_f.js deleted file mode 100644 index 2bd0b45..0000000 --- a/data_structures_correct/INTEGRAL_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function INTEGRAL_f() { - - INTEGRAL_f.prototype.define = function INTEGRAL_f() { - this.x0 = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["integr"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTEGRAL_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTEGRAL_f.prototype.details = function INTEGRAL_f() { - return this.x; - } -} - diff --git a/data_structures_correct/INTEGRAL_m.js b/data_structures_correct/INTEGRAL_m.js deleted file mode 100644 index 042d5ff..0000000 --- a/data_structures_correct/INTEGRAL_m.js +++ /dev/null @@ -1,29 +0,0 @@ -function INTEGRAL_m() { - - INTEGRAL_m.prototype.define = function INTEGRAL_m() { - this.maxp = 1; - this.minp = -1; - this.rpar = []; - - var model = scicos_model(); - model.state = new ScilabDouble([0]); - model.sim = list(new ScilabString(["integral_func"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([0], [0], [0], [this.maxp], [this.minp]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTEGRAL_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTEGRAL_m.prototype.details = function INTEGRAL_m() { - return this.x; - } -} - diff --git a/data_structures_correct/INTMUL.js b/data_structures_correct/INTMUL.js deleted file mode 100644 index e24c496..0000000 --- a/data_structures_correct/INTMUL.js +++ /dev/null @@ -1,29 +0,0 @@ -function INTMUL() { - - INTMUL.prototype.define = function INTMUL() { - this.sgn = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["matmul_i32"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-2]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.out2 = new ScilabDouble([-3]); - model.intyp = new ScilabDouble([3, 3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTMUL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTMUL.prototype.details = function INTMUL() { - return this.x; - } -} - diff --git a/data_structures_correct/INTRP2BLK_f.js b/data_structures_correct/INTRP2BLK_f.js deleted file mode 100644 index 6d002ab..0000000 --- a/data_structures_correct/INTRP2BLK_f.js +++ /dev/null @@ -1,27 +0,0 @@ -function INTRP2BLK_f() { - - INTRP2BLK_f.prototype.define = function INTRP2BLK_f() { - this.a = [[0],[1]]; - this.b = [[0],[1]]; - this.c = [[0,1],[1,2]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["intrp2"]), new ScilabDouble([1])); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.a,...this.b,...colon_operator(this.c)); - model.ipar = new ScilabDouble([2], [2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.a)],[sci2exp(this.b)],[sci2exp(this.c)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INTRP2BLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INTRP2BLK_f.prototype.details = function INTRP2BLK_f() { - return this.x; - } -} - diff --git a/data_structures_correct/INTRPLBLK_f.js b/data_structures_correct/INTRPLBLK_f.js deleted file mode 100644 index 2b073e0..0000000 --- a/data_structures_correct/INTRPLBLK_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function INTRPLBLK_f() { - - INTRPLBLK_f.prototype.define = function INTRPLBLK_f() { - this.a = [[0],[1]]; - - this.b = [[0],[1]]; - - var model = scicos_model(); - model.sim = new ScilabString(["intrpl"]); - model.in = new ScilabDouble(1); - model.out = new ScilabDouble(1); - model.rpar = new ScilabDouble(...this.a, ...this.b); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = new ScilabString([sci2exp(this.a)], [sci2exp(this.b)]); - - var gr_i = ["xstringb(orig(1),orig(2),\"INTRPLBLK_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - INTRPLBLK_f.prototype.details = function INTRPLBLK_f() { - return this.x; - } -} diff --git a/data_structures_correct/INVBLK.js b/data_structures_correct/INVBLK.js deleted file mode 100644 index 34da523..0000000 --- a/data_structures_correct/INVBLK.js +++ /dev/null @@ -1,23 +0,0 @@ -function INVBLK() { - - INVBLK.prototype.define = function INVBLK() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["invblk4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"INVBLK\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - INVBLK.prototype.details = function INVBLK() { - return this.x; - } -} - diff --git a/data_structures_correct/IN_f.js b/data_structures_correct/IN_f.js deleted file mode 100644 index c269a7a..0000000 --- a/data_structures_correct/IN_f.js +++ /dev/null @@ -1,52 +0,0 @@ -function IN_f () { - - IN_f.prototype.internal = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["IN_f"]); // changed - block.graphics.out_implicit = new ScilabString(["E"]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.out_label = new ScilabString([""]); - return block; - } - - IN_f.prototype.define = function IN_f() { - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - - this.explicitInBlock = new ExplicitInBlock(this.x); - this.displayParameter = [this.explicitInBlock.ordering]; - return this.explicitInBlock; - - } - - IN_f.prototype.details = function IN_f() { - return this.x; - } -} diff --git a/data_structures_correct/ISELECT_m.js b/data_structures_correct/ISELECT_m.js deleted file mode 100644 index e2f2c10..0000000 --- a/data_structures_correct/ISELECT_m.js +++ /dev/null @@ -1,35 +0,0 @@ -function ISELECT_m() { - - ISELECT_m.prototype.define = function ISELECT_m() { - this.z0 = 1; - this.nout = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["selector_m"]), new ScilabDouble([4])); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-2], [-2]); - model.outtyp = new ScilabDouble([1]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin = new ScilabDouble(...ones(this.nout, 1)); - model.dstate = new ScilabDouble([this.z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(this.nout)], [sci2exp(this.z0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ISELECT_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - ISELECT_m.prototype.details = function ISELECT_m() { - return this.x; - } -} - diff --git a/data_structures_correct/IdealTransformer.js b/data_structures_correct/IdealTransformer.js deleted file mode 100644 index b6be14d..0000000 --- a/data_structures_correct/IdealTransformer.js +++ /dev/null @@ -1,60 +0,0 @@ -function IdealTransformer() { - - IdealTransformer.prototype.define = function IdealTransformer() { - this.ModelName = "IdealTransformer"; - this.PrametersValue = [1]; - this.ParametersName = ["N"]; - - var model = scicos_model(); - - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[2.5,90,2,0],[2.5,10,2,0],[97.5,90,-2,0],[97.5,10,-2,0]]; - this.PortName = [["p1"],["n1"],["p2"],["n2"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(this.PrametersValue); - mo.parameters = list(new ScilabString(this.ParametersName), new ScilabDouble(this.PrametersValue), new ScilabDouble(zeros(getData(this.ParametersName)))); - var exprs = new ScilabString(["1"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"IdealTransformer\",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, list(gr_i), new ScilabDouble([0])); - this.x.graphics.in_implicit = new ScilabDouble(this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(this.Typeout); - return new BasicBlock(this.x); - } - - IdealTransformer.prototype.details = function IdealTransformer() { - return this.x; - } - -} diff --git a/data_structures_correct/Inductor.js b/data_structures_correct/Inductor.js deleted file mode 100644 index ed0406f..0000000 --- a/data_structures_correct/Inductor.js +++ /dev/null @@ -1,34 +0,0 @@ -function Inductor() { - - Inductor.prototype.define = function Inductor() { - this.L = 1.0E-5; - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.L.toExponential(1)]); - model.sim = new ScilabString(["Inductor"]); - - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Inductor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["L"]), list(new ScilabDouble([this.L.toExponential(1)]))); - model.equations = mo; - - var exprs = new ScilabString([this.L]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Inductor\",sz(1),sz(2));"]); - this.x = standard_define([2, 0.9], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Inductor.prototype.details = function Inductor() { - return this.x; - } -} - diff --git a/data_structures_correct/JKFLIPFLOP.js b/data_structures_correct/JKFLIPFLOP.js deleted file mode 100644 index a16b5bd..0000000 --- a/data_structures_correct/JKFLIPFLOP.js +++ /dev/null @@ -1,897 +0,0 @@ -function JKFLIPFLOP() { - - JKFLIPFLOP.prototype.define = function JKFLIPFLOP() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["JKFLIPFLOP"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([60]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["DOLLAR_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([299.96961, 261.584]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([false]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"], ["1"]), - pin: new ScilabDouble([7]), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"DOLLAR_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["DOLLAR_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["dollar4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(int8([0])), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["EDGE_TRIGGER"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([30]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["EDGETRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([288.58631, 257.1131]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["-1"]), - pin: new ScilabDouble([5]), - pout: new ScilabDouble([3]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGETRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["EDGETRIGGER"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["edgetrig"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([0]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([-1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([1]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IFTHEL_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([388.28869, 247.1131]), - sz: new ScilabDouble([60, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"]), - pin: new ScilabDouble([3]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([7], [0]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IFTHEL_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["IFTHEL_f"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["ifthel"]), new ScilabDouble([-1])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["l"]), - firing: new ScilabDouble([-1], [-1]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([240.01488, 267.1131]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([398.28869, 181.39881]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([7]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in1: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["EDGE_TRIGGER"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([292.52452, 323.54888]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([14]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([8]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"EDGE_TRIGGER",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["EDGE_TRIGGER"]) - }), - model: scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGIC"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([302.79613, 202.52782]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["[0;1;1;1;0;0;1;0]"], ["0"]), - pin: new ScilabDouble([5], [16], [18]), - pout: new ScilabDouble([4]), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGIC",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGIC"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logic"]), new ScilabDouble([4])), - in: new ScilabDouble([1], [1], [1]), - in2: new ScilabDouble([1], [1], [1]), - intyp: new ScilabDouble([5], [5], [5]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0], [1], [1], [1], [0], [0], [1], [0])), - blocktype: new ScilabString(["c"]), - firing: new ScilabBoolean(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([368.82793, 243.45067]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([11]), - pout: new ScilabDouble([7], [20], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGICAL_OP"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([377.63217, 159.25363]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["5"], ["5"], ["0"]), - pin: new ScilabDouble([12]), - pout: new ScilabDouble([22]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGICAL_OP",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["LOGICAL_OP"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logicalop_i8"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([5], [0]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([368.82793, 223.06473]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([4]), - pout: new ScilabDouble([11], [12], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([243.95309, 333.54888]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([14]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([254.2247, 212.52782]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([16]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([254.2247, 202.52782]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["3"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([18]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([3]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([388.82793, 233.45067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([20]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([466.2036, 169.25363]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([22]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([357.15774], [362.99107], [379.71726]), - yy: new ScilabDouble([277.1131], [277.1131], [277.1131]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([260.01488], [280.01488]), - yy: new ScilabDouble([277.1131], [277.1131]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([408.28869], [408.28869]), - yy: new ScilabDouble([241.39881], [211.39881]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([351.36756], [368.82793], [368.82793]), - yy: new ScilabDouble([222.52782], [222.52782], [223.06473]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([10, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([291.39818], [274.18235], [274.18235], [294.2247]), - yy: new ScilabDouble([281.584], [281.584], [232.52782], [232.52782]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([368.82793], [368.82793], [345.68389]), - yy: new ScilabDouble([243.45067], [281.584], [281.584]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([322.52452], [374.69743], [374.69743], [322.79613]), - yy: new ScilabDouble([317.8346], [317.8346], [248.24211], [248.24211]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([368.82793], [368.82793]), - yy: new ScilabDouble([223.06473], [243.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([368.82793], [368.82793], [369.06074]), - yy: new ScilabDouble([223.06473], [177.7867], [179.25363]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([10, 2, 0]), - to: new ScilabDouble([9, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([263.95309], [283.95309]), - yy: new ScilabDouble([343.54888], [343.54888]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([13, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([274.2247], [294.2247]), - yy: new ScilabDouble([222.52782], [222.52782]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([15, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([274.2247], [294.2247]), - yy: new ScilabDouble([212.52782], [212.52782]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([17, 1, 0]), - to: new ScilabDouble([3, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([368.82793], [388.82793]), - yy: new ScilabDouble([243.45067], [243.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([6, 2, 0]), - to: new ScilabDouble([19, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([446.2036], [466.2036]), - yy: new ScilabDouble([179.25363], [179.25363]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([9, 1, 0]), - to: new ScilabDouble([21, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1], [1]); - model.in2 = new ScilabDouble([1], [1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, 1, 5]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = new ScilabDouble(); - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - JKFLIPFLOP.prototype.details = function JKFLIPFLOP() { - return this.x; - } -} diff --git a/data_structures_correct/LOGBLK_f.js b/data_structures_correct/LOGBLK_f.js deleted file mode 100644 index 07f70f9..0000000 --- a/data_structures_correct/LOGBLK_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function LOGBLK_f() { - - LOGBLK_f.prototype.define = function LOGBLK_f() { - this.in1 = 1; - this.a = Math.E; - - var model = scicos_model(); - model.sim = new ScilabString(["logblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["%e"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - LOGBLK_f.prototype.details = function LOGBLK_f() { - return this.x; - } -} - diff --git a/data_structures_correct/LOGIC.js b/data_structures_correct/LOGIC.js deleted file mode 100644 index 0c1db7e..0000000 --- a/data_structures_correct/LOGIC.js +++ /dev/null @@ -1,30 +0,0 @@ -function LOGIC() { - - LOGIC.prototype.define = function LOGIC() { - this.mat = [[0],[0],[0],[1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["logic"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.intyp = new ScilabDouble([5, 5]); - model.outtyp = new ScilabDouble([5]); - model.opar = list(int8(...this.mat)); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.mat)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGIC\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - LOGIC.prototype.details = function LOGIC() { - return this.x; - } -} diff --git a/data_structures_correct/LOGICAL_OP.js b/data_structures_correct/LOGICAL_OP.js deleted file mode 100644 index c7ccea1..0000000 --- a/data_structures_correct/LOGICAL_OP.js +++ /dev/null @@ -1,26 +0,0 @@ -function LOGICAL_OP() { - - LOGICAL_OP.prototype.define = function LOGICAL_OP() { - this.in1 = [[-1], [-1]]; - this.ipar = 0; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["logicalop"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], [this.ipar]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOGICAL_OP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - LOGICAL_OP.prototype.details = function LOGICAL_OP() { - return this.x; - } -} - diff --git a/data_structures_correct/LOOKUP_f.js b/data_structures_correct/LOOKUP_f.js deleted file mode 100644 index bce7f4c..0000000 --- a/data_structures_correct/LOOKUP_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function LOOKUP_f() { - - LOOKUP_f.prototype.define = function LOOKUP_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["lookup"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-2], [-1], [1], [2], [-1], [1], [-1], [1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"LOOKUP_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], gr_i); - return new BasicBlock(this.x); - } - LOOKUP_f.prototype.details = function LOOKUP_f() { - return this.x; - } -} - diff --git a/data_structures_correct/MATBKSL.js b/data_structures_correct/MATBKSL.js deleted file mode 100644 index 22a873c..0000000 --- a/data_structures_correct/MATBKSL.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATBKSL() { - - MATBKSL.prototype.define = function MATBKSL() { - this.function_name = "mat_bksl"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-3]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATBKSL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATBKSL.prototype.details = function MATBKSL() { - return this.x; - } -} - diff --git a/data_structures_correct/MATCATH.js b/data_structures_correct/MATCATH.js deleted file mode 100644 index b1dc096..0000000 --- a/data_structures_correct/MATCATH.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATCATH() { - - MATCATH.prototype.define = function MATCATH() { - this.funtyp = 4; - this.function_name = "mat_cath"; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([0]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(2)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATCATH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATCATH.prototype.details = function MATCATH() { - return this.x; - } -} - diff --git a/data_structures_correct/MATCATV.js b/data_structures_correct/MATCATV.js deleted file mode 100644 index 317309b..0000000 --- a/data_structures_correct/MATCATV.js +++ /dev/null @@ -1,36 +0,0 @@ -function MATCATV() { - - MATCATV.prototype.define = function MATCATV() { - this.l1 = [[2], [2]]; - this.function_name = "mat_catv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in2 = new ScilabDouble([-1], [-1]); - model.in = new ScilabDouble([-2], [-3]); - model.intyp = new ScilabDouble([-1, -1]); - model.out = new ScilabDouble([0]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(2)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATCATV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATCATV.prototype.details = function MATCATV() { - return this.x; - } -} - diff --git a/data_structures_correct/MATDET.js b/data_structures_correct/MATDET.js deleted file mode 100644 index 7005d7c..0000000 --- a/data_structures_correct/MATDET.js +++ /dev/null @@ -1,36 +0,0 @@ -function MATDET() { - - MATDET.prototype.define = function MATDET() { - var model = scicos_model(); - - this.function_name = "mat_det"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDET\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATDET.prototype.details = function MATDET() { - return this.x; - } -} diff --git a/data_structures_correct/MATDIAG.js b/data_structures_correct/MATDIAG.js deleted file mode 100644 index c622a95..0000000 --- a/data_structures_correct/MATDIAG.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATDIAG() { - - MATDIAG.prototype.define = function MATDIAG() { - this.function_name = "mat_diag"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDIAG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATDIAG.prototype.details = function MATDIAG() { - return this.x; - } -} - diff --git a/data_structures_correct/MATDIV.js b/data_structures_correct/MATDIV.js deleted file mode 100644 index 6715345..0000000 --- a/data_structures_correct/MATDIV.js +++ /dev/null @@ -1,37 +0,0 @@ -function MATDIV() { - - MATDIV.prototype.define = function MATDIV() { - var model = scicos_model(); - - this.function_name = "mat_div"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-2]); - model.in2 = new ScilabDouble([-3], [-3]); - model.intyp = new ScilabDouble([1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATDIV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATDIV.prototype.details = function MATDIV() { - return this.x; - } - -} diff --git a/data_structures_correct/MATEIG.js b/data_structures_correct/MATEIG.js deleted file mode 100644 index aefc690..0000000 --- a/data_structures_correct/MATEIG.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATEIG() { - - MATEIG.prototype.define = function MATEIG() { - this.function_name = "mat_vps"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATEIG\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATEIG.prototype.details = function MATEIG() { - return this.x; - } -} - diff --git a/data_structures_correct/MATEXPM.js b/data_structures_correct/MATEXPM.js deleted file mode 100644 index 6e58a87..0000000 --- a/data_structures_correct/MATEXPM.js +++ /dev/null @@ -1,34 +0,0 @@ -function MATEXPM() { - - MATEXPM.prototype.define = function MATEXPM() { - this.function_name = "mat_expm"; - this.funtyp = 4; - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATEXPM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATEXPM.prototype.details = function MATEXPM() { - return this.x; - } -} - diff --git a/data_structures_correct/MATINV.js b/data_structures_correct/MATINV.js deleted file mode 100644 index e118137..0000000 --- a/data_structures_correct/MATINV.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATINV() { - - MATINV.prototype.define = function MATINV() { - this.function_name = "mat_inv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATINV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATINV.prototype.details = function MATINV() { - return this.x; - } -} - diff --git a/data_structures_correct/MATLU.js b/data_structures_correct/MATLU.js deleted file mode 100644 index 126d164..0000000 --- a/data_structures_correct/MATLU.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATLU() { - - MATLU.prototype.define = function MATLU() { - this.function_name = "mat_lu"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-1], [-1]); - model.outtyp = new ScilabDouble([1, 1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATLU\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATLU.prototype.details = function CSCOPE() { - return this.x; - } -} - diff --git a/data_structures_correct/MATMAGPHI.js b/data_structures_correct/MATMAGPHI.js deleted file mode 100644 index 0748d27..0000000 --- a/data_structures_correct/MATMAGPHI.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATMAGPHI() { - - MATMAGPHI.prototype.define = function MATMAGPHI() { - this.function_name = "matz_abs"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1], [-1]); - model.out2 = new ScilabDouble([-2], [-2]); - model.outtyp = new ScilabDouble([1, 1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATMAGPHI\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATMAGPHI.prototype.details = function MATMAGPHI() { - return this.x; - } -} - diff --git a/data_structures_correct/MATMUL.js b/data_structures_correct/MATMUL.js deleted file mode 100644 index 88f425b..0000000 --- a/data_structures_correct/MATMUL.js +++ /dev/null @@ -1,24 +0,0 @@ -function MATMUL() { - - MATMUL.prototype.define = function MATMUL() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["matmul_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-2]); - model.in2 = new ScilabDouble([-2], [-3]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-3]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([1]); - - var label = new ScilabString([sci2exp(parseInt(getData(model.ipar)))]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATMUL\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATMUL.prototype.details = function MATMUL() { - return this.x; - } -} - diff --git a/data_structures_correct/MATPINV.js b/data_structures_correct/MATPINV.js deleted file mode 100644 index 855d8a3..0000000 --- a/data_structures_correct/MATPINV.js +++ /dev/null @@ -1,36 +0,0 @@ -function MATPINV() { - - MATPINV.prototype.define = function MATPINV() { - this.function_name = "mat_pinv"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATPINV\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATPINV.prototype.details = function MATPINV() { - return this.x; - } -} - diff --git a/data_structures_correct/MATRESH.js b/data_structures_correct/MATRESH.js deleted file mode 100644 index 1db99fa..0000000 --- a/data_structures_correct/MATRESH.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATRESH() { - - MATRESH.prototype.define = function MATRESH() { - this.function_name = "mat_reshape"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp([1, 1])], [sci2exp([1, 1])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATRESH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATRESH.prototype.details = function MATRESH() { - return this.x; - } -} - diff --git a/data_structures_correct/MATSING.js b/data_structures_correct/MATSING.js deleted file mode 100644 index d99399e..0000000 --- a/data_structures_correct/MATSING.js +++ /dev/null @@ -1,36 +0,0 @@ -function MATSING() { - - MATSING.prototype.define = function MATSING() { - var model = scicos_model(); - - this.function_name = "mat_sing"; - this.funtyp = 4; - - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATSING\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - MATSING.prototype.details = function MATSING() { - return this.x; - } -} diff --git a/data_structures_correct/MATSUM.js b/data_structures_correct/MATSUM.js deleted file mode 100644 index 5af9624..0000000 --- a/data_structures_correct/MATSUM.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATSUM() { - - MATSUM.prototype.define = function MATSUM() { - this.function_name = "mat_sum"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATSUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATSUM.prototype.details = function MATSUM() { - return this.x; - } -} - diff --git a/data_structures_correct/MATTRAN.js b/data_structures_correct/MATTRAN.js deleted file mode 100644 index 2ab793a..0000000 --- a/data_structures_correct/MATTRAN.js +++ /dev/null @@ -1,23 +0,0 @@ -function MATTRAN() { - - MATTRAN.prototype.define = function MATTRAN() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["mattran_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATTRAN\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATTRAN.prototype.details = function MATTRAN() { - return this.x; - } -} - diff --git a/data_structures_correct/MATZCONJ.js b/data_structures_correct/MATZCONJ.js deleted file mode 100644 index 7ef31bf..0000000 --- a/data_structures_correct/MATZCONJ.js +++ /dev/null @@ -1,35 +0,0 @@ -function MATZCONJ() { - - MATZCONJ.prototype.define = function MATZCONJ() { - this.function_name = "matz_conj"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MATZCONJ\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - MATZCONJ.prototype.details = function MATZCONJ() { - return this.x; - } -} - diff --git a/data_structures_correct/MATZREIM.js b/data_structures_correct/MATZREIM.js deleted file mode 100644 index 0d7c68c..0000000 --- a/data_structures_correct/MATZREIM.js +++ /dev/null @@ -1,34 +0,0 @@ -function MATZREIM() { - MATZREIM.prototype.define = function MATZREIM() { - var model = scicos_model(); - - this.function_name = "matz_reim"; - this.funtyp = new ScilabDouble([4]); - model.sim = list(this.function_name, this.funtyp); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble(-1, -1); - model.out2 = new ScilabDouble(-2, -2); - model.outtyp = new ScilabDouble([1,1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - this.label = sci2exp(new ScilabDouble(1)); - - var gr_i = ["xstringb(orig(1),orig(2),\"MATZREIM\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([3,2]), model, this.label, gr_i); - return new BasicBlock(this.x); - } - - MATZREIM.prototype.details = function MATZREIM() { - return this.x; - } -} diff --git a/data_structures_correct/MAXMIN.js b/data_structures_correct/MAXMIN.js deleted file mode 100644 index c9d7ce6..0000000 --- a/data_structures_correct/MAXMIN.js +++ /dev/null @@ -1,23 +0,0 @@ -function MAXMIN() { - - MAXMIN.prototype.define = function MAXMIN() { - var model = scicos_model(); - model.sim = list(new ScilabString(["minmax"]), new ScilabDouble([4])); - model.out = new ScilabDouble([1]); - model.in = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.ipar = new ScilabDouble([0]); - - var exprs = new ScilabString(...math.transpose([[2, 1, 1]])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MAXMIN\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["MAXMIN;displayedLabel=MAX"]); - return new BasicBlock(this.x); - } - - MAXMIN.prototype.details = function MAXMIN() { - return this.x; - } -} diff --git a/data_structures_correct/MAX_f.js b/data_structures_correct/MAX_f.js deleted file mode 100644 index a55e66b..0000000 --- a/data_structures_correct/MAX_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function MAX_f() { - - MAX_f.prototype.define = function MAX_f() { - this.in = new ScilabDouble([-1]); - - var model = scicos_model(); - model.sim = new ScilabString(["maxblk"]); - model.in = this.in; - model.out = new ScilabDouble(1); - model.dstate = new ScilabDouble([0], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = ["xstringb(orig(1),orig(2),\"MAX_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - MAX_f.prototype.details = function MAX_f() { - return this.x; - } -} diff --git a/data_structures_correct/MBLOCK.js b/data_structures_correct/MBLOCK.js deleted file mode 100644 index c916ccd..0000000 --- a/data_structures_correct/MBLOCK.js +++ /dev/null @@ -1,45 +0,0 @@ -function MBLOCK() { - - MBLOCK.prototype.define = function MBLOCK() { - this.in1 = ["u1"]; - this.intype = ["I"]; - this.out = [["y1"],["y2"]]; - this.outtype = [["I"],["E"]]; - this.param = [["R"],["L"]]; - this.paramv = list(new ScilabDouble([0.1]), new ScilabDouble([0.0001])); - this.pprop = [[0],[0]]; - this.nameF = "generic"; - - var exprs = tlist(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"], new ScilabString(["MBLOCK", "in", "intype", "out", "outtype", "param", "paramv", "pprop", "nameF", "funtxt"]), new ScilabString([sci2exp(this.in1)]), new ScilabString([sci2exp(this.intype)]), new ScilabString([sci2exp(this.out)]), new ScilabString([sci2exp(this.outtype)]), new ScilabString([sci2exp(this.param)]), list(new ScilabString([0.1]), new ScilabString([0.0001])), new ScilabString([sci2exp(this.pprop)]), new ScilabString([this.nameF]), new ScilabDouble()); - - var model = scicos_model(); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - model.rpar = []; - - for (var i = 0; i < this.paramv.length; i++) { - model.rpar.push(getData(this.paramv[i])); - } - - model.rpar = new ScilabDouble(...model.rpar); - var mo = new modelica_function(); - mo.model = new ScilabString([this.nameF]); - mo.parameters = list(new ScilabString(...this.param), this.paramv); - model.sim = list(mo.model, new ScilabDouble([30004])); - mo.inputs = new ScilabString(this.in1); - mo.outputs = new ScilabString(...this.out); - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "r"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "r"), 1)); - model.equations = mo; - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MBLOCK\",sz(1),sz(2));"]); - - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(this.intype); - this.x.graphics.out_implicit = new ScilabString(...this.outtype); - return new BasicBlock(this.x); - } - - MBLOCK.prototype.details = function MBLOCK() { - return this.x; - } -} diff --git a/data_structures_correct/MCLOCK_f.js b/data_structures_correct/MCLOCK_f.js deleted file mode 100644 index b6e1b67..0000000 --- a/data_structures_correct/MCLOCK_f.js +++ /dev/null @@ -1,139 +0,0 @@ -function MCLOCK_f() { - - MCLOCK_f.prototype.define = function MCLOCK_f() { - this.nn = 2; - this.dt = 0.1; - var exprs = new ScilabString([this.dt], [this.nn]); - - var mfclck = new MFCLCK_f().internal(); - mfclck.graphics.orig = new ScilabDouble([334, 199]); - mfclck.graphics.sz = new ScilabDouble([40, 40]); - mfclck.graphics.flip = new ScilabBoolean([true]); - mfclck.graphics.exprs = exprs; - mfclck.graphics.pein = new ScilabDouble([12]); - mfclck.graphics.peout = new ScilabDouble([4], [3]); - mfclck.model.rpar = new ScilabDouble([0.1]); - mfclck.model.ipar = new ScilabDouble([this.nn]); - mfclck.model.firing = new ScilabDouble([-1, 0]); - mfclck.model.uid = new ScilabString([count]); - mfclck.doc = list(new ScilabString([count++])); - - var clksom = new CLKSOM_f().internal(); - clksom.graphics.orig = new ScilabDouble([457, 161]); - clksom.graphics.sz = new ScilabDouble([16.666667, 16.666667]); - clksom.graphics.flip = new ScilabBoolean([true]); - clksom.graphics.exprs = new ScilabString(["0.1"], ["0.1"]); - clksom.graphics.pein = new ScilabDouble([4], [9], [0]); - clksom.graphics.peout = new ScilabDouble([5]); - clksom.model.uid = new ScilabString([count]); - clksom.doc = list(new ScilabString([count++])); - - var output_port1 = new CLKOUT_f().internal(); - output_port1.graphics.orig = new ScilabDouble([509, 261]); - output_port1.graphics.sz = new ScilabDouble([20, 20]); - output_port1.graphics.flip = new ScilabBoolean([true]); - output_port1.graphics.exprs = new ScilabString(["1"]); - output_port1.graphics.pein = new ScilabDouble([10]); - output_port1.model.ipar = new ScilabDouble([1]); - output_port1.model.uid = new ScilabString([count]); - output_port1.doc = list(new ScilabString([count++])); - - var output_port2 = new CLKOUT_f().internal(); - output_port2.graphics.orig = new ScilabDouble([509, 142]); - output_port2.graphics.sz = new ScilabDouble([20, 20]); - output_port2.graphics.flip = new ScilabBoolean([true]); - output_port2.graphics.exprs = new ScilabString(["2"]); - output_port2.graphics.pein = new ScilabDouble([13]); - output_port2.model.ipar = new ScilabDouble([2]); - output_port2.model.uid = new ScilabString([count]); - output_port2.doc = list(new ScilabString([count++])); - - var split1 = new CLKSPLIT_f().internal(); - split1.graphics.orig = new ScilabDouble([411.92504, 169.33333]); - split1.graphics.pein = new ScilabDouble([3]); - split1.graphics.peout = new ScilabDouble([9], [10]); - split1.model.uid = new ScilabString([count]); - split1.doc = list(new ScilabString([count++])); - - var split2 = new CLKSPLIT_f().internal(); - split2.graphics.orig = new ScilabDouble([482.45315, 169.33333]); - split2.graphics.pein = new ScilabDouble([5]); - split2.graphics.peout = new ScilabDouble([12], [13]); - split2.model.uid = new ScilabString([count]); - split2.doc = list(new ScilabString([count++])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"MCLOCK_f",sz(1),sz(2));"]); - - var diagram = scicos_diagram(); - diagram.objs.push(mfclck); - diagram.objs.push(clksom); - diagram.objs.push(output_port1); - diagram.objs.push(output_port2); - diagram.objs.push(split1); - diagram.objs.push(split2); - - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([360.7], [360.7], [411.9]), - yy: new ScilabDouble([193.3], [169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([347.3], [347.3], [461.8], [461.8]), - yy: new ScilabDouble([193.3], [155.5], [155.5], [161]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([468.9], [482.5]), - yy: new ScilabDouble([169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([411.9], [457]), - yy: new ScilabDouble([169.3], [169.3]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([411.9], [411.9], [509]), - yy: new ScilabDouble([169.3], [271], [271]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([482.5], [489.6], [489.6], [354], [354]), - yy: new ScilabDouble([169.3], [169.3], [338.3], [338.3], [244.7]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - diagram.objs.push(scicos_link({ - xx: new ScilabDouble([482.4], [482.4], [509]), - yy: new ScilabDouble([169.3], [152], [152]), - ct: new ScilabDouble([10, -1]), - from: new ScilabDouble([6, 2, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - - this.x = scicos_block(); - this.x.gui = new ScilabString(["MCLOCK_f"]); - this.x.graphics.sz = new ScilabDouble([3, 2]); - this.x.graphics.gr_i = gr_i; - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1], [1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.rpar = diagram; - this.x.graphics.peout = new ScilabDouble([0], [0]); - return new BasicBlock(this.x); - } - MCLOCK_f.prototype.details = function MCLOCK_f() { - return this.x; - } -} diff --git a/data_structures_correct/MFCLCK_f.js b/data_structures_correct/MFCLCK_f.js deleted file mode 100644 index 6e0a6aa..0000000 --- a/data_structures_correct/MFCLCK_f.js +++ /dev/null @@ -1,50 +0,0 @@ -function MFCLCK_f() { - - MFCLCK_f.prototype.define = function MFCLCK_f() { - this.nn = 2; - this.dt = 0.1; - - var model = scicos_model(); - model.sim = new ScilabString(["mfclck"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.dt]); - model.ipar = new ScilabDouble([this.nn]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1], [0]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.dt], [this.nn]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MFCLCK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MFCLCK_f.prototype.internal = function MFCLCK_f() { - this.nn = 2; - this.dt = 0.1; - - var model = scicos_model(); - model.sim = new ScilabString(["mfclck"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1], [1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([this.dt]); - model.ipar = new ScilabDouble([this.nn]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1], [0]); - model.dep_ut = new ScilabBoolean([false, false]); - model.outtyp = new ScilabDouble(); - - var exprs = new ScilabString([this.dt], [this.nn]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MFCLCK_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["MFCLCK_f"]); - return block; - } - MFCLCK_f.prototype.details = function MFCLCK_f() { - return this.x; - } -} diff --git a/data_structures_correct/MIN_f.js b/data_structures_correct/MIN_f.js deleted file mode 100644 index e64f3af..0000000 --- a/data_structures_correct/MIN_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function MIN_f() { - - MIN_f.prototype.define = function MIN_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["minblk"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MIN_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MIN_f.prototype.details = function MIN_f() { - return this.x; - } -} - diff --git a/data_structures_correct/MUX.js b/data_structures_correct/MUX.js deleted file mode 100644 index f968deb..0000000 --- a/data_structures_correct/MUX.js +++ /dev/null @@ -1,26 +0,0 @@ -function MUX() { - - MUX.prototype.define = function MUX() { - this.in1 = 2; - var arr = []; - arr.push(math.range(-1, -this.in1, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["multiplex"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...math.transpose(arr)); - model.out = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.in1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MUX.prototype.details = function MUX() { - return this.x; - } -} - diff --git a/data_structures_correct/MUX_f.js b/data_structures_correct/MUX_f.js deleted file mode 100644 index fa55526..0000000 --- a/data_structures_correct/MUX_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function MUX_f() { - - MUX_f.prototype.define = function MUX_f() { - this.in1 = 2; - var arr = []; - arr.push(math.range(-1, -this.in1, -1, true)._data); - - var model = scicos_model(); - model.sim = list(new ScilabString(["mux"]), new ScilabDouble([1])); - model.in = new ScilabDouble(...math.transpose(arr)); - model.out = new ScilabDouble([0]); - model.ipar = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.in1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"MUX_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([0.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - MUX_f.prototype.details = function MUX_f() { - return this.x; - } -} - diff --git a/data_structures_correct/M_SWITCH.js b/data_structures_correct/M_SWITCH.js deleted file mode 100644 index ec04419..0000000 --- a/data_structures_correct/M_SWITCH.js +++ /dev/null @@ -1,26 +0,0 @@ -function M_SWITCH() { - - M_SWITCH.prototype.define = function M_SWITCH() { - this.in1 = [[1], [-1], [-1]]; - this.ipar = [[1], [3]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["mswitch"]), new ScilabDouble([4])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(...this.ipar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin], ...this.ipar); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"M_SWITCH\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - M_SWITCH.prototype.details = function M_SWITCH() { - return this.x; - } -} - diff --git a/data_structures_correct/M_freq.js b/data_structures_correct/M_freq.js deleted file mode 100644 index e335809..0000000 --- a/data_structures_correct/M_freq.js +++ /dev/null @@ -1,24 +0,0 @@ -function M_freq() { - - M_freq.prototype.define = function M_freq() { - var model = scicos_model(); - model.sim = list(new ScilabString(["m_frequ"]), new ScilabDouble([4])); - model.evtout = new ScilabDouble([1], [1], [1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.opar = list(new ScilabDouble([1, 1, 0], [1, 1, 1], [1, 3, 2]), new ScilabDouble([1]), new ScilabDouble([0]), new ScilabDouble([0])); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0, -1, -1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp([[1], [2]])], [sci2exp([[0], [0]])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"M_freq\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - M_freq.prototype.details = function M_freq() { - return this.x; - } -} diff --git a/data_structures_correct/Modulo_Count.js b/data_structures_correct/Modulo_Count.js deleted file mode 100644 index dfff095..0000000 --- a/data_structures_correct/Modulo_Count.js +++ /dev/null @@ -1,46 +0,0 @@ -function Modulo_Count() { - - Modulo_Count.prototype.define = function Modulo_Count() { - this.ini_c = 0; - this.base = 3; - - var model = scicos_model(); - model.sim = list(new ScilabString(["modulo_count"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.ini_c]); - model.ipar = new ScilabDouble([this.base]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.ini_c], [this.base]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Modulo_Count\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - Modulo_Count.prototype.internal = function Modulo_Count() { - this.ini_c = 0; - this.base = 3; - - var model = scicos_model(); - model.sim = list(new ScilabString(["modulo_count"]), new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.dstate = new ScilabDouble([this.ini_c]); - model.ipar = new ScilabDouble([this.base]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.ini_c], [this.base]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Modulo_Count\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - block.graphics.style = new ScilabString(["Modulo_Count"]); - return block; - } - Modulo_Count.prototype.details = function Modulo_Count() { - return this.x; - } -} diff --git a/data_structures_correct/NEGTOPOS_f.js b/data_structures_correct/NEGTOPOS_f.js deleted file mode 100644 index f28db43..0000000 --- a/data_structures_correct/NEGTOPOS_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function NEGTOPOS_f() { - - NEGTOPOS_f.prototype.define = function NEGTOPOS_f() { - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [0], [-1]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NEGTOPOS_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - NEGTOPOS_f.prototype.details = function NEGTOPOS_f() { - return this.x; - } -} diff --git a/data_structures_correct/NMOS.js b/data_structures_correct/NMOS.js deleted file mode 100644 index f18e7f1..0000000 --- a/data_structures_correct/NMOS.js +++ /dev/null @@ -1,40 +0,0 @@ -function NMOS() { - - NMOS.prototype.define = function NMOS() { - this.W = 20.e-6; - this.L = 6.e-6; - this.Beta = 0.041e-3; - this.Vt = 0.8; - this.K2 = 1.144; - this.K5 = 0.7311; - this.dW = -2.5e-6; - this.dL = -1.5e-6; - this.RDS = 1.e+7; - - var model = scicos_model(); - model.sim = new ScilabString(["NMOS"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["NMOS"]); - mo.outputs = new ScilabString(["D"], ["B"], ["S"]); - mo.inputs = new ScilabString(["G"]); - mo.parameters = list(new ScilabString(["W"], ["L"], ["Beta"], ["Vt"], ["K2"], ["K5"], ["dW"], ["dL"], ["RDS"]), new ScilabDouble([this.W], [this.L], [this.Beta], [this.Vt], [this.K2], [this.K5], [this.dW], [this.dL], [this.RDS])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.W], [this.L], [this.Beta], [this.Vt], [this.K2], [this.K5], [this.dW], [this.dL], [this.RDS]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NMOS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["I"], ["I"]); - return new BasicBlock(this.x); - } - NMOS.prototype.details = function NMOS() { - return this.x; - } -} - diff --git a/data_structures_correct/NPN.js b/data_structures_correct/NPN.js deleted file mode 100644 index 3a78293..0000000 --- a/data_structures_correct/NPN.js +++ /dev/null @@ -1,56 +0,0 @@ -function NPN() { - - NPN.prototype.define = function NPN() { - this.ModelName = "NPN"; - this.PrametersValue = [[50], [0.1], [0], [0.02], [1.200e-10], [5.000e-09], [1.000e-12], [4.000e-13], [5.000e-13], [0.8], [0.4], [0.8], [0.333], [1.000e-15], [1.000e-15], [0.02585], [40]]; - this.ParametersName = [["Bf"], ["Br"], ["Is"], ["Vak"], ["Tauf"], ["Taur"], ["Ccs"], ["Cje"], ["Cjc"], ["Phie"], ["Me"], ["Phic"], ["Mc"], ["Gbc"], ["Gbe"], ["Vt"], ["EMinMax"]]; - this.model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[100, 90, -2, 0], [0, 50, 2, 0], [100, 10, -2, 0]]; - this.PortName = [["C"], ["B"], ["E"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - var model = scicos_model(); - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(...this.PrametersValue); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...zeros(this.ParametersName))); - var exprs = new ScilabString(["50"], ["0.1"], ["1.e-16"], ["0.02"], ["0.12e-9"], ["5e-9"], ["1e-12"], ["0.4e-12"], ["0.5e-12"], ["0.8"], ["0.4"], ["0.8"], ["0.333"], ["1e-15"], ["1e-15"], ["0.02585"], ["40"]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"NPN",sz(1),sz(2));"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(...this.Typein); - this.x.graphics.out_implicit = new ScilabString(...this.Typeout); - return new BasicBlock(this.x); - } - NPN.prototype.details = function NPN() { - return this.x; - } -} diff --git a/data_structures_correct/NRMSOM_f.js b/data_structures_correct/NRMSOM_f.js deleted file mode 100644 index f80bb88..0000000 --- a/data_structures_correct/NRMSOM_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function NRMSOM_f() { - - NRMSOM_f.prototype.define = function NRMSOM_f() { - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = new ScilabString(["junk"]); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nin]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"NRMSOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([.2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - NRMSOM_f.prototype.details = function NRMSOM_f() { - return this.x; - } -} - diff --git a/data_structures_correct/OUTIMPL_f.js b/data_structures_correct/OUTIMPL_f.js deleted file mode 100644 index 3b5337c..0000000 --- a/data_structures_correct/OUTIMPL_f.js +++ /dev/null @@ -1,33 +0,0 @@ -function OUTIMPL_f() { - - OUTIMPL_f.prototype.define = function OUTIMPL_f() { - var model = scicos_model(); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - - this.prt = 1; - model.sim = new ScilabString(["outimpl"]); - model.ipar = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PORT"]); - mo.inputs = new ScilabString(["n"]); - mo.outputs = new ScilabDouble(); - model.equations = mo; - - var exprs = new ScilabString(["1"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"OUTIMPL_f",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - - this.implicitOutBlock = new ImplicitOutBlock(this.x); - this.displayParameter = [this.implicitOutBlock.ordering]; - return this.implicitOutBlock; - } - OUTIMPL_f.prototype.details = function OUTIMPL_f() { - return this.x; - } -} diff --git a/data_structures_correct/OUT_f.js b/data_structures_correct/OUT_f.js deleted file mode 100644 index e480a65..0000000 --- a/data_structures_correct/OUT_f.js +++ /dev/null @@ -1,53 +0,0 @@ -function OUT_f () { - - OUT_f.prototype.internal = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["OUT_f"]); // changed - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.in_label = new ScilabString([""]); - block.graphics.in_implicit = new ScilabString(["E"]); - return block; - } - - OUT_f.prototype.define = function OUT_f() { - this.n = -1; - this.prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([sci2exp(this.prt)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OUT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - this.x.graphics.style = new ScilabString(["OUT_f"]); - - this.explicitOutBlock = new ExplicitOutBlock(this.x); - this.displayParameter = [this.explicitOutBlock.ordering]; - return this.explicitOutBlock; - } - - OUT_f.prototype.details = function OUT_f() { - return this.x; - } -} diff --git a/data_structures_correct/OpAmp.js b/data_structures_correct/OpAmp.js deleted file mode 100644 index c55b893..0000000 --- a/data_structures_correct/OpAmp.js +++ /dev/null @@ -1,34 +0,0 @@ -function OpAmp() { - - OpAmp.prototype.define = function OpAmp() { - this.S = []; - this.Z = []; - - var model = scicos_model(); - model.sim = new ScilabString(["OpAmp"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = model.sim; - mo.inputs = new ScilabString(["in_p"], ["in_n"]); - mo.outputs = new ScilabString(["out"]); - mo.parameters = list(new ScilabDouble(), new ScilabDouble()); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - model.rpar = new ScilabDouble(); - - var exprs = new ScilabString(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"OpAmp\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 5]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"], ["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - OpAmp.prototype.details = function OpAmp() { - return this.x; - } -} - diff --git a/data_structures_correct/PDE.js b/data_structures_correct/PDE.js deleted file mode 100644 index 2aa3a6d..0000000 --- a/data_structures_correct/PDE.js +++ /dev/null @@ -1,24 +0,0 @@ -function PDE() { - - PDE.prototype.define = function PDE() { - this.params_pde = tlist(["paramspde", "a", "b", "txt_exp", "check_op1", "a1", "b1", "check_op2", "a2", "b2", "check_op3", "a3", "b3", "check_op4", "a4", "b4", "check_op5", "a5", "b5", "check_op6", "a6", "b6", "check_op7", "a7", "b7", "discr_cst", "discr_non_cst", "signe", "rad_automatique", "rad_manuel", "methode", "ord1", "ord2", "ord3", "degre", "nnode", "txt_pas", "CI", "dCI", "CLa", "CLa_exp", "CLb", "CLb_exp", "points"], new ScilabString(["paramspde"], ["a"], ["b"], ["txt_exp"], ["check_op1"], ["a1"], ["b1"], ["check_op2"], ["a2"], ["b2"], ["check_op3"], ["a3"], ["b3"], ["check_op4"], ["a4"], ["b4"], ["check_op5"], ["a5"], ["b5"], ["check_op6"], ["a6"], ["b6"], ["check_op7"], ["a7"], ["b7"], ["discr_cst"], ["discr_non_cst"], ["signe"], ["rad_automatique"], ["rad_manuel"], ["methode"], ["ord1"], ["ord2"], ["ord3"], ["degre"], ["nnode"], ["txt_pas"], ["CI"], ["dCI"], ["CLa"], ["CLa_exp"], ["CLb"], ["CLb_exp"], ["points"]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP1(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP2(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP3(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP4(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP5(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP6(t)"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString(["IN_EDP7(t)"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString(["0"]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString([""]), new ScilabString(["0"]), new ScilabString(["IN_CL1(t)"]), new ScilabString(["0"]), new ScilabString(["IN_CL2(t)"]), new ScilabString([""])); - - var model = scicos_model(); - model.state = new ScilabDouble(...zeros(10, 1)); - model.sim = list(new ScilabString(["PDE"]), new ScilabDouble([0])); - model.in = new ScilabDouble([1], [1], [1], [1], [1]); - model.out = new ScilabDouble([10], [0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var label = list(this.params_pde, new ScilabDouble(), new ScilabString([""])); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PDE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 3]), model, label, gr_i); - return new BasicBlock(this.x); - } - PDE.prototype.details = function PDE() { - return this.x; - } -} - diff --git a/data_structures_correct/PID.js b/data_structures_correct/PID.js deleted file mode 100644 index 894446b..0000000 --- a/data_structures_correct/PID.js +++ /dev/null @@ -1,626 +0,0 @@ -function PID() { - - PID.prototype.define = function PID() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["PID"]), - tol: new ScilabDouble([0.0001], [0.000001], [1.000E-10], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["INTEGRAL_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([318.304, 183.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["0"], ["0"], ["0"], ["1"], ["-1"]), - pin: new ScilabDouble([7]), - pout: new ScilabDouble([9]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"INTEGRAL_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString(["1/s"]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["INTEGRAL_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["integral_func"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble([0]), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString(["1/s"]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SUMMATION"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([387.97067, 172.85067]), - sz: new ScilabDouble([40, 60]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"], ["[1;1;1]"]), - pin: new ScilabDouble([10], [9], [11]), - pout: new ScilabDouble([19]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SUMMATION",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SUMMATION"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["summation"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1], [-1]), - in2: new ScilabDouble([-2], [-2], [-2]), - intyp: new ScilabDouble([1], [1], [1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1], [1], [1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([321.23733, 235.91733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([17]), - pout: new ScilabDouble([10]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["DERIV"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([319.03733, 135.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([8]), - pout: new ScilabDouble([11]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"DERIV",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString(["s"]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["DERIV"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["deriv"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["x"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString(["s"]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([255.23733, 183.11733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([13]), - pout: new ScilabDouble([7]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["GAINBLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([255.23733, 135.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([14]), - pout: new ScilabDouble([8]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"GAINBLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["GAINBLK"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["gainblk"]), new ScilabDouble([4])), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([234.704, 203.11733]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([16]), - pout: new ScilabDouble([16], [17], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([233.97067, 203.11733]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([21]), - pout: new ScilabDouble([18], [19], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([456.5421, 192.85067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([19]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([193.97067, 193.11733]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([21]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([303.80876], [309.73257]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([303.80876], [310.4659]), - yy: new ScilabDouble([155.45067], [155.45067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([366.87543], [379.39924]), - yy: new ScilabDouble([203.11733], [202.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([2, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([369.80876], [379.39924], [379.39924]), - yy: new ScilabDouble([255.91733], [255.91733], [217.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([367.60876], [379.39924], [379.39924]), - yy: new ScilabDouble([155.45067], [155.45067], [187.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([2, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([234.704], [246.6659]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([12, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([234.704], [234.704], [246.6659]), - yy: new ScilabDouble([203.11733], [155.45067], [155.45067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([12, 2, 0]), - to: new ScilabDouble([6, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([233.97067], [234.704]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([15, 1, 0]), - to: new ScilabDouble([12, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([233.97067], [233.97067], [312.6659]), - yy: new ScilabDouble([203.11733], [255.91733], [255.91733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([15, 2, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([436.5421], [456.5421]), - yy: new ScilabDouble([202.85067], [202.85067]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([18, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([213.97067], [233.97067]), - yy: new ScilabDouble([203.11733], [203.11733]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([20, 1, 0]), - to: new ScilabDouble([15, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false, false]); - model.rpar = scs_m; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PID\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - PID.prototype.details = function PID() { - return this.x; - } -} diff --git a/data_structures_correct/PNP.js b/data_structures_correct/PNP.js deleted file mode 100644 index 0665ae0..0000000 --- a/data_structures_correct/PNP.js +++ /dev/null @@ -1,63 +0,0 @@ -function PNP() { - - PNP.prototype.define = function PNP() { - this.ModelName = "PNP"; - this.PrametersValue = [[50],[0.1],[0],[0.02],[1.200e-10],[5.000e-09],[1.000e-12],[4.000e-13],[5.000e-13],[0.8],[0.4],[0.8],[0.333],[1.000e-15],[1.000e-15],[0.02585],[40]]; - this.ParametersName = [["Bf"],["Br"],["Is"],["Vak"],["Tauf"],["Taur"],["Ccs"],["Cje"],["Cjc"],["Phie"],["Me"],["Phic"],["Mc"],["Gbc"],["Gbe"],["Vt"],["EMinMax"]]; - - var model = scicos_model(); - this.Typein = []; - this.Typeout = []; - this.MI = []; - this.MO = []; - this.P = [[100, 90, -2, 0], [0, 50, 2, 0], [100, 10, -2, 0]]; - this.PortName = [["C"], ["B"], ["E"]]; - - for (var i = 0; i < size(this.P, "r"); i++) { - if (this.P[i][2] == 1) { - this.Typein.push(["E"]); - this.MI.push(this.PortName[i]); - } - - if (this.P[i][2] == 2) { - this.Typein.push(["I"]); - this.MI.push(this.PortName[i]); - } - if (this.P[i][2] == -1) { - this.Typeout.push(["E"]); - this.MO.push(this.PortName[i]); - } - if (this.P[i][2] == -2) { - this.Typeout.push(["I"]); - this.MO.push(this.PortName[i]); - } - } - - var mo = new modelica_function(); - model.sim = new ScilabString([this.ModelName]); - mo.inputs = new ScilabString(...this.MI); - mo.outputs = new ScilabString(...this.MO); - model.rpar = new ScilabDouble(...this.PrametersValue); - - var arr = []; - arr.push(zeros(getData(this.ParametersName))); - mo.parameters = list(new ScilabString(...this.ParametersName), new ScilabDouble(...this.PrametersValue), new ScilabDouble(...math.transpose(arr))); - var exprs = new ScilabString(["50"], ["0.1"], ["1.e-16"], ["0.02"], ["0.12e-9"], ["5e-9"], ["1e-12"], ["0.4e-12"], ["0.5e-12"], ["0.8"], ["0.4"], ["0.8"], ["0.333"], ["1e-15"], ["1e-15"], ["0.02585"], ["40"]); - var gr_i = "xstringb(orig(1),orig(2),\"PNP\",sz(1),sz(2));" - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - mo.model = new ScilabString([this.ModelName]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(this.MI, "*"), 1)); - model.out = new ScilabDouble(...ones(size(this.MO, "*"), 1)); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, list(new ScilabString([gr_i]), new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabDouble(...this.Typein); - this.x.graphics.out_implicit = new ScilabDouble(...this.Typeout); - - return new BasicBlock(this.x); - } - - PNP.prototype.details = function PNP() { - return this.x; - } -} diff --git a/data_structures_correct/POSTONEG_f.js b/data_structures_correct/POSTONEG_f.js deleted file mode 100644 index 97d9aa6..0000000 --- a/data_structures_correct/POSTONEG_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function POSTONEG_f() { - - POSTONEG_f.prototype.define = function POSTONEG_f() { - this.rpar = [[-1], [-1], [-1], [0]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [-1], [0]); - model.blocktype = new ScilabString(["z"]); - model.dep_ut = new ScilabBoolean([true, false]); - model.firing = new ScilabDouble([-1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"POSTONEG_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, [], gr_i); - return new BasicBlock(this.x); - } - POSTONEG_f.prototype.details = function POSTONEG_f() { - return this.x; - } -} - diff --git a/data_structures_correct/POWBLK_f.js b/data_structures_correct/POWBLK_f.js deleted file mode 100644 index 0e19fc1..0000000 --- a/data_structures_correct/POWBLK_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function POWBLK_f() { - - POWBLK_f.prototype.define = function POWBLK_f() { - this.in = 1; - this.a = 1.5; - - var model = scicos_model(); - model.sim = new ScilabString(["powblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.a]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"POWBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - POWBLK_f.prototype.details = function POWBLK_f() { - return this.x; - } -} diff --git a/data_structures_correct/PRODUCT.js b/data_structures_correct/PRODUCT.js deleted file mode 100644 index 0e9e6c8..0000000 --- a/data_structures_correct/PRODUCT.js +++ /dev/null @@ -1,23 +0,0 @@ -function PRODUCT() { - - PRODUCT.prototype.define = function PRODUCT() { - this.sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["product"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"PRODUCT",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - return new Product(this.x); - } - PRODUCT.prototype.details = function PRODUCT() { - return this.x; - } -} diff --git a/data_structures_correct/PROD_f.js b/data_structures_correct/PROD_f.js deleted file mode 100644 index d46b7d9..0000000 --- a/data_structures_correct/PROD_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function PROD_f() { - - PROD_f.prototype.define = function PROD_f() { - - var model = scicos_model(); - model.sim = list(new ScilabString(["prod"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - this.x = new standard_define(new ScilabDouble([1, 1]), model, new ScilabDouble(), new ScilabString()); - return new RoundBlock(this.x); - } - PROD_f.prototype.details = function PROD_f() { - return this.x; - } -} - diff --git a/data_structures_correct/PULSE_SC.js b/data_structures_correct/PULSE_SC.js deleted file mode 100644 index 3ffa991..0000000 --- a/data_structures_correct/PULSE_SC.js +++ /dev/null @@ -1,381 +0,0 @@ -function PULSE_SC() { - - PULSE_SC.prototype.define = function PULSE_SC() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 600, 450]), - Title: new ScilabString(["SuperBlock"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([10]), - context: new ScilabString(["E2=E+W/100*F"], ["if (W<0 | W>100) then error(''Width must be between 0 and 100'');end"], ["if (E2 >= F) then error (''Offset must be lower than (frequency*(1-Width/100))''); end"]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CONST_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([30.801202, 158.91733]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["A"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([5]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CONST_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CONST_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(new ScilabDouble([1])), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["Ground_g"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([31.534535, 215.384]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble([4]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"Ground_g",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["Ground_g"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["cstblk4_m"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(new ScilabDouble([0])), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["SELECT_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([106.00652, 186.09381]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["-1"], ["2"], ["1"]), - pin: new ScilabDouble([4], [5]), - pout: new ScilabDouble([11]), - pein: new ScilabDouble([9], [8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SELECT_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""]), - out_label: new ScilabString([""]), - style: new ScilabString(["SELECT_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["selector_m"]), new ScilabDouble([4])), - in: new ScilabDouble([-1], [-1]), - in2: new ScilabDouble([-2], [-2]), - intyp: new ScilabDouble([-1], [-1]), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([-2]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble([1], [1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble([1]), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["SampleCLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([82.349744, 274.21741]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["F"], ["E2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([9]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SampleCLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["SampleCLK"]) - }), - model: scicos_model({ - sim: new ScilabString(["sampleclk"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1], [0.4]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["SampleCLK"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([160.48879, 274.21741]), - sz: new ScilabDouble([60, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["F"], ["E"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble([8]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SampleCLK",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["SampleCLK"]) - }), - model: scicos_model({ - sim: new ScilabString(["sampleclk"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([1], [0.1]), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble([-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([174.57795, 196.09381]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([11]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([80.105964], [97.43509], [97.43509]), - yy: new ScilabDouble([235.384], [235.384], [212.76048]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([79.372631], [97.43509], [97.43509]), - yy: new ScilabDouble([178.91733], [178.91733], [199.42714]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([190.48879], [190.48879], [132.67318], [132.67318]), - yy: new ScilabDouble([274.21741], [240.99048], [240.99048], [231.80809]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([7, 1, 0]), - to: new ScilabDouble([3, 2, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([112.34974], [112.34974], [119.33985], [119.33985]), - yy: new ScilabDouble([274.21741], [248.21372], [248.21372], [231.80809]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([6, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([154.57795], [174.57795]), - yy: new ScilabDouble([206.09381], [206.09381]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([10, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.odstate = list(); - model.rpar = scs_m_1; - model.ipar = new ScilabDouble([1]); - model.opar = list(); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - model.label = new ScilabString([""]); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - model.equations = list(); - this.E = 0.1; - this.W = 30; - this.F = 1; - this.A = 1; - var exprs = new ScilabString([sci2exp(this.E)], [sci2exp(this.W)], [sci2exp(this.F)], [sci2exp(this.A)]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PULSE_SC\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - PULSE_SC.prototype.details = function PULSE_SC() { - return this.x; - } -} diff --git a/data_structures_correct/PerteDP.js b/data_structures_correct/PerteDP.js deleted file mode 100644 index 139898f..0000000 --- a/data_structures_correct/PerteDP.js +++ /dev/null @@ -1,41 +0,0 @@ -function PerteDP() { - - PerteDP.prototype.define = function PerteDP() { - this.L = 10; - this.D = 0.2; - this.lambda = 0.03; - this.z1 = 0; - this.z2 = 0; - this.p_rho = 0; - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho]); - model.sim = new ScilabString(["PerteDP"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PerteDP"]); - mo.inputs = new ScilabString(["C1"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters = list(new ScilabString(["L"], ["D"], ["lambda"], ["z1"], ["z2"], ["p_rho"]), new ScilabDouble([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.L], [this.D], [this.lambda], [this.z1], [this.z2], [this.p_rho]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PerteDP\",sz(1),sz(2));"]); - this.x = standard_define([2, 1], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - PerteDP.prototype.details = function PerteDP() { - return this.x; - } - -} - diff --git a/data_structures_correct/PotentialSensor.js b/data_structures_correct/PotentialSensor.js deleted file mode 100644 index 5195935..0000000 --- a/data_structures_correct/PotentialSensor.js +++ /dev/null @@ -1,31 +0,0 @@ -function PotentialSensor() { - - PotentialSensor.prototype.define = function PotentialSensor() { - - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.sim = new ScilabString(["PotentialSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["PotentialSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["v"]); - model.equations = mo; - - var exprs = new ScilabString([""]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PotentialSensor\",sz(1),sz(2));"]); - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - return new BasicBlock(this.x); - } - PotentialSensor.prototype.details = function PotentialSensor() { - return this.x; - } -} - diff --git a/data_structures_correct/PuitsP.js b/data_structures_correct/PuitsP.js deleted file mode 100644 index ad6e1f1..0000000 --- a/data_structures_correct/PuitsP.js +++ /dev/null @@ -1,34 +0,0 @@ -function PuitsP() { - - PuitsP.prototype.define = function PuitsP() { - this.P0 = 100000; - this.T0 = 290; - this.H0 = 100000; - this.option_temperature = 1; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]); - model.sim = new ScilabString(["Puits"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Puits"]); - mo.inputs = new ScilabString(["C"]); - mo.outputs = new ScilabDouble(); - mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - - var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"PuitsP\",sz(1),sz(2));"]); - this.x = standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble(0))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - PuitsP.prototype.details = function PuitsP() { - return this.x; - } -} - diff --git a/data_structures_correct/QUANT_f.js b/data_structures_correct/QUANT_f.js deleted file mode 100644 index 1934882..0000000 --- a/data_structures_correct/QUANT_f.js +++ /dev/null @@ -1,26 +0,0 @@ -function QUANT_f() { - - QUANT_f.prototype.define = function QUANT_f() { - this.pas = 0.1; - this.meth = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["qzrnd"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble([this.pas]); - model.ipar = new ScilabDouble([this.meth]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.pas], [this.meth]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"QUANT_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - QUANT_f.prototype.details = function QUANT_f() { - return this.x; - } -} - diff --git a/data_structures_correct/RAMP.js b/data_structures_correct/RAMP.js deleted file mode 100644 index 947aa27..0000000 --- a/data_structures_correct/RAMP.js +++ /dev/null @@ -1,29 +0,0 @@ -function RAMP() { - - RAMP.prototype.define = function RAMP() { - this.slope = 0; - this.iout = 0; - this.stt = 0; - this.rpar = [[this.slope], [this.stt], [this.iout]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["ramp"]), new ScilabDouble([4])); - model.in = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString(...this.rpar); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RAMP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RAMP.prototype.details = function RAMP() { - return this.x; - } -} - diff --git a/data_structures_correct/RAND_m.js b/data_structures_correct/RAND_m.js deleted file mode 100644 index e5eff23..0000000 --- a/data_structures_correct/RAND_m.js +++ /dev/null @@ -1,39 +0,0 @@ -function RAND_m() { - - RAND_m.prototype.define = function RAND_m() { - this.a = 0; - this.b = 1; - this.dt = 0; - this.flag = 0; - this.function_name = "rndblk_m"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble([parseInt(Math.random() * 10000000)], [0 * this.a]); - model.rpar = new ScilabDouble([this.a, this.b]); - model.ipar = new ScilabDouble([this.flag]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(1)], [this.flag], [sci2exp([this.a])], [sci2exp([this.b])], [sci2exp([parseInt(getData(model.dstate)[0]), parseInt(Math.random() * 10000000)])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RAND_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RAND_m.prototype.details = function RAND_m() { - return this.x; - } -} - diff --git a/data_structures_correct/RATELIMITER.js b/data_structures_correct/RATELIMITER.js deleted file mode 100644 index 881b020..0000000 --- a/data_structures_correct/RATELIMITER.js +++ /dev/null @@ -1,26 +0,0 @@ -function RATELIMITER() { - - RATELIMITER.prototype.define = function RATELIMITER() { - this.minp = -1; - this.maxp = 1; - this.rpar = [[this.maxp], [this.minp]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["ratelimiter"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RATELIMITER\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RATELIMITER.prototype.details = function RATELIMITER() { - return this.x; - } -} - diff --git a/data_structures_correct/READAU_f.js b/data_structures_correct/READAU_f.js deleted file mode 100644 index 38f3d96..0000000 --- a/data_structures_correct/READAU_f.js +++ /dev/null @@ -1,33 +0,0 @@ -function READAU_f() { - - READAU_f.prototype.define = function READAU_f() { - this.frmt = "uc "; - this.fname = "test.au"; - this.lunit = 0; - this.N = 20; - this.M = 1; - this.tmask = []; - this.swap = 0; - this.offset = 1; - this.outmask = 1; - this.ievt = 0; - this.nout = size(this.outmask, "*"); - var model = scicos_model(); - model.sim = list(new ScilabString(["readau"]), new ScilabDouble([2])); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros(this.N * this.M, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.ievt], [this.N], [this.M], [this.swap], [this.offset], ..._str2code(this.fname), [this.outmask]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.fname], [this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"READAU_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - READAU_f.prototype.details = function READAU_f() { - return this.x; - } -} diff --git a/data_structures_correct/READC_f.js b/data_structures_correct/READC_f.js deleted file mode 100644 index a851fbb..0000000 --- a/data_structures_correct/READC_f.js +++ /dev/null @@ -1,39 +0,0 @@ -function READC_f() { - - READC_f.prototype.define = function READC_f() { - this.frmt = "d "; - this.fname = "foo"; - this.lunit = 0; - this.N = 20; - this.M = 1; - this.rpar = []; - this.tmask = 0; - this.swap = 0; - this.offset = 1; - this.outmask = 1; - this.ievt = 0; - this.nout = size(this.outmask, "*"); - - var ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.ievt], [this.N], [this.M], [this.swap], [this.offset], ..._str2code(this.fname), [this.tmask], [this.outmask]); - - var model = scicos_model(); - model.sim = list(new ScilabString(["readc"]), new ScilabDouble([2])); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros(this.N * this.M, 1)); - model.ipar = ipar; - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(["[]"], [this.outmask], [this.fname], [this.frmt], [this.M], [this.N], [this.offset], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"READC_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - READC_f.prototype.details = function READC_f() { - return this.x; - } -} diff --git a/data_structures_correct/REGISTER.js b/data_structures_correct/REGISTER.js deleted file mode 100644 index 7704450..0000000 --- a/data_structures_correct/REGISTER.js +++ /dev/null @@ -1,26 +0,0 @@ -function REGISTER() { - - REGISTER.prototype.define = function REGISTER() { - this.z0 = new ScilabDouble(...zeros(10, 1)); - - var model = scicos_model(); - model.sim = list(new ScilabString(["delay4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = this.z0; - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString(this.z0); - - var gr_i = ["xstringb(orig(1),orig(2),\"REGISTER\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([3,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - - } - - REGISTER.prototype.details = function REGISTER() { - return this.x; - } -} diff --git a/data_structures_correct/REGISTER_f.js b/data_structures_correct/REGISTER_f.js deleted file mode 100644 index bf4c28e..0000000 --- a/data_structures_correct/REGISTER_f.js +++ /dev/null @@ -1,28 +0,0 @@ -function REGISTER_f () { - - REGISTER_f.prototype.internal = function REGISTER_f() { - this.z0 = zeros(10,1); - - var model = scicos_model(); - model.sim = new ScilabString(["delay"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate= new ScilabDouble(...this.z0); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = new ScilabString([this.z0.toString().replace(/,/g, ";")]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"REGISTER_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([2.5,2.5]),model,exprs,gr_i); - block.graphics.style = new ScilabString(["REGISTER_f"]); - block.graphics.in_implicit = new ScilabString(["E"]); // changed - block.graphics.out_implicit = new ScilabString(["E"]); - block.graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - block.graphics.in_label = new ScilabString([""]); - block.graphics.out_label = new ScilabString([""]); - return block; - } -} diff --git a/data_structures_correct/RELATIONALOP.js b/data_structures_correct/RELATIONALOP.js deleted file mode 100644 index 100570e..0000000 --- a/data_structures_correct/RELATIONALOP.js +++ /dev/null @@ -1,26 +0,0 @@ -function RELATIONALOP() { - - RELATIONALOP.prototype.define = function RELATIONALOP() { - this.ipar = 2; - this.label = "<"; - - var model = scicos_model(); - model.sim = list(new ScilabString(["relationalop"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - model.ipar = new ScilabDouble([this.ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.ipar], [0]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RELATIONALOP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.style = new ScilabString(["fontSize=13;fontStyle=1;displayedLabel=" + label]); - return new BasicBlock(this.x); - } - RELATIONALOP.prototype.details = function RELATIONALOP() { - return this.x; - } -} - diff --git a/data_structures_correct/RELAY_f.js b/data_structures_correct/RELAY_f.js deleted file mode 100644 index 5b323d5..0000000 --- a/data_structures_correct/RELAY_f.js +++ /dev/null @@ -1,28 +0,0 @@ -function RELAY_f() { - - RELAY_f.prototype.define = function RELAY_f() { - this.i0 = 0; - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["relay"]), new ScilabDouble([2])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(...ones(this.in1)); - model.dstate = new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, true]); - - var exprs = new ScilabString([this.nin], [this.i0 + 1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RELAY_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RELAY_f.prototype.details = function RELAY_f() { - return this.x; - } -} - diff --git a/data_structures_correct/RFILE_f.js b/data_structures_correct/RFILE_f.js deleted file mode 100644 index f0d79e7..0000000 --- a/data_structures_correct/RFILE_f.js +++ /dev/null @@ -1,36 +0,0 @@ -function RFILE_f() { - - RFILE_f.prototype.define = function RFILE_f() { - this.out = 1; - this.nout = this.out; - this.frmt = "(7(e10.3,1x))"; - this.fname = "foo"; - this.lunit = 0; - this.N = 2; - this.rpar = []; - this.tmask = 0; - this.outmask = 1; - - var ipar = new ScilabDouble([this.fname.length], [this.frmt.length], [0], [this.N], ..._str2code(this.fname), ..._str2code(this.frmt), [this.tmask], [this.outmask]); - - var dstate = new ScilabDouble([1], [1], [this.lunit], ...zeros((this.nout) * this.N, 1)); - - var model = scicos_model(); - model.sim = new ScilabString(["readf"]); - model.out = new ScilabDouble([this.nout]); - model.evtin = new ScilabDouble([1]); - model.dstate = dstate; - model.ipar = ipar; - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp([])], [sci2exp(this.outmask)], [this.fname], [this.frmt], [this.N], [this.out]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RFILE_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - RFILE_f.prototype.details = function RFILE_f() { - return this.x; - } -} diff --git a/data_structures_correct/RICC.js b/data_structures_correct/RICC.js deleted file mode 100644 index 5664207..0000000 --- a/data_structures_correct/RICC.js +++ /dev/null @@ -1,35 +0,0 @@ -function RICC() { - - RICC.prototype.define = function RICC() { - this.function_name = "ricc_m"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.in2 = new ScilabDouble([-1], [-1], [-1]); - model.intyp = new ScilabDouble([1, 1, 1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1], [1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"RICC\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - RICC.prototype.details = function RICC() { - return this.x; - } -} - diff --git a/data_structures_correct/ROOTCOEF.js b/data_structures_correct/ROOTCOEF.js deleted file mode 100644 index 96e72c6..0000000 --- a/data_structures_correct/ROOTCOEF.js +++ /dev/null @@ -1,35 +0,0 @@ -function ROOTCOEF() { - - ROOTCOEF.prototype.define = function ROOTCOEF() { - this.function_name = "root_coef"; - this.funtyp = 4; - - var model = scicos_model(); - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ROOTCOEF\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - ROOTCOEF.prototype.details = function ROOTCOEF() { - return this.x; - } -} - diff --git a/data_structures_correct/Resistor.js b/data_structures_correct/Resistor.js deleted file mode 100644 index ff52450..0000000 --- a/data_structures_correct/Resistor.js +++ /dev/null @@ -1,33 +0,0 @@ -function Resistor() { - - Resistor.prototype.define = function Resistor() { - this.R = 0.01; - - var model = scicos_model(); - model.rpar = new ScilabDouble([this.R]); - model.sim = new ScilabString(["resistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Resistor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["R"]), list(new ScilabDouble([this.R]))); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.R]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Resistor\",sz(1),sz(2));"]); - this.x = standard_define([2, 1], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - Resistor.prototype.details = function Resistor() { - return this.x; - } -} - diff --git a/data_structures_correct/SAMPHOLD_m.js b/data_structures_correct/SAMPHOLD_m.js deleted file mode 100644 index 7c42b73..0000000 --- a/data_structures_correct/SAMPHOLD_m.js +++ /dev/null @@ -1,27 +0,0 @@ -function SAMPHOLD_m() { - - SAMPHOLD_m.prototype.define = function SAMPHOLD_m() { - var model = scicos_model(); - model.sim = list(new ScilabString(["samphold4_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = [sci2exp(1)]; - - var gr_i = ["xstringb(orig(1),orig(2),\"SAMPHOLD_m\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - - } - - SAMPHOLD_m.prototype.details = function SAMPHOLD_m() { - return this.x; - } -} diff --git a/data_structures_correct/SATURATION.js b/data_structures_correct/SATURATION.js deleted file mode 100644 index 99bd3fa..0000000 --- a/data_structures_correct/SATURATION.js +++ /dev/null @@ -1,28 +0,0 @@ -function SATURATION() { - - SATURATION.prototype.define = function SATURATION() { - this.minp = -1; - this.maxp = 1; - this.rpar = [[this.maxp], [this.minp]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["satur"]), new ScilabDouble([4])); - model.in = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.maxp], [this.minp], [parseInt(getData(model.nmode)[0])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SATURATION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SATURATION.prototype.details = function SATURATION() { - return this.x; - } -} - diff --git a/data_structures_correct/SAWTOOTH_f.js b/data_structures_correct/SAWTOOTH_f.js deleted file mode 100644 index 75a8fec..0000000 --- a/data_structures_correct/SAWTOOTH_f.js +++ /dev/null @@ -1,23 +0,0 @@ -function SAWTOOTH_f() { - - SAWTOOTH_f.prototype.define = function SAWTOOTH_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sawtth"]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SAWTOOTH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SAWTOOTH_f.prototype.details = function SAWTOOTH_f() { - return this.x; - } -} diff --git a/data_structures_correct/SCALAR2VECTOR.js b/data_structures_correct/SCALAR2VECTOR.js deleted file mode 100644 index f701a95..0000000 --- a/data_structures_correct/SCALAR2VECTOR.js +++ /dev/null @@ -1,23 +0,0 @@ -function SCALAR2VECTOR() { - - SCALAR2VECTOR.prototype.define = function SCALAR2VECTOR() { - this.nout = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scalar2vector"]), new ScilabDouble([4])); - model.out = new ScilabDouble([this.nout]); - model.in = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.nout]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SCALAR2VECTOR\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SCALAR2VECTOR.prototype.details = function SCALAR2VECTOR() { - return this.x; - } -} - diff --git a/data_structures_correct/SELECT_m.js b/data_structures_correct/SELECT_m.js deleted file mode 100644 index 95583a6..0000000 --- a/data_structures_correct/SELECT_m.js +++ /dev/null @@ -1,35 +0,0 @@ -function SELECT_m() { - - SELECT_m.prototype.define = function SELECT_m() { - this.z0 = 1; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["selector_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.in2 = new ScilabDouble([-2], [-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin = new ScilabDouble(...ones(this.nin, 1)); - model.dstate = new ScilabDouble([this.z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp([this.nin])], [sci2exp([this.z0])]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SELECT_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SELECT_m.prototype.details = function SELECT_m() { - return this.x; - } -} - diff --git a/data_structures_correct/SELF_SWITCH.js b/data_structures_correct/SELF_SWITCH.js deleted file mode 100644 index 286d822..0000000 --- a/data_structures_correct/SELF_SWITCH.js +++ /dev/null @@ -1,30 +0,0 @@ -function SELF_SWITCH() { - - SELF_SWITCH.prototype.define = function SELF_SWITCH() { - this.stateOpen = true; - - this.x = scicos_block(); - this.x.gui = new ScilabString(["SELF_SWITCH"]); - this.x.graphics.sz = new ScilabDouble([2, 2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false, false]); - this.x.model.rpar = genSwitchInnerDiagram(this.stateOpen); - this.x.model.opar = list(new ScilabBoolean([this.stateOpen])); - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - this.x.graphics.style = new ScilabString(["SELF_SWITCH;SELF_SWITCH_OFF"]); - return new BasicBlock(this.x); - } - - SELF_SWITCH.prototype.details = function SELF_SWITCH() { - return this.x; - } -} diff --git a/data_structures_correct/SHIFT.js b/data_structures_correct/SHIFT.js deleted file mode 100644 index a0e9283..0000000 --- a/data_structures_correct/SHIFT.js +++ /dev/null @@ -1,30 +0,0 @@ -function SHIFT() { - - SHIFT.prototype.define = function SHIFT() { - this.sgn = [[0],[0]]; - this.OPER = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["shift_32_LA"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(3)], [sci2exp(0)], [sci2exp(0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SHIFT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SHIFT.prototype.details = function SHIFT() { - return this.x; - } -} diff --git a/data_structures_correct/SIGNUM.js b/data_structures_correct/SIGNUM.js deleted file mode 100644 index 1cbac1e..0000000 --- a/data_structures_correct/SIGNUM.js +++ /dev/null @@ -1,25 +0,0 @@ -function SIGNUM() { - - SIGNUM.prototype.define = function SIGNUM() { - this.nu = -1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["signum"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.out = new ScilabDouble([this.nu]); - model.nzcross = new ScilabDouble([this.nu]); - model.nmode = new ScilabDouble([this.nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SIGNUM\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SIGNUM.prototype.details = function SIGNUM() { - return this.x; - } -} - diff --git a/data_structures_correct/SINBLK_f.js b/data_structures_correct/SINBLK_f.js deleted file mode 100644 index 170f5d5..0000000 --- a/data_structures_correct/SINBLK_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function SINBLK_f() { - - SINBLK_f.prototype.define = function SINBLK_f() { - - var model = scicos_model(); - model.sim = new ScilabString(["sinblk"]); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SINBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - SINBLK_f.prototype.details = function SINBLK_f() { - return this.x; - } -} - diff --git a/data_structures_correct/SOM_f.js b/data_structures_correct/SOM_f.js deleted file mode 100644 index 2d49214..0000000 --- a/data_structures_correct/SOM_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function SOM_f() { - - SOM_f.prototype.define = function SOM_f() { - this.sgn = [[1], [1], [1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["sum"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.out = new ScilabDouble([-1]); - model.rpar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SOM_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2,2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SINBLK_f.prototype.details = function SINBLK_f() { - return this.x; - } -} diff --git a/data_structures_correct/SQRT.js b/data_structures_correct/SQRT.js deleted file mode 100644 index f9ddb24..0000000 --- a/data_structures_correct/SQRT.js +++ /dev/null @@ -1,24 +0,0 @@ -function SQRT() { - - SQRT.prototype.define = function SQRT() { - var model = scicos_model(); - model.sim = list(new ScilabString(["mat_sqrt"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SQRT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - - SQRT.prototype.details = function SQRT() { - return this.x; - } -} diff --git a/data_structures_correct/SRFLIPFLOP.js b/data_structures_correct/SRFLIPFLOP.js deleted file mode 100644 index 439fc4a..0000000 --- a/data_structures_correct/SRFLIPFLOP.js +++ /dev/null @@ -1,439 +0,0 @@ -function SRFLIPFLOP() { - - SRFLIPFLOP.prototype.define = function SRFLIPFLOP() { - var scs_m = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["SRFLIPFLOP"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100000]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["LOGIC"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([298.504, 201.45067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["[0 1;1 0;1 0;1 0;0 1;0 1;0 0;0 0]"], ["1"]), - pin: new ScilabDouble([4], [10], [12]), - pout: new ScilabDouble([3], [8]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"LOGIC",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"], ["E"], ["E"]), - out_implicit: new ScilabString(["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""], [""], [""]), - out_label: new ScilabString([""], [""]), - style: new ScilabString(["LOGIC"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["logic"]), new ScilabDouble([4])), - in: new ScilabDouble([1], [1], [1]), - in2: new ScilabDouble([1], [1], [1]), - intyp: new ScilabDouble([5], [5], [5]), - out: new ScilabDouble([1], [1]), - out2: new ScilabDouble([1], [1]), - outtyp: new ScilabDouble([5], [5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(int8([0, 1], [1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 0], [0, 0])), - blocktype: new ScilabString(["c"]), - firing: new ScilabBoolean([false]), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["DOLLAR_m"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([299.23733, 254.25067]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([false]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["int8(0)"], ["1"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble([4]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"DOLLAR_m",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""]), - style: new ScilabString(["DOLLAR_m"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["dollar4_m"]), new ScilabDouble([4])), - in: new ScilabDouble([1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([5]), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([5]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(int8([0])), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["SPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([363.03733, 248.584]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble([3]), - pout: new ScilabDouble([10], [14], [0]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"SPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabString(["E"], ["E"], ["E"]), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - out_label: new ScilabString([""], [""], [""]), - style: new ScilabString(["SPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["lsplit"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([1]), - out: new ScilabDouble([-1], [-1], [-1]), - out2: new ScilabDouble([1], [1], [1]), - outtyp: new ScilabDouble([1], [1], [1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([true, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([367.07543, 204.784]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble([8]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([249.93257, 211.45067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([10]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["IN_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([249.93257, 201.45067]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["2"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([12]), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"IN_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["IN_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["input"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([-1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([2]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([383.03733, 238.584]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([14]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([1]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.07543], [363.03733], [363.03733]), - yy: new ScilabDouble([228.11733], [228.11733], [248.584]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([290.6659], [272.104], [272.104], [289.93257]), - yy: new ScilabDouble([274.25067], [274.25067], [231.45067], [231.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([2, 1, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([363.03733], [363.03733], [344.95162]), - yy: new ScilabDouble([248.584], [274.25067], [274.25067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([347.07543], [367.07543]), - yy: new ScilabDouble([214.784], [214.784]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 2, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.93257], [289.93257]), - yy: new ScilabDouble([221.45067], [221.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([9, 1, 0]), - to: new ScilabDouble([1, 2, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([269.93257], [289.93257]), - yy: new ScilabDouble([211.45067], [221.45067]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([11, 1, 0]), - to: new ScilabDouble([1, 3, 1]) - })); - scs_m.objs.push(scicos_link({ - xx: new ScilabDouble([363.03733], [383.03733]), - yy: new ScilabDouble([248.584], [248.584]), - id: new ScilabString(['drawlink']), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([5, 2, 0]), - to: new ScilabDouble([13, 1, 1]) - })); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in = new ScilabDouble([1], [1]); - model.in2 = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1], [1]); - model.out2 = new ScilabDouble([1], [1]); - model.intyp = new ScilabDouble([5, 5]); - model.outtyp = new ScilabDouble([5, 5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true, false]); - model.rpar = scs_m; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SRFLIPFLOP\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - SRFLIPFLOP.prototype.details = function SRFLIPFLOP() { - return this.x; - } -} diff --git a/data_structures_correct/STEP_FUNCTION.js b/data_structures_correct/STEP_FUNCTION.js deleted file mode 100644 index 0c379ab..0000000 --- a/data_structures_correct/STEP_FUNCTION.js +++ /dev/null @@ -1,79 +0,0 @@ -function STEP_FUNCTION() { - - STEP_FUNCTION.prototype.define = function STEP_FUNCTION() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new STEP().internal()); - scs_m_1.objs.push(new OUT_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([0, 0]); - graphics.sz = new ScilabDouble([40, 40]); - graphics.flip = new ScilabBoolean([true]); - graphics.pein = new ScilabDouble([4]); - graphics.peout = new ScilabDouble([4]); - graphics.pout = new ScilabDouble([3]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.in_style = new ScilabDouble(); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.in_label = new ScilabDouble(); - graphics.out_label = new ScilabString([""]); - model.evtin = new ScilabDouble([-1]); - model.evtout = new ScilabDouble([-1]); - model.uid = new ScilabString([count]); - blk.graphics = graphics; - blk.model = model; - blk.doc = list(new ScilabString([count++])); - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([80, 10]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.flip = new ScilabBoolean([true]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([3]); - model.outtyp = new ScilabDouble(); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - var lnk = scs_m_1.objs[2]; - lnk.xx = new ScilabDouble([104], [136]); - lnk.yy = new ScilabDouble([-40], [-60]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([2, 1, 1]); - scs_m_1.objs[2] = lnk; - - lnk = scs_m_1.objs[3]; - lnk.xx = new ScilabDouble([0], [20], [-20], [-20], [20], [1]); - lnk.yy = new ScilabDouble([0], [-20], [-20], [60], [60], [1]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[3] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"STEP_FUNCTION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabString(), gr_i); - return new BasicBlock(this.x); - } - - STEP_FUNCTION.prototype.details = function STEP_FUNCTION() { - return this.x; - } -} diff --git a/data_structures_correct/SUBMAT.js b/data_structures_correct/SUBMAT.js deleted file mode 100644 index ece918b..0000000 --- a/data_structures_correct/SUBMAT.js +++ /dev/null @@ -1,38 +0,0 @@ -function SUBMAT() { - - SUBMAT.prototype.define = function SUBMAT() { - var model = scicos_model(); - - this.function_name = new ScilabString(["submat"]); - - this.funtyp = new ScilabDouble([4]); - model.sim = list(this.function_name, this.funtyp); - model.in = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1], [1], [1], [1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - this.label = new ScilabString([sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)], [sci2exp(1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUBMAT\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2.5, 2]), model, this.label, gr_i); - - return new BasicBlock(this.x); - - } - SUBMAT.prototype.details = function SUBMAT() { - return this.x; - - } -} diff --git a/data_structures_correct/SUMMATION.js b/data_structures_correct/SUMMATION.js deleted file mode 100644 index 867c9fd..0000000 --- a/data_structures_correct/SUMMATION.js +++ /dev/null @@ -1,25 +0,0 @@ -function SUMMATION() { - SUMMATION.prototype.define = function SUMMATION() { - this.sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim = list(new ScilabString(["summation"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2], [-2]); - model.out2 = new ScilabDouble([-2]); - model.ipar = new ScilabDouble(...this.sgn); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.sgn)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUMMATION\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 3]), model, exprs, gr_i); - return new Summation(this.x); - } - - SUMMATION.prototype.details = function SUMMATION() { - return this.x; - } -} diff --git a/data_structures_correct/SUM_f.js b/data_structures_correct/SUM_f.js deleted file mode 100644 index 6677eac..0000000 --- a/data_structures_correct/SUM_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function SUM_f() { - - SUM_f.prototype.define = function SUM_f() { - var model = scicos_model(); - - model.sim = list(new ScilabString(["plusblk"]), new ScilabDouble([2])); - model.in = new ScilabDouble([-1], [-1], [-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SUM_f\",sz(1),sz(2));"]); - var exprs = new ScilabString(); - - this.x = new standard_define(new ScilabDouble([1, 1]), model, exprs, gr_i); - - return new RoundBlock(this.x); - - } - - SUM_f.prototype.details = function SUM_f() { - return this.x; - - } -} diff --git a/data_structures_correct/SUPER_f.js b/data_structures_correct/SUPER_f.js deleted file mode 100644 index fb95e3a..0000000 --- a/data_structures_correct/SUPER_f.js +++ /dev/null @@ -1,42 +0,0 @@ -function SUPER_f() { - - SUPER_f.prototype.define = function SUPER_f() { - var scs = scicos_diagram(); - scs.props.title = new ScilabString(["Super_Block"]); - - var in1 = new IN_f().internal(); - in1.graphics.orig = new ScilabDouble([40, 40]); - in1.graphics.sz = new ScilabDouble([20, 20]); - in1.graphics.flip = new ScilabBoolean([true]); - in1.graphics.pout = new ScilabDouble([0]); - in1.model.uid = new ScilabString([count]); - in1.doc = list(new ScilabString([count++])); - - var out = new OUT_f().internal(); - out.graphics.orig = new ScilabDouble([240, 40]); - out.graphics.sz = new ScilabDouble([20, 20]); - out.graphics.flip = new ScilabBoolean([true]); - out.graphics.pin = new ScilabDouble([0]); - out.model.outtyp = new ScilabDouble(); - out.model.uid = new ScilabString([count]); - out.doc = list(new ScilabString([count++])); - scs.objs.push(in1); - scs.objs.push(out); - - var model = scicos_model(); - model.sim = new ScilabString(["super"]); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = scs; - model.blocktype = new ScilabString(["h"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = ["xstringb(orig(1),orig(2),\"SUPER_f\",sz(1),sz(2));"]; - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new SuperBlock(this.x); - } - - SUPER_f.prototype.details = function SUPER_f() { - return this.x; - } -} diff --git a/data_structures_correct/SWITCH2_m.js b/data_structures_correct/SWITCH2_m.js deleted file mode 100644 index 405c5ce..0000000 --- a/data_structures_correct/SWITCH2_m.js +++ /dev/null @@ -1,33 +0,0 @@ -function SWITCH2_m() { - - SWITCH2_m.prototype.define = function SWITCH2_m() { - this.ipar = [0]; - this.nzz = 1; - this.rpar = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["switch2_m"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1], [1], [-1]); - model.in2 = new ScilabDouble([-2], [1], [-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.ipar = new ScilabDouble(this.ipar); - model.rpar = new ScilabDouble([this.rpar]); - model.nzcross = new ScilabDouble([this.nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([1], this.ipar, [this.rpar], [this.nzz]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH2_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SWITCH2_m.prototype.details = function SWITCH2_m() { - return this.x; - } -} diff --git a/data_structures_correct/SWITCH_f.js b/data_structures_correct/SWITCH_f.js deleted file mode 100644 index c9cefb1..0000000 --- a/data_structures_correct/SWITCH_f.js +++ /dev/null @@ -1,48 +0,0 @@ -function SWITCH_f() { - - SWITCH_f.prototype.define = function SWITCH_f() { - this.i0 = 0; - this.in1 = [[-1], [-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["switchn"]), new ScilabDouble([2])); - model.in = new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar = new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, true]); - - var exprs = new ScilabString([this.nin], [this.i0 + 1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - SWITCH_f.prototype.internal = function SWITCH_f() { - this.i0 = 0; - this.in1 = [[-1],[-1]]; - this.nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["switchn"]),new ScilabDouble([2])); - model.in=new ScilabDouble(...this.in1); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([this.i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,true]); - - var exprs = new ScilabString([this.nin],[this.i0+1]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SWITCH_f\",sz(1),sz(2));"]); - var block=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return block; - } - - SWITCH_f.prototype.details = function SWITCH_f() { - return this.x; - } -} diff --git a/data_structures_correct/SampleCLK.js b/data_structures_correct/SampleCLK.js deleted file mode 100644 index 5568e10..0000000 --- a/data_structures_correct/SampleCLK.js +++ /dev/null @@ -1,22 +0,0 @@ -function SampleCLK() { - - SampleCLK.prototype.define = function SampleCLK() { - - var model = scicos_model(); - model.sim = new ScilabString(["sampleclk"]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1, 0]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(1)], [sci2exp(0)]); - - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, ["xstringb(orig(1),orig(2),\"SampleCLK\",sz(1),sz(2));"]); - return new BasicBlock(this.x); - } - SampleCLK.prototype.details = function SampleCLK() { - return this.x; - } -} - diff --git a/data_structures_correct/Sigbuilder.js b/data_structures_correct/Sigbuilder.js deleted file mode 100644 index 15b6da0..0000000 --- a/data_structures_correct/Sigbuilder.js +++ /dev/null @@ -1,272 +0,0 @@ -function Sigbuilder() { - - Sigbuilder.prototype.define = function Sigbuilder() { - var scs_m_1 = scicos_diagram({ - version: new ScilabString(["scicos4.2"]), - props: scicos_params({ - wpar: new ScilabDouble([600, 450, 0, 0, 450, 600]), - Title: new ScilabString(["Sigbuilder"]), - tol: new ScilabDouble([0.0001], [0.000001], [Math.pow(10, -10)], [100001], [0], [0], [0]), - tf: new ScilabDouble([100]), - context: new ScilabString([" "]), - void1: new ScilabDouble(), - options: tlist(["scsopt", "3D", "Background", "Link", "ID", "Cmap"], new ScilabString(["scsopt", "3D", "Background", "Link", "ID", "Cmap"]), list(new ScilabBoolean([true]), new ScilabDouble([33])), new ScilabDouble([8, 1]), new ScilabDouble([1, 5]), list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])), new ScilabDouble([0.8, 0.8, 0.8])), - void2: new ScilabDouble(), - void3: new ScilabDouble(), - doc: list() - }) - }); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CURVE_c"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([329.63473, 606.18517]), - sz: new ScilabDouble([40, 40]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["3"], ["[0,1,2]"], ["[10,20,-30]"], ["y"], ["n"]), - pin: new ScilabDouble(), - pout: new ScilabDouble([6]), - pein: new ScilabDouble([4]), - peout: new ScilabDouble([2]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CURVE_c",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabString(["E"]), - out_style: new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]), - out_label: new ScilabString([""]), - style: new ScilabString(["CURVE_c"]) - }), - model: scicos_model({ - sim: list(new ScilabString(["curve_c"]), new ScilabDouble([4])), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble([0], [1], [2], [10], [20], [-30]), - ipar: new ScilabDouble([3], [3], [1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble([0]), - dep_ut: new ScilabBoolean([false, true]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKSPLIT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([349.49528, 565.10704]), - sz: new ScilabDouble([0.3333333, 0.3333333]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabDouble(), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([2]), - peout: new ScilabDouble([8], [4]), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKSPLIT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKSPLIT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["split"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble([1], [1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabBoolean([-1], [-1]), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["OUT_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([398.20616, 616.18517]), - sz: new ScilabDouble([20, 20]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble([6]), - pout: new ScilabDouble(), - pein: new ScilabDouble(), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"OUT_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabString(["E"]), - out_implicit: new ScilabDouble(), - in_style: new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]), - in_label: new ScilabString([""]), - style: new ScilabString(["OUT_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble([-1]), - in2: new ScilabDouble([-2]), - intyp: new ScilabDouble([-1]), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble(), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["c"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_block({ - gui: new ScilabString(["CLKOUTV_f"]), - graphics: scicos_graphics({ - orig: new ScilabDouble([339.49528, 505.10704]), - sz: new ScilabDouble([20, 30]), - flip: new ScilabBoolean([true]), - theta: new ScilabDouble([0]), - exprs: new ScilabString(["1"]), - pin: new ScilabDouble(), - pout: new ScilabDouble(), - pein: new ScilabDouble([8]), - peout: new ScilabDouble(), - gr_i: list(new ScilabString(["xstringb(orig(1),orig(2),"CLKOUTV_f",sz(1),sz(2));"]), new ScilabDouble([8])), - id: new ScilabString([""]), - in_implicit: new ScilabDouble(), - out_implicit: new ScilabDouble(), - style: new ScilabString(["CLKOUTV_f"]) - }), - model: scicos_model({ - sim: new ScilabString(["output"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble(), - out2: new ScilabDouble(), - outtyp: new ScilabDouble(), - evtin: new ScilabDouble([1]), - evtout: new ScilabDouble(), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: new ScilabDouble(), - ipar: new ScilabDouble([1]), - opar: list(), - blocktype: new ScilabString(["d"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list(), - uid: new ScilabString([count]) - }), - doc: list(new ScilabString([count++])) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.63473], [349.49528]), - yy: new ScilabDouble([600.47089], [565.10704]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([3, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.49528], [266.69602], [266.69602], [270.35525], [342.80795], [342.80795], [349.63473]), - yy: new ScilabDouble([565.10704], [565.10704], [680.99483], [680.99483], [680.99483], [651.89946], [651.89946]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 2, 0]), - to: new ScilabDouble([1, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([378.20616], [398.20616]), - yy: new ScilabDouble([626.18517], [626.18517]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([1, 1]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([5, 1, 1]) - })); - scs_m_1.objs.push(scicos_link({ - xx: new ScilabDouble([349.49528], [349.49528]), - yy: new ScilabDouble([565.10704], [535.10704]), - id: new ScilabString(["drawlink"]), - thick: new ScilabDouble([0, 0]), - ct: new ScilabDouble([5, -1]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([7, 1, 1]) - })); - - var model = scicos_model({ - sim: new ScilabString(["csuper"]), - in: new ScilabDouble(), - in2: new ScilabDouble(), - intyp: new ScilabDouble(), - out: new ScilabDouble([-1]), - out2: new ScilabDouble([1]), - outtyp: new ScilabDouble([1]), - evtin: new ScilabDouble(), - evtout: new ScilabDouble([1]), - state: new ScilabDouble(), - dstate: new ScilabDouble(), - odstate: list(), - rpar: scs_m_1, - ipar: new ScilabDouble(), - opar: list(), - blocktype: new ScilabString(["h"]), - firing: new ScilabDouble(), - dep_ut: new ScilabBoolean([false, false]), - label: new ScilabString([""]), - nzcross: new ScilabDouble([0]), - nmode: new ScilabDouble([0]), - equations: list() - }); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Sigbuilder\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - Sigbuilder.prototype.details = function Sigbuilder() { - return this.x; - } -} diff --git a/data_structures_correct/SineVoltage.js b/data_structures_correct/SineVoltage.js deleted file mode 100644 index 9cc43f3..0000000 --- a/data_structures_correct/SineVoltage.js +++ /dev/null @@ -1,38 +0,0 @@ -function SineVoltage() { - - SineVoltage.prototype.define = function SineVoltage() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - this.V = 1; - this.ph = 0; - this.frq = 1; - this.offset = 0; - this.start = 0; - - model.rpar = new ScilabDouble([this.V], [this.ph], [this.frq], [this.offset], [this.start]); - model.sim = new ScilabString(["SineVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["SineVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["V"], ["phase"], ["freqHz"], ["offset"], ["startTime"]), list(new ScilabDouble([this.V]), new ScilabDouble([this.ph]), new ScilabDouble([this.frq]), new ScilabDouble([this.offset]), new ScilabDouble([this.start]))); - model.equations = mo; - - var exprs = new ScilabString([this.V], [this.ph], [this.frq], [this.offset], [this.start]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SineVoltage\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - SineVoltage.prototype.details = function SineVoltage() { - return this.x; - } -} diff --git a/data_structures_correct/SourceP.js b/data_structures_correct/SourceP.js deleted file mode 100644 index 73deebf..0000000 --- a/data_structures_correct/SourceP.js +++ /dev/null @@ -1,36 +0,0 @@ -function SourceP() { - - SourceP.prototype.define = function SourceP() { - var model = scicos_model(); - - this.P0 = 300000; - this.T0 = 290; - this.H0 = 100000; - this.option_temperature = 1; - - model.rpar = new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature]); - model.sim = new ScilabString(["Source"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["Source"]); - mo.inputs = new ScilabDouble(); - mo.outputs = new ScilabString(["C"]); - mo.parameters = list(new ScilabString(["P0"], ["T0"], ["H0"], ["option_temperature"]), new ScilabDouble([this.P0], [this.T0], [this.H0], [this.option_temperature])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.P0], [this.T0], [this.H0], [this.option_temperature]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"SourceP\",sz(1),sz(2));"]); - this.x = new standard_define([2.5, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - SourceP.prototype.details = function SourceP() { - return this.x; - } -} diff --git a/data_structures_correct/Switch.js b/data_structures_correct/Switch.js deleted file mode 100644 index 79c5736..0000000 --- a/data_structures_correct/Switch.js +++ /dev/null @@ -1,42 +0,0 @@ -function Switch() { - - Switch.prototype.define = function Switch() { - var model = scicos_model(); - - this.Ron = 0.01; - this.Roff = 1e5; - this.S = [["Ron"], ["Roff"]]; - - var scope = { - Ron: 0.01, - Roff: 1e5 - } - this.Z = math.eval('[ Ron ; Roff ]', scope)._data; - - model.sim = new ScilabString(["Switch"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = model.sim; - mo.inputs = new ScilabString(["p"], ["inp"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(...this.S), new ScilabDouble(...this.Z)); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - model.rpar = new ScilabDouble(...this.Z); - - var exprs = new ScilabString(...this.Z); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Switch\",sz(1),sz(2));"]); - this.x = standard_define(new ScilabDouble([2, 2]), model, exprs, list(gr_i, new ScilabDouble(0))); - this.x.graphics.in_implicit = new ScilabString([["I"], ["E"]]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - Switch.prototype.details = function Switch() { - this.x; - } -} diff --git a/data_structures_correct/TANBLK_f.js b/data_structures_correct/TANBLK_f.js deleted file mode 100644 index d468e84..0000000 --- a/data_structures_correct/TANBLK_f.js +++ /dev/null @@ -1,23 +0,0 @@ -function TANBLK_f() { - - TANBLK_f.prototype.define = function TANBLK_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["tanblk"]); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(in1)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TANBLK_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TANBLK_f.prototype.details = function TANBLK_f() { - return this.x; - } -} diff --git a/data_structures_correct/TCLSS.js b/data_structures_correct/TCLSS.js deleted file mode 100644 index e102d93..0000000 --- a/data_structures_correct/TCLSS.js +++ /dev/null @@ -1,34 +0,0 @@ -function TCLSS() { - - TCLSS.prototype.define = function TCLSS() { - this.x0 = 0; - this.A = 0; - this.B = 1; - this.C = 1; - this.D = 0; - this.in1 = 1; - this.nx = size(this.x0, "*"); - this.out = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tcslti4"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.in1], [this.nx]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble([1]); - model.state = new ScilabDouble([this.x0]); - model.rpar = new ScilabDouble([this.A], [this.B], [this.C], [this.D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([sci2exp(this.A)], [sci2exp(this.B)], [sci2exp(this.C)], [sci2exp(this.D)], [sci2exp(this.x0)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TCLSS\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - - TCLSS.prototype.details = function TCLSS() { - return this.x; - } -} diff --git a/data_structures_correct/TEXT_f.js b/data_structures_correct/TEXT_f.js deleted file mode 100644 index cb5a481..0000000 --- a/data_structures_correct/TEXT_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function TEXT_f() { - - TEXT_f.prototype.define = function TEXT_f() { - this.font = 2; - this.siz = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["text"]); - model.rpar = new ScilabString(["Text"]); - model.ipar = new ScilabDouble([this.font], [this.siz]); - - var exprs = ["Text", this.font, this.siz]; - - var graphics = scicos_graphics(); - graphics.orig = new ScilabDouble([0, 0]); - graphics.sz = new ScilabDouble([2, 1]); - graphics.exprs = new ScilabString(exprs); - this.x = mlist(["Text", "graphics", "model", "void", "gui"], new ScilabString(["Text", "graphics", "model", "void", "gui"]), graphics, model, new ScilabString([" "]), new ScilabString(["TEXT_f"])); - return new TextBlock(this.x); - } - - TEXT_f.prototype.details = function TEXT_f() { - return this.x; - } -} diff --git a/data_structures_correct/TIME_DELAY.js b/data_structures_correct/TIME_DELAY.js deleted file mode 100644 index 8438941..0000000 --- a/data_structures_correct/TIME_DELAY.js +++ /dev/null @@ -1,28 +0,0 @@ -function TIME_DELAY() { - - TIME_DELAY.prototype.define = function TIME_DELAY() { - this.nin = 1; - this.T = 1; - this.init = 0; - this.N = 1024; - - var model = scicos_model(); - model.sim = list(new ScilabString(["time_delay"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nin]); - model.out = new ScilabDouble([this.nin]); - model.rpar = new ScilabDouble([this.T, this.init]); - model.ipar = new ScilabDouble([this.N]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var exprs = new ScilabString([this.T], [this.init], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TIME_DELAY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3.5, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TIME_DELAY.prototype.details = function TIME_DELAY() { - return this.x; - } -} diff --git a/data_structures_correct/TIME_f.js b/data_structures_correct/TIME_f.js deleted file mode 100644 index a9c233c..0000000 --- a/data_structures_correct/TIME_f.js +++ /dev/null @@ -1,18 +0,0 @@ -function TIME_f() { - - TIME_f.prototype.define = function TIME_f() { - var model = scicos_model(); - model.sim = new ScilabString(["timblk"]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, true]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TIME_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - - TIME_f.prototype.details = function TIME_f() { - return this.x; - } -} diff --git a/data_structures_correct/TKSCALE.js b/data_structures_correct/TKSCALE.js deleted file mode 100644 index 532a923..0000000 --- a/data_structures_correct/TKSCALE.js +++ /dev/null @@ -1,26 +0,0 @@ -function TKSCALE() { - - TKSCALE.prototype.define = function TKSCALE() { - this.a = -10; - this.b = 10; - this.f = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tkscaleblk"]), new ScilabDouble([5])); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([this.a], [this.b], [this.f]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([sci2exp(this.a)], [sci2exp(this.b)], [sci2exp(this.f)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TKSCALE\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TKSCALE.prototype.details = function TKSCALE() { - return this.x; - } -} diff --git a/data_structures_correct/TOWS_c.js b/data_structures_correct/TOWS_c.js deleted file mode 100644 index e4ea771..0000000 --- a/data_structures_correct/TOWS_c.js +++ /dev/null @@ -1,33 +0,0 @@ -function TOWS_c() { - - TOWS_c.prototype.define = function TOWS_c() { - this.nu = -1; - this.nz = 128; - this.varnam = "A"; - this.herit = 0; - - var model = scicos_model(); - model.sim = list(new ScilabString(["tows_c"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nu]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([this.nz], [this.varnam.length], ascii(this.varnam)); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TOWS_c\",sz(1),sz(2));"]);; - - var exprs = new ScilabString([this.nz], [this.varnam], [this.herit]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TOWS_c.prototype.details = function TOWS_c() { - return this.x; - } -} diff --git a/data_structures_correct/TRASH_f.js b/data_structures_correct/TRASH_f.js deleted file mode 100644 index 27da7c0..0000000 --- a/data_structures_correct/TRASH_f.js +++ /dev/null @@ -1,23 +0,0 @@ -function TRASH_f() { - - TRASH_f.prototype.define = function TRASH_f() { - this.in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.in = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([" "]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TRASH_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TRASH_f.prototype.details = function TRASH_f() { - return this.x; - } -} diff --git a/data_structures_correct/TrigFun.js b/data_structures_correct/TrigFun.js deleted file mode 100644 index e23141c..0000000 --- a/data_structures_correct/TrigFun.js +++ /dev/null @@ -1,21 +0,0 @@ -function TrigFun() { - - TrigFun.prototype.define = function TrigFun() { - var model = scicos_model(); - model.sim = list(new ScilabString(["sin_blk"]), new ScilabDouble([4])); - model.in = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString(["sin"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"TrigFun\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - TrigFun.prototype.details = function TrigFun() { - return this.x; - } -} diff --git a/data_structures_correct/VARIABLE_DELAY.js b/data_structures_correct/VARIABLE_DELAY.js deleted file mode 100644 index 11f8d4b..0000000 --- a/data_structures_correct/VARIABLE_DELAY.js +++ /dev/null @@ -1,28 +0,0 @@ -function VARIABLE_DELAY() { - - VARIABLE_DELAY.prototype.define = function VARIABLE_DELAY() { - this.nin = 1; - this.T = 1; - this.init = 0; - this.N = 1024; - - var model = scicos_model(); - model.sim = list(new ScilabString(["variable_delay"]), new ScilabDouble([4])); - model.in = new ScilabDouble([this.nin], [1]); - model.out = new ScilabDouble([this.nin]); - model.rpar = new ScilabDouble([this.T, this.init]); - model.ipar = new ScilabDouble([this.N]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([this.T], [this.init], [this.N]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VARIABLE_DELAY\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - VARIABLE_DELAY.prototype.details = function VARIABLE_DELAY() { - return this.x; - } -} diff --git a/data_structures_correct/VVsourceAC.js b/data_structures_correct/VVsourceAC.js deleted file mode 100644 index 120b3bb..0000000 --- a/data_structures_correct/VVsourceAC.js +++ /dev/null @@ -1,39 +0,0 @@ -function VVsourceAC() { - - VVsourceAC.prototype.define = function VVsourceAC() { - var model = scicos_model(); - - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - - this.VA = 220; - this.FR = 50; - - model.rpar = new ScilabDouble([this.FR]); - model.sim = new ScilabString(["VVsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = modelica_function(); - mo.model = new ScilabString(["VVsourceAC"]); - mo.inputs = new ScilabString(["p", "VA"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["f"]), list(new ScilabDouble([this.FR]))); - model.equations = mo; - - var exprs = new ScilabString([this.FR]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VVsourceAC\",sz(1),sz(2));"]); - - - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I", "E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - return new BasicBlock(this.x); - } - - VVsourceAC.prototype.details = function VVsourceAC() { - return this.x; - } -} diff --git a/data_structures_correct/VanneReglante.js b/data_structures_correct/VanneReglante.js deleted file mode 100644 index a501c2f..0000000 --- a/data_structures_correct/VanneReglante.js +++ /dev/null @@ -1,37 +0,0 @@ -function VanneReglante() { - - VanneReglante.prototype.define = function VanneReglante() { - var model = scicos_model(); - model.in = new ScilabDouble([1], [1]); - model.out = new ScilabDouble([1]); - - this.Cvmax = 8005.42; - this.p_rho = 0; - - model.rpar = new ScilabDouble([this.Cvmax], [this.p_rho]); - model.sim = new ScilabString(["VanneReglante"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VanneReglante"]); - mo.inputs = new ScilabString(["C1", "Ouv"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters = list(new ScilabString(["Cvmax"], ["p_rho"]), new ScilabDouble([this.Cvmax], [this.p_rho])); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabString([this.Cvmax], [this.p_rho]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VanneReglante\",sz(1),sz(2));"]); - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"], ["E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - VanneReglante.prototype.details = function VanneReglante() { - return this.x; - } -} diff --git a/data_structures_correct/VariableResistor.js b/data_structures_correct/VariableResistor.js deleted file mode 100644 index 4e5a5e1..0000000 --- a/data_structures_correct/VariableResistor.js +++ /dev/null @@ -1,29 +0,0 @@ -function VariableResistor() { - - VariableResistor.prototype.define = function VariableResistor() { - var model = scicos_model(); - model.sim = new ScilabString(["VariableResistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VariableResistor"]); - mo.inputs = new ScilabString(["p", "R"]); - mo.outputs = new ScilabString(["n"]); - model.equations = mo; - model.in = new ScilabDouble(...ones(size(getData(mo.inputs), "*"), 1)); - model.out = new ScilabDouble(...ones(size(getData(mo.outputs), "*"), 1)); - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VariableResistor\",sz(1),sz(2));"]);; - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I", "E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x); - } - - VariableResistor.prototype.details = function VariableResistor() { - return this.x; - } -} diff --git a/data_structures_correct/VirtualCLK0.js b/data_structures_correct/VirtualCLK0.js deleted file mode 100644 index 79f8e6e..0000000 --- a/data_structures_correct/VirtualCLK0.js +++ /dev/null @@ -1,22 +0,0 @@ -function VirtualCLK0() { - - VirtualCLK0.prototype.define = function VirtualCLK0() { - var model = scicos_model(); - model.sim = new ScilabString(["vrtclk0"]); - model.evtin = new ScilabDouble([1]); - model.opar = list(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabDouble(); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, new ScilabString([" "])); - return new BasicBlock(this.x); - } - - VirtualCLK0.prototype.details = function VirtualCLK0() { - return this.x; - } - -} diff --git a/data_structures_correct/VoltageSensor.js b/data_structures_correct/VoltageSensor.js deleted file mode 100644 index 0d00317..0000000 --- a/data_structures_correct/VoltageSensor.js +++ /dev/null @@ -1,29 +0,0 @@ -function VoltageSensor() { - - VoltageSensor.prototype.define = function VoltageSensor() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1], [, 1]); - model.sim = new ScilabString(["VoltageSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = new modelica_function(); - mo.model = new ScilabString(["VoltageSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"], ["v"]); - model.equations = mo; - - var exprs = new ScilabDouble(); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VoltageSensor\",sz(1),sz(2));"]);; - this.x = standard_define([2, 2], model, exprs, list(gr_i, new ScilabDouble([0]))); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"], ["E"]); - return new VoltageSensorBlock(this.x); - } - - VoltageSensor.prototype.details = function VoltageSensor() { - return this.x; - } -} diff --git a/data_structures_correct/VsourceAC.js b/data_structures_correct/VsourceAC.js deleted file mode 100644 index 59cc3b4..0000000 --- a/data_structures_correct/VsourceAC.js +++ /dev/null @@ -1,37 +0,0 @@ -function VsourceAC() { - - VsourceAC.prototype.define = function VsourceAC() { - var model = scicos_model(); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - this.VA = 220; - - this.FR = 50; - model.rpar = new ScilabDouble([this.VA], [this.FR]); - model.sim = new ScilabString(["VsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var mo = modelica_function(); - mo.model = new ScilabString(["VsourceAC"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters = list(new ScilabString(["VA"], ["f"]), list(new ScilabDouble([this.VA]), new ScilabDouble([this.FR]))); - model.equations = mo; - - var exprs = new ScilabString([this.VA], [this.FR]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"VsourceAC\",sz(1),sz(2));"]); - - this.x = standard_define([2, 2], model, exprs, list(gr_i, 0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - - return new BasicBlock(this.x); - } - - VsourceAC.prototype.details = function VsourceAC() { - return this.x; - } -} diff --git a/data_structures_correct/WRITEAU_f.js b/data_structures_correct/WRITEAU_f.js deleted file mode 100644 index 8bc9657..0000000 --- a/data_structures_correct/WRITEAU_f.js +++ /dev/null @@ -1,31 +0,0 @@ -function WRITEAU_f() { - - WRITEAU_f.prototype.define = function WRITEAU_f() { - this.in1 = 1; - this.nin = math.sum(this.in1); - this.frmt = "uc "; - this.fname = "/dev/audio"; - this.swap = 0; - this.lunit = 0; - this.N = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["writeau"]), new ScilabDouble([2])); - model.in = new ScilabDouble([this.in1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [this.lunit], ...zeros((this.nin + 1) * this.N, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.N], [this.swap], ..._str2code(this.fname)); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"WRITEAU_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - WRITEAU_f.prototype.details = function WRITEAU_f() { - return this.x; - } -} diff --git a/data_structures_correct/WRITEC_f.js b/data_structures_correct/WRITEC_f.js deleted file mode 100644 index 0e6fefa..0000000 --- a/data_structures_correct/WRITEC_f.js +++ /dev/null @@ -1,31 +0,0 @@ -function WRITEC_f() { - - WRITEC_f.prototype.define = function WRITEC_f() { - this.in = 1; - this.nin = math.sum(this.in); - this.frmt = "c "; - this.fname = "foo"; - this.swap = 0; - this.lunit = 0; - this.N = 2; - - var model = scicos_model(); - model.sim = list(new ScilabString(["writec"]), new ScilabDouble([2])); - model.in = new ScilabDouble([this.in]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1], [this.lunit], ...zeros((this.nin + 1) * this.N, 1)); - model.ipar = new ScilabDouble([this.fname.length], ..._str2code(this.frmt), [this.N], [this.swap], ..._str2code(this.fname)); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in)], [this.fname], [this.frmt], [this.N], [this.swap]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"WRITEC_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - - WRITEC_f.prototype.details = function WRITEC_f() { - return this.x; - } -} diff --git a/data_structures_correct/ZCROSS_f.js b/data_structures_correct/ZCROSS_f.js deleted file mode 100644 index 8d2e66a..0000000 --- a/data_structures_correct/ZCROSS_f.js +++ /dev/null @@ -1,29 +0,0 @@ -function ZCROSS_f() { - - ZCROSS_f.prototype.define = function ZCROSS_f() { - this.rpar = [[-1], [-1], [0], [0]]; - - this.in = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["zcross"]), new ScilabDouble([1])); - model.in = new ScilabDouble([this.in]); - model.nzcross = new ScilabDouble([this.in]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1], [-1], [0], [0]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = new ScilabString([sci2exp(this.in)]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"ZCROSS_f\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i); - - return new BasicBlock(this.x); - } - - ZCROSS_f.prototype.details = function ZCROSS_f() { - return this.x; - } -} diff --git a/data_structures_correct/c_block.js b/data_structures_correct/c_block.js deleted file mode 100644 index 7481ea7..0000000 --- a/data_structures_correct/c_block.js +++ /dev/null @@ -1,33 +0,0 @@ -function c_block() { - - c_block.prototype.define = function c_block() { - - this.in1 = 1; - this.out = 1; - this.rpar = []; - this.typ = "c"; - this.funam = "toto"; - - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([2001])); - model.in = new ScilabDouble([this.in1]); - model.out = new ScilabDouble([this.out]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = list(new ScilabString([sci2exp(this.in1)], [sci2exp(this.out)], [sci2exp(this.rpar)], [this.funam]), list(new ScilabDouble())); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"c_block\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - c_block.prototype.details = function c_block() { - return this.x; - } -} diff --git a/data_structures_correct/combine_script.bat b/data_structures_correct/combine_script.bat deleted file mode 100644 index 54d2926..0000000 --- a/data_structures_correct/combine_script.bat +++ /dev/null @@ -1 +0,0 @@ -copy /b *.js ..\combined.js diff --git a/data_structures_correct/fortran_block.js b/data_structures_correct/fortran_block.js deleted file mode 100644 index adfa5ef..0000000 --- a/data_structures_correct/fortran_block.js +++ /dev/null @@ -1,29 +0,0 @@ -function fortran_block() { - - fortran_block.prototype.define = function fortran_block() { - var model = scicos_model(); - model.sim = list(new ScilabString([" "]), new ScilabDouble([1001])); - model.in = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - this.funam = "forty"; - - var label = list(new ScilabString([sci2exp(parseInt(getData(model.in)))], [sci2exp(parseInt(getData(model.out)))], [sci2exp(getData(model.rpar))], [this.funam]), list(new ScilabDouble())); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"fortran_block\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - fortran_block.prototype.details = function fortran_block() { - return this.x; - } -} diff --git a/data_structures_correct/freq_div.js b/data_structures_correct/freq_div.js deleted file mode 100644 index c8cb1cc..0000000 --- a/data_structures_correct/freq_div.js +++ /dev/null @@ -1,146 +0,0 @@ -function freq_div() { - - freq_div.prototype.define = function freq_div() { - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(new Modulo_Count().internal()); - scs_m_1.objs.push(new CLKINV_f().internal()); - scs_m_1.objs.push(new CLKOUTV_f().internal()); - scs_m_1.objs.push(new IFTHEL_f().internal()); - scs_m_1.objs.push(new CLKSPLIT_f().internal()); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs[0]; - var graphics = blk.graphics; - var model = blk.model; - graphics.orig = new ScilabDouble([0, -100]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["0"], ["3"]); - model.dstate = new ScilabDouble([3]); - model.ipar = new ScilabDouble([3]); - graphics.pout = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([10]); - graphics.out_implicit = new ScilabString(["E"]); - graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - graphics.out_label = new ScilabString([""]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[0] = blk; - - blk = scs_m_1.objs[1]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([120, 0]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.peout = new ScilabDouble([6]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[1] = blk; - - blk = scs_m_1.objs[2]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([130, -160]); - graphics.sz = new ScilabDouble([20, 20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[2] = blk; - - blk = scs_m_1.objs[3]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([100, -100]); - graphics.sz = new ScilabDouble([60, 40]); - graphics.exprs = new ScilabString(["1"], ["0"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([9]); - graphics.peout = new ScilabDouble([0], [8]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[3] = blk; - - blk = scs_m_1.objs[4]; - graphics = blk.graphics; - model = blk.model; - graphics.orig = new ScilabDouble([127, -33]); - graphics.sz = new ScilabDouble([7, 7]); - graphics.pein = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([9], [10]); - model.uid = new ScilabString([count]); - blk.doc = list(new ScilabString([count++])); - blk.graphics = graphics; - blk.model = model; - scs_m_1.objs[4] = blk; - - var lnk = scs_m_1.objs[5]; - lnk.xx = new ScilabDouble([170], [170.5]); - lnk.yy = new ScilabDouble([-44], [-75]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([2, 1, 0]); - lnk.to = new ScilabDouble([5, 1, 1]); - scs_m_1.objs[5] = lnk; - - lnk = scs_m_1.objs[6]; - lnk.xx = new ScilabDouble([104], [136]); - lnk.yy = new ScilabDouble([-100], [-100]); - lnk.from = new ScilabDouble([1, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[6] = lnk; - - lnk = scs_m_1.objs[7]; - lnk.xx = new ScilabDouble([180], [180]); - lnk.yy = new ScilabDouble([-124], [-176]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([4, 2, 0]); - lnk.to = new ScilabDouble([3, 1, 1]); - scs_m_1.objs[7] = lnk; - - lnk = scs_m_1.objs[8]; - lnk.xx = new ScilabDouble([170], [170.5]); - lnk.yy = new ScilabDouble([-44], [-75]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([5, 1, 0]); - lnk.to = new ScilabDouble([4, 1, 1]); - scs_m_1.objs[8] = lnk; - - lnk = scs_m_1.objs[9]; - lnk.xx = new ScilabDouble([169], [170]); - lnk.yy = new ScilabDouble([-90], [-76]); - lnk.xx = new ScilabDouble([0, 30, 1]); - lnk.yy = new ScilabDouble([0, -30, 1]); - lnk.ct = new ScilabDouble([5, -1]); - lnk.from = new ScilabDouble([5, 2, 0]); - lnk.to = new ScilabDouble([1, 1, 1]); - scs_m_1.objs[9] = lnk; - - model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = scs_m_1; - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),"freq_div",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([3, 2]), model, new ScilabDouble(), gr_i); - return new BasicBlock(this.x); - } - freq_div.prototype.details = function freq_div() { - return this.x; - } -} diff --git a/data_structures_correct/generic_block3.js b/data_structures_correct/generic_block3.js deleted file mode 100644 index 6679727..0000000 --- a/data_structures_correct/generic_block3.js +++ /dev/null @@ -1,25 +0,0 @@ -function generic_block3() { - - generic_block3.prototype.define = function generic_block3() { - var model = scicos_model(); - this.function_name = "sinblk"; - this.funtyp = 4; - model.sim = list(new ScilabString([this.function_name]), new ScilabDouble([this.funtyp])); - model.in = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true, false]); - - var label = new ScilabString([this.function_name], [sci2exp(this.funtyp)], [sci2exp([parseInt(getData(model.in)[0]), parseInt(getData(model.in2)[0])])], [sci2exp(parseInt(getData(model.intyp)[0]))], [sci2exp([parseInt(getData(model.out)[0]), parseInt(getData(model.out2)[0])])], [sci2exp(parseInt(getData(model.outtyp)[0]))], [sci2exp(getData(model.evtin))], [sci2exp(getData(model.evtout))], [sci2exp(getData(model.state))], [sci2exp(getData(model.dstate))], [sci2exp(model.odstate)], [sci2exp(getData(model.rpar))], [sci2exp(getData(model.ipar))], [sci2exp(model.opar)], [sci2exp(parseInt(getData(model.nmode)[0]))], [sci2exp(parseInt(getData(model.nzcross)[0]))], [sci2exp(getData(model.firing))], ["y"], ["n"]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"generic_block3\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, label, gr_i); - return new BasicBlock(this.x); - } - generic_block3.prototype.details = function generic_block3() { - return this.x; - } -} diff --git a/data_structures_correct/scifunc_block_m.js b/data_structures_correct/scifunc_block_m.js deleted file mode 100644 index a15ee4a..0000000 --- a/data_structures_correct/scifunc_block_m.js +++ /dev/null @@ -1,43 +0,0 @@ -function scifunc_block_m() { - - scifunc_block_m.prototype.define = function scifunc_block_m() { - this.in1 = 1; - this.out = 1; - this.clkin = []; - this.clkout = []; - this.x0 = []; - this.z0 = []; - this.typ = "c"; - this.auto = []; - this.rpar = []; - this.it = 1; - - var model = scicos_model(); - model.sim = list(new ScilabString(["scifunc"]), new ScilabDouble([3])); - model.in = new ScilabDouble([this.in1]); - model.in2 = new ScilabDouble([this.in1]); - model.intyp = new ScilabDouble([this.it]); - model.out = new ScilabDouble([this.out]); - model.out2 = new ScilabDouble([this.out]); - model.outtyp = new ScilabDouble([this.it]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.opar = list(); - model.blocktype = new ScilabString([this.typ]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true, false]); - - var exprs = list(new ScilabString([sci2exp([this.in1, this.in1])], [sci2exp([this.out, this.out])], [sci2exp(this.clkin)], [sci2exp(this.clkout)], [sci2exp(this.x0)], [sci2exp(this.z0)], [sci2exp(this.rpar)], [sci2exp(this.auto)], [sci2exp(0)]), list(new ScilabString(["y1=sin(u1)"]), new ScilabString([" "]), new ScilabString([" "]), new ScilabString(["y1=sin(u1)"]), new ScilabString([" "]), new ScilabString([" "]), new ScilabString([" "]))); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"scifunc_block_m\",sz(1),sz(2));"]); - this.x = new standard_define(new ScilabDouble([4, 2]), model, exprs, gr_i); - return new BasicBlock(this.x); - } - scifunc_block_m.prototype.details = function scifunc_block_m() { - return this.x; - } -} diff --git a/dependencies.js b/dependencies.js deleted file mode 100644 index 36106e8..0000000 --- a/dependencies.js +++ /dev/null @@ -1,1497 +0,0 @@ -$.getScript('math.js'); - -// @Adhitya: 02-07-2016: Commented Jitesh's work to call Data Structures individually, -// and combined all of them into combined.js using combine_script.bat - -/* -$.ajax({ - type: "POST", - // Invoke filenames.php - url: "filenames.php", - // Receive the resultant filenames from the php script in JSON format - dataType: "json", - // Add url for the required folder - data: { - url: "/data_structures_correct/" - }, - success: function (data) { - - // @Parameter: data will have the required filenames in the mentioned folder - // For each url, add the script to the body div element with getScript function - for (i in data) { - $.getScript(data[i]); - } - } -}); -*/ - -// Added to handle ordering for a few blocks. - -window.inBitMap='0'; -window.outBitMap='0'; - -String.prototype.replaceAt=function(index, character) { - return this.substr(0, index) + character + this.substr(index+character.length); -} - -/* - Maverick, Adhitya - ImplicitInBlock, ImplicitOutBlock, ExplicitInBlock, ExplicitOutBlock - These blocks need their orderings to be handled. - We are using a bitmap to do the same. -*/ - -function handleOrdering(inOrOut){ - var bitmap; - if(inOrOut=='in'){ - bitmap=window.inBitMap; - } - else{ - bitmap=window.outBitMap; - } - var index = bitmap.indexOf('0'); - if(index == -1){ - bitmap += '0'; - index = bitmap.indexOf('0'); - } - bitmap = bitmap.replaceAt(index,'1'); - if(inOrOut=='in'){ - window.inBitMap=bitmap; - } - else{ - window.outBitMap=bitmap; - } - var position = 1+index; - - return position; -} - -function AfficheBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - if (dep_ut[1] == "true") - this.dependsOnT = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.dState = options.model.dstate; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "AfficheBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function BigSom() { - if (arguments.length > 0) { - var options = arguments[0]; - - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = "+"; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "BigSom"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function EventInBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.equations = list(); // Not Known - this.blockName = "EventInBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function EventOutBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.equations = list(); // Not Known - this.blockName = "EventOutBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function RoundBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "RoundBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function GroundBlock() { - - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.oDState = list(); - this.equations = options.model.equations; // Not Known - this.blockName = "GroundBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function TextBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options["model"].blocktype)[0]; - this.connectable = options.connectable; // Not Known - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options["model"].sim[0])[0]; - var func_type; - switch (getData(options[model].sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options["model"].sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options["graphics"].exprs; - this.realParameters = options["model"].rpar; - this.objectsParameters = options["model"].opar; - this.nbZerosCrossing = options["model"].nzcross; - this.nmode = options["model"].nmode; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "TextBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function Product() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - if (dep_ut[1] == "true") - this.dependsOnT = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - if(!isEmpty(options.graphics.style)) { - this.style = getData(options.graphics.style)[0]; - } - else { - this.style = arguments.callee.caller.name; - } - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.oDState = options.model.odstate; - this.equations = options.model.equations; - this.blockName = "Product"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function ImplicitOutBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - if (dep_ut[1] == "true") - this.dependsOnT = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = handleOrdering('out'); - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.equations = options.model.equations; - this.blockName = "ImplicitOutBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function ImplicitInBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - if (dep_ut[1] == "true") - this.dependsOnT = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = handleOrdering('in'); - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.equations = options.model.equations; - this.blockName = "ImplicitInBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function ExplicitInBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = handleOrdering('in'); - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.equations = options.model.equations; - this.blockName = "ExplicitInBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - - -function ExplicitOutBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = handleOrdering('out'); - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.equations = options.model.equations; - this.blockName = "ExplicitOutBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function VoltageSensorBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.oDState = list(); - this.equations = options.model.equations; // Not Known - this.blockName = "VoltageSensorBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function Summation() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "Summation"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function SuperBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") { - this.dependsOnU = "1"; - } - if (dep_ut[1] == "true") { - this.dependsOnT = "1"; - } - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.realParameters = options.model.rpar; - this.oDState = list(); - this.equations = list(); // Not Known - this.blockName = "SuperBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function zeros() { - if (arguments.length == 0) { - return [0]; - } else if (arguments.length == 1) { - var a = arguments[0]; - if (typeof a.length === 'undefined') { - return [0]; - } else { - return math.zeros(math.size(a)); - } - } else { - var args = Array.prototype.slice.call(arguments); - return math.zeros(args); - } -} - -function ones() { - if (arguments.length == 0) { - return [1]; - } else if (arguments.length == 1) { - var a = arguments[0]; - if (typeof a.length === 'undefined') { - return [1]; - } else { - return math.ones(math.size(a)); - } - } else { - var args = Array.prototype.slice.call(arguments); - return math.ones(args); - } -} - -function size() { - - if (arguments.length == 1) - return math.size(arguments[0]) - else { - var res = math.size(arguments[0]); - - if (res.length == 1) - res.push(1); - - switch (arguments[1]) { - case 'r': - case 1: - return res[0]; - case 'c': - case 2: - return res[1]; - case '*': - return res[0] * res[1]; - default: - return res[arguments[1]]; - } - } -} - -function inverse() { - var str = "[[" - var arg = arguments[0]; - arg = arg.replace(/ /g, "],["); - str += arg + "]]"; - var array = JSON.parse(str); - return array; -} - -function _str2code() { - var conversion = "0123456789abcdefghijklmnopqrstuvwxyz_#!$ ();:+-*/\\=.,'[]%|&<>~^"; - var conversion2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ00?0 00000000$000\"{}000`0@0r"; - var str = arguments[0]; - var code = []; - for (var i = 0; i < str.length; i++) { - code[i] = [conversion.indexOf(str[i])]; - if (code[i] == -1) { - code[i] = [conversion2.indexOf(str[i]) * -1]; - } - } - return code; -} - -function real() { - var matrix = arguments[0]; - var sz = math.size(matrix); - var res = []; - for (var i = 0; i < sz[0]; i++) { - for (var j = 0; j < sz[1]; j++) { - res.push([math.re(matrix[i][j])]); - } - } - return res; -} - -function imag() { - var matrix = arguments[0]; - var sz = math.size(matrix); - var res = []; - for (var i = 0; i < sz[0]; i++) { - for (var j = 0; j < sz[1]; j++) { - res.push([math.im(matrix[i][j])]); - } - } - return res; -} - -function _check() { - var param = arguments[0]; - if(typeof param == "object") { - var str = param.toString(); - str = str.substring(1, str.length - 1); - str = str.replace(/\B\+/,"+%i*"); - str = str.replace(/\B-/,"-%i*"); - str = param.toString().substring(0,1) + str; - str = str.replace(/ /g,''); - return str; - } - else if(typeof param == "string") { - return '"'+param+'"'; - } - else { - return param; - } -} - -// Converts String to Array of ASCII values - -function ascii() { - - var convertAscii = []; - - for (var i = 0; i < arguments[0].length; i++) { - convertAscii.push(arguments[0].charCodeAt(i)); - } - - return convertAscii; -} - -function genSwitchInnerDiagram(stateOpen) { - diagram = scicos_diagram(); - // Input forward - diagram.objs.push(new IN_f().internal()); - diagram.objs[0].graphics.pout = new ScilabDouble([5]); - diagram.objs[0].graphics.flip = new ScilabBoolean([true]); - diagram.objs[0].model.uid = new ScilabString([count]); - diagram.objs[0].doc = list(new ScilabString([count++])); - - // Output's forward - diagram.objs.push(new OUT_f().internal()); - diagram.objs[1].graphics.pin = new ScilabDouble([7]); - diagram.objs[1].graphics.flip = new ScilabBoolean([true]); - diagram.objs[1].model.outtyp = new ScilabDouble(); - diagram.objs[1].model.uid = new ScilabString([count]); - diagram.objs[1].doc = list(new ScilabString([count++])); - - diagram.objs.push(new CONST_m().internal()); - diagram.objs[2].graphics.pout = new ScilabDouble([6]); - diagram.objs[2].graphics.flip = new ScilabBoolean([true]); - diagram.objs[2].graphics.exprs = new ScilabString(["0"]); - diagram.objs[2].graphics.out_implicit = new ScilabString(["E"]); - diagram.objs[2].graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - diagram.objs[2].graphics.out_label = new ScilabString([""]); - diagram.objs[2].model.rpar = new ScilabDouble([0]); - diagram.objs[2].model.uid = new ScilabString([count]); - diagram.objs[2].doc = list(new ScilabString([count++])); - - diagram.objs.push(new SWITCH_f().internal()); - diagram.objs[3].graphics.pin = new ScilabDouble([5], [6]); - diagram.objs[3].graphics.flip = new ScilabBoolean([true]); - diagram.objs[3].graphics.pout = new ScilabDouble([7]); - diagram.objs[3].graphics.in_implicit = new ScilabString(["E"], ["E"]); - diagram.objs[3].graphics.in_style = new ScilabString(["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"], ["ExplicitInputPort;align=left;verticalAlign=middle;spacing=10.0;rotation=0"]); - diagram.objs[3].graphics.in_label = new ScilabString([""], [""]); - diagram.objs[3].graphics.out_implicit = new ScilabString(["E"]); - diagram.objs[3].graphics.out_style = new ScilabString(["ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"]); - diagram.objs[3].graphics.out_label = new ScilabString([""]); - diagram.objs[3].graphics.style = new ScilabString(["SWITCH_f"]); - diagram.objs[3].model.in2 = new ScilabDouble([1], [1]); - diagram.objs[3].model.intyp = new ScilabDouble([1], [1]); - diagram.objs[3].model.out2 = new ScilabDouble([1]); - diagram.objs[3].model.uid = new ScilabString([count]); - diagram.objs[3].doc = list(new ScilabString([count++])); - - if (stateOpen == true) { - diagram.objs[3].model.ipar = new ScilabDouble([1]); - diagram.objs[3].graphics.exprs = new ScilabString(["2"], ["2"]); - } else { - diagram.objs[3].model.ipar = new ScilabDouble([0]); - diagram.objs[3].graphics.exprs = new ScilabString(["2"], ["1"]); - } - - // IN_f <-> SWITCH_f - diagram.objs[4] = scicos_link({ - xx: new ScilabDouble([0], [0]), - yy: new ScilabDouble([0], [0]), - from: new ScilabDouble([1, 1, 0]), - to: new ScilabDouble([4, 1, 1]) - }); - // CONST_m <-> SWITCH_f - diagram.objs[5] = scicos_link({ - xx: new ScilabDouble([0], [0]), - yy: new ScilabDouble([0], [0]), - from: new ScilabDouble([3, 1, 0]), - to: new ScilabDouble([4, 2, 1]) - }); - // SWITCH_f <-> OUT_f - diagram.objs[6] = scicos_link({ - xx: new ScilabDouble([0], [0]), - yy: new ScilabDouble([0], [0]), - from: new ScilabDouble([4, 1, 0]), - to: new ScilabDouble([2, 1, 1]) - }); - - return diagram; -} diff --git a/details.js b/details.js deleted file mode 100644 index fa4211e..0000000 --- a/details.js +++ /dev/null @@ -1,643 +0,0 @@ -// All arrays - separated by ',' or ';' or ' ' are taken to be 1 Dimensional -// Only during printing, their nomenclature will change -// Good read: http://javascript.info/tutorial/arguments#keyword-arguments -/* -Authors: Adhitya, Nimish, Chhavi, Saarang -*/ -var script = document.createElement("script"); -script.src = "dependencies.js"; -document.head.appendChild(script); -var count = 1; - -function scicos_block() { - var options = arguments[0] || new Object(); - var block_type = ["Block", "graphics", "model", "gui", "doc"]; - this.Block = new ScilabString(block_type); - this.graphics = options.graphics || new scicos_graphics(); - this.model = options.model || new scicos_model(); - this.gui = options.gui || new ScilabString(); - this.doc = options.doc || list(); - - return mlist(block_type, this.Block, this.graphics, this.model, this.gui, this.doc); -} - -function standard_define() { - var sz = arguments[0]; - var model = arguments[1]; - var label = arguments[2]; - var gr_i = arguments[3] || new ScilabString(); - - var pin = new ScilabDouble(); - var pout = new ScilabDouble(); - var pein = new ScilabDouble(); - var peout = new ScilabDouble(); - - var nin = model.in.length; - if (nin > 0) { - pin = zeros(nin); - } - var nout = model.out.length; - if (nout > 0) { - pout = zeros(nout); - } - var ncin = model.evtin.length; - if (ncin > 0) { - pein = zeros(ncin); - } - var ncout = model.evtout.length; - if (ncout > 0) { - peout = zeros(ncout); - } - - gr_i = list(gr_i, new ScilabDouble([8])); - - if (gr_i[1] == []) { - gr_i[1] = new ScilabDouble([8]); - } - if (gr_i[1] == 0) { - gr_i[1] = new ScilabDouble(); - } - - var graphics_options = { - sz: sz, - pin: pin, - pout: pout, - pein: pein, - peout: peout, - gr_i: gr_i, - exprs: label - }; - var graphics = new scicos_graphics(graphics_options); - var block_options = { - graphics: graphics, - model: model, - gui: new ScilabString([arguments.callee.caller.name]) - }; - return new scicos_block(block_options); -} - -function scicos_graphics() { - var options = arguments[0] || new Object(); - var graphics_type = ["graphics", "orig", "sz", "flip", "theta", "exprs", "pin", "pout", "pein", "peout", "gr_i", "id", "in_implicit", "out_implicit", "in_style", "out_style", "in_label", "out_label", "style"]; - this.graphics = new ScilabString(graphics_type); - this.orig = options.orig || new ScilabDouble([0, 0]); - this.sz = options.sz || new ScilabDouble([80, 80]); // Space and comma works the same! - this.flip = options.flip || new ScilabBoolean([false]); - this.theta = options.theta || new ScilabDouble([0]); - this.exprs = options.exprs || new ScilabDouble(); - this.pin = options.pin || new ScilabDouble(); - this.pout = options.pout || new ScilabDouble(); - this.pein = options.pein || new ScilabDouble(); - this.peout = options.peout || new ScilabDouble(); - this.gr_i = options.gr_i || new ScilabString(); - this.id = options.id || new ScilabString([""]); - this.in_implicit = options.in_implicit || new ScilabDouble(); - this.out_implicit = options.out_implicit || new ScilabDouble(); // There is only one! - this.in_style = options.in_style || new ScilabDouble(); - this.out_style = options.out_style || new ScilabDouble(); - this.in_label = options.in_label || new ScilabDouble(); - this.out_label = options.out_label || new ScilabDouble(); - this.style = options.style || new ScilabString(); - - return mlist(graphics_type, this.graphics, this.orig, this.sz, this.flip, this.theta, this.exprs, this.pin, this.pout, this.pein, this.peout, this.gr_i, this.id, this.in_implicit, this.out_implicit, this.in_style, this.out_style, this.in_label, this.out_label, this.style); -} - -function scicos_model() { - var options = arguments[0] || new Object(); - var model_type = ["model", "sim", "in", "in2", "intyp", "out", "out2", "outtyp", "evtin", "evtout", "state", "dstate", "odstate", "rpar", "ipar", "opar", "blocktype", "firing", "dep_ut", "label", "nzcross", "nmode", "equations", "uid"]; - this.model = new ScilabString(model_type); - this.sim = options.sim || new ScilabString(); - this.in = options.in || new ScilabDouble(); - this.in2 = options.in2 || new ScilabDouble(); - this.intyp = options.intyp || new ScilabDouble(); // [1] - this.out = options.out || new ScilabDouble(); - this.out2 = options.out2 || new ScilabDouble(); - this.outtyp = options.outtyp || new ScilabDouble([1]); - this.evtin = options.evtin || new ScilabDouble(); - this.evtout = options.evtout || new ScilabDouble(); - this.state = options.state || new ScilabDouble(); - this.dstate = options.dstate || new ScilabDouble(); - this.odstate = options.odstate || list(); - this.ipar = options.ipar || new ScilabDouble(); - this.rpar = options.rpar || new ScilabDouble(); - this.opar = options.opar || list(); // new ScilabDouble(); - this.blocktype = options.blocktype || new ScilabString(["c"]); - this.firing = options.firing || new ScilabDouble(); - this.dep_ut = options.dep_ut || new ScilabBoolean([false, false]); - this.label = options.label || new ScilabString([""]); // If label not available, use image - this.nzcross = options.nzcross || new ScilabDouble([0]); - this.nmode = options.nmode || new ScilabDouble([0]);; - this.equations = options.equations || list(); - this.uid = options.uid || new ScilabString(); - - return mlist(model_type, this.model, this.sim, this.in, this.in2, this.intyp, this.out, this.out2, this.outtyp, this.evtin, this.evtout, this.state, this.dstate, this.odstate, this.ipar, this.rpar, this.opar, this.blocktype, this.firing, this.dep_ut, this.label, this.nzcross, this.nmode, this.equations, this.uid); -} - - - -function scicos_diagram() { - var options = arguments[0] || new Object(); - var diagram_type = ["diagram", "props", "objs", "version", "contrib"]; - this.diagram = new ScilabString(diagram_type); - this.props = options.props || scicos_params(); - this.objs = options.objs || list(); - this.version = options.version || new ScilabString([""]); - this.contrib = options.contrib || list(); - - return mlist(diagram_type, this.diagram, this.props, this.objs, this.version, this.contrib); -} - - -function scicos_params() { - var options = arguments[0] || new Object(); - var params_type = ["params", "wpar", "title", "tol", "tf", "context", "void1", "options", "void2", "void3", "doc"]; - this.params = new ScilabString(params_type); - this.wpar = options.wpar || new ScilabDouble([600, 450, 0, 0, 600, 450]); - this.title = options.title || options.Title || new ScilabString(["Untitled"]); - this.tf = options.tf || new ScilabDouble([100000]); - this.tol = options.tol || new ScilabDouble([Math.pow(10, -6)], [Math.pow(10, -6)], [Math.pow(10, -10)], [100001], [0], [1], [0]); - this.context = options.context || new ScilabString([""]); - this.void1 = new ScilabDouble(); - this.options = options.options || new default_options(); - this.void2 = new ScilabDouble(); - this.void3 = new ScilabDouble(); - this.doc = options.doc || list(); - - return tlist(params_type, this.params, this.wpar, this.title, this.tol, this.tf, this.context, this.void1, this.options, this.void2, this.void3, this.doc); -} - -function default_options() { - var options_type = ["scsopt", "3D", "Background", "Link", "ID", "Cmap"]; - this.scsopt = new ScilabString(options_type); - this.D3 = list(new ScilabBoolean([true]), new ScilabDouble([33])); - this.Background = new ScilabDouble([8, 1]); - this.Link = new ScilabDouble([1, 5]); - this.ID = list(new ScilabDouble([5, 1]), new ScilabDouble([4, 1])); - this.Cmap = new ScilabDouble([0.8, 0.8, 0.8]); - - return tlist(options_type, this.scsopt, this.D3, this.Background, this.Link, this.ID, this.Cmap); -} - - -function scicos_link() { - var options = arguments[0]; - var link_type = ["Link", "xx", "yy", "id", "thick", "ct", "from", "to"]; - this.Link = new ScilabString(link_type); - this.xx = options.xx || new ScilabDouble(); //inverse array - this.yy = options.yy || new ScilabDouble(); //inverse array - this.id = options.id || new ScilabString(["drawlink"]); // changed - this.thick = options.thick || new ScilabDouble([0, 0]); - this.ct = options.ct || new ScilabDouble([1, 1]); - this.from = options.from || new ScilabDouble(); - this.to = options.to || new ScilabDouble(); - - return mlist(link_type, this.Link, this.xx, this.yy, this.id, this.thick, this.ct, this.from, this.to); -} - - -function list() { - this.ScilabList = []; - for (var i = 0; i < arguments.length; i++) { - this.ScilabList.push(arguments[i]); - } - this.ScilabList.scilabClass = "ScilabList"; - - return this.ScilabList; -} - -function mlist() { - this.ScilabMList = {}; - for (var i = 1, j = 0; i < arguments.length; i++, j++) { - this.ScilabMList[arguments[0][j]] = arguments[i]; - } - this.ScilabMList.varName = ""; - this.ScilabMList.scilabClass = "ScilabMList"; - - return this.ScilabMList; -} - -function tlist() { - this.ScilabTList = {}; - for (var i = 1, j = 0; i < arguments.length; i++, j++) { - this.ScilabTList[arguments[0][j]] = arguments[i]; - } - this.ScilabTList.scilabClass = "ScilabTList"; - - return this.ScilabTList; -} - - -function ScilabString() { - var i = 0, - j = 0; - if (arguments.length) { - var array = arguments; - this.height = array.length; - this.width = array[0].length; - for (i = 0; i < this.height; i++) { - for (j = 0; j < this.width; j++) { - this["data" + i + j] = new data(); - this["data" + i + j].value = array[i][j]; - this["data" + i + j].line = i; - this["data" + i + j].column = j; - } - } - } -} - -function ScilabBoolean() { - var i = 0, - j = 0; - if (arguments.length) { - var array = arguments; - this.height = array.length; - this.width = array[0].length; - for (i = 0; i < this.height; i++) { - for (j = 0; j < this.width; j++) { - this["data" + i + j] = new data(); - this["data" + i + j].value = array[i][j].toString(); - this["data" + i + j].line = i; - this["data" + i + j].column = j; - } - } - } -} - -function ScilabDouble() { - var i = 0, - j = 0; - if (arguments.length) { - var array = arguments; - this.height = array.length; - this.width = array[0].length; - for (i = 0; i < this.height; i++) { - for (j = 0; j < this.width; j++) { - this["data" + i + j] = new data(); - if(array[i][j] % 1 == 0) { - this["data" + i + j].realPart = array[i][j].toFixed(1); - } - else { - this["data" + i + j].realPart = array[i][j]; - } - this["data" + i + j].line = i; - this["data" + i + j].column = j; - } - } - } -} - -function ScilabInteger() { - var i = 0, - j = 0; - if (arguments.length) { - var array = arguments; - this.height = array.length; - this.width = array[0].length; - for (i = 0; i < this.height; i++) { - for (j = 0; j < this.width; j++) { - this["data" + i + j] = new data(); - this["data" + i + j].value = array[i][j]; - this["data" + i + j].line = i; - this["data" + i + j].column = j; - } - } - } -} - -function int32() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_int32"; - return int; -} - -function int16() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_int16"; - return int; -} - -function int8() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_int8"; - return int; -} - -function uint32() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_uint32"; - return int; -} - -function uint16() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_uint16"; - return int; -} - -function uint8() { - var args = Array.prototype.slice.call(arguments); - var int = new ScilabInteger(...args); - int.intPrecision = "sci_uint8"; - return int; -} - - -function data() { - this.line; - this.column; - this.realPart; - this.value; -} - -function getData() { - var dataObject = arguments[0]; - var key; - var dataArray = []; - for (key in dataObject) { - if (key != "height" && key != "width") { - if (typeof dataObject[key].value === "undefined") { - dataArray.push(dataObject[key].realPart); - } else { - dataArray.push(dataObject[key].value); - } - } - } - return dataArray; -} - -function isEmpty() { - return !getData(arguments[0]).length; -} - -function modelica_function() { - var modelica_type = ["modelica", "model", "inputs", "outputs", "parameters"]; - this.modelica = new ScilabString(modelica_type); - this.model = []; - this.inputs = []; - this.outputs = []; - this.parameters = list([], list()); - var mo = tlist(modelica_type, this.modelica, this.model, this.inputs, this.outputs, this.parameters); - return mo; -} - -// To add Block name under the instance tag in xml. -function instance() { - this.instance = arguments[0]; -} - -function createInstanceTag() { - return new instance(arguments[0]); -} - - -function CLKIN_f() { - - CLKIN_f.prototype.internal = function CLKIN_f() { - var model = scicos_model(); - var port = 1; - - model.sim = new ScilabString(["input"]); - model.outtyp = new ScilabDouble(); //changed - model.evtout = new ScilabDouble([-1]); // 1, 1 -> -1, -1 - model.ipar = new ScilabDouble([port]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([port]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKIN_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - - block.graphics.style = new ScilabString(["CLKIN_f"]); - return block; - } -} - -function CLKOUT_f() { - - CLKOUT_f.prototype.internal = function CLKOUT_f() { - var model = scicos_model(); - var port = 1; - - model.sim = new ScilabString(["output"]); - model.outtyp = new ScilabDouble(); - model.evtin = new ScilabDouble([-1]); // 1, 1 -> -1, -1 - model.ipar = new ScilabDouble([port]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = ScilabString(["" + port]); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKOUT_f\",sz(1),sz(2));"]); - var block = new standard_define(new ScilabDouble([80, 80]), model, exprs, gr_i); // 1 -> 80 - - block.graphics.style = new ScilabString(["CLKOUT_f"]); - return block; - } -} - -function CLKSPLIT_f() { - - CLKSPLIT_f.prototype.internal = function CLKSPLIT_f() { - var model = scicos_model(); - model.sim = new ScilabString(["split"]); - model.evtin = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble(); // changed - model.evtout = new ScilabDouble([-1], [-1]) // 1, 1 -> -1, -1 inverse - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1], [-1]); // inverse - model.dep_ut = new ScilabBoolean([false, false]); - - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"CLKSPLIT_f\",sz(1),sz(2));"]); - - var block = new standard_define(new ScilabDouble([80, 80]), model, new ScilabDouble(), gr_i); // 1 -> 80 - block.graphics.style = new ScilabString(["CLKSPLIT_f"]); - return block; - } -} - -function STEP() { - - STEP.prototype.internal = function STEP() { - this.rpar=[[0],[1]]; - var model = scicos_model(); - model.sim = list(new ScilabString(["step_func"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.firing = new ScilabDouble([1]); - model.rpar = new ScilabDouble(...this.rpar); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false, false]); - - var exprs = new ScilabString([1],...this.rpar); - var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"STEP\",sz(1),sz(2));"]); - - var block = new standard_define(new ScilabDouble([80, 80]), model,exprs, gr_i); // 1 -> 80 - block.graphics.style = new ScilabString(["STEP"]); - return block; - } -} - - -function BasicBlock() { - if (arguments.length > 0) { - var options = arguments[0]; - this.angle = options.angle; // Not Known - this.blockType = getData(options.model.blocktype)[0]; - this.connectable = options.connectable; // Not Known - var dep_ut = getData(options.model.dep_ut); - if (dep_ut[0] == "true") - this.dependsOnU = "1"; - if (dep_ut[1] == "true") - this.dependsOnT = "1"; - this.id = options.id; - this.interfaceFunctionName = arguments.callee.caller.name; - this.ordering = options.ordering; - this.parent = options.parent; - if (options.model.sim instanceof Array) { - this.simulationFunctionName = getData(options.model.sim[0])[0]; - var func_type; - switch (getData(options.model.sim[1])[0].toString()) { - case "-2.0": - func_type = "ESELECT"; - break; - case "-1.0": - func_type = "IFTHENELSE"; - break; - case "1.0": - func_type = "TYPE_1"; - break; - case "2.0": - func_type = "TYPE_2"; - break; - case "3.0": - func_type = "TYPE_3"; - break; - case "4.0": - func_type = "C_OR_FORTRAN"; - break; - case "5.0": - func_type = "SCILAB"; - break; - case "99.0": - func_type = "DEBUG"; - break; - case "1001.0": - func_type = "DYNAMIC_FORTRAN_1"; - break; - case "2001.0": - func_type = "DYNAMIC_C_1"; - break; - case "2004.0": - func_type = "DYNAMIC_EXPLICIT_4"; - break; - case "10001.0": - func_type = "OLDBLOCKS"; - break; - case "10004.0": - func_type = "IMPLICIT_C_OR_FORTRAN"; - break; - case "30004.0": - func_type = "MODELICA"; - break; - } - this.simulationFunctionType = func_type; - } else { - this.simulationFunctionName = getData(options.model.sim)[0]; - this.simulationFunctionType = "DEFAULT"; - } - this.style = arguments.callee.caller.name; - this.value = options.value; // Not Known - this.vertex = options.vertex; // Not Known - this.visible = options.visible; // Not Known - this.exprs = options.graphics.exprs; - this.realParameters = options.model.rpar; - this.integerParameters = options.model.ipar; - this.objectsParameters = options.model.opar; - this.nbZerosCrossing = options.model.nzcross; - this.nmode = options.model.nmode; - if(!isEmpty(options.model.state)) { - this.state = options.model.state; - } - if(!isEmpty(options.model.dstate)) { - this.dState = options.model.dstate; - } - this.oDState = options.model.odstate; - this.equations = options.model.equations; - this.blockName = "BasicBlock"; - this.blockElementName = arguments.callee.caller.name; - } -} - -function sci2exp(c) { - if (c.scilabClass == "ScilabList") { - c = Object.create(c); - c.scilabClass = ""; - if (c.length) { - return "list(" + sci2exp(c) + ")"; - } else { - return "list()"; - } - } else if (typeof c.length === "undefined") { - return _check(c); - } else if (c.length == 0) { - return "[]"; - } else if (c.length == 1) { - return _check(c[0]); - } else { - var result = "["; - for (var i = 0; i < c.length; i++) { - if (typeof c[i].length === 'undefined') { - result += _check(c[i]) + ","; - } else { - for (var j = 0; j < c[i].length - 1; j++) { - result += _check(c[i][j]) + ","; - } - result += _check(c[i][c[i].length - 1]) + ";"; - } - } - result = result.substring(0, result.length - 1); - result += "]"; - return result; - } -} - -function transpose(a) { - return a[0].map(function(_, c) { - return a.map(function(r) { - return r[c]; - }); - }); -} - -function colon_operator() { - var array = arguments[0]; - var new_arr = []; - var i, j; - for (i = 0; i < array[0].length; i++) { - for (j = 0; j < array.length; j++) { - new_arr.push([array[j][i]]); - } - } - return new_arr; -} - -// Returns ScilabDouble which contains a list with size = n and all values = 0 -/*function zeros(n) { - var arg = new Array(n + 1).join("0").split("").map(parseFloat); - var port = new ScilabDouble(); - var i = 0; - - for (i = 0; i < arg[0].length; i++) - port.list.push(arg[0][i]); - - return port; -}*/ diff --git a/documentation/servlet.md b/documentation/servlet.md deleted file mode 100644 index 86cff6b..0000000 --- a/documentation/servlet.md +++ /dev/null @@ -1,4 +0,0 @@ - - Download apache-tomcat-xxx. - - Create a folder 'temp' in the tomcat directory. - - Paste the entire 'xcos-on-web' directory inside the '/path/to/tomcat/webapps' directory. - - Run the server and access using a web browser. \ No newline at end of file diff --git a/documentation/wires.md b/documentation/wires.md deleted file mode 100644 index 988e448..0000000 --- a/documentation/wires.md +++ /dev/null @@ -1,82 +0,0 @@ -# Xcos-on-Web Wires Connection -#### @jiteshjha @pooja - -Track our progress on wires connection here on [xcos-on-web group](https://groups.google.com/forum/#!searchin/xcos-on-web/authorname$3A$20Jitesh$20Jha). - -[Depends on mxGraph library, version 1.10.4.1, which can be found [here](https://github.com/rmoriz/mxgraph). ] - -## Purpose - - - One of the major feature of xcos-on-desktop is the connections between blocks. - - We used [wires.html](https://github.com/rmoriz/mxgraph/blob/master/javascript/examples/wires.html) example as the basic structure of our xcos-on-web application, with many additions explained below to closely resemble the connections possible on xcos-on-desktop. - -##Documentation - -#### `mxConnectionHandler.prototype.movePreviewAway` - - - Switch to enable moving the preview away from the mousepointer. This is required in browsers where the preview cannot be made transparent to events and if the built-in hit detection on the HTML elements in the page should be used. This is set as false in index.html. - -#### `mxConnectionHandler.prototype.waypointsEnabled` - - - Specifies if single clicks should add waypoints on the new edge. This is set as true in index.html. - -#### `mxGraph.prototype.resetEdgesOnConnect` - - - Specifies if edge control points should be reset after the the edge has been reconnected. This is set as true in index.html. - -#### `graph.setPanning(true)` - - - Specifies if panning should be enabled. - -#### `graph.setConnectable(true)` - - - Specifies if the graph should allow new connections. - -#### `setConnectableEdges(true)` - - - Specifies if edges should be connectable. - -#### `setDisconnectOnMove(false)` - - - Specifies if edges should be disconnected when moved. (Note: Cloned edges are always disconnected) - -#### `foldingEnabled = false` - - - Specifies if folding. (collapse and expand via an image icon in the graph should be enabled) - -[**NOTE**: The following six functions are implemented from the [wires.html](https://github.com/rmoriz/mxgraph/blob/master/javascript/examples/wires.html) under javascript-example of [mxGraph](https://github.com/rmoriz/mxgraph). ] - -### function `connectionHandlerIsStartEvent()` - - - Starts connections on the background in wire-mode. - - function connectionHandlerMouseUp() depends on this function. - -### function `connectionHandlerMouseUp()` - - - Avoids any connections for gestures within tolerance except when in wire-mode or when over a port. - - Responsible for the removal of self connections over an mxCell (edges or vertices) in wire-mode. - -### function `updateFixedTerminalPoint()` - - - Updates connection points before the routing is called. - - Enables connection from any point on an edge. - - Without this function, default edge characteristics ( mid-point-specific connections only) come in play. - -### function `createEdgeState()` - - - Overrides methods to preview and create new edges. - - Enables horizontal and vertical edges in preview state. - - Without this function, any connection from an edge will have it's source point and target point chosen based on the assumed center of a straight edge having source edge's source point and target point. - -### function `createMarker()` - - - Adds in-place highlighting for complete cell area (no hotspot). - - Uses complete area of cell for new connections. - - Adds in-place highlighting when reconnecting existing edges. - -### function `WireConnector()` - - - Creates a custom horizontal and vertical edge style. - - Without this function, the source and terminal of a connection from an source edge is assumed as if the source edge were an perpendicular connection. - - diff --git a/filenames.php b/filenames.php deleted file mode 100644 index 81ca89f..0000000 --- a/filenames.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/finalmodsheet.xsl b/finalmodsheet.xsl deleted file mode 100644 index c5919f9..0000000 --- a/finalmodsheet.xsl +++ /dev/null @@ -1,2192 +0,0 @@ - - - - - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MavXcos - - - - - - - - 1 - 0 - defaultParent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - model - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DEFAULT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - UNKNOW_TYPE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - REAL_MATRIX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - REAL_MATRIX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - REAL_MATRIX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - REAL_MATRIX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UNKNOW_TYPE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/highcharts/highcharts.js b/highcharts/highcharts.js deleted file mode 100755 index 76a39d5..0000000 --- a/highcharts/highcharts.js +++ /dev/null @@ -1,347 +0,0 @@ -/* - Highcharts JS v4.2.7 (2016-09-21) - - (c) 2009-2016 Torstein Honsi - - License: www.highcharts.com/license -*/ -(function(D,ea){typeof module==="object"&&module.exports?module.exports=D.document?ea(D):ea:D.Highcharts=ea(D)})(typeof window!=="undefined"?window:this,function(D){function ea(a,b){var c="Highcharts error #"+a+": www.highcharts.com/errors/"+a;if(b)throw Error(c);D.console&&console.log(c)}function tb(a,b,c){this.options=b;this.elem=a;this.prop=c}function E(){var a,b=arguments,c,d={},e=function(a,b){var c,d;typeof a!=="object"&&(a={});for(d in b)b.hasOwnProperty(d)&&(c=b[d],a[d]=u.isObject(c,!0)&& -d!=="renderTo"&&typeof c.nodeType!=="number"?e(a[d]||{},c):b[d]);return a};b[0]===!0&&(d=b[1],b=Array.prototype.slice.call(b,2));c=b.length;for(a=0;a-1?h.thousandsSep: -""))):e=Ta(f,e)}j.push(e);a=a.slice(c+1);c=(d=!d)?"}":"{"}j.push(a);return j.join("")}function vb(a){return Z.pow(10,V(Z.log(a)/Z.LN10))}function wb(a,b,c,d,e){var f,g=a,c=p(c,1);f=a/c;b||(b=[1,2,2.5,5,10],d===!1&&(c===1?b=[1,2,5,10]:c<=0.1&&(b=[1/c])));for(d=0;d=a||!e&&f<=(b[d]+(b[d+1]||b[d]))/2)break;g*=c;return g}function kb(a,b){var c=a.length,d,e;for(e=0;ec&&(c=a[b]);return c}function Ua(a,b){for(var c in a)a[c]&&a[c]!==b&&a[c].destroy&&a[c].destroy(),delete a[c]}function Va(a){lb||(lb=ca(Pa));a&&lb.appendChild(a);lb.innerHTML=""}function $(a,b){return parseFloat(a.toPrecision(b||14))}function cb(a,b){b.renderer.globalAnimation=p(a,b.animation)}function Wa(a){return ba(a)?E(a):{duration:a?500:0}}function Hb(){var a=T.global,b= -a.useUTC,c=b?"getUTC":"get",d=b?"setUTC":"set";ma=a.Date||D.Date;ub=b&&a.timezoneOffset;bb=b&&a.getTimezoneOffset;mb=function(a,c,d,h,i,j){var k;b?(k=ma.UTC.apply(0,arguments),k+=ab(k)):k=(new ma(a,c,p(d,1),p(h,0),p(i,0),p(j,0))).getTime();return k};xb=c+"Minutes";yb=c+"Hours";zb=c+"Day";Xa=c+"Date";db=c+"Month";eb=c+"FullYear";Ib=d+"Milliseconds";Jb=d+"Seconds";Kb=d+"Minutes";Lb=d+"Hours";nb=d+"Date";Ab=d+"Month";Bb=d+"FullYear"}function na(a){if(!(this instanceof na))return new na(a);this.init(a)} -function J(){}function Ya(a,b,c,d){this.axis=a;this.pos=b;this.type=c||"";this.isNew=!0;!c&&!d&&this.addLabel()}function Mb(a,b,c,d,e){var f=a.chart.inverted;this.axis=a;this.isNegative=c;this.options=b;this.x=d;this.total=null;this.points={};this.stack=e;this.rightCliff=this.leftCliff=0;this.alignOptions={align:b.align||(f?c?"left":"right":"center"),verticalAlign:b.verticalAlign||(f?"middle":c?"bottom":"top"),y:p(b.y,f?4:c?14:-6),x:p(b.x,f?c?-6:6:0)};this.textAlign=b.textAlign||(f?c?"right":"left": -"center")}var z,y=D.document,Z=Math,C=Z.round,V=Z.floor,va=Z.ceil,t=Z.max,F=Z.min,Q=Z.abs,W=Z.cos,da=Z.sin,ta=Z.PI,ka=ta*2/360,Ba=D.navigator&&D.navigator.userAgent||"",Nb=D.opera,Aa=/(msie|trident|edge)/i.test(Ba)&&!Nb,ob=y&&y.documentMode===8,pb=!Aa&&/AppleWebKit/.test(Ba),Qa=/Firefox/.test(Ba),Ob=/(Mobile|Android|Windows Phone)/.test(Ba),Ia="http://www.w3.org/2000/svg",fa=y&&y.createElementNS&&!!y.createElementNS(Ia,"svg").createSVGRect,Sb=Qa&&parseInt(Ba.split("Firefox/")[1],10)<4,la=y&&!fa&& -!Aa&&!!y.createElement("canvas").getContext,fb,gb,Pb={},Cb=0,lb,T,Ta,G,Ca=function(){},U=[],hb=0,Pa="div",X="M",S="L",Tb=/[0-9]/g,qb=["plotTop","marginRight","marginBottom","plotLeft"],ma,mb,ub,bb,xb,yb,zb,Xa,db,eb,Ib,Jb,Kb,Lb,nb,Ab,Bb,L={},u;u=D.Highcharts?ea(16,!0):{win:D};u.seriesTypes=L;var Ja=[],oa,pa,q,Da,Db,Ea,N,Y,H,Za,Ka;tb.prototype={dSetter:function(){var a=this.paths[0],b=this.paths[1],c=[],d=this.now,e=a.length,f;if(d===1)c=this.toD;else if(e===b.length&&d<1)for(;e--;)f=parseFloat(a[e]), -c[e]=isNaN(f)?a[e]:d*parseFloat(b[e]-f)+f;else c=b;this.elem.attr("d",c)},update:function(){var a=this.elem,b=this.prop,c=this.now,d=this.options.step;if(this[b+"Setter"])this[b+"Setter"]();else a.attr?a.element&&a.attr(b,c):a.style[b]=c+this.unit;d&&d.call(a,c,this)},run:function(a,b,c){var d=this,e=function(a){return e.stopped?!1:d.step(a)},f;this.startTime=+new ma;this.start=a;this.end=b;this.unit=c;this.now=this.start;this.pos=0;e.elem=this.elem;if(e()&&Ja.push(e)===1)e.timerId=setInterval(function(){for(f= -0;f=f+this.startTime){this.now=this.end;this.pos=1;this.update();a=g[this.prop]=!0;for(h in g)g[h]!==!0&&(a=!1);a&&e&&e.call(c);c=!1}else this.pos=d.easing((b-this.startTime)/f),this.now=this.start+(this.end-this.start)*this.pos,this.update(),c=!0;return c},initPath:function(a, -b,c){function d(a){for(n=a.length;n--;)(a[n]===X||a[n]===S)&&a.splice(n+1,0,a[n+1],a[n+2],a[n+1],a[n+2])}function e(a,b){for(;a.length0&&c--;)m=a.slice().splice(a.length/A-k,k*A),m[0]=b[l-k-c*k],j&&(m[k-6]=m[k-2],m[k-5]=m[k-1]),[].splice.apply(a,[a.length/A,0].concat(m)),o&&c--}var b=b||"",g,h=a.startX, -i=a.endX,j=b.indexOf("C")>-1,k=j?7:3,l,m,n,b=b.split(" "),c=c.slice(),o=a.isArea,A=o?2:1,r;j&&(d(b),d(c));if(h&&i){for(n=0;n3?g.length%3:0;c=p(c,e.decimalPoint);d=p(d,e.thousandsSep);a=a<0?"-":"";a+=h?g.substr(0,h)+d:"";a+=g.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+d);b&&(d=Math.abs(i-g+Math.pow(10,-Math.max(b,f)-1)),a+=c+d.toFixed(b).slice(2));return a};Math.easeInOutSine=function(a){return-0.5*(Math.cos(Math.PI*a)-1)};oa=function(a,b){var c;if(b=== -"width")return Math.min(a.offsetWidth,a.scrollWidth)-oa(a,"padding-left")-oa(a,"padding-right");else if(b==="height")return Math.min(a.offsetHeight,a.scrollHeight)-oa(a,"padding-top")-oa(a,"padding-bottom");return(c=D.getComputedStyle(a,void 0))&&B(c.getPropertyValue(b))};pa=function(a,b){return b.indexOf?b.indexOf(a):[].indexOf.call(b,a)};Da=function(a,b){return[].filter.call(a,b)};Ea=function(a,b){for(var c=[],d=0,e=a.length;d-1&&(f.splice(h,1),g[b]=f),d(b,c)):(e(),g[b]=[])):(e(),a.hcEvents={})};H=function(a,b,c,d){var e;e=a.hcEvents;var f,g,c=c|| -{};if(y.createEvent&&(a.dispatchEvent||a.fireEvent))e=y.createEvent("Events"),e.initEvent(b,!0,!0),e.target=a,x(e,c),a.dispatchEvent?a.dispatchEvent(e):a.fireEvent(b,e);else if(e){e=e[b]||[];f=e.length;if(!c.preventDefault)c.preventDefault=function(){c.defaultPrevented=!0};c.target=a;if(!c.type)c.type=b;for(b=0;b{point.key}
',pointFormat:'\u25cf {series.name}: {point.y}
',shadow:!0,snap:Ob?25:10,style:{color:"#333333",cursor:"default",fontSize:"12px",padding:"8px",pointerEvents:"none",whiteSpace:"nowrap"}},credits:{enabled:!0,text:"Highcharts.com", -href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#909090",fontSize:"9px"}}};var ga=T.plotOptions,ha=ga.line;Hb();na.prototype={parsers:[{regex:/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,parse:function(a){return[B(a[1]),B(a[2]),B(a[3]),parseFloat(a[4],10)]}},{regex:/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,parse:function(a){return[B(a[1],16),B(a[2],16),B(a[3],16), -1]}},{regex:/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,parse:function(a){return[B(a[1]),B(a[2]),B(a[3]),1]}}],init:function(a){var b,c,d,e;if((this.input=a)&&a.stops)this.stops=Ea(a.stops,function(a){return new na(a[1])});else for(d=this.parsers.length;d--&&!c;)e=this.parsers[d],(b=e.regex.exec(a))&&(c=e.parse(b));this.rgba=c||[]},get:function(a){var b=this.input,c=this.rgba,d;this.stops?(d=E(b),d.stops=[].concat(d.stops),q(this.stops,function(b,c){d.stops[c]=[d.stops[c][0], -b.get(a)]})):d=c&&I(c[0])?a==="rgb"||!a&&c[3]===1?"rgb("+c[0]+","+c[1]+","+c[2]+")":a==="a"?c[3]:"rgba("+c.join(",")+")":b;return d},brighten:function(a){var b,c=this.rgba;if(this.stops)q(this.stops,function(b){b.brighten(a)});else if(I(a)&&a!==0)for(b=0;b<3;b++)c[b]+=B(a*255),c[b]<0&&(c[b]=0),c[b]>255&&(c[b]=255);return this},setOpacity:function(a){this.rgba[3]=a;return this}};J.prototype={opacity:1,textProps:"direction,fontSize,fontWeight,fontFamily,fontStyle,color,lineHeight,width,textDecoration,textOverflow,textShadow".split(","), -init:function(a,b){this.element=b==="span"?ca(b):y.createElementNS(Ia,b);this.renderer=a},animate:function(a,b,c){b=p(b,this.renderer.globalAnimation,!0);Ka(this);if(b){if(c)b.complete=c;Za(this,a,b)}else this.attr(a,null,c);return this},colorGradient:function(a,b,c){var d=this.renderer,e,f,g,h,i,j,k,l,m,n,o,A=[],r;a.linearGradient?f="linearGradient":a.radialGradient&&(f="radialGradient");if(f){g=a[f];i=d.gradients;k=a.stops;n=c.radialReference;za(g)&&(a[f]=g={x1:g[0],y1:g[1],x2:g[2],y2:g[3],gradientUnits:"userSpaceOnUse"}); -f==="radialGradient"&&n&&!s(g.gradientUnits)&&(h=g,g=E(g,d.getRadialAttr(n,h),{gradientUnits:"userSpaceOnUse"}));for(o in g)o!=="id"&&A.push(o,g[o]);for(o in k)A.push(k[o]);A=A.join(",");i[A]?n=i[A].attr("id"):(g.id=n="highcharts-"+Cb++,i[A]=j=d.createElement(f).attr(g).add(d.defs),j.radAttr=h,j.stops=[],q(k,function(a){a[1].indexOf("rgba")===0?(e=na(a[1]),l=e.get("rgb"),m=e.get("a")):(l=a[1],m=1);a=d.createElement("stop").attr({offset:a[0],"stop-color":l,"stop-opacity":m}).add(j);j.stops.push(a)})); -r="url("+d.url+"#"+n+")";c.setAttribute(b,r);c.gradient=A;a.toString=function(){return r}}},applyTextShadow:function(a){var b=this.element,c,d=a.indexOf("contrast")!==-1,e={},f=this.renderer.forExport,g=f||b.style.textShadow!==z&&!Aa;if(d)e.textShadow=a=a.replace(/contrast/g,this.renderer.getContrast(b.style.fill));if(pb||f)e.textRendering="geometricPrecision";g?this.css(e):(this.fakeTS=!0,this.ySetter=this.xSetter,c=[].slice.call(b.getElementsByTagName("tspan")),q(a.split(/\s?,\s?/g),function(a){var d= -b.firstChild,e,f,a=a.split(" ");e=a[a.length-1];(f=a[a.length-2])&&q(c,function(a,c){var g;c===0&&(a.setAttribute("x",b.getAttribute("x")),c=b.getAttribute("y"),a.setAttribute("y",c||0),c===null&&b.setAttribute("y",0));g=a.cloneNode(1);O(g,{"class":"highcharts-text-shadow",fill:e,stroke:e,"stroke-opacity":1/t(B(f),3),"stroke-width":f,"stroke-linejoin":"round"});b.insertBefore(g,d)})}))},attr:function(a,b,c){var d,e=this.element,f,g=this,h;typeof a==="string"&&b!==z&&(d=a,a={},a[d]=b);if(typeof a=== -"string")g=(this[a+"Getter"]||this._defaultGetter).call(this,a,e);else{for(d in a){b=a[d];h=!1;this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)/.test(d)&&(f||(this.symbolAttr(a),f=!0),h=!0);if(this.rotation&&(d==="x"||d==="y"))this.doTransform=!0;h||(h=this[d+"Setter"]||this._defaultSetter,h.call(this,b,d,e),this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(d)&&this.updateShadows(d,b,h))}if(this.doTransform)this.updateTransform(),this.doTransform=!1}c&& -c();return g},updateShadows:function(a,b,c){for(var d=this.shadows,e=d.length;e--;)c.call(d[e],a==="height"?Math.max(b-(d[e].cutHeight||0),0):a==="d"?this.d:b,a,d[e])},addClass:function(a){var b=this.element,c=O(b,"class")||"";c.indexOf(a)===-1&&O(b,"class",c+" "+a);return this},symbolAttr:function(a){var b=this;q("x,y,r,start,end,width,height,innerR,anchorX,anchorY".split(","),function(c){b[c]=p(a[c],b[c])});b.attr({d:b.renderer.symbols[b.symbolName](b.x,b.y,b.width,b.height,b)})},clip:function(a){return this.attr("clip-path", -a?"url("+this.renderer.url+"#"+a.id+")":"none")},crisp:function(a){var b,c={},d,e=this.strokeWidth||0;d=C(e)%2/2;a.x=V(a.x||this.x||0)+d;a.y=V(a.y||this.y||0)+d;a.width=V((a.width||this.width||0)-2*d);a.height=V((a.height||this.height||0)-2*d);a.strokeWidth=e;for(b in a)this[b]!==a[b]&&(this[b]=c[b]=a[b]);return c},css:function(a){var b=this.styles,c={},d=this.element,e,f,g="";e=!b;if(a&&a.color)a.fill=a.color;if(b)for(f in a)a[f]!==b[f]&&(c[f]=a[f],e=!0);if(e){e=this.textWidth=a&&a.width&&d.nodeName.toLowerCase()=== -"text"&&B(a.width)||this.textWidth;b&&(a=x(b,c));this.styles=a;e&&(la||!fa&&this.renderer.forExport)&&delete a.width;if(Aa&&!fa)M(this.element,a);else{b=function(a,b){return"-"+b.toLowerCase()};for(f in a)g+=f.replace(/([A-Z])/g,b)+":"+a[f]+";";O(d,"style",g)}e&&this.added&&this.renderer.buildText(this)}return this},on:function(a,b){var c=this,d=c.element;gb&&a==="click"?(d.ontouchstart=function(a){c.touchEventFired=ma.now();a.preventDefault();b.call(d,a)},d.onclick=function(a){(Ba.indexOf("Android")=== --1||ma.now()-(c.touchEventFired||0)>1100)&&b.call(d,a)}):d["on"+a]=b;return this},setRadialReference:function(a){var b=this.renderer.gradients[this.element.gradient];this.element.radialReference=a;b&&b.radAttr&&b.animate(this.renderer.getRadialAttr(a,b.radAttr));return this},translate:function(a,b){return this.attr({translateX:a,translateY:b})},invert:function(){this.inverted=!0;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,b=this.translateY||0,c=this.scaleX, -d=this.scaleY,e=this.inverted,f=this.rotation,g=this.element;e&&(a+=this.attr("width"),b+=this.attr("height"));a=["translate("+a+","+b+")"];e?a.push("rotate(90) scale(-1,1)"):f&&a.push("rotate("+f+" "+(g.getAttribute("x")||0)+" "+(g.getAttribute("y")||0)+")");(s(c)||s(d))&&a.push("scale("+p(c,1)+" "+p(d,1)+")");a.length&&g.setAttribute("transform",a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,b,c){var d,e,f,g,h={};e=this.renderer;f=e.alignedObjects; -if(a){if(this.alignOptions=a,this.alignByTranslate=b,!c||ya(c))this.alignTo=d=c||"renderer",ra(f,this),f.push(this),c=null}else a=this.alignOptions,b=this.alignByTranslate,d=this.alignTo;c=p(c,e[d],e);d=a.align;e=a.verticalAlign;f=(c.x||0)+(a.x||0);g=(c.y||0)+(a.y||0);if(d==="right"||d==="center")f+=(c.width-(a.width||0))/{right:1,center:2}[d];h[b?"translateX":"x"]=C(f);if(e==="bottom"||e==="middle")g+=(c.height-(a.height||0))/({bottom:1,middle:2}[e]||1);h[b?"translateY":"y"]=C(g);this[this.placed? -"animate":"attr"](h);this.placed=!0;this.alignAttr=h;return this},getBBox:function(a,b){var c,d=this.renderer,e,f,g,h=this.element,i=this.styles;e=this.textStr;var j,k=h.style,l,m=d.cache,n=d.cacheKeys,o;f=p(b,this.rotation);g=f*ka;e!==z&&(o=e.toString().replace(Tb,"0")+["",f||0,i&&i.fontSize,h.style.width].join(","));o&&!a&&(c=m[o]);if(!c){if(h.namespaceURI===Ia||d.forExport){try{l=this.fakeTS&&function(a){q(h.querySelectorAll(".highcharts-text-shadow"),function(b){b.style.display=a})},Qa&&k.textShadow? -(j=k.textShadow,k.textShadow=""):l&&l("none"),c=h.getBBox?x({},h.getBBox()):{width:h.offsetWidth,height:h.offsetHeight},j?k.textShadow=j:l&&l("")}catch(A){}if(!c||c.width<0)c={width:0,height:0}}else c=this.htmlGetBBox();if(d.isSVG){d=c.width;e=c.height;if(Aa&&i&&i.fontSize==="11px"&&e.toPrecision(3)==="16.9")c.height=e=14;if(f)c.width=Q(e*da(g))+Q(d*W(g)),c.height=Q(e*W(g))+Q(d*da(g))}if(o&&c.height>0){for(;n.length>250;)delete m[n.shift()];m[o]||n.push(o);m[o]=c}}return c},show:function(a){return this.attr({visibility:a? -"inherit":"visible"})},hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var b=this;b.animate({opacity:0},{duration:a||150,complete:function(){b.attr({y:-9999})}})},add:function(a){var b=this.renderer,c=this.element,d;if(a)this.parentGroup=a;this.parentInverted=a&&a.inverted;this.textStr!==void 0&&b.buildText(this);this.added=!0;if(!a||a.handleZ||this.zIndex)d=this.zIndexSetter();d||(a?a.element:b.box).appendChild(c);if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var b= -a.parentNode;b&&b.removeChild(a)},destroy:function(){var a=this,b=a.element||{},c=a.shadows,d=a.renderer.isSVG&&b.nodeName==="SPAN"&&a.parentGroup,e,f;b.onclick=b.onmouseout=b.onmouseover=b.onmousemove=b.point=null;Ka(a);if(a.clipPath)a.clipPath=a.clipPath.destroy();if(a.stops){for(f=0;f]*>/g,"")))},textSetter:function(a){if(a!==this.textStr)delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this)},fillSetter:function(a,b,c){typeof a==="string"?c.setAttribute(b,a):a&&this.colorGradient(a,b,c)},visibilitySetter:function(a,b, -c){a==="inherit"?c.removeAttribute(b):c.setAttribute(b,a)},zIndexSetter:function(a,b){var c=this.renderer,d=this.parentGroup,c=(d||c).element||c.box,e,f,g=this.element,h;e=this.added;var i;if(s(a))g.zIndex=a,a=+a,this[b]===a&&(e=!1),this[b]=a;if(e){if((a=this.zIndex)&&d)d.handleZ=!0;d=c.childNodes;for(i=0;ia||!s(a)&&s(f)))c.insertBefore(g,e),h=!0;h||c.appendChild(g)}return h},_defaultSetter:function(a,b,c){c.setAttribute(b,a)}};J.prototype.yGetter= -J.prototype.xGetter;J.prototype.translateXSetter=J.prototype.translateYSetter=J.prototype.rotationSetter=J.prototype.verticalAlignSetter=J.prototype.scaleXSetter=J.prototype.scaleYSetter=function(a,b){this[b]=a;this.doTransform=!0};J.prototype.opacitySetter=J.prototype.displaySetter=function(a,b,c){this[b]=a;c.setAttribute(b,a)};J.prototype["stroke-widthSetter"]=J.prototype.strokeSetter=function(a,b,c){this[b]=a;if(this.stroke&&this["stroke-width"])this.strokeWidth=this["stroke-width"],J.prototype.fillSetter.call(this, -this.stroke,"stroke",c),c.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0;else if(b==="stroke-width"&&a===0&&this.hasStroke)c.removeAttribute("stroke"),this.hasStroke=!1};var Fa=function(){this.init.apply(this,arguments)};Fa.prototype={Element:J,init:function(a,b,c,d,e,f){var g,d=this.createElement("svg").attr({version:"1.1"}).css(this.getStyle(d));g=d.element;a.appendChild(g);a.innerHTML.indexOf("xmlns")===-1&&O(g,"xmlns",Ia);this.isSVG=!0;this.box=g;this.boxWrapper=d;this.alignedObjects= -[];this.url=(Qa||pb)&&y.getElementsByTagName("base").length?D.location.href.replace(/#.*?$/,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(y.createTextNode("Created with Highcharts 4.2.7"));this.defs=this.createElement("defs").add();this.allowHTML=f;this.forExport=e;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,c,!1);var h;if(Qa&&a.getBoundingClientRect)this.subPixelFix=b=function(){M(a,{left:0,top:0}); -h=a.getBoundingClientRect();M(a,{left:va(h.left)-h.left+"px",top:va(h.top)-h.top+"px"})},b(),N(D,"resize",b)},getStyle:function(a){return this.style=x({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();Ua(this.gradients||{});this.gradients=null;if(a)this.defs=a.destroy();this.subPixelFix&&Y(D,"resize", -this.subPixelFix);return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);return b},draw:function(){},getRadialAttr:function(a,b){return{cx:a[0]-a[2]/2+b.cx*a[2],cy:a[1]-a[2]/2+b.cy*a[2],r:b.r*a[2]}},buildText:function(a){for(var b=a.element,c=this,d=c.forExport,e=p(a.textStr,"").toString(),f=e.indexOf("<")!==-1,g=b.childNodes,h,i,j,k=O(b,"x"),l=a.styles,m=a.textWidth,n=l&&l.lineHeight,o=l&&l.textShadow,A=l&&l.textOverflow==="ellipsis",r=g.length,K=m&&!a.added&& -this.box,w=function(a){return n?B(n):c.fontMetrics(/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:l&&l.fontSize||c.style.fontSize||12,a).h},v=function(a){return a.replace(/</g,"<").replace(/>/g,">")};r--;)b.removeChild(g[r]);!f&&!o&&!A&&!m&&e.indexOf(" ")===-1?b.appendChild(y.createTextNode(v(e))):(h=/<.*style="([^"]+)".*>/,i=/<.*href="(http[^"]+)".*>/,K&&K.appendChild(b),e=f?e.replace(/<(b|strong)>/g,'').replace(/<(i|em)>/g,'').replace(//g,"").split(//g):[e],e=Da(e,function(a){return a!==""}),q(e,function(e,f){var g,n=0,e=e.replace(/^\s+|\s+$/g,"").replace(//g,"|||");g=e.split("|||");q(g,function(e){if(e!==""||g.length===1){var o={},r=y.createElementNS(Ia,"tspan"),p;h.test(e)&&(p=e.match(h)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),O(r,"style",p));i.test(e)&&!d&&(O(r,"onclick",'location.href="'+e.match(i)[1]+'"'),M(r,{cursor:"pointer"})); -e=v(e.replace(/<(.|\n)*?>/g,"")||" ");if(e!==" "){r.appendChild(y.createTextNode(e));if(n)o.dx=0;else if(f&&k!==null)o.x=k;O(r,o);b.appendChild(r);!n&&f&&(!fa&&d&&M(r,{display:"block"}),O(r,"dy",w(r)));if(m){for(var o=e.replace(/([^\^])-/g,"$1- ").split(" "),q=l.whiteSpace==="nowrap",K=g.length>1||f||o.length>1&&!q,Ra,s,La=[],t=w(r),x=1,C=a.rotation,u=e,z=u.length;(K||A)&&(o.length||La.length);)a.rotation=0,Ra=a.getBBox(!0),s=Ra.width,!fa&&c.forExport&&(s=c.measureSpanWidth(r.firstChild.data,a.styles)), -Ra=s>m,j===void 0&&(j=Ra),A&&j?(z/=2,u===""||!Ra&&z<0.5?o=[]:(u=e.substring(0,u.length+(Ra?-1:1)*va(z)),o=[u+(m>3?"\u2026":"")],r.removeChild(r.firstChild))):!Ra||o.length===1?(o=La,La=[],o.length&&!q&&(x++,r=y.createElementNS(Ia,"tspan"),O(r,{dy:t,x:k}),p&&O(r,"style",p),b.appendChild(r)),s>m&&(m=s)):(r.removeChild(r.firstChild),La.unshift(o.pop())),o.length&&r.appendChild(y.createTextNode(o.join(" ").replace(/- /g,"-")));a.rotation=C}n++}}})}),j&&a.attr("title",a.textStr),K&&K.removeChild(b),o&& -a.applyTextShadow&&a.applyTextShadow(o))},getContrast:function(a){a=na(a).rgba;return a[0]+a[1]+a[2]>384?"#000000":"#FFFFFF"},button:function(a,b,c,d,e,f,g,h,i){var j=this.label(a,b,c,i,null,null,null,null,"button"),k=0,l,m,n,o,A,r,a={x1:0,y1:0,x2:0,y2:1},e=E({"stroke-width":1,stroke:"#CCCCCC",fill:{linearGradient:a,stops:[[0,"#FEFEFE"],[1,"#F6F6F6"]]},r:2,padding:5,style:{color:"black"}},e);n=e.style;delete e.style;f=E(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#FFF"],[1,"#ACF"]]}},f);o= -f.style;delete f.style;g=E(e,{stroke:"#68A",fill:{linearGradient:a,stops:[[0,"#9BD"],[1,"#CDF"]]}},g);A=g.style;delete g.style;h=E(e,{style:{color:"#CCC"}},h);r=h.style;delete h.style;N(j.element,Aa?"mouseover":"mouseenter",function(){k!==3&&j.attr(f).css(o)});N(j.element,Aa?"mouseout":"mouseleave",function(){k!==3&&(l=[e,f,g][k],m=[n,o,A][k],j.attr(l).css(m))});j.setState=function(a){(j.state=k=a)?a===2?j.attr(g).css(A):a===3&&j.attr(h).css(r):j.attr(e).css(n)};return j.on("click",function(a){k!== -3&&d.call(j,a)}).attr(e).css(x({cursor:"default"},n))},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=C(a[1])-b%2/2);a[2]===a[5]&&(a[2]=a[5]=C(a[2])+b%2/2);return a},path:function(a){var b={fill:"none"};za(a)?b.d=a:ba(a)&&x(b,a);return this.createElement("path").attr(b)},circle:function(a,b,c){a=ba(a)?a:{x:a,y:b,r:c};b=this.createElement("circle");b.xSetter=b.ySetter=function(a,b,c){c.setAttribute("c"+b,a)};return b.attr(a)},arc:function(a,b,c,d,e,f){if(ba(a))b=a.y,c=a.r,d=a.innerR,e=a.start,f=a.end, -a=a.x;a=this.symbol("arc",a||0,b||0,c||0,c||0,{innerR:d||0,start:e||0,end:f||0});a.r=c;return a},rect:function(a,b,c,d,e,f){var e=ba(a)?a.r:e,g=this.createElement("rect"),a=ba(a)?a:a===z?{}:{x:a,y:b,width:t(c,0),height:t(d,0)};if(f!==z)g.strokeWidth=f,a=g.crisp(a);if(e)a.r=e;g.rSetter=function(a,b,c){O(c,{rx:a,ry:a})};return g.attr(a)},setSize:function(a,b,c){var d=this.alignedObjects,e=d.length;this.width=a;this.height=b;for(this.boxWrapper[p(c,!0)?"animate":"attr"]({width:a,height:b});e--;)d[e].align()}, -g:function(a){var b=this.createElement("g");return s(a)?b.attr({"class":"highcharts-"+a}):b},image:function(a,b,c,d,e){var f={preserveAspectRatio:"none"};arguments.length>1&&x(f,{x:b,y:c,width:d,height:e});f=this.createElement("image").attr(f);f.element.setAttributeNS?f.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):f.element.setAttribute("hc-svg-href",a);return f},symbol:function(a,b,c,d,e,f){var g=this,h,i=this.symbols[a],i=i&&i(C(b),C(c),d,e,f),j=/^url\((.*?)\)$/,k,l;if(i)h=this.path(i), -x(h,{symbolName:a,x:b,y:c,width:d,height:e}),f&&x(h,f);else if(j.test(a))l=function(a,b){a.element&&(a.attr({width:b[0],height:b[1]}),a.alignByTranslate||a.translate(C((d-b[0])/2),C((e-b[1])/2)))},k=a.match(j)[1],a=Pb[k]||f&&f.width&&f.height&&[f.width,f.height],h=this.image(k).attr({x:b,y:c}),h.isImg=!0,a?l(h,a):(h.attr({width:0,height:0}),ca("img",{onload:function(){var a=U[g.chartIndex];this.width===0&&(M(this,{position:"absolute",top:"-999em"}),y.body.appendChild(this));l(h,Pb[k]=[this.width, -this.height]);this.parentNode&&this.parentNode.removeChild(this);g.imgCount--;if(!g.imgCount&&a&&a.onload)a.onload()},src:k}),this.imgCount++);return h},symbols:{circle:function(a,b,c,d){var e=0.166*c;return[X,a+c/2,b,"C",a+c+e,b,a+c+e,b+d,a+c/2,b+d,"C",a-e,b+d,a-e,b,a+c/2,b,"Z"]},square:function(a,b,c,d){return[X,a,b,S,a+c,b,a+c,b+d,a,b+d,"Z"]},triangle:function(a,b,c,d){return[X,a+c/2,b,S,a+c,b+d,a,b+d,"Z"]},"triangle-down":function(a,b,c,d){return[X,a,b,S,a+c,b,a+c/2,b+d,"Z"]},diamond:function(a, -b,c,d){return[X,a+c/2,b,S,a+c,b+d/2,a+c/2,b+d,a,b+d/2,"Z"]},arc:function(a,b,c,d,e){var f=e.start,c=e.r||c||d,g=e.end-0.001,d=e.innerR,h=e.open,i=W(f),j=da(f),k=W(g),g=da(g),e=e.end-fc&&e>b+g&&eb+g&&ed&&h>a+g&&ha+g&&hk&&/[ \-]/.test(b.textContent||b.innerText))M(b,{width:k+"px",display:"block",whiteSpace:l||"normal"});this.getSpanCorrection(b.offsetWidth,j,h,i,g)}M(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"});if(pb)j=b.offsetHeight;this.cTT=m}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d={},e=Aa?"-ms-transform":pb?"-webkit-transform":Qa?"MozTransform":Nb?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)";d[e+(Qa?"Origin":"-origin")]= -d.transformOrigin=b*100+"% "+c+"px";M(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c;this.yCorr=-b}});x(Fa.prototype,{html:function(a,b,c){var d=this.createElement("span"),e=d.element,f=d.renderer,g=f.isSVG,h=function(a,b){q(["display","opacity","visibility"],function(c){ib(a,c+"Setter",function(a,c,d,e){a.call(this,c,d,e);b[d]=c})})};d.textSetter=function(a){a!==e.innerHTML&&delete this.bBox;e.innerHTML=this.textStr=a;d.htmlUpdateTransform()};g&&h(d,d.element.style);d.xSetter= -d.ySetter=d.alignSetter=d.rotationSetter=function(a,b){b==="align"&&(b="textAlign");d[b]=a;d.htmlUpdateTransform()};d.attr({text:a,x:C(b),y:C(c)}).css({position:"absolute",fontFamily:this.style.fontFamily,fontSize:this.style.fontSize});e.style.whiteSpace="nowrap";d.css=d.htmlCss;if(g)d.add=function(a){var b,c=f.box.parentNode,g=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)g.push(a),a=a.parentGroup;q(g.reverse(),function(a){var d,e=O(a.element,"class");e&&(e={className:e});b=a.div=a.div||ca(Pa, -e,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||c);d=b.style;x(a,{translateXSetter:function(b,c){d.left=b+"px";a[c]=b;a.doTransform=!0},translateYSetter:function(b,c){d.top=b+"px";a[c]=b;a.doTransform=!0}});h(a,d)})}}else b=c;b.appendChild(e);d.added=!0;d.alignOnAdd&&d.htmlUpdateTransform();return d};return d}});var P;if(!fa&&!la){P={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'], -d=["position: ","absolute",";"],e=b===Pa;(b==="shape"||e)&&d.push("left:0;top:0;width:1px;height:1px;");d.push("visibility: ",e?"hidden":"visible");c.push(' style="',d.join(""),'"/>');if(b)c=e||b==="span"||b==="img"?c.join(""):a.prepVML(c),this.element=ca(c);this.renderer=a},add:function(a){var b=this.renderer,c=this.element,d=b.box,e=a&&a.inverted,d=a?a.element||a:d;if(a)this.parentGroup=a;e&&b.invertChild(c,d);d.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform(); -if(this.onAdd)this.onAdd();return this},updateTransform:J.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=W(a*ka),c=da(a*ka);M(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,c,d,e){var f=d?W(d*ka):1,g=d?da(d*ka):0,h=p(this.elemHeight,this.element.offsetHeight),i;this.xCorr=f<0&&-a;this.yCorr=g<0&&-h;i=f*g<0;this.xCorr+=g*b*(i? -1-c:c);this.yCorr-=f*b*(d?i?c:1-c:1);e&&e!=="left"&&(this.xCorr-=a*c*(f<0?-1:1),d&&(this.yCorr-=h*c*(g<0?-1:1)),M(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)if(I(a[b]))c[b]=C(a[b]*10)-5;else if(a[b]==="Z")c[b]="x";else if(c[b]=a[b],a.isArc&&(a[b]==="wa"||a[b]==="at"))c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1);return c.join(" ")||"x"},clip:function(a){var b=this,c;a?(c=a.members,ra(c,b),c.push(b),b.destroyClip=function(){ra(c, -b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:ob?"inherit":"rect(auto)"});return b.css(a)},css:J.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Va(a)},destroy:function(){this.destroyClip&&this.destroyClip();return J.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=D.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);c=a.length;if(c===9||c===11)a[c-4]=a[c-2]=B(a[c-2])-10*b;return a.join(" ")}, -shadow:function(a,b,c){var d=[],e,f=this.element,g=this.renderer,h,i=f.style,j,k=f.path,l,m,n,o;k&&typeof k.value!=="string"&&(k="x");m=k;if(a){n=p(a.width,3);o=(a.opacity||0.15)/n;for(e=1;e<=3;e++){l=n*2+1-2*e;c&&(m=this.cutOffPath(k.value,l+0.5));j=[''];h=ca(g.prepVML(j),null,{left:B(i.left)+p(a.offsetX,1),top:B(i.top)+p(a.offsetY,1)});if(c)h.cutOff=l+1;j=[''];ca(g.prepVML(j),null,null,h);b?b.element.appendChild(h):f.parentNode.insertBefore(h,f);d.push(h)}this.shadows=d}return this},updateShadows:Ca,setAttr:function(a,b){ob?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){this.element.className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]||ca(this.renderer.prepVML([""]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var d=this.shadows,a=a||[];this.d= -a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(d)for(c=d.length;c--;)d[c].path=d[c].cutOff?this.cutOffPath(a,d[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var d=c.nodeName;if(d==="SPAN")c.style.color=a;else if(d!=="IMG")c.filled=a!=="none",this.setAttr("fillcolor",this.renderer.color(a,c,b,this))},"fill-opacitySetter":function(a,b,c){ca(this.renderer.prepVML(["<",b.split("-")[0],' opacity="',a,'"/>']),null,null,c)},opacitySetter:Ca,rotationSetter:function(a,b,c){c=c.style;this[b]= -c[b]=a;c.left=-C(da(a*ka)+1)+"px";c.top=C(W(a*ka))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b,this))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;I(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){a==="inherit"&&(a="visible");this.shadows&&q(this.shadows,function(c){c.style[b]=a});c.nodeName==="DIV"&&(a=a==="hidden"?"-999em":0,ob||(c.style[b]=a?"visible":"hidden"), -b="top");c.style[b]=a},displaySetter:function(a,b,c){c.style[b]=a},xSetter:function(a,b,c){this[b]=a;b==="x"?b="left":b==="y"&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}};P["stroke-opacitySetter"]=P["fill-opacitySetter"];u.VMLElement=P=sa(J,P);P.prototype.ySetter=P.prototype.widthSetter=P.prototype.heightSetter=P.prototype.xSetter;var Eb={Element:P,isIE8:Ba.indexOf("MSIE 8.0")>-1,init:function(a,b,c,d){var e;this.alignedObjects= -[];d=this.createElement(Pa).css(x(this.getStyle(d),{position:"relative"}));e=d.element;a.appendChild(d.element);this.isVML=!0;this.box=e;this.boxWrapper=d;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,c,!1);if(!y.namespaces.hcv){y.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{y.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){y.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}}, -isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,d){var e=this.createElement(),f=ba(a);return x(e,{members:[],count:0,left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=a.element,c=b.nodeName,a=a.inverted,d=this.top-(c==="shape"?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+C(a?e:d)+"px,"+C(a?f:b)+"px,"+C(a?b:f)+"px,"+C(a?d:e)+"px)"};!a&&ob&&c==="DIV"&&x(d,{width:b+"px",height:f+"px"});return d}, -updateClipping:function(){q(e.members,function(a){a.element&&a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var e=this,f,g=/^rgba/,h,i,j="none";a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern");if(i){var k,l,m=a.linearGradient||a.radialGradient,n,o,A,r,p,w="",a=a.stops,v,s=[],t=function(){h=[''];ca(e.prepVML(h),null,null,b)};n=a[0];v=a[a.length-1];n[0]>0&&a.unshift([0, -n[1]]);v[0]<1&&a.push([1,v[1]]);q(a,function(a,b){g.test(a[1])?(f=na(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1);s.push(a[0]*100+"% "+k);b?(A=l,r=k):(o=l,p=k)});if(c==="fill")if(i==="gradient")c=m.x1||m[0]||0,a=m.y1||m[1]||0,n=m.x2||m[2]||0,m=m.y2||m[3]||0,w='angle="'+(90-Z.atan((m-a)/(n-c))*180/ta)+'"',t();else{var j=m.r,aa=j*2,x=j*2,u=m.cx,C=m.cy,z=b.radialReference,y,j=function(){z&&(y=d.getBBox(),u+=(z[0]-y.x)/y.width-0.5,C+=(z[1]-y.y)/y.height-0.5,aa*=z[2]/y.width,x*=z[2]/y.height);w='src="'+ -T.global.VMLRadialGradientURL+'" size="'+aa+","+x+'" origin="0.5,0.5" position="'+u+","+C+'" color2="'+p+'" ';t()};d.added?j():d.onAdd=j;j=r}else j=k}else if(g.test(a)&&b.tagName!=="IMG")f=na(a),d[c+"-opacitySetter"](f.get("a"),c,b),j=f.get("rgb");else{j=b.getElementsByTagName(c);if(j.length)j[0].opacity=1,j[0].type="solid";j=a}return j},prepVML:function(a){var b=this.isIE8,a=a.join("");b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=a.indexOf('style="')===-1?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'): -a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","1&&f.attr({x:b,y:c,width:d,height:e});return f},createElement:function(a){return a==="rect"?this.symbol(a):Fa.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this,d=b.style,e=a.tagName==="IMG"&&a.style;M(a,{flip:"x",left:B(d.width)-(e?B(e.top):1),top:B(d.height)-(e?B(e.left):1),rotation:-90});q(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c|| -d,c=e.innerR,d=W(f),i=da(f),j=W(g),k=da(g);if(g-f===0)return["x"];f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k];e.open&&!c&&f.push("e",X,a,b);f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e");f.isArc=!0;return f},circle:function(a,b,c,d,e){e&&(c=d=2*e.r);e&&e.isCircle&&(a-=c/2,b-=d/2);return["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){return Fa.prototype.symbols[!s(e)||!e.r?"square":"callout"].call(0,a,b,c,d,e)}}};u.VMLRenderer=P=function(){this.init.apply(this, -arguments)};P.prototype=E(Fa.prototype,Eb);fb=P}Fa.prototype.measureSpanWidth=function(a,b){var c=y.createElement("span"),d;d=y.createTextNode(a);c.appendChild(d);M(c,b);this.box.appendChild(c);d=c.offsetWidth;Va(c);return d};var Qb;if(la)u.CanVGRenderer=P=function(){Ia="http://www.w3.org/1999/xhtml"},P.prototype.symbols={},Qb=function(){function a(){var a=b.length,d;for(d=0;d0&&c+i*j>e&&(n=C((d-c)/W(h*ka)));else if(d=c+(1-i)*j,c-i*je&&(l=e-a.x+l*i,m=-1),l=F(k,l),ll||b.autoRotation&&g.styles.width)n=l;if(n){o.width=n;if(!b.options.labels.style.textOverflow)o.textOverflow="ellipsis";g.css(o)}},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+ -c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth||f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,m=i.tickRotCorr||{x:0,y:0},n=e.y;s(n)||(n=i.side===0?c.rotation?-8:-c.getBBox().height:i.side===2?m.y+8:W(c.rotation*ka)*(m.y-c.getBBox(!1,0).height/2));a=a+e.x+m.x-(f&&d?f*j*(k?-1:1):0);b=b+n-(f&&!d?f*j*(k? -1:-1):0);l&&(c=g/(h||1)%l,i.opposite&&(c=l-c-1),b+=c*(i.labelOffset/l));return{x:a,y:C(b)}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine([X,a,b,S,a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options,f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,m=h?h+"Grid":"grid",n=h?h+"Tick":"tick",o=e[m+"LineWidth"],A=e[m+"LineColor"],r=e[m+"LineDashStyle"],m=d.tickSize(n),n=e[n+"Color"],q=this.mark,w=k.step,v=!0,s=d.tickmarkOffset,t= -this.getPosition(g,j,s,b),aa=t.x,t=t.y,x=g&&aa===d.pos+d.len||!g&&t===d.pos?-1:1,c=p(c,1);this.isActive=!0;if(o){j=d.getPlotLinePath(j+s,o*x,b,!0);if(l===z){l={stroke:A,"stroke-width":o};if(r)l.dashstyle=r;if(!h)l.zIndex=1;if(b)l.opacity=0;this.gridLine=l=o?f.path(j).attr(l).add(d.gridGroup):null}if(!b&&l&&j)l[this.isNew?"attr":"animate"]({d:j,opacity:c})}if(m)d.opposite&&(m[0]=-m[0]),h=this.getMarkPath(aa,t,m[0],m[1]*x,g,f),q?q.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:n,"stroke-width":m[1], -opacity:c}).add(d.axisGroup);if(i&&I(aa))i.xy=t=this.getLabelPosition(aa,t,i,g,k,s,a,w),this.isFirst&&!this.isLast&&!p(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!p(e.showLastLabel,1)?v=!1:g&&!d.isRadial&&!k.step&&!k.rotation&&!b&&c!==0&&this.handleOverflow(t),w&&a%w&&(v=!1),v&&I(t.y)?(t.opacity=c,i[this.isNew?"attr":"animate"](t)):(Ka(i),i.attr("y",-9999)),this.isNew=!1},destroy:function(){Ua(this,this.axis)}};u.PlotLineOrBand=function(a,b){this.axis=a;if(b)this.options=b,this.id=b.id};u.PlotLineOrBand.prototype= -{render:function(){var a=this,b=a.axis,c=b.horiz,d=a.options,e=d.label,f=a.label,g=d.width,h=d.to,i=d.from,j=s(i)&&s(h),k=d.value,l=d.dashStyle,m=a.svgElem,n=[],o,A=d.color,r=p(d.zIndex,0),q=d.events,w={},v=b.chart.renderer,n=b.log2lin;b.isLog&&(i=n(i),h=n(h),k=n(k));if(g){if(n=b.getPlotLinePath(k,g),w={stroke:A,"stroke-width":g},l)w.dashstyle=l}else if(j){n=b.getPlotBandPath(i,h,d);if(A)w.fill=A;if(d.borderWidth)w.stroke=d.borderColor,w["stroke-width"]=d.borderWidth}else return;w.zIndex=r;if(m)if(n)m.show(), -m.animate({d:n});else{if(m.hide(),f)a.label=f=f.destroy()}else if(n&&n.length&&(a.svgElem=m=v.path(n).attr(w).add(),q))for(o in d=function(b){m.on(b,function(c){q[b].apply(a,[c])})},q)d(o);e&&s(e.text)&&n&&n.length&&b.width>0&&b.height>0&&!n.flat?(e=E({align:c&&j&&"center",x:c?!j&&4:10,verticalAlign:!c&&j&&"middle",y:c?j?16:10:j?6:-4,rotation:c&&!j&&90},e),this.renderLabel(e,n,j,r)):f&&f.hide();return a},renderLabel:function(a,b,c,d){var e=this.label,f=this.axis.chart.renderer;if(!e)e={align:a.textAlign|| -a.align,rotation:a.rotation},e.zIndex=d,this.label=e=f.text(a.text,0,0,a.useHTML).attr(e).css(a.style).add();d=[b[1],b[4],c?b[6]:b[1]];b=[b[2],b[5],c?b[7]:b[2]];c=Oa(d);f=Oa(b);e.align(a,!1,{x:c,y:f,width:Ha(d)-c,height:Ha(b)-f});e.show()},destroy:function(){ra(this.axis.plotLinesAndBands,this);delete this.axis;Ua(this)}};var ia=u.Axis=function(){this.init.apply(this,arguments)};ia.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M", -day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#D8D8D8",labels:{enabled:!0,style:{color:"#606060",cursor:"default",fontSize:"11px"},x:0},lineColor:"#C0D0E0",lineWidth:1,minPadding:0.01,maxPadding:0.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0",minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle", -style:{color:"#707070"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},lineWidth:0,maxPadding:0.05,minPadding:0.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return u.numberFormat(this.total,-1)},style:E(ga.line.dataLabels.style,{color:"#000000"})}},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45], -x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var c=b.isX;this.chart=a;this.horiz=a.inverted?!c:c;this.isXAxis=c;this.coll=this.coll||(c?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var d=this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.reversed=d.reversed;this.visible= -d.visible!==!1;this.zoomEnabled=d.zoomEnabled!==!1;this.hasNames=e==="category"||d.categories===!0;this.categories=d.categories||this.hasNames;this.names=this.names||[];this.isLog=e==="logarithmic";this.isDatetimeAxis=e==="datetime";this.isLinked=s(d.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks={};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=d.minRange||d.maxZoom;this.range=d.range;this.offset=d.offset||0;this.stacks={};this.oldStacks={}; -this.stacksTouched=0;this.min=this.max=null;this.crosshair=p(d.crosshair,ua(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;pa(this,a.axes)===-1&&(c?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];if(a.inverted&&c&&this.reversed===z)this.reversed=!0;this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)N(this,f,d[f]);if(this.isLog)this.val2lin=this.log2lin,this.lin2val=this.lin2log},setOptions:function(a){this.options= -E(this.defaultOptions,this.coll==="yAxis"&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],E(T[this.coll],a))},defaultLabelFormatter:function(){var a=this.axis,b=this.value,c=a.categories,d=this.dateTimeLabelFormat,e=T.lang.numericSymbols,f=e&&e.length,g,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Na(h,this);else if(c)g=b;else if(d)g=Ta(d,b);else if(f&&a>=1E3)for(;f--&&g===z;)c= -Math.pow(1E3,f+1),a>=c&&b*10%c===0&&e[f]!==null&&b!==0&&(g=u.numberFormat(b/c,-1)+e[f]);g===z&&(g=Q(b)>=1E4?u.numberFormat(b,-1):u.numberFormat(b,-1,z,""));return g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();q(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var d=c.options,e=d.threshold,f;a.hasVisibleSeries=!0;a.isLog&&e<=0&&(e=null);if(a.isXAxis){if(d= -c.xData,d.length)c=Oa(d),!I(c)&&!(c instanceof ma)&&(d=Da(d,function(a){return I(a)}),c=Oa(d)),a.dataMin=F(p(a.dataMin,d[0]),c),a.dataMax=t(p(a.dataMax,d[0]),Ha(d))}else{c.getExtremes();f=c.dataMax;c=c.dataMin;if(s(c)&&s(f))a.dataMin=F(p(a.dataMin,c),c),a.dataMax=t(p(a.dataMax,f),f);if(s(e))a.threshold=e;if(!d.softThreshold||a.isLog)a.softThreshold=!1}}})},translate:function(a,b,c,d,e,f){var g=this.linkedParent||this,h=1,i=0,j=d?g.oldTransA:g.transA,d=d?g.oldMin:g.min,k=g.minPixelPadding,e=(g.isOrdinal|| -g.isBroken||g.isLog&&e)&&g.lin2val;if(!j)j=g.transA;if(c)h*=-1,i=g.len;g.reversed&&(h*=-1,i-=h*(g.sector||g.len));b?(a=a*h+i,a-=k,a=a/j+d,e&&(a=g.lin2val(a))):(e&&(a=g.val2lin(a)),f==="between"&&(f=0.5),a=h*(a-d)*j+i+h*k+(I(f)?j*f*g.pointRange:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,e){var f=this.chart,g=this.left,h=this.top, -i,j,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth,m;i=this.transB;var n=function(a,b,c){if(ac)d?a=F(t(b,a),c):m=!0;return a},e=p(e,this.translate(a,null,null,c)),a=c=C(e+i);i=j=C(k-e-i);I(e)?this.horiz?(i=h,j=k-this.bottom,a=c=n(a,g,g+this.width)):(a=g,c=l-this.right,i=j=n(i,h,h+this.height)):m=!0;return m&&!d?null:f.renderer.crispLine([X,a,i,S,c,j],b||1)},getLinearTickPositions:function(a,b,c){var d,e=$(V(b/a)*a),f=$(va(c/a)*a),g=[];if(b===c&&I(b))return[b];for(b= -e;b<=f;){g.push(b);b=$(b+a);if(b===d)break;d=b}return g},getMinorTickPositions:function(){var a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[],e,f=this.pointRangePadding||0;e=this.min-f;var f=this.max+f,g=f-e;if(g&&g/c=this.minRange,f,g,h,i,j,k;if(this.isXAxis&&this.minRange===z&&!this.isLog)s(a.min)||s(a.max)?this.minRange=null:(q(this.series,function(a){i=a.xData;for(g=j=a.xIncrement?1:i.length-1;g>0;g--)if(h=i[g]-i[g-1],f===z||h0)this.names.length=0,this.minRange=void 0,q(this.series||[],function(b){b.processedXData||(b.processData(),b.generatePoints());q(b.points,function(c,d){var e;if(c.options&&c.options.x===void 0&&(e=a.nameToX(c),e!==c.x))c.x=e,b.xData[d]=e})})},setAxisTranslation:function(a){var b= -this,c=b.max-b.min,d=b.axisPointRange||0,e,f=0,g=0,h=b.linkedParent,i=!!b.categories,j=b.transA,k=b.isXAxis;if(k||i||d)if(h?(f=h.minPointOffset,g=h.pointRangePadding):(e=b.getClosest(),q(b.series,function(a){var c=i?1:k?p(a.options.pointRange,e,0):b.axisPointRange||0,a=a.options.pointPlacement;d=t(d,c);b.single||(f=t(f,ya(a)?0:c/2),g=t(g,a==="on"?0:c))})),h=b.ordinalSlope&&e?b.ordinalSlope/e:1,b.minPointOffset=f*=h,b.pointRangePadding=g*=h,b.pointRange=F(d,c),k)b.closestPointRange=e;if(a)b.oldTransA= -j;b.translationSlope=b.transA=j=b.len/(c+g||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=j*f},minFromRange:function(){return this.max-this.range},setTickInterval:function(a){var b=this,c=b.chart,d=b.options,e=b.isLog,f=b.log2lin,g=b.isDatetimeAxis,h=b.isXAxis,i=b.isLinked,j=d.maxPadding,k=d.minPadding,l=d.tickInterval,m=d.tickPixelInterval,n=b.categories,o=b.threshold,A=b.softThreshold,r,K,w,v;!g&&!n&&!i&&this.getTickAmount();w=p(b.userMin,d.min);v=p(b.userMax,d.max);i?(b.linkedParent=c[b.coll][d.linkedTo], -c=b.linkedParent.getExtremes(),b.min=p(c.min,c.dataMin),b.max=p(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&ea(11,1)):(!A&&s(o)&&(b.dataMin>=o?(r=o,k=0):b.dataMax<=o&&(K=o,j=0)),b.min=p(w,r,b.dataMin),b.max=p(v,K,b.dataMax));if(e)!a&&F(b.min,p(b.dataMin,b.min))<=0&&ea(10,1),b.min=$(f(b.min),15),b.max=$(f(b.max),15);if(b.range&&s(b.max))b.userMin=b.min=w=t(b.min,b.minFromRange()),b.userMax=v=b.max,b.range=null;H(b,"foundExtremes");b.beforePadding&&b.beforePadding();b.adjustForMinRange(); -if(!n&&!b.axisPointRange&&!b.usePercentage&&!i&&s(b.min)&&s(b.max)&&(f=b.max-b.min))!s(w)&&k&&(b.min-=f*k),!s(v)&&j&&(b.max+=f*j);if(I(d.floor))b.min=t(b.min,d.floor);if(I(d.ceiling))b.max=F(b.max,d.ceiling);if(A&&s(b.dataMin))if(o=o||0,!s(w)&&b.min=o)b.min=o;else if(!s(v)&&b.max>o&&b.dataMax<=o)b.max=o;b.tickInterval=b.min===b.max||b.min===void 0||b.max===void 0?1:i&&!l&&m===b.linkedParent.options.tickPixelInterval?l=b.linkedParent.tickInterval:p(l,this.tickAmount?(b.max-b.min)/t(this.tickAmount- -1,1):void 0,n?1:(b.max-b.min)*m/t(b.len,m));h&&!a&&q(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)});b.setAxisTranslation(!0);b.beforeSetTickPositions&&b.beforeSetTickPositions();if(b.postProcessTickInterval)b.tickInterval=b.postProcessTickInterval(b.tickInterval);if(b.pointRange&&!l)b.tickInterval=t(b.pointRange,b.tickInterval);a=p(d.minTickInterval,b.isDatetimeAxis&&b.closestPointRange);if(!l&&b.tickInterval0.5&&b.tickInterval<5&&b.max>1E3&&b.max<9999)),!!this.tickAmount);if(!this.tickAmount)b.tickInterval=b.unsquish();this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions,d=a.tickPositioner,e=a.startOnTick,f=a.endOnTick,g;this.tickmarkOffset=this.categories&&a.tickmarkPlacement==="between"&&this.tickInterval===1?0.5:0;this.minorTickInterval=a.minorTickInterval==="auto"&&this.tickInterval?this.tickInterval/ -5:a.minorTickInterval;this.tickPositions=b=c&&c.slice();if(!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,d&&(d=d.apply(this,[this.min,this.max]))))this.tickPositions= -b=d;if(!this.isLinked)this.trimTicks(b,e,f),this.min===this.max&&s(this.min)&&!this.tickAmount&&(g=!0,this.min-=0.5,this.max+=0.5),this.single=g,!c&&!d&&this.adjustTickAmount()},trimTicks:function(a,b,c){var d=a[0],e=a[a.length-1],f=this.minPointOffset||0;if(b)this.min=d;else for(;this.min-f>a[0];)a.shift();if(c)this.max=e;else for(;this.max+fc&&(this.tickInterval*=2,this.setTickPositions());if(s(d)){for(a=c=b.length;a--;)(d===3&&a%2===1||d<=2&&a>0&&a=e&&(b=e));this.displayBtn=a!==z||b!==z;this.setExtremes(a,b,!1,z,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,d=this.horiz,e=p(b.width, -a.plotWidth-c+(b.offsetRight||0)),f=p(b.height,a.plotHeight),g=p(b.top,a.plotTop),b=p(b.left,a.plotLeft+c),c=/%$/;c.test(f)&&(f=Math.round(parseFloat(f)/100*a.plotHeight));c.test(g)&&(g=Math.round(parseFloat(g)/100*a.plotHeight+a.plotTop));this.left=b;this.top=g;this.width=e;this.height=f;this.bottom=a.chartHeight-f-g;this.right=a.chartWidth-e-b;this.len=t(d?e:f,0);this.pos=d?b:g},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?$(b(this.min)):this.min,max:a?$(b(this.max)):this.max, -dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=this.lin2log,d=b?c(this.min):this.min,b=b?c(this.max):this.max;a===null?a=d:d>a?a=d:b15&&a<165?"right":a>195&&a<345?"left":"center"},tickSize:function(a){var b=this.options,c=b[a+"Length"],d=p(b[a+"Width"],a==="tick"&&this.isXAxis?1:0);if(d&&c)return b[a+"Position"]=== -"inside"&&(c=-c),[c,d]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,c=this.tickInterval,d=c,e=this.len/(((this.categories?1:0)+this.max-this.min)/c),f,g=a.rotation,h=this.labelMetrics(),i,j=Number.MAX_VALUE,k,l=function(a){a/=e||1;a=a>1?va(a):1;return a*c};b?(k=!a.staggerLines&&!a.step&&(s(g)?[g]:e=-90&&a<=90)i=l(Q(h.h/da(ka*a))),b=i+Q(a/360),bm)m=a.labelLength});this.maxLabelLength=m;if(this.autoRotation)m>h&&m>j.h?i.rotation=this.labelRotation:this.labelRotation=0;else if(g&&(l={width:h+"px"},!k)){l.textOverflow="clip";for(n=c.length;!f&&n--;)if(o=c[n],h=d[o].label)if(h.styles.textOverflow=== -"ellipsis"?h.css({textOverflow:"clip"}):d[o].labelLength>g&&h.css({width:g+"px"}),h.getBBox().height>this.len/c.length-(j.h-j.f))h.specCss={textOverflow:"ellipsis"}}if(i.rotation&&(l={width:(m>a.chartHeight*0.5?a.chartHeight*0.33:a.chartHeight)+"px"},!k))l.textOverflow="ellipsis";if(this.labelAlign=e.align||this.autoLabelAlign(this.labelRotation))i.align=this.labelAlign;q(c,function(a){var b=(a=d[a])&&a.label;if(b)b.attr(i),l&&b.css(E(l,b.specCss)),delete b.specCss,a.rotation=i.rotation});this.tickRotCorr= -b.rotCorr(j.b,this.labelRotation||0,this.side!==0)},hasData:function(){return this.hasVisibleSeries||s(this.min)&&s(this.max)&&!!this.tickPositions},getOffset:function(){var a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,j,k,l=0,m,n=0,o=d.title,A=d.labels,r=0,K=a.opposite,w=b.axisOffset,b=b.clipOffset,v=[-1,1,1,-1][h],x,u=a.axisParent,aa=this.tickSize("tick");j=a.hasData();a.showAxis=k=j||p(d.showEmpty,!0);a.staggerLines=a.horiz&& -A.staggerLines;if(!a.axisGroup)a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(u),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(u),a.labelGroup=c.g("axis-labels").attr({zIndex:A.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels").add(u);if(j||a.isLinked){if(q(e,function(b){f[b]?f[b].addLabel():f[b]=new Ya(a,b)}),a.renderUnsquish(),A.reserveSpace!==!1&&(h===0||h===2||{1:"left",3:"right"}[h]===a.labelAlign||a.labelAlign==="center")&&q(e,function(a){r=t(f[a].getLabelSize(), -r)}),a.staggerLines)r*=a.staggerLines,a.labelOffset=r*(a.opposite?-1:1)}else for(x in f)f[x].destroy(),delete f[x];if(o&&o.text&&o.enabled!==!1){if(!a.axisTitle)(x=o.textAlign)||(x=(g?{low:"left",middle:"center",high:"right"}:{low:K?"right":"left",middle:"center",high:K?"left":"right"})[o.align]),a.axisTitle=c.text(o.text,0,0,o.useHTML).attr({zIndex:7,rotation:o.rotation||0,align:x}).addClass("highcharts-"+this.coll.toLowerCase()+"-title").css(o.style).add(a.axisGroup),a.axisTitle.isNew=!0;if(k)l= -a.axisTitle.getBBox()[g?"height":"width"],m=o.offset,n=s(m)?0:p(o.margin,g?5:10);a.axisTitle[k?"show":"hide"](!0)}a.offset=v*p(d.offset,w[h]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};c=h===0?-a.labelMetrics().h:h===2?a.tickRotCorr.y:0;n=Math.abs(r)+n;r&&(n-=c,n+=v*(g?p(A.y,a.tickRotCorr.y+v*8):A.x));a.axisTitleMargin=p(m,n);w[h]=t(w[h],a.axisTitleMargin+l+v*a.offset,n,j&&e.length&&aa?aa[0]:0);d=d.offset?0:V(d.lineWidth/2)*2;b[i]=t(b[i],d)},getLinePath:function(a){var b=this.chart,c=this.opposite,d= -this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;c&&(a*=-1);return b.renderer.crispLine([X,e?this.left:f,e?d:this.top,S,e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=e.x||0,j=e.y||0,k=this.chart.renderer.fontMetrics(e.style.fontSize).f,d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align], -b=(a?c+this.height:b)+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(this.side===2?k:0);return{x:a?d+i:b+(g?this.width:0)+h+i,y:a?b+j-(g?this.height:0)+h:d+j}},render:function(){var a=this,b=a.chart,c=b.renderer,d=a.options,e=a.isLog,f=a.lin2log,g=a.isLinked,h=a.tickPositions,i=a.axisTitle,j=a.ticks,k=a.minorTicks,l=a.alternateBands,m=d.stackLabels,n=d.alternateGridColor,o=a.tickmarkOffset,A=d.lineWidth,r,p=b.hasRendered&&I(a.oldMin),w=a.showAxis,v=Wa(c.globalAnimation),s,t;a.labelEdge.length=0;a.overlap= -!1;q([j,k,l],function(a){for(var b in a)a[b].isActive=!1});if(a.hasData()||g){a.minorTickInterval&&!a.categories&&q(a.getMinorTickPositions(),function(b){k[b]||(k[b]=new Ya(a,b,"minor"));p&&k[b].isNew&&k[b].render(null,!0);k[b].render(null,!1,1)});if(h.length&&(q(h,function(b,c){if(!g||b>=a.min&&b<=a.max)j[b]||(j[b]=new Ya(a,b)),p&&j[b].isNew&&j[b].render(c,!0,0.1),j[b].render(c)}),o&&(a.min===0||a.single)))j[-1]||(j[-1]=new Ya(a,-1,null,!0)),j[-1].render(-1);n&&q(h,function(c,d){t=h[d+1]!==z?h[d+ -1]+o:a.max-o;if(d%2===0&&c=G.second?0:k*V(i.getMilliseconds()/k));if(j>=G.second)i[Jb](j>=G.minute?0:k*V(i.getSeconds()/k));if(j>=G.minute)i[Kb](j>=G.hour?0:k*V(i[xb]()/k));if(j>=G.hour)i[Lb](j>=G.day?0:k*V(i[yb]()/k));if(j>=G.day)i[nb](j>=G.month?1:k*V(i[Xa]()/k));j>=G.month&&(i[Ab](j>=G.year?0:k*V(i[db]()/k)),h=i[eb]());j>=G.year&&(h-=h%k,i[Bb](h));if(j===G.week)i[nb](i[Xa]()- -i[zb]()+p(d,1));b=1;if(ub||bb)i=i.getTime(),i=new ma(i+ab(i));h=i[eb]();for(var d=i.getTime(),l=i[db](),m=i[Xa](),n=!g||!!bb,o=(G.day+(g?ab(i):i.getTimezoneOffset()*6E4))%G.day;d=0.5)a=C(a),i=this.getLinearTickPositions(a,b,c);else if(a>=0.08)for(var f=V(b),j,k,l,m,n,e=a>0.3?[1,2,4]:a>0.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];fb&&(!d||m<=c)&&m!==z&&i.push(m),m>c&&(n=!0),m=l}else if(b=g(b),c=g(c),a=e[d?"minorTickInterval":"tickInterval"],a=p(a==="auto"?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/ -(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=wb(a,null,vb(a)),i=Ea(this.getLinearTickPositions(a,b,c),h),!d)this._minorAutoInterval=a/5;if(!d)this.tickInterval=a;return i};ia.prototype.log2lin=function(a){return Z.log(a)/Z.LN10};ia.prototype.lin2log=function(a){return Z.pow(10,a)};var Rb=u.Tooltip=function(){this.init.apply(this,arguments)};Rb.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=B(d.padding);this.chart=a;this.options=b;this.crosshairs=[];this.now={x:0,y:0};this.isHidden= -!0;this.label=a.renderer.label("",0,0,b.shape||"callout",null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8,display:"none"}).css(d).css({padding:0}).add();la||this.label.shadow(b.shadow);this.shared=b.shared},destroy:function(){if(this.label)this.label=this.label.destroy();clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==!1&&!e.isHidden&&(Q(a-f.x)>1|| -Q(b-f.y)>1),h=e.followPointer||e.len>1;x(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:h?z:g?(2*f.anchorX+c)/3:c,anchorY:h?z:g?(f.anchorY+d)/2:d});e.label.attr(f);if(g)clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32)},hide:function(a){var b=this;clearTimeout(this.hideTimer);a=p(a,this.options.hideDelay,500);if(!this.isHidden)this.hideTimer=Sa(function(){b.label[a?"fadeOut":"hide"]();b.isHidden=!0},a)},getAnchor:function(a,b){var c,d=this.chart,e=d.inverted, -f=d.plotTop,g=d.plotLeft,h=0,i=0,j,k,a=ua(a);c=a[0].tooltipPos;this.followPointer&&b&&(b.chartX===z&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]);c||(q(a,function(a){j=a.series.yAxis;k=a.series.xAxis;h+=a.plotX+(!e&&k?k.left-g:0);i+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&j?j.top-f:0)}),h/=a.length,i/=a.length,c=[e?d.plotWidth-i:h,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-h:i]);return Ea(c,C)},getPosition:function(a,b,c){var d=this.chart,e=this.distance, -f={},g=c.h||0,h,i=["y",d.chartHeight,b,c.plotY+d.plotTop,d.plotTop,d.plotTop+d.plotHeight],j=["x",d.chartWidth,a,c.plotX+d.plotLeft,d.plotLeft,d.plotLeft+d.plotWidth],k=!this.followPointer&&p(c.ttBelow,!d.inverted===!!c.negative),l=function(a,b,c,d,h,i){var j=cb?d:d+g);else return!1},m=function(a,b,c,d){var g;db-e?g=!1:f[a]=db-c/2?b-c-2:d-c/2;return g},n=function(a){var b= -i;i=j;j=b;h=a},o=function(){l.apply(0,i)!==!1?m.apply(0,j)===!1&&!h&&(n(!0),o()):h?f.x=f.y=0:(n(!0),o())};(d.inverted||this.len>1)&&n();o();return f},defaultFormatter:function(a){var b=this.points||ua(this),c;c=[a.tooltipFooterHeaderFormatter(b[0])];c=c.concat(a.bodyFormatter(b));c.push(a.tooltipFooterHeaderFormatter(b[0],!0));return c.join("")},refresh:function(a,b){var c=this.chart,d=this.label,e=this.options,f,g,h,i={},j,k=[];j=e.formatter||this.defaultFormatter;var i=c.hoverPoints,l,m=this.shared; -clearTimeout(this.hideTimer);this.followPointer=ua(a)[0].series.tooltipOptions.followPointer;h=this.getAnchor(a,b);f=h[0];g=h[1];m&&(!a.series||!a.series.noSharedTooltip)?(c.hoverPoints=a,i&&q(i,function(a){a.setState()}),q(a,function(a){a.setState("hover");k.push(a.getLabelConfig())}),i={x:a[0].category,y:a[0].y},i.points=k,this.len=k.length,a=a[0]):i=a.getLabelConfig();j=j.call(i,this);i=a.series;this.distance=p(i.tooltipOptions.distance,16);j===!1?this.hide():(this.isHidden&&(Ka(d),d.attr({opacity:1, -display:"block"}).show()),d.attr({text:j}),l=e.borderColor||a.color||i.color||"#606060",d.attr({stroke:l}),this.updatePosition({plotX:f,plotY:g,negative:a.negative,ttBelow:a.ttBelow,h:h[2]||0}),this.isHidden=!1);H(c,"tooltipRefresh",{text:j,x:f+c.plotLeft,y:g+c.plotTop,borderColor:l})},updatePosition:function(a){var b=this.chart,c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(C(c.x),C(c.y||0),a.plotX+b.plotLeft,a.plotY+b.plotTop)},getXDateFormat:function(a, -b,c){var d,b=b.dateTimeLabelFormats,e=c&&c.closestPointRange,f,g={millisecond:15,second:12,minute:9,hour:6,day:3},h,i="millisecond";if(e){h=Ta("%m-%d %H:%M:%S.%L",a.x);for(f in G){if(e===G.week&&+Ta("%w",a.x)===c.options.startOfWeek&&h.substr(6)==="00:00:00.000"){f="week";break}if(G[f]>e){f=i;break}if(g[f]&&h.substr(g[f])!=="01-01 00:00:00.000".substr(g[f]))break;f!=="week"&&(i=f)}f&&(d=b[f])}else d=b.day;return d||b.year},tooltipFooterHeaderFormatter:function(a,b){var c=b?"footer":"header",d=a.series, -e=d.tooltipOptions,f=e.xDateFormat,g=d.xAxis,h=g&&g.options.type==="datetime"&&I(a.key),c=e[c+"Format"];h&&!f&&(f=this.getXDateFormat(a,e,g));h&&f&&(c=c.replace("{point.key}","{point.key:"+f+"}"));return Na(c,{point:a,series:d})},bodyFormatter:function(a){return Ea(a,function(a){var c=a.series.tooltipOptions;return(c.pointFormatter||a.point.tooltipFormatter).call(a.point,c.pointFormat)})}};var ja;gb=y&&y.documentElement.ontouchstart!==z;var $a=u.Pointer=function(a,b){this.init(a,b)};$a.prototype= -{init:function(a,b){var c=b.chart,d=c.events,e=la?"":c.zoomType,c=a.inverted,f;this.options=b;this.chart=a;this.zoomX=f=/x/.test(e);this.zoomY=e=/y/.test(e);this.zoomHor=f&&!c||e&&c;this.zoomVert=e&&!c||f&&c;this.hasZoom=f||e;this.runChartClick=d&&!!d.click;this.pinchDown=[];this.lastValidTouch={};if(u.Tooltip&&b.tooltip.enabled)a.tooltip=new Rb(a,b.tooltip),this.followTouchMove=p(b.tooltip.followTouchMove,!0);this.setDOMEvents()},normalize:function(a,b){var c,d,a=a||D.event;if(!a.target)a.target= -a.srcElement;d=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;if(!b)this.chartPosition=b=Db(this.chart.container);d.pageX===z?(c=t(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top);return x(a,{chartX:C(c),chartY:C(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};q(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},runPointActions:function(a){var b=this.chart,c=b.series,d=b.tooltip, -e=d?d.shared:!1,f=!0,g=b.hoverPoint,h=b.hoverSeries,i,j,k,l=[],m;if(!e&&!h)for(i=0;i -b.series.group.zIndex?-1:1;return c!==0?c:d!==0?d:e}));if(e)for(i=l.length;i--;)(l[i].clientX!==l[0].clientX||l[i].series.noSharedTooltip)&&l.splice(i,1);if(l[0]&&(l[0]!==this.hoverPoint||d&&d.isHidden)){if(e&&!l[0].series.noSharedTooltip){for(i=0;i>=0;i--)l[i].onMouseOver(a,l[i]!==(h&&h.directTouch&&g||l[0]));if(h&&h.directTouch&&g&&g!==l[0])g.onMouseOver(a,!1);l.length&&d&&d.refresh(l.sort(function(a,b){return a.series.index-b.series.index}),a)}else if(d&&d.refresh(l[0],a),!h||!h.directTouch)l[0].onMouseOver(a); -this.prevKDPoint=l[0];f=!1}f&&(c=h&&h.tooltipOptions.followPointer,d&&c&&!d.isHidden&&(c=d.getAnchor([{}],a),d.updatePosition({plotX:c[0],plotY:c[1]})));if(!this._onDocumentMouseMove)this._onDocumentMouseMove=function(a){if(U[ja])U[ja].pointer.onDocumentMouseMove(a)},N(y,"mousemove",this._onDocumentMouseMove);q(e?l:[p(g,l[0])],function(c){q(b.axes,function(b){(!c||c.series&&c.series[b.coll]===b)&&b.drawCrosshair(a,c)})})},reset:function(a,b){var c=this.chart,d=c.hoverSeries,e=c.hoverPoint,f=c.hoverPoints, -g=c.tooltip,h=g&&g.shared?f:e;a&&h&&q(ua(h),function(b){b.series.isCartesian&&b.plotX===void 0&&(a=!1)});if(a)g&&h&&(g.refresh(h),e&&(e.setState(e.state,!0),q(c.axes,function(a){a.crosshair&&a.drawCrosshair(null,e)})));else{if(e)e.onMouseOut();f&&q(f,function(a){a.setState()});if(d)d.onMouseOut();g&&g.hide(b);if(this._onDocumentMouseMove)Y(y,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove=null;q(c.axes,function(a){a.hideCrosshair()});this.hoverX=this.prevKDPoint=c.hoverPoints=c.hoverPoint= -null}},scaleGroups:function(a,b){var c=this.chart,d;q(c.series,function(e){d=a||e.getPlotBox();e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart, -d=a.chartX,e=a.chartY,f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,l,m=this.selectionMarker,n=this.mouseDownX,o=this.mouseDownY,p=c.panKey&&a[c.panKey+"Key"];if(!m||!m.touch)if(dh+j&&(d=h+j),ei+k&&(e=i+k),this.hasDragged=Math.sqrt(Math.pow(n-d,2)+Math.pow(o-e,2)),this.hasDragged>10){l=b.isInsidePlot(n-h,o-i);if(b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!p&&!m)this.selectionMarker=m=b.renderer.rect(h,i,f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill|| -"rgba(69,114,167,0.25)",zIndex:7}).add();m&&f&&(d-=n,m.attr({width:Q(d),x:(d>0?0:d)+n}));m&&g&&(d=e-o,m.attr({height:Q(d),y:(d>0?0:d)+o}));l&&!m&&c.panning&&b.pan(a,c.panning)}},drop:function(a){var b=this,c=this.chart,d=this.hasPinched;if(this.selectionMarker){var e={originalEvent:a,xAxis:[],yAxis:[]},f=this.selectionMarker,g=f.attr?f.attr("x"):f.x,h=f.attr?f.attr("y"):f.y,i=f.attr?f.attr("width"):f.width,j=f.attr?f.attr("height"):f.height,k;if(this.hasDragged||d)q(c.axes,function(c){if(c.zoomEnabled&& -s(c.min)&&(d||b[{xAxis:"zoomX",yAxis:"zoomY"}[c.coll]])){var f=c.horiz,n=a.type==="touchend"?c.minPixelPadding:0,o=c.toValue((f?g:h)+n),f=c.toValue((f?g+i:h+j)-n);e[c.coll].push({axis:c,min:F(o,f),max:t(o,f)});k=!0}}),k&&H(c,"selection",e,function(a){c.zoom(x(a,d?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();d&&this.scaleGroups()}if(c)M(c.container,{cursor:c._cursor}),c.cancelClick=this.hasDragged>10,c.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[]}, -onContainerMouseDown:function(a){a=this.normalize(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(a){U[ja]&&U[ja].pointer.drop(a)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,a=this.normalize(a,c);c&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&&this.reset()},onContainerMouseLeave:function(a){var b=U[ja];if(b&&(a.relatedTarget||a.toElement))b.pointer.reset(),b.pointer.chartPosition= -null},onContainerMouseMove:function(a){var b=this.chart;if(!s(ja)||!U[ja]||!U[ja].mouseIsDown)ja=b.index;a=this.normalize(a);a.returnValue=!1;b.mouseIsDown==="mousedown"&&this.drag(a);(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=O(a,"class")){if(c.indexOf(b)!==-1)return!0;if(c.indexOf("highcharts-container")!==-1)return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b= -this.chart.hoverSeries,a=a.relatedTarget||a.toElement;if(b&&a&&!b.options.stickyTracking&&!this.inClass(a,"highcharts-tooltip")&&!this.inClass(a,"highcharts-series-"+b.index))b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,a=this.normalize(a);b.cancelClick||(c&&this.inClass(a.target,"highcharts-tracker")?(H(c.series,"click",x(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(x(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY- -e)&&H(b,"click",a)))},setDOMEvents:function(){var a=this,b=a.chart.container;b.onmousedown=function(b){a.onContainerMouseDown(b)};b.onmousemove=function(b){a.onContainerMouseMove(b)};b.onclick=function(b){a.onContainerClick(b)};N(b,"mouseleave",a.onContainerMouseLeave);hb===1&&N(y,"mouseup",a.onDocumentMouseUp);if(gb)b.ontouchstart=function(b){a.onContainerTouchStart(b)},b.ontouchmove=function(b){a.onContainerTouchMove(b)},hb===1&&N(y,"touchend",a.onDocumentTouchEnd)},destroy:function(){var a;Y(this.chart.container, -"mouseleave",this.onContainerMouseLeave);hb||(Y(y,"mouseup",this.onDocumentMouseUp),Y(y,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(a in this)this[a]=null}};x(u.Pointer.prototype,{pinchTranslate:function(a,b,c,d,e,f){(this.zoomHor||this.pinchHor)&&this.pinchTranslateDirection(!0,a,b,c,d,e,f);(this.zoomVert||this.pinchVert)&&this.pinchTranslateDirection(!1,a,b,c,d,e,f)},pinchTranslateDirection:function(a,b,c,d,e,f,g,h){var i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+ -k,m=a?"width":"height",n=i["plot"+(a?"Left":"Top")],o,p,r=h||1,q=i.inverted,w=i.bounds[a?"h":"v"],v=b.length===1,t=b[0][l],s=c[0][l],x=!v&&b[1][l],u=!v&&c[1][l],z,c=function(){!v&&Q(t-x)>20&&(r=h||Q(s-u)/Q(t-x));p=(n-s)/r+t;o=i["plot"+(a?"Width":"Height")]/r};c();b=p;bw.max&&(b=w.max-o,z=!0);z?(s-=0.8*(s-g[j][0]),v||(u-=0.8*(u-g[j][1])),c()):g[j]=[s,u];q||(f[j]=p-n,f[m]=o);f=q?1/r:r;e[m]=o;e[j]=b;d[q?a?"scaleY":"scaleX":"scale"+k]=r;d["translate"+k]=f*n+(s-f*t)},pinch:function(a){var b= -this,c=b.chart,d=b.pinchDown,e=a.touches,f=e.length,g=b.lastValidTouch,h=b.hasZoom,i=b.selectionMarker,j={},k=f===1&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||b.runChartClick),l={};if(f>1)b.initiated=!0;h&&b.initiated&&!k&&a.preventDefault();Ea(e,function(a){return b.normalize(a)});if(a.type==="touchstart")q(e,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),g.x=[d[0].chartX,d[1]&&d[1].chartX],g.y=[d[0].chartY,d[1]&&d[1].chartY],q(c.axes,function(a){if(a.zoomEnabled){var b= -c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(p(a.options.min,a.dataMin)),f=a.toPixels(p(a.options.max,a.dataMax)),g=F(e,f),e=t(e,f);b.min=F(a.pos,g-d);b.max=t(a.pos+a.len,e+d)}}),b.res=!0;else if(d.length){if(!i)b.selectionMarker=i=x({destroy:Ca,touch:!0},c.plotBox);b.pinchTranslate(d,e,j,i,l,g);b.hasPinched=h;b.scaleGroups(j,l);if(!h&&b.followTouchMove&&f===1)this.runPointActions(b.normalize(a));else if(b.res)b.res=!1,this.reset(!1,0)}},touch:function(a,b){var c=this.chart,d;ja=c.index; -if(a.touches.length===1)if(a=this.normalize(a),c.isInsidePlot(a.chartX-c.plotLeft,a.chartY-c.plotTop)&&!c.openMenu){b&&this.runPointActions(a);if(a.type==="touchmove")c=this.pinchDown,d=c[0]?Math.sqrt(Math.pow(c[0].chartX-a.chartX,2)+Math.pow(c[0].chartY-a.chartY,2))>=4:!1;p(d,!0)&&this.pinch(a)}else b&&this.reset();else a.touches.length===2&&this.pinch(a)},onContainerTouchStart:function(a){this.touch(a,!0)},onContainerTouchMove:function(a){this.touch(a)},onDocumentTouchEnd:function(a){U[ja]&&U[ja].pointer.drop(a)}}); -if(D.PointerEvent||D.MSPointerEvent){var wa={},Fb=!!D.PointerEvent,Ub=function(){var a,b=[];b.item=function(a){return this[a]};for(a in wa)wa.hasOwnProperty(a)&&b.push({pageX:wa[a].pageX,pageY:wa[a].pageY,target:wa[a].target});return b},Gb=function(a,b,c,d){if((a.pointerType==="touch"||a.pointerType===a.MSPOINTER_TYPE_TOUCH)&&U[ja])d(a),d=U[ja].pointer,d[b]({type:c,target:a.currentTarget,preventDefault:Ca,touches:Ub()})};x($a.prototype,{onContainerPointerDown:function(a){Gb(a,"onContainerTouchStart", -"touchstart",function(a){wa[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){Gb(a,"onContainerTouchMove","touchmove",function(a){wa[a.pointerId]={pageX:a.pageX,pageY:a.pageY};if(!wa[a.pointerId].target)wa[a.pointerId].target=a.currentTarget})},onDocumentPointerUp:function(a){Gb(a,"onDocumentTouchEnd","touchend",function(a){delete wa[a.pointerId]})},batchMSEvents:function(a){a(this.chart.container,Fb?"pointerdown":"MSPointerDown",this.onContainerPointerDown); -a(this.chart.container,Fb?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(y,Fb?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}});ib($a.prototype,"init",function(a,b,c){a.call(this,b,c);this.hasZoom&&M(b.container,{"-ms-touch-action":"none","touch-action":"none"})});ib($a.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(N)});ib($a.prototype,"destroy",function(a){this.batchMSEvents(Y);a.call(this)})}var sb=u.Legend=function(a, -b){this.init(a,b)};sb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=b.itemMarginTop||0;this.options=b;if(b.enabled)c.itemStyle=d,c.itemHiddenStyle=E(d,b.itemHiddenStyle),c.itemMarginTop=e,c.padding=d=p(b.padding,8),c.initialItemX=d,c.initialItemY=d-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.symbolWidth=p(b.symbolWidth,16),c.pages=[],c.render(),N(c.chart,"endResize",function(){c.positionCheckboxes()})},colorizeItem:function(a,b){var c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol, -g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color||"#CCC":g,g=a.options&&a.options.marker,i={fill:h},j;d&&d.css({fill:c,color:c});e&&e.attr({stroke:h});if(f){if(g&&f.isMarker)for(j in i.stroke=h,g=a.convertAttribs(g),g)d=g[j],d!==z&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,e=d[0],d=d[1],f=a.checkbox;(a=a.legendGroup)&&a.element&&a.translate(b?e:this.legendWidth-e-2*c-4,d);if(f)f.x=e,f.y=d},destroyItem:function(a){var b= -a.checkbox;q(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())});b&&Va(a.checkbox)},destroy:function(){var a=this.group,b=this.box;if(b)this.box=b.destroy();if(a)this.group=a.destroy()},positionCheckboxes:function(a){var b=this.group.alignAttr,c,d=this.clipHeight||this.legendHeight,e=this.titleHeight;if(b)c=b.translateY,q(this.allItems,function(f){var g=f.checkbox,h;g&&(h=c+e+g.y+(a||0)+3,M(g,{left:b.translateX+f.checkboxOffset+g.x-20+"px",top:h+"px", -display:h>c-6&&h(m||b.chartWidth-2*j-A-d.x))this.itemX=A,this.itemY+=o+this.lastLineHeight+n,this.lastLineHeight=0;this.maxItemWidth=t(this.maxItemWidth,f);this.lastItemY=o+this.itemY+n;this.lastLineHeight=t(g,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];e?this.itemX+=f:(this.itemY+=o+g+n,this.lastLineHeight=g);this.offsetWidth=m||t((e?this.itemX-A-k:f)+j,this.offsetWidth)},getAllItems:function(){var a=[];q(this.chart.series, -function(b){var c=b.options;if(p(c.showInLegend,!s(c.linkedTo)?z:!1,!0))a=a.concat(b.legendItems||(c.legendType==="point"?b.data:b))});return a},adjustMargins:function(a,b){var c=this.chart,d=this.options,e=d.align.charAt(0)+d.verticalAlign.charAt(0)+d.layout.charAt(0);d.floating||q([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(f,g){f.test(e)&&!s(a[g])&&(c[qb[g]]=t(c[qb[g]],c.legend[(g+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][g]*d[g%2?"x":"y"]+p(d.margin,12)+b[g]))})}, -render:function(){var a=this,b=a.chart,c=b.renderer,d=a.group,e,f,g,h,i=a.box,j=a.options,k=a.padding,l=j.borderWidth,m=j.backgroundColor;a.itemX=a.initialItemX;a.itemY=a.initialItemY;a.offsetWidth=0;a.lastItemY=0;if(!d)a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup);a.renderTitle();e=a.getAllItems();kb(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});j.reversed&& -e.reverse();a.allItems=e;a.display=f=!!e.length;a.lastLineHeight=0;q(e,function(b){a.renderItem(b)});g=(j.width||a.offsetWidth)+k;h=a.lastItemY+a.lastLineHeight+a.titleHeight;h=a.handleOverflow(h);h+=k;if(l||m){if(i){if(g>0&&h>0)i[i.isNew?"attr":"animate"](i.crisp({width:g,height:h})),i.isNew=!1}else a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:m||"none"}).add(d).shadow(j.shadow),i.isNew=!0;i[f?"show":"hide"]()}a.legendWidth=g;a.legendHeight=h;q(e, -function(b){a.positionItem(b)});f&&d.align(x({width:g,height:h},j),!0,"spacingBox");b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var b=this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+(e.verticalAlign==="top"?-f:f)-this.padding,g=e.maxHeight,h,i=this.clipRect,j=e.navigation,k=p(j.animation,!0),l=j.arrowSize||12,m=this.nav,n=this.pages,o=this.padding,A,r=this.allItems,s=function(a){i.attr({height:a});if(b.contentGroup.div)b.contentGroup.div.style.clip= -"rect("+o+"px,9999px,"+(o+a)+"px,0)"};e.layout==="horizontal"&&(f/=2);g&&(f=F(f,g));n.length=0;if(a>f&&j.enabled!==!1){this.clipHeight=h=t(f-20-this.titleHeight-o,0);this.currentPage=p(this.currentPage,1);this.fullHeight=a;q(r,function(a,b){var c=a._legendItemPos[1],d=C(a.legendItem.getBBox().height),e=n.length;if(!e||c-n[e-1]>h&&(A||c)!==n[e-1])n.push(A||c),e++;b===r.length-1&&c+d-n[e-1]>h&&n.push(c);c!==A&&(A=c)});if(!i)i=b.clipRect=d.clipRect(0,o,9999,0),b.contentGroup.clip(i);s(h);if(!m)this.nav= -m=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(m),this.pager=d.text("",15,10).css(j.style).add(m),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(m);b.scroll(0);a=f}else if(m)s(c.chartHeight),m.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0;return a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor, -g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d);if(e>0)b!==z&&cb(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:e===1?g:h}).css({cursor:e===1?"default":"pointer"}),i.attr({text:e+"/"+d}),this.down.attr({x:18+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c)}};P= -u.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||a.fontMetrics.f;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-c+1,a.symbolWidth,c,a.options.symbolRadius||0).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var b=this.options,c=b.marker,d=a.symbolWidth,e=this.chart.renderer,f=this.legendGroup,a=a.baseline-C(a.fontMetrics.b*0.3),g;if(b.lineWidth){g={"stroke-width":b.lineWidth};if(b.dashStyle)g.dashstyle=b.dashStyle;this.legendLine=e.path([X,0,a,S, -d,a]).attr(g).add(f)}if(c&&c.enabled!==!1)b=c.radius,this.legendSymbol=c=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b,c).add(f),c.isMarker=!0}};(/Trident\/7\.0/.test(Ba)||Qa)&&ib(sb.prototype,"positionItem",function(a,b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};d();setTimeout(d)});var jb=u.Chart=function(){this.getArgs.apply(this,arguments)};u.chart=function(a,b,c){return new jb(a,b,c)};jb.prototype={callbacks:[],getArgs:function(){var a=[].slice.call(arguments);if(ya(a[0])||a[0].nodeName)this.renderTo= -a.shift();this.init(a[0],a[1])},init:function(a,b){var c,d=a.series;a.series=null;c=E(T,a);c.series=a.series=d;this.userOptions=a;d=c.chart;this.margin=this.splashArray("margin",d);this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}};this.callback=b;this.isResizing=0;this.options=c;this.axes=[];this.series=[];this.hasCartesianSeries=d.showAxes;var f=this,g;f.index=U.length;U.push(f);hb++;d.reflow!==!1&&N(f,"load",function(){f.initReflow()});if(e)for(g in e)N(f,g,e[g]); -f.xAxis=[];f.yAxis=[];f.animation=la?!1:p(d.animation,!0);f.pointCount=f.colorCounter=f.symbolCounter=0;f.firstRender()},initSeries:function(a){var b=this.options.chart;(b=L[a.type||b.type||b.defaultSeriesType])||ea(17,!0);b=new b;b.init(this,a);return b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},redraw:function(a){var b=this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,g,h,i=this.hasCartesianSeries,j=this.isDirtyBox, -k=c.length,l=k,m=this.renderer,n=m.isHidden(),o=[];cb(a,this);n&&this.cloneRenderTo();for(this.layOutTitles();l--;)if(a=c[l],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(l=k;l--;)if(a=c[l],a.options.stacking)a.isDirty=!0;q(c,function(a){a.isDirty&&a.options.legendType==="point"&&(a.updateTotals&&a.updateTotals(),f=!0);a.isDirtyData&&H(a,"updatedData")});if(f&&e.options.enabled)e.render(),this.isDirtyLegend=!1;g&&this.getStacks();if(i&&!this.isResizing)this.maxTicks=null,q(b,function(a){a.updateNames(); -a.setScale()});this.getMargins();i&&(q(b,function(a){a.isDirty&&(j=!0)}),q(b,function(a){var b=a.min+","+a.max;if(a.extKey!==b)a.extKey=b,o.push(function(){H(a,"afterSetExtremes",x(a.eventArgs,a.getExtremes()));delete a.eventArgs});(j||g)&&a.redraw()}));j&&this.drawChartBox();q(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()});d&&d.reset(!0);m.draw();H(this,"redraw");n&&this.cloneRenderTo(!0);q(o,function(a){a.call()})},get:function(a){var b=this.axes,c=this.series,d,e;for(d= -0;d19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container; -if(a){if(b){for(;b.childNodes.length;)this.renderTo.appendChild(b.firstChild);Va(b);delete this.renderToClone}}else c&&c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),M(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),y.body.appendChild(b),c&&b.appendChild(c)},getContainer:function(){var a,b=this.options,c=b.chart,d,e;a=this.renderTo;var f="highcharts-"+Cb++;if(!a)this.renderTo= -a=c.renderTo;if(ya(a))this.renderTo=a=y.getElementById(a);a||ea(13,!0);d=B(O(a,"data-highcharts-chart"));I(d)&&U[d]&&U[d].hasRendered&&U[d].destroy();O(a,"data-highcharts-chart",this.index);a.innerHTML="";!c.skipClone&&!a.offsetWidth&&this.cloneRenderTo();this.getChartSize();d=this.chartWidth;e=this.chartHeight;this.container=a=ca(Pa,{className:"highcharts-container"+(c.className?" "+c.className:""),id:f},x({position:"relative",overflow:"hidden",width:d+"px",height:e+"px",textAlign:"left",lineHeight:"normal", -zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},c.style),this.renderToClone||a);this._cursor=a.style.cursor;this.renderer=new (u[c.renderer]||fb)(a,d,e,c.style,c.forExport,b.exporting&&b.exporting.allowHTML);la&&this.renderer.create(this,a,d,e);this.renderer.chartIndex=this.index},getMargins:function(a){var b=this.spacing,c=this.margin,d=this.titleOffset;this.resetMargins();if(d&&!s(c[0]))this.plotTop=t(this.plotTop,d+this.options.title.margin+b[0]);this.legend.display&&this.legend.adjustMargins(c, -b);this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);a||this.getAxisMargins()},getAxisMargins:function(){var a=this,b=a.axisOffset=[0,0,0,0],c=a.margin;a.hasCartesianSeries&&q(a.axes,function(a){a.visible&&a.getOffset()});q(qb,function(d,e){s(c[e])||(a[d]+=b[e])});a.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,e=s(c.width),f=c.width||oa(d,"width"),c=c.height||oa(d,"height"),d=a?a.target:D;if(!e&& -!b.isPrinting&&f&&c&&(d===D||d===y)){if(f!==b.containerWidth||c!==b.containerHeight)clearTimeout(b.reflowTimeout),b.reflowTimeout=Sa(function(){b.container&&b.setSize(void 0,void 0,!1)},a?100:0);b.containerWidth=f;b.containerHeight=c}},initReflow:function(){var a=this,b=function(b){a.reflow(b)};N(D,"resize",b);N(a,"destroy",function(){Y(D,"resize",b)})},setSize:function(a,b,c){var d=this,e=d.renderer;d.isResizing+=1;cb(c,d);d.oldChartHeight=d.chartHeight;d.oldChartWidth=d.chartWidth;if(a!==void 0)d.options.chart.width= -a;if(b!==void 0)d.options.chart.height=b;d.getChartSize();a=e.globalAnimation;(a?Za:M)(d.container,{width:d.chartWidth+"px",height:d.chartHeight+"px"},a);d.setChartSize(!0);e.setSize(d.chartWidth,d.chartHeight,c);d.maxTicks=null;q(d.axes,function(a){a.isDirty=!0;a.setScale()});q(d.series,function(a){a.isDirty=!0});d.isDirtyLegend=!0;d.isDirtyBox=!0;d.layOutTitles();d.getMargins();d.redraw(c);d.oldChartHeight=null;H(d,"resize");Sa(function(){d&&H(d,"endResize",null,function(){d.isResizing-=1})},Wa(a).duration)}, -setChartSize:function(a){var b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset,i,j,k,l;this.plotLeft=i=C(this.plotLeft);this.plotTop=j=C(this.plotTop);this.plotWidth=k=t(0,C(d-i-this.marginRight));this.plotHeight=l=t(0,C(e-j-this.marginBottom));this.plotSizeX=b?l:k;this.plotSizeY=b?k:l;this.plotBorderWidth=f.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]};this.plotBox=c.plotBox= -{x:i,y:j,width:k,height:l};d=2*V(this.plotBorderWidth/2);b=va(t(d,h[3])/2);c=va(t(d,h[0])/2);this.clipBox={x:b,y:c,width:V(this.plotSizeX-t(d,h[1])/2-b),height:t(0,V(this.plotSizeY-t(d,h[2])/2-c))};a||q(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a=this;q(qb,function(b,c){a[b]=p(a.margin[c],a.spacing[c])});a.axisOffset=[0,0,0,0];a.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight, -e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,m=a.plotBorderWidth||0,n,o=this.plotLeft,p=this.plotTop,r=this.plotWidth,q=this.plotHeight,w=this.plotBox,v=this.clipRect,s=this.clipBox;n=i+(a.shadow?8:0);if(i||j)if(e)e.animate(e.crisp({width:c-n,height:d-n}));else{e={fill:j||"none"};if(i)e.stroke=a.borderColor,e["stroke-width"]=i;this.chartBackground=b.rect(n/2,n/2,c-n,d-n,a.borderRadius, -i).attr(e).addClass("highcharts-background").add().shadow(a.shadow)}if(k)f?f.animate(w):this.plotBackground=b.rect(o,p,r,q,0).attr({fill:k}).add().shadow(a.plotShadow);if(l)h?h.animate(w):this.plotBGImage=b.image(l,o,p,r,q).add();v?v.animate({width:s.width,height:s.height}):this.clipRect=b.clipRect(s);if(m)g?(g.strokeWidth=-m,g.animate(g.crisp({x:o,y:p,width:r,height:q}))):this.plotBorder=b.rect(o,p,r,q,0,-m).attr({stroke:a.plotBorderColor,"stroke-width":m,fill:"none",zIndex:1}).add();this.isDirtyBox= -!1},propFromSeries:function(){var a=this,b=a.options.chart,c,d=a.options.series,e,f;q(["inverted","angular","polar"],function(g){c=L[b.type||b.defaultSeriesType];f=a[g]||b[g]||c&&c.prototype[g];for(e=d&&d.length;!f&&e--;)(c=L[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;q(b,function(a){a.linkedSeries.length=0});q(b,function(b){var d=b.options.linkedTo;if(ya(d)&&(d=d===":previous"?a.series[b.index-1]:a.get(d))&&d.linkedParent!==b)d.linkedSeries.push(b), -b.linkedParent=d,b.visible=p(b.options.visible,d.options.visible,b.visible)})},renderSeries:function(){q(this.series,function(a){a.translate();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;b.items&&q(b.items,function(c){var d=x(b.style,c.style),e=B(d.left)+a.plotLeft,f=B(d.top)+a.plotTop+12;delete d.left;delete d.top;a.renderer.text(c.html,e,f).attr({zIndex:2}).css(d).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options,d,e,f,g;this.setTitle();this.legend= -new sb(this,c.legend);this.getStacks&&this.getStacks();this.getMargins(!0);this.setChartSize();d=this.plotWidth;e=this.plotHeight-=21;q(a,function(a){a.setScale()});this.getAxisMargins();f=d/this.plotWidth>1.1;g=e/this.plotHeight>1.05;if(f||g)this.maxTicks=null,q(a,function(a){(a.horiz&&f||!a.horiz&&g)&&a.setTickInterval(!0)}),this.getMargins();this.drawChartBox();this.hasCartesianSeries&&q(a,function(a){a.visible&&a.render()});if(!this.seriesGroup)this.seriesGroup=b.g("series-group").attr({zIndex:3}).add(); -this.renderSeries();this.renderLabels();this.showCredits(c.credits);this.hasRendered=!0},showCredits:function(a){if(a.enabled&&!this.credits)this.credits=this.renderer.text(a.text,0,0).on("click",function(){if(a.href)D.location.href=a.href}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position)},destroy:function(){var a=this,b=a.axes,c=a.series,d=a.container,e,f=d&&d.parentNode;H(a,"destroy");U[a.index]=z;hb--;a.renderTo.removeAttribute("data-highcharts-chart");Y(a);for(e=b.length;e--;)b[e]= -b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();q("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())});if(d)d.innerHTML="",Y(d),f&&Va(d);for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!fa&&D==D.top&&y.readyState!=="complete"||la&&!D.canvg?(la?Qb.push(function(){a.firstRender()},a.options.global.canvasToolsURL): -y.attachEvent("onreadystatechange",function(){y.detachEvent("onreadystatechange",a.firstRender);y.readyState==="complete"&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options;if(a.isReadyToRender()){a.getContainer();H(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();q(b.series||[],function(b){a.initSeries(b)});a.linkSeries();H(a,"beforeRender");if(u.Pointer)a.pointer=new $a(a,b);a.render();a.renderer.draw();if(!a.renderer.imgCount&&a.onload)a.onload(); -a.cloneRenderTo(!0)}},onload:function(){var a=this;q([this.callback].concat(this.callbacks),function(b){b&&a.index!==void 0&&b.apply(a,[a])});H(a,"load");this.onload=null},splashArray:function(a,b){var c=b[a],c=ba(c)?c:[c,c,c,c];return[p(b[a+"Top"],c[0]),p(b[a+"Right"],c[1]),p(b[a+"Bottom"],c[2]),p(b[a+"Left"],c[3])]}};var Eb=u.CenteredSeriesMixin={getCenter:function(){var a=this.options,b=this.chart,c=2*(a.slicedOffset||0),d=b.plotWidth-2*c,b=b.plotHeight-2*c,e=a.center,e=[p(e[0],"50%"),p(e[1],"50%"), -a.size||"100%",a.innerSize||0],f=F(d,b),g,h;for(g=0;g<4;++g)h=e[g],a=g<2||g===2&&/%$/.test(h),e[g]=(/%$/.test(h)?[d,b,f,e[2]][g]*parseFloat(h)/100:parseFloat(h))+(a?c:0);e[3]>e[2]&&(e[3]=e[2]);return e}},Ma=function(){};Ma.prototype={init:function(a,b,c){this.series=a;this.color=a.color;this.applyOptions(b,c);this.pointAttr={};if(a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length))a.colorCounter=0;a.chart.pointCount++; -return this},applyOptions:function(a,b){var c=this.series,d=c.options.pointValKey||c.pointValKey,a=Ma.prototype.optionsToObject.call(this,a);x(this,a);this.options=this.options?x(this.options,a):a;a.group&&delete this.group;if(d)this.y=this[d];this.isNull=p(this.isValid&&!this.isValid(),this.x===null||!I(this.y,!0));if("name"in this&&b===void 0&&c.xAxis&&c.xAxis.hasNames)this.x=c.xAxis.nameToX(this);if(this.x===void 0&&c)this.x=b===void 0?c.autoIncrement(this):b;return this},optionsToObject:function(a){var b= -{},c=this.series,d=c.options.keys,e=d||c.pointArrayMap||["y"],f=e.length,g=0,h=0;if(I(a)||a===null)b[e[0]]=a;else if(za(a)){if(!d&&a.length>f){c=typeof a[0];if(c==="string")b.name=a[0];else if(c==="number")b.x=a[0];g++}for(;hm){for(c=0;k===null&&ci||this.forceCrop))if(b[d- -1]o)b=[],c=[];else if(b[0]o)e=this.cropData(this.xData,this.yData,n,o),b=e.xData,c=e.yData,e=e.start,f=!0;for(i=b.length||1;--i;)d=m?j(b[i])-j(b[i-1]):b[i]-b[i-1],d>0&&(g===z||d=c){f=t(0,i-h);break}for(c=i;cd){g=c+h;break}return{xData:a.slice(f, -g),yData:b.slice(f,g),start:f,end:g}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,i,j=this.hasGroupedData,k,l=[],m;if(!b&&!j)b=[],b.length=a.length,b=this.data=b;for(m=0;m0),j=this.getExtremesFromAll||this.options.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)k[i]!== -null&&(e[f++]=k[i]);else e[f++]=k;this.dataMin=Oa(e);this.dataMax=Ha(e)},translate:function(){this.processedXData||this.processData();this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,i=a.pointPlacement,j=i==="between"||I(i),k=a.threshold,l=a.startFromThreshold?k:0,m,n,o,q,r=Number.MAX_VALUE,a=0;a=0&&n<=e.len&&m>=0&&m<=c.len;K.clientX=j?$(c.translate(w,0,0,0,1,i)):m;K.negative=K.y<(k||0);K.category=d&&d[K.x]!==z?d[K.x]:K.x;K.isNull||(o!==void 0&&(r=F(r,Q(m-o))),o=m)}this.closestPointRangePx=r},getValidPoints:function(a,b){var c=this.chart;return Da(a||this.points||[],function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options, -d=b.renderer,e=b.inverted,f=this.clipBox,g=f||b.clipBox,h=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,g.height,c.xAxis,c.yAxis].join(","),i=b[h],j=b[h+"m"];if(!i){if(a)g.width=0,b[h+"m"]=j=d.clipRect(-99,e?-b.plotLeft:-b.plotTop,99,e?b.chartWidth:b.chartHeight);b[h]=i=d.clipRect(g);i.count={length:0}}a&&!i.count[this.index]&&(i.count[this.index]=!0,i.count.length+=1);if(c.clip!==!1)this.group.clip(a||f?i:b.clipRect),this.markerGroup.clip(j),this.sharedClipKey=h;a||(i.count[this.index]&& -(delete i.count[this.index],i.count.length-=1),i.count.length===0&&h&&b[h]&&(f||(b[h]=b[h].destroy()),b[h+"m"]&&(b[h+"m"]=b[h+"m"].destroy())))},animate:function(a){var b=this.chart,c=Wa(this.options.animation),d;a?this.setClip(c):(d=this.sharedClipKey,(a=b[d])&&a.animate({width:b.plotSizeX},c),b[d+"m"]&&b[d+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip();H(this,"afterAnimate")},drawPoints:function(){var a,b=this.points,c=this.chart,d,e,f,g,h,i,j, -k,l=this.options.marker,m=this.pointAttr[""],n,o,q,r=this.markerGroup,s=p(l.enabled,this.xAxis.isRadial,this.closestPointRangePx>2*l.radius);if(l.enabled!==!1||this._hasPointMarkers)for(f=b.length;f--;)if(g=b[f],d=V(g.plotX),e=g.plotY,k=g.graphic,n=g.marker||{},o=!!g.marker,a=s&&n.enabled===z||n.enabled,q=g.isInside,a&&I(e)&&g.y!==null)if(a=g.pointAttr[g.selected?"select":""]||m,h=a.r,i=p(n.symbol,this.symbol),j=i.indexOf("url")===0,k)k[q?"show":"hide"](!0).attr(a).animate(x({x:d-h,y:e-h},k.symbolName? -{width:2*h,height:2*h}:{}));else{if(q&&(h>0||j))g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h,o?n:l).attr(a).add(r)}else if(k)g.graphic=k.destroy()},convertAttribs:function(a,b,c,d){var e=this.pointAttrToOptions,f,g,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=p(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var a=this,b=a.options,c=ga[a.type].marker?b.marker:b,d=c.states,e=d.hover,f,g=a.color,h=a.options.negativeColor,i={stroke:g,fill:g},j=a.points||[],k,l=[],m,n=a.pointAttrToOptions; -f=a.hasPointSpecificOptions;var o=c.lineColor,A=c.fillColor;k=b.turboThreshold;var r=a.zones,t=a.zoneAxis||"y",w,v;b.marker?(e.radius=+e.radius||+c.radius+ +e.radiusPlus,e.lineWidth=e.lineWidth||c.lineWidth+e.lineWidthPlus):(e.color=e.color||na(e.color||g).brighten(e.brightness).get(),e.negativeColor=e.negativeColor||na(e.negativeColor||h).brighten(e.brightness).get());l[""]=a.convertAttribs(c,i);q(["hover","select"],function(b){l[b]=a.convertAttribs(d[b],l[""])});a.pointAttr=l;g=j.length;if(!k|| -g=i.value;)i=r[++f];k.color=k.fillColor=i=p(i.color,a.color)}f=b.colorByPoint||k.color;if(k.options)for(v in n)s(c[n[v]])&&(f=!0);if(f){c=c||{};m=[];d=c.states||{};f=d.hover=d.hover||{};if(!b.marker||k.negative&&!f.fillColor&&!e.fillColor)f[a.pointAttrToOptions.fill]=f.color||!k.options.color&&e[k.negative&&h?"negativeColor":"color"]||na(k.color).brighten(f.brightness|| -e.brightness).get();w={color:k.color};if(!A)w.fillColor=k.color;if(!o)w.lineColor=k.color;c.hasOwnProperty("color")&&!c.color&&delete c.color;if(i&&!e.fillColor)f.fillColor=i;m[""]=a.convertAttribs(x(w,c),l[""]);m.hover=a.convertAttribs(d.hover,l.hover,m[""]);m.select=a.convertAttribs(d.select,l.select,m[""])}else m=l;k.pointAttr=m}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(Ba),d,e=a.data||[],f,g,h;H(a,"destroy");Y(a);q(a.axisTypes||[],function(b){if(h=a[b])ra(h.series,a), -h.isDirty=h.forceRedraw=!0});a.legendItem&&a.chart.legend.destroyItem(a);for(d=e.length;d--;)(f=e[d])&&f.destroy&&f.destroy();a.points=null;clearTimeout(a.animationTimeout);for(g in a)a[g]instanceof J&&!a[g].survive&&(d=c&&g==="group"?"hide":"destroy",a[g][d]());if(b.hoverSeries===a)b.hoverSeries=null;ra(b.series,a);for(g in a)delete a[g]},getGraphPath:function(a,b,c){var d=this,e=d.options,f=e.step,g,h=[],i=[],j,a=a||d.points;(g=a.reversed)&&a.reverse();(f={right:1,center:2}[f]||f&&3)&&g&&(f=4-f); -e.connectNulls&&!b&&!c&&(a=this.getValidPoints(a));q(a,function(g,l){var m=g.plotX,n=g.plotY,o=a[l-1];if((g.leftCliff||o&&o.rightCliff)&&!c)j=!0;g.isNull&&!s(b)&&l>0?j=!e.connectNulls:g.isNull&&!b?j=!0:(l===0||j?o=[X,g.plotX,g.plotY]:d.getPointSpline?o=d.getPointSpline(a,g,l):f?(o=f===1?[S,o.plotX,n]:f===2?[S,(o.plotX+m)/2,o.plotY,S,(o.plotX+m)/2,n]:[S,m,o.plotY],o.push(S,m,n)):o=[S,m,n],i.push(g.x),f&&i.push(g.x),h.push.apply(h,o),j=!1)});h.xMap=i;return d.graphPath=h},drawGraph:function(){var a= -this,b=this.options,c=[["graph",b.lineColor||this.color,b.dashStyle]],d=b.lineWidth,e=b.linecap!=="square",f=(this.gappedPath||this.getGraphPath).call(this);q(this.zones,function(d,e){c.push(["zoneGraph"+e,d.color||a.color,d.dashStyle||b.dashStyle])});q(c,function(c,h){var i=c[0],j=a[i];if(j)j.endX=f.xMap,j.animate({d:f});else if(d&&f.length)j={stroke:c[1],"stroke-width":d,fill:"none",zIndex:1},c[2]?j.dashstyle=c[2]:e&&(j["stroke-linecap"]=j["stroke-linejoin"]="round"),j=a[i]=a.chart.renderer.path(f).attr(j).add(a.group).shadow(h< -2&&b.shadow);if(j)j.startX=f.xMap,j.isArea=f.isArea})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,d=this.zones,e,f,g=this.clips||[],h,i=this.graph,j=this.area,k=t(b.chartWidth,b.chartHeight),l=this[(this.zoneAxis||"y")+"Axis"],m,n,o=b.inverted,A,r,s,w,v=!1;if(d.length&&(i||j)&&l&&l.min!==z)n=l.reversed,A=l.horiz,i&&i.hide(),j&&j.hide(),m=l.getExtremes(),q(d,function(d,q){e=n?A?b.plotWidth:0:A?0:l.toPixels(m.min);e=F(t(p(f,e),0),k);f=F(t(C(l.toPixels(p(d.value,m.max),!0)),0),k);v&& -(e=f=l.toPixels(m.max));r=Math.abs(e-f);s=F(e,f);w=t(e,f);if(l.isXAxis){if(h={x:o?w:s,y:0,width:r,height:k},!A)h.x=b.plotHeight-h.x}else if(h={x:0,y:o?w:s,width:k,height:r},A)h.y=b.plotWidth-h.y;o&&c.isVML&&(h=l.isXAxis?{x:0,y:n?s:w,height:h.width,width:b.chartWidth}:{x:h.y-b.plotLeft-b.spacingBox.x,y:0,width:h.height,height:b.chartHeight});g[q]?g[q].animate(h):(g[q]=c.clipRect(h),i&&a["zoneGraph"+q].clip(g[q]),j&&a["zoneArea"+q].clip(g[q]));v=d.value>m.max}),this.clips=g},invertGroups:function(){function a(){var a= -{width:b.yAxis.len,height:b.xAxis.len};q(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;if(b.xAxis)N(c,"resize",a),N(b,"destroy",function(){Y(c,"resize",a)}),a(),b.invertGroups=a},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;g&&(this[a]=f=this.chart.renderer.g(b).attr({zIndex:d||0.1}).add(e),f.addClass("highcharts-series-"+this.index));f.attr({visibility:c})[g?"attr":"animate"](this.getPlotBox());return f},getPlotBox:function(){var a=this.chart,b=this.xAxis, -c=this.yAxis;if(a.inverted)b=c,c=this.xAxis;return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,d=a.options,e=!!a.animate&&b.renderer.isSVG&&Wa(d.animation).duration,f=a.visible?"inherit":"hidden",g=d.zIndex,h=a.hasRendered,i=b.seriesGroup;c=a.plotGroup("group","series",f,g,i);a.markerGroup=a.plotGroup("markerGroup","markers",f,g,i);e&&a.animate(!0);a.getAttribs();c.inverted=a.isCartesian?b.inverted:!1;a.drawGraph&&(a.drawGraph(), -a.applyZones());q(a.points,function(a){a.redraw&&a.redraw()});a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&a.options.enableMouseTracking!==!1&&a.drawTracker();b.inverted&&a.invertGroups();d.clip!==!1&&!a.sharedClipKey&&!h&&c.clip(b.clipRect);e&&a.animate();if(!h)a.animationTimeout=Sa(function(){a.afterAnimate()},e);a.isDirty=a.isDirtyData=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis; -c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:p(d&&d.left,a.plotLeft),translateY:p(e&&e.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdDimensions:1,kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,d=this.yAxis,e=this.chart.inverted;return this.searchKDTree({clientX:e?c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:e?d.len-a.chartX+d.pos:a.chartY-d.pos},b)},buildKDTree:function(){function a(c,e,f){var g,h;if(h=c&& -c.length)return g=b.kdAxisArray[e%f],c.sort(function(a,b){return a[g]-b[g]}),h=Math.floor(h/2),{point:c[h],left:a(c.slice(0,h),e+1,f),right:a(c.slice(h+1),e+1,f)}}var b=this,c=b.kdDimensions;delete b.kdTree;Sa(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c)},b.options.kdNow?0:1)},searchKDTree:function(a,b){function c(a,b,j,k){var l=b.point,m=d.kdAxisArray[j%k],n,o,p=l;o=s(a[e])&&s(l[e])?Math.pow(a[e]-l[e],2):null;n=s(a[f])&&s(l[f])?Math.pow(a[f]-l[f],2):null;n=(o||0)+(n||0);l.dist= -s(n)?Math.sqrt(n):Number.MAX_VALUE;l.distX=s(o)?Math.sqrt(o):Number.MAX_VALUE;m=a[m]-l[m];n=m<0?"left":"right";o=m<0?"right":"left";b[n]&&(n=c(a,b[n],j+1,k),p=n[g]0&&this.singleStacks===!1&&(r.points[x][0]=r.points[this.index+","+v+",0"][0])}e==="percent"?(q=q?i:j,k&&m[q]&&m[q][v]?(q=m[q][v],r.total=q.total=t(q.total,r.total)+Q(u)||0):r.total=$(r.total+(Q(u)||0))):r.total=$(r.total+(u||0));r.cum=p(r.cum,g)+(u||0);if(u!==null)r.points[x].push(r.cum),c[w]=r.cum}if(e==="percent")l.usePercentage=!0;this.stackedYData= -c;l.oldStacks={}}};R.prototype.setPercentStacks=function(){var a=this,b=a.stackKey,c=a.yAxis.stacks,d=a.processedXData,e;q([b,"-"+b],function(b){var f;for(var g=d.length,h,i;g--;)if(h=d[g],e=a.getStackIndicator(e,h,a.index),f=(i=c[b]&&c[b][h])&&i.points[e.key],h=f)i=i.total?100/i.total:0,h[0]=$(h[0]*i),h[1]=$(h[1]*i),a.stackedYData[g]=h[1]})};R.prototype.getStackIndicator=function(a,b,c){!s(a)||a.x!==b?a={x:b,index:0}:a.index++;a.key=[c,b,a.index].join(",");return a};x(jb.prototype,{addSeries:function(a, -b,c){var d,e=this;a&&(b=p(b,!0),H(e,"addSeries",{options:a},function(){d=e.initSeries(a);e.isDirtyLegend=!0;e.linkSeries();b&&e.redraw(c)}));return d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options,a=E(a,{index:this[e].length,isX:b});new ia(this,a);f[e]=ua(f[e]||{});f[e].push(a);p(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this,c=b.options,d=b.loadingDiv,e=c.loading,f=function(){d&&M(d,{left:b.plotLeft+"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+ -"px"})};if(!d)b.loadingDiv=d=ca(Pa,{className:"highcharts-loading"},x(e.style,{zIndex:10,display:"none"}),b.container),b.loadingSpan=ca("span",null,e.labelStyle,d),N(b,"redraw",f);b.loadingSpan.innerHTML=a||c.lang.loading;if(!b.loadingShown)M(d,{opacity:0,display:""}),Za(d,{opacity:e.style.opacity},{duration:e.showDuration||0}),b.loadingShown=!0;f()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&Za(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){M(b,{display:"none"})}}); -this.loadingShown=!1}});x(Ma.prototype,{update:function(a,b,c,d){function e(){f.applyOptions(a);if(f.y===null&&h)f.graphic=h.destroy();if(ba(a,!0))f.redraw=function(){if(h&&h.element&&a&&a.marker&&a.marker.symbol)f.graphic=h.destroy();if(a&&a.dataLabels&&f.dataLabel)f.dataLabel=f.dataLabel.destroy();f.redraw=null};i=f.index;g.updateParallelArrays(f,i);k.data[i]=ba(k.data[i],!0)?f.options:a;g.isDirty=g.isDirtyData=!0;if(!g.fixedBox&&g.hasCartesianSeries)j.isDirtyBox=!0;if(k.legendType==="point")j.isDirtyLegend= -!0;b&&j.redraw(c)}var f=this,g=f.series,h=f.graphic,i,j=g.chart,k=g.options,b=p(b,!0);d===!1?e():f.firePointEvent("update",{options:a},e)},remove:function(a,b){this.series.removePoint(pa(this,this.series.data),a,b)}});x(R.prototype,{addPoint:function(a,b,c,d){var e=this.options,f=this.data,g=this.chart,h=this.xAxis&&this.xAxis.names,i=e.data,j,k,l=this.xData,m,n,b=p(b,!0);j={series:this};this.pointClass.prototype.applyOptions.apply(j,[a]);n=j.x;m=l.length;if(this.requireSorting&&nn;)m--;this.updateParallelArrays(j,"splice",m,0,0);this.updateParallelArrays(j,m);if(h&&j.name)h[n]=j.name;i.splice(m,0,a);k&&(this.data.splice(m,0,null),this.processData());e.legendType==="point"&&this.generatePoints();c&&(f[0]&&f[0].remove?f[0].remove(!1):(f.shift(),this.updateParallelArrays(j,"shift"),i.shift()));this.isDirtyData=this.isDirty=!0;b&&(this.getAttribs(),g.redraw(d))},removePoint:function(a,b,c){var d=this,e=d.data,f=e[a],g=d.points,h=d.chart,i=function(){g&&g.length===e.length&& -g.splice(a,1);e.splice(a,1);d.options.data.splice(a,1);d.updateParallelArrays(f||{series:d},"splice",a,1);f&&f.destroy();d.isDirty=!0;d.isDirtyData=!0;b&&h.redraw()};cb(c,h);b=p(b,!0);f?f.firePointEvent("remove",null,i):i()},remove:function(a,b,c){function d(){e.destroy();f.isDirtyLegend=f.isDirtyBox=!0;f.linkSeries();p(a,!0)&&f.redraw(b)}var e=this,f=e.chart;c!==!1?H(e,"remove",null,d):d()},update:function(a,b){var c=this,d=this.chart,e=this.userOptions,f=this.type,g=L[f].prototype,h=["group","markerGroup", -"dataLabelsGroup"],i;if(a.type&&a.type!==f||a.zIndex!==void 0)h.length=0;q(h,function(a){h[a]=c[a];delete c[a]});a=E(e,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1,null,!1);for(i in g)this[i]=z;x(this,L[a.type||f].prototype);q(h,function(a){c[a]=h[a]});this.init(d,a);d.linkSeries();p(b,!0)&&d.redraw(!1)}});x(ia.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=E(this.userOptions,a);this.destroy(!0);this.init(c, -x(a,{events:z}));c.isDirtyBox=!0;p(b,!0)&&c.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,d=this.series,e=d.length;e--;)d[e]&&d[e].remove(!1);ra(b.axes,this);ra(b[c],this);b.options[c].splice(this.options.index,1);q(b[c],function(a,b){a.options.index=b});this.destroy();b.isDirtyBox=!0;p(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}});var xa=sa(R);L.line=xa;ga.area=E(ha,{softThreshold:!1,threshold:0}); -var qa=sa(R,{type:"area",singleStacks:!1,getStackPoints:function(){var a=[],b=[],c=this.xAxis,d=this.yAxis,e=d.stacks[this.stackKey],f={},g=this.points,h=this.index,i=d.series,j=i.length,k,l=p(d.options.reversedStacks,!0)?1:-1,m,n;if(this.options.stacking){for(m=0;m=0&&m=0&&ma&&h>e?(h=t(a,e),j=2*e-h):hc&&j>e?(j=t(c,e),h=2*e-j):j0.5;b=Math.round(b)+f;d-=b;g&&d&&(b-=1,d+=1);return{x:a,y:b,width:c,height:d}},translate:function(){var a=this,b=a.chart,c=a.options,d=a.borderWidth=p(c.borderWidth,a.closestPointRange*a.xAxis.transA<2?0:1),e=a.yAxis,f=a.translatedThreshold=e.getThreshold(c.threshold),g=p(c.minPointLength,5),h=a.getColumnMetrics(),i=h.width, -j=a.barW=t(i,1+2*d),k=a.pointXOffset=h.offset;b.inverted&&(f-=0.5);c.pointPadding&&(j=va(j));R.prototype.translate.apply(a);q(a.points,function(c){var d=F(p(c.yBottom,f),9E4),h=999+Q(d),h=F(t(-h,c.plotY),e.len+h),o=c.plotX+k,q=j,r=F(h,d),s,w=t(h,d)-r;Q(w)g?d-g:f-(s?g:0));c.barX=o;c.pointWidth=i;c.tooltipPos=b.inverted?[e.len+e.pos-b.plotLeft-h,a.xAxis.len-o-q/2,w]:[o+q/2,h+e.pos-b.plotTop,w];c.shapeType="rect";c.shapeArgs=a.crispCol.apply(a, -c.isNull?[c.plotX,e.len/2,0,0]:[o,r,q,w])})},getSymbol:Ca,drawLegendSymbol:P.drawRectangle,drawGraph:Ca,drawPoints:function(){var a=this,b=this.chart,c=a.options,d=b.renderer,e=c.animationLimit||250,f,g;q(a.points,function(h){var i=h.graphic,j;if(I(h.plotY)&&h.y!==null)f=h.shapeArgs,j=s(a.borderWidth)?{"stroke-width":a.borderWidth}:{},g=h.pointAttr[h.selected?"select":""]||a.pointAttr[""],i?(Ka(i),i.attr(j).attr(g)[b.pointCount\u25cf {series.name}
',pointFormat:"x: {point.x}
y: {point.y}
"}});qa=sa(R,{type:"scatter",sorted:!1,requireSorting:!1,noSharedTooltip:!0, -trackerGroups:["group","markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,kdDimensions:2,drawGraph:function(){this.options.lineWidth&&R.prototype.drawGraph.call(this)}});L.scatter=qa;ga.pie=E(ha,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.y===null?void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,states:{hover:{brightness:0.1, -shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}});ha={type:"pie",isCartesian:!1,pointClass:sa(Ma,{init:function(){Ma.prototype.init.apply(this,arguments);var a=this,b;a.name=p(a.name,"Slice");b=function(b){a.slice(b.type==="select")};N(a,"select",b);N(a,"unselect",b);return a},setVisible:function(a,b){var c=this,d=c.series,e=d.chart,f=d.options.ignoreHiddenPoint,b=p(b,f);if(a!==c.visible){c.visible=c.options.visible=a=a===z?!c.visible:a;d.options.data[pa(c,d.data)]=c.options;q(["graphic", -"dataLabel","connector","shadowGroup"],function(b){if(c[b])c[b][a?"show":"hide"](!0)});c.legendItem&&e.legend.colorizeItem(c,a);!a&&c.state==="hover"&&c.setState("");if(f)d.isDirty=!0;b&&e.redraw()}},slice:function(a,b,c){var d=this.series;cb(c,d.chart);p(b,!0);this.sliced=this.options.sliced=a=s(a)?a:!this.sliced;d.options.data[pa(this,d.data)]=this.options;a=a?this.slicedTranslation:{translateX:0,translateY:0};this.graphic.animate(a);this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var b= -this.shapeArgs,c=this.series.chart;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.plotLeft+b.x,c.plotTop+b.y,b.r+a,b.r+a,{innerR:this.shapeArgs.r,start:b.start,end:b.end})}}),requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},animate:function(a){var b=this,c=b.points,d=b.startAngleRad;if(!a)q(c,function(a){var c=a.graphic,g=a.shapeArgs; -c&&(c.attr({r:a.startR||b.center[3]/2,start:d,end:d}),c.animate({r:g.r,start:g.start,end:g.end},b.options.animation))}),b.animate=null},updateTotals:function(){var a,b=0,c=this.points,d=c.length,e,f=this.options.ignoreHiddenPoint;for(a=0;a0&&(e.visible||!f)?e.y/b*100:0,e.total=b},generatePoints:function(){R.prototype.generatePoints.call(this);this.updateTotals()},translate:function(a){this.generatePoints(); -var b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,f,g,h,i=c.startAngle||0,j=this.startAngleRad=ta/180*(i-90),i=(this.endAngleRad=ta/180*(p(c.endAngle,i+360)-90))-j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,m,n=k.length,o;if(!a)this.center=a=this.getCenter();this.getX=function(b,c){h=Z.asin(F((b-a[1])/(a[2]/2+l),1));return a[0]+(c?-1:1)*W(h)*(a[2]/2+l)};for(m=0;m1.5*ta?h-=2*ta:h<-ta/2&&(h+=2*ta);o.slicedTranslation={translateX:C(W(h)*d),translateY:C(da(h)*d)};f=W(h)*a[2]/2;g=da(h)*a[2]/2;o.tooltipPos=[a[0]+f*0.7,a[1]+g*0.7];o.half=h<-ta/2||h>ta/2?1:0;o.angle=h;e=F(e,l/2);o.labelPos=[a[0]+f+W(h)*l,a[1]+g+da(h)*l,a[0]+f+W(h)*e,a[1]+g+da(h)*e,a[0]+f,a[1]+g,l<0?"center":o.half?"right":"left",h]}},drawGraph:null,drawPoints:function(){var a=this,b=a.chart.renderer,c,d,e=a.options.shadow,f, -g,h,i;if(e&&!a.shadowGroup)a.shadowGroup=b.g("shadow").add(a.group);q(a.points,function(j){if(j.y!==null){d=j.graphic;h=j.shapeArgs;f=j.shadowGroup;g=j.pointAttr[j.selected?"select":""];if(!g.stroke)g.stroke=g.fill;if(e&&!f)f=j.shadowGroup=b.g("shadow").add(a.shadowGroup);c=j.sliced?j.slicedTranslation:{translateX:0,translateY:0};f&&f.attr(c);if(d)d.setRadialReference(a.center).attr(g).animate(x(h,c));else{i={"stroke-linejoin":"round"};if(!j.visible)i.visibility="hidden";j.graphic=d=b[j.shapeType](h).setRadialReference(a.center).attr(g).attr(i).attr(c).add(a.group).shadow(e, -f)}}})},searchPoint:Ca,sortByAngle:function(a,b){a.sort(function(a,d){return a.angle!==void 0&&(d.angle-a.angle)*b})},drawLegendSymbol:P.drawRectangle,getCenter:Eb.getCenter,getSymbol:Ca};ha=sa(R,ha);L.pie=ha;R.prototype.drawDataLabels=function(){var a=this,b=a.options,c=b.cursor,d=b.dataLabels,e=a.points,f,g,h=a.hasRendered||0,i,j,k=p(d.defer,!0),l=a.chart.renderer;if(d.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(d),j=a.plotGroup("dataLabelsGroup","data-labels",k&&!h?"hidden": -"visible",d.zIndex||6),k&&(j.attr({opacity:+h}),h||N(a,"afterAnimate",function(){a.visible&&j.show(!0);j[b.animation?"animate":"attr"]({opacity:1},{duration:200})})),g=d,q(e,function(e){var h,k=e.dataLabel,q,r,t=e.connector,w=!0,v,u={};f=e.dlOptions||e.options&&e.options.dataLabels;h=p(f&&f.enabled,g.enabled)&&e.y!==null;if(k&&!h)e.dataLabel=k.destroy();else if(h){d=E(g,f);v=d.style;h=d.rotation;q=e.getLabelConfig();i=d.format?Na(d.format,q):d.formatter.call(q,d);v.color=p(d.color,v.color,a.color, -"black");if(k)if(s(i))k.attr({text:i}),w=!1;else{if(e.dataLabel=k=k.destroy(),t)e.connector=t.destroy()}else if(s(i)){k={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:h,padding:d.padding,zIndex:1};if(v.color==="contrast")u.color=d.inside||d.distance<0||b.stacking?l.getContrast(e.color||a.color):"#000000";if(c)u.cursor=c;for(r in k)k[r]===z&&delete k[r];k=e.dataLabel=l[h?"text":"label"](i,0,-9999,d.shape,null,null,d.useHTML).attr(k).css(x(v,u)).add(j).shadow(d.shadow)}k&& -a.alignDataLabel(e,k,d,null,w)}})};R.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=p(a.plotX,-9999),i=p(a.plotY,-9999),j=b.getBBox(),k=f.renderer.fontMetrics(c.style.fontSize).b,l=c.rotation,m=c.align,n=this.visible&&(a.series.forceDL||f.isInsidePlot(h,C(i),g)||d&&f.isInsidePlot(h,g?d.x+1:d.y+d.height-1,g)),o=p(c.overflow,"justify")==="justify";if(n)d=x({x:g?f.plotWidth-i:h,y:C(g?f.plotHeight-h:i),width:0,height:0},d),x(c,{width:j.width,height:j.height}),l?(o=!1,g=f.renderer.rotCorr(k, -l),g={x:d.x+c.x+d.width/2+g.x,y:d.y+c.y+{top:0,middle:0.5,bottom:1}[c.verticalAlign]*d.height},b[e?"attr":"animate"](g).attr({align:m}),h=(l+720)%360,h=h>180&&h<360,m==="left"?g.y-=h?j.height:0:m==="center"?(g.x-=j.width/2,g.y-=j.height/2):m==="right"&&(g.x-=j.width,g.y-=h?0:j.height)):(b.align(c,null,d),g=b.alignAttr),o?this.justifyDataLabel(b,c,g,j,d,e):p(c.crop,!0)&&(n=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)),c.shape&&!l&&b.attr({anchorX:a.plotX,anchorY:a.plotY});if(!n)Ka(b), -b.attr({y:-9999}),b.placed=!1};R.prototype.justifyDataLabel=function(a,b,c,d,e,f){var g=this.chart,h=b.align,i=b.verticalAlign,j,k,l=a.box?0:a.padding||0;j=c.x+l;if(j<0)h==="right"?b.align="left":b.x=-j,k=!0;j=c.x+d.width-l;if(j>g.plotWidth)h==="left"?b.align="right":b.x=g.plotWidth-j,k=!0;j=c.y+l;if(j<0)i==="bottom"?b.verticalAlign="top":b.y=-j,k=!0;j=c.y+d.height-l;if(j>g.plotHeight)i==="top"?b.verticalAlign="bottom":b.y=g.plotHeight-j,k=!0;if(k)a.placed=!f,a.align(b,null,e)};if(L.pie)L.pie.prototype.drawDataLabels= -function(){var a=this,b=a.data,c,d=a.chart,e=a.options.dataLabels,f=p(e.connectorPadding,10),g=p(e.connectorWidth,1),h=d.plotWidth,i=d.plotHeight,j,k,l=p(e.softConnector,!0),m=e.distance,n=a.center,o=n[2]/2,s=n[1],r=m>0,u,w,v,x=[[],[]],z,y,D,E,B,G=[0,0,0,0],M=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){R.prototype.drawDataLabels.apply(a);q(b,function(a){if(a.dataLabel&&a.visible)x[a.half].push(a),a.dataLabel._pos=null});for(E=2;E--;){var H=[],N=[],I=x[E],L=I.length, -J;if(L){a.sortByAngle(I,E-0.5);for(B=b=0;!b&&I[B];)b=I[B]&&I[B].dataLabel&&(I[B].dataLabel.getBBox().height||21),B++;if(m>0){w=F(s+o+m,d.plotHeight);for(B=t(0,s-o-m);B<=w;B+=b)H.push(B);w=H.length;if(L>w){c=[].concat(I);c.sort(M);for(B=L;B--;)c[B].rank=B;for(B=L;B--;)I[B].rank>=w&&I.splice(B,1);L=I.length}for(B=0;B0){if(w=N.pop(),J=w.i,y=w.y,c>y&&H[J+1]!==null||ch-f&&(G[1]=t(C(z+w-h+f),G[1])),y- -b/2<0?G[0]=t(C(-y+b/2),G[0]):y+b/2>i&&(G[2]=t(C(y+b/2-i),G[2]))}}}if(Ha(G)===0||this.verifyDataLabelOverflow(G))this.placeDataLabels(),r&&g&&q(this.points,function(b){j=b.connector;v=b.labelPos;if((u=b.dataLabel)&&u._pos&&b.visible)D=u._attr.visibility,z=u.connX,y=u.connY,k=l?[X,z+(v[6]==="left"?5:-5),y,"C",z,y,2*v[2]-v[4],2*v[3]-v[5],v[2],v[3],S,v[4],v[5]]:[X,z+(v[6]==="left"?5:-5),y,S,v[2],v[3],S,v[4],v[5]],j?(j.animate({d:k}),j.attr("visibility",D)):b.connector=j=a.chart.renderer.path(k).attr({"stroke-width":g, -stroke:e.connectorColor||b.color||"#606060",visibility:D}).add(a.dataLabelsGroup);else if(j)b.connector=j.destroy()})}},L.pie.prototype.placeDataLabels=function(){q(this.points,function(a){var b=a.dataLabel;if(b&&a.visible)(a=b._pos)?(b.attr(b._attr),b[b.moved?"animate":"attr"](a),b.moved=!0):b&&b.attr({y:-9999})})},L.pie.prototype.alignDataLabel=Ca,L.pie.prototype.verifyDataLabelOverflow=function(a){var b=this.center,c=this.options,d=c.center,e=c.minSize||80,f=e,g;d[0]!==null?f=t(b[2]-t(a[1],a[3]), -e):(f=t(b[2]-a[1]-a[3],e),b[0]+=(a[3]-a[1])/2);d[1]!==null?f=t(F(f,b[2]-t(a[0],a[2])),e):(f=t(F(f,b[2]-a[0]-a[2]),e),b[1]+=(a[0]-a[2])/2);fp(this.translatedThreshold, -g.yAxis.len)),j=p(c.inside,!!this.options.stacking);if(h){d=E(h);if(d.y<0)d.height+=d.y,d.y=0;h=d.y+d.height-g.yAxis.len;h>0&&(d.height-=h);f&&(d={x:g.yAxis.len-d.y-d.height,y:g.xAxis.len-d.x-d.width,width:d.height,height:d.width});if(!j)f?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0)}c.align=p(c.align,!f||j?"center":i?"right":"left");c.verticalAlign=p(c.verticalAlign,f||j?"middle":i?"top":"bottom");R.prototype.alignDataLabel.call(this,a,b,c,d,e)};(function(a){var b=a.Chart,c=a.each, -d=a.pick,e=a.addEvent;b.prototype.callbacks.push(function(a){function b(){var e=[];c(a.series,function(a){var b=a.options.dataLabels,f=a.dataLabelCollections||["dataLabel"];(b.enabled||a._hasPointLabels)&&!b.allowOverlap&&a.visible&&c(f,function(b){c(a.points,function(a){if(a[b])a[b].labelrank=d(a.labelrank,a.shapeArgs&&a.shapeArgs.height),e.push(a[b])})})});a.hideOverlappingLabels(e)}b();e(a,"redraw",b)});b.prototype.hideOverlappingLabels=function(a){var b=a.length,d,e,j,k,l,m,n,o,p;for(e=0;el.x+n.translateX+(j.width-p)||m.x+o.translateX+(k.width-p)l.y+n.translateY+(j.height-p)||m.y+o.translateY+(k.height-p)h;if(b.series.length&&(i||l>F(k.dataMin,k.min))&&(!i||j - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/AFFICH_m.xcos b/history/blocks_xcos/AFFICH_m.xcos deleted file mode 100644 index f74c3ce..0000000 --- a/history/blocks_xcos/AFFICH_m.xcos +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ANDBLK.xcos b/history/blocks_xcos/ANDBLK.xcos deleted file mode 100644 index 9afb4ec..0000000 --- a/history/blocks_xcos/ANDBLK.xcos +++ /dev/null @@ -1,1355 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ANDLOG_f.xcos b/history/blocks_xcos/ANDLOG_f.xcos deleted file mode 100644 index 5d1829a..0000000 --- a/history/blocks_xcos/ANDLOG_f.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/AUTOMAT.xcos b/history/blocks_xcos/AUTOMAT.xcos deleted file mode 100644 index 1f9b45c..0000000 --- a/history/blocks_xcos/AUTOMAT.xcos +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BACKLASH.xcos b/history/blocks_xcos/BACKLASH.xcos deleted file mode 100644 index 9ae1e74..0000000 --- a/history/blocks_xcos/BACKLASH.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BARXY.xcos b/history/blocks_xcos/BARXY.xcos deleted file mode 100644 index 8c6812f..0000000 --- a/history/blocks_xcos/BARXY.xcos +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BIGSOM_f.xcos b/history/blocks_xcos/BIGSOM_f.xcos deleted file mode 100644 index 714a7c2..0000000 --- a/history/blocks_xcos/BIGSOM_f.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BITCLEAR.xcos b/history/blocks_xcos/BITCLEAR.xcos deleted file mode 100644 index fec7a41..0000000 --- a/history/blocks_xcos/BITCLEAR.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BITSET.xcos b/history/blocks_xcos/BITSET.xcos deleted file mode 100644 index 77867f1..0000000 --- a/history/blocks_xcos/BITSET.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BOUNCE.xcos b/history/blocks_xcos/BOUNCE.xcos deleted file mode 100644 index 714ed25..0000000 --- a/history/blocks_xcos/BOUNCE.xcos +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BOUNCEXY.xcos b/history/blocks_xcos/BOUNCEXY.xcos deleted file mode 100644 index 15ee007..0000000 --- a/history/blocks_xcos/BOUNCEXY.xcos +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/BPLATFORM.xcos b/history/blocks_xcos/BPLATFORM.xcos deleted file mode 100644 index b690031..0000000 --- a/history/blocks_xcos/BPLATFORM.xcos +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Bache.xcos b/history/blocks_xcos/Bache.xcos deleted file mode 100644 index ccfc2ac..0000000 --- a/history/blocks_xcos/Bache.xcos +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CANIMXY.xcos b/history/blocks_xcos/CANIMXY.xcos deleted file mode 100644 index d182992..0000000 --- a/history/blocks_xcos/CANIMXY.xcos +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CANIMXY3D.xcos b/history/blocks_xcos/CANIMXY3D.xcos deleted file mode 100644 index 7acd1bb..0000000 --- a/history/blocks_xcos/CANIMXY3D.xcos +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CBLOCK.xcos b/history/blocks_xcos/CBLOCK.xcos deleted file mode 100644 index bb2f3d1..0000000 --- a/history/blocks_xcos/CBLOCK.xcos +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CBLOCK4.xcos b/history/blocks_xcos/CBLOCK4.xcos deleted file mode 100644 index c6a6805..0000000 --- a/history/blocks_xcos/CBLOCK4.xcos +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CCS.xcos b/history/blocks_xcos/CCS.xcos deleted file mode 100644 index 756db4e..0000000 --- a/history/blocks_xcos/CCS.xcos +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CEVENTSCOPE.xcos b/history/blocks_xcos/CEVENTSCOPE.xcos deleted file mode 100644 index 00a65b7..0000000 --- a/history/blocks_xcos/CEVENTSCOPE.xcos +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CFSCOPE.xcos b/history/blocks_xcos/CFSCOPE.xcos deleted file mode 100644 index 48aebe4..0000000 --- a/history/blocks_xcos/CFSCOPE.xcos +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLINDUMMY_f.xcos b/history/blocks_xcos/CLINDUMMY_f.xcos deleted file mode 100644 index 276e9d6..0000000 --- a/history/blocks_xcos/CLINDUMMY_f.xcos +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLKFROM.xcos b/history/blocks_xcos/CLKFROM.xcos deleted file mode 100644 index 191d104..0000000 --- a/history/blocks_xcos/CLKFROM.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/history/blocks_xcos/CLKGOTO.xcos b/history/blocks_xcos/CLKGOTO.xcos deleted file mode 100644 index 2e9b622..0000000 --- a/history/blocks_xcos/CLKGOTO.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/history/blocks_xcos/CLKGotoTagVisibility.xcos b/history/blocks_xcos/CLKGotoTagVisibility.xcos deleted file mode 100644 index be251d1..0000000 --- a/history/blocks_xcos/CLKGotoTagVisibility.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLKINV_f.xcos b/history/blocks_xcos/CLKINV_f.xcos deleted file mode 100644 index 27db6b6..0000000 --- a/history/blocks_xcos/CLKINV_f.xcos +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLKOUTV_f.xcos b/history/blocks_xcos/CLKOUTV_f.xcos deleted file mode 100644 index 0d1666c..0000000 --- a/history/blocks_xcos/CLKOUTV_f.xcos +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLKSOMV_f.xcos b/history/blocks_xcos/CLKSOMV_f.xcos deleted file mode 100644 index 4bdffa8..0000000 --- a/history/blocks_xcos/CLKSOMV_f.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLOCK_c.xcos b/history/blocks_xcos/CLOCK_c.xcos deleted file mode 100644 index aebd6c6..0000000 --- a/history/blocks_xcos/CLOCK_c.xcos +++ /dev/null @@ -1,738 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLR.xcos b/history/blocks_xcos/CLR.xcos deleted file mode 100644 index b28e0a5..0000000 --- a/history/blocks_xcos/CLR.xcos +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CLSS.xcos b/history/blocks_xcos/CLSS.xcos deleted file mode 100644 index b606d08..0000000 --- a/history/blocks_xcos/CLSS.xcos +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CMAT3D.xcos b/history/blocks_xcos/CMAT3D.xcos deleted file mode 100644 index 15fb657..0000000 --- a/history/blocks_xcos/CMAT3D.xcos +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CMATVIEW.xcos b/history/blocks_xcos/CMATVIEW.xcos deleted file mode 100644 index 5fbf0f1..0000000 --- a/history/blocks_xcos/CMATVIEW.xcos +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CMSCOPE.xcos b/history/blocks_xcos/CMSCOPE.xcos deleted file mode 100644 index f9d6eba..0000000 --- a/history/blocks_xcos/CMSCOPE.xcos +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONST.xcos b/history/blocks_xcos/CONST.xcos deleted file mode 100644 index c014c23..0000000 --- a/history/blocks_xcos/CONST.xcos +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONSTRAINT2_c.xcos b/history/blocks_xcos/CONSTRAINT2_c.xcos deleted file mode 100644 index 9714445..0000000 --- a/history/blocks_xcos/CONSTRAINT2_c.xcos +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONSTRAINT_c.xcos b/history/blocks_xcos/CONSTRAINT_c.xcos deleted file mode 100644 index 20e4158..0000000 --- a/history/blocks_xcos/CONSTRAINT_c.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONST_f.xcos b/history/blocks_xcos/CONST_f.xcos deleted file mode 100644 index 1d98597..0000000 --- a/history/blocks_xcos/CONST_f.xcos +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONST_m.xcos b/history/blocks_xcos/CONST_m.xcos deleted file mode 100644 index 5218346..0000000 --- a/history/blocks_xcos/CONST_m.xcos +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CONVERT.xcos b/history/blocks_xcos/CONVERT.xcos deleted file mode 100644 index 1700ce5..0000000 --- a/history/blocks_xcos/CONVERT.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/COSBLK_f.xcos b/history/blocks_xcos/COSBLK_f.xcos deleted file mode 100644 index 89a5b00..0000000 --- a/history/blocks_xcos/COSBLK_f.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CSCOPE.xcos b/history/blocks_xcos/CSCOPE.xcos deleted file mode 100644 index 92ef748..0000000 --- a/history/blocks_xcos/CSCOPE.xcos +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CSCOPXY.xcos b/history/blocks_xcos/CSCOPXY.xcos deleted file mode 100644 index faf9c2c..0000000 --- a/history/blocks_xcos/CSCOPXY.xcos +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CSCOPXY3D.xcos b/history/blocks_xcos/CSCOPXY3D.xcos deleted file mode 100644 index d01bc08..0000000 --- a/history/blocks_xcos/CSCOPXY3D.xcos +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CUMSUM.xcos b/history/blocks_xcos/CUMSUM.xcos deleted file mode 100644 index 8bbada9..0000000 --- a/history/blocks_xcos/CUMSUM.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CURV_f.xcos b/history/blocks_xcos/CURV_f.xcos deleted file mode 100644 index ecd0e3c..0000000 --- a/history/blocks_xcos/CURV_f.xcos +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CVS.xcos b/history/blocks_xcos/CVS.xcos deleted file mode 100644 index 3a5275d..0000000 --- a/history/blocks_xcos/CVS.xcos +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Capacitor.xcos b/history/blocks_xcos/Capacitor.xcos deleted file mode 100644 index c9d5d23..0000000 --- a/history/blocks_xcos/Capacitor.xcos +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ConstantVoltage.xcos b/history/blocks_xcos/ConstantVoltage.xcos deleted file mode 100644 index 0538708..0000000 --- a/history/blocks_xcos/ConstantVoltage.xcos +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Counter.xcos b/history/blocks_xcos/Counter.xcos deleted file mode 100644 index 020a6d9..0000000 --- a/history/blocks_xcos/Counter.xcos +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/CurrentSensor.xcos b/history/blocks_xcos/CurrentSensor.xcos deleted file mode 100644 index 990209b..0000000 --- a/history/blocks_xcos/CurrentSensor.xcos +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DEADBAND.xcos b/history/blocks_xcos/DEADBAND.xcos deleted file mode 100644 index c5ece68..0000000 --- a/history/blocks_xcos/DEADBAND.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DEBUG.xcos b/history/blocks_xcos/DEBUG.xcos deleted file mode 100644 index 980eb09..0000000 --- a/history/blocks_xcos/DEBUG.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DELAYV_f.xcos b/history/blocks_xcos/DELAYV_f.xcos deleted file mode 100644 index 33a51bf..0000000 --- a/history/blocks_xcos/DELAYV_f.xcos +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DELAY_f.xcos b/history/blocks_xcos/DELAY_f.xcos deleted file mode 100644 index dd2a33f..0000000 --- a/history/blocks_xcos/DELAY_f.xcos +++ /dev/null @@ -1,1182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DEMUX.xcos b/history/blocks_xcos/DEMUX.xcos deleted file mode 100644 index 5afccae..0000000 --- a/history/blocks_xcos/DEMUX.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DEMUX_f.xcos b/history/blocks_xcos/DEMUX_f.xcos deleted file mode 100644 index 002f17f..0000000 --- a/history/blocks_xcos/DEMUX_f.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DERIV.xcos b/history/blocks_xcos/DERIV.xcos deleted file mode 100644 index b00b937..0000000 --- a/history/blocks_xcos/DERIV.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DFLIPFLOP.xcos b/history/blocks_xcos/DFLIPFLOP.xcos deleted file mode 100644 index 9bdd370..0000000 --- a/history/blocks_xcos/DFLIPFLOP.xcos +++ /dev/null @@ -1,7807 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DIFF_f.xcos b/history/blocks_xcos/DIFF_f.xcos deleted file mode 100644 index c8c6665..0000000 --- a/history/blocks_xcos/DIFF_f.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DLATCH.xcos b/history/blocks_xcos/DLATCH.xcos deleted file mode 100644 index 3bf0ae0..0000000 --- a/history/blocks_xcos/DLATCH.xcos +++ /dev/null @@ -1,2262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DLR.xcos b/history/blocks_xcos/DLR.xcos deleted file mode 100644 index fff2daf..0000000 --- a/history/blocks_xcos/DLR.xcos +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DLRADAPT_f.xcos b/history/blocks_xcos/DLRADAPT_f.xcos deleted file mode 100644 index e0f9379..0000000 --- a/history/blocks_xcos/DLRADAPT_f.xcos +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DLSS.xcos b/history/blocks_xcos/DLSS.xcos deleted file mode 100644 index 125fd5c..0000000 --- a/history/blocks_xcos/DLSS.xcos +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DOLLAR.xcos b/history/blocks_xcos/DOLLAR.xcos deleted file mode 100644 index 0b73e0b..0000000 --- a/history/blocks_xcos/DOLLAR.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DOLLAR_f.xcos b/history/blocks_xcos/DOLLAR_f.xcos deleted file mode 100644 index eb62713..0000000 --- a/history/blocks_xcos/DOLLAR_f.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/DOLLAR_m.xcos b/history/blocks_xcos/DOLLAR_m.xcos deleted file mode 100644 index caaea09..0000000 --- a/history/blocks_xcos/DOLLAR_m.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Diode.xcos b/history/blocks_xcos/Diode.xcos deleted file mode 100644 index aebd811..0000000 --- a/history/blocks_xcos/Diode.xcos +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EDGE_TRIGGER.xcos b/history/blocks_xcos/EDGE_TRIGGER.xcos deleted file mode 100644 index d62b775..0000000 --- a/history/blocks_xcos/EDGE_TRIGGER.xcos +++ /dev/null @@ -1,934 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ENDBLK.xcos b/history/blocks_xcos/ENDBLK.xcos deleted file mode 100644 index 4f2afa8..0000000 --- a/history/blocks_xcos/ENDBLK.xcos +++ /dev/null @@ -1,340 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/END_c.xcos b/history/blocks_xcos/END_c.xcos deleted file mode 100644 index b190241..0000000 --- a/history/blocks_xcos/END_c.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ESELECT_f.xcos b/history/blocks_xcos/ESELECT_f.xcos deleted file mode 100644 index 87a6b14..0000000 --- a/history/blocks_xcos/ESELECT_f.xcos +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EVTDLY_c.xcos b/history/blocks_xcos/EVTDLY_c.xcos deleted file mode 100644 index 5e1ce59..0000000 --- a/history/blocks_xcos/EVTDLY_c.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EVTGEN_f.xcos b/history/blocks_xcos/EVTGEN_f.xcos deleted file mode 100644 index 8392d4c..0000000 --- a/history/blocks_xcos/EVTGEN_f.xcos +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EVTVARDLY.xcos b/history/blocks_xcos/EVTVARDLY.xcos deleted file mode 100644 index 63f09fe..0000000 --- a/history/blocks_xcos/EVTVARDLY.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXPBLK_m.xcos b/history/blocks_xcos/EXPBLK_m.xcos deleted file mode 100644 index 134ea3d..0000000 --- a/history/blocks_xcos/EXPBLK_m.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXPRESSION.xcos b/history/blocks_xcos/EXPRESSION.xcos deleted file mode 100644 index cee3743..0000000 --- a/history/blocks_xcos/EXPRESSION.xcos +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXTRACT.xcos b/history/blocks_xcos/EXTRACT.xcos deleted file mode 100644 index 2527ce7..0000000 --- a/history/blocks_xcos/EXTRACT.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXTRACTBITS.xcos b/history/blocks_xcos/EXTRACTBITS.xcos deleted file mode 100644 index c8fdf4f..0000000 --- a/history/blocks_xcos/EXTRACTBITS.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXTRACTOR.xcos b/history/blocks_xcos/EXTRACTOR.xcos deleted file mode 100644 index e150a93..0000000 --- a/history/blocks_xcos/EXTRACTOR.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/EXTTRI.xcos b/history/blocks_xcos/EXTTRI.xcos deleted file mode 100644 index 70653ae..0000000 --- a/history/blocks_xcos/EXTTRI.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Extract_Activation.xcos b/history/blocks_xcos/Extract_Activation.xcos deleted file mode 100644 index 0923ef1..0000000 --- a/history/blocks_xcos/Extract_Activation.xcos +++ /dev/null @@ -1,950 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/FROM.xcos b/history/blocks_xcos/FROM.xcos deleted file mode 100644 index daff6fe..0000000 --- a/history/blocks_xcos/FROM.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/FROMMO.xcos b/history/blocks_xcos/FROMMO.xcos deleted file mode 100644 index 848d843..0000000 --- a/history/blocks_xcos/FROMMO.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/FROMWSB.xcos b/history/blocks_xcos/FROMWSB.xcos deleted file mode 100644 index f391969..0000000 --- a/history/blocks_xcos/FROMWSB.xcos +++ /dev/null @@ -1,571 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Flowmeter.xcos b/history/blocks_xcos/Flowmeter.xcos deleted file mode 100644 index a9973ff..0000000 --- a/history/blocks_xcos/Flowmeter.xcos +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GAINBLK.xcos b/history/blocks_xcos/GAINBLK.xcos deleted file mode 100644 index 43f921b..0000000 --- a/history/blocks_xcos/GAINBLK.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GAINBLK_f.xcos b/history/blocks_xcos/GAINBLK_f.xcos deleted file mode 100644 index c2817f8..0000000 --- a/history/blocks_xcos/GAINBLK_f.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GAIN_f.xcos b/history/blocks_xcos/GAIN_f.xcos deleted file mode 100644 index 046ee69..0000000 --- a/history/blocks_xcos/GAIN_f.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GENERAL_f.xcos b/history/blocks_xcos/GENERAL_f.xcos deleted file mode 100644 index 0221f32..0000000 --- a/history/blocks_xcos/GENERAL_f.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GENSIN_f.xcos b/history/blocks_xcos/GENSIN_f.xcos deleted file mode 100644 index b4ee5cb..0000000 --- a/history/blocks_xcos/GENSIN_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GENSQR_f.xcos b/history/blocks_xcos/GENSQR_f.xcos deleted file mode 100644 index 69ea76e..0000000 --- a/history/blocks_xcos/GENSQR_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GOTO.xcos b/history/blocks_xcos/GOTO.xcos deleted file mode 100644 index a8f787c..0000000 --- a/history/blocks_xcos/GOTO.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GOTOMO.xcos b/history/blocks_xcos/GOTOMO.xcos deleted file mode 100644 index c90c5f9..0000000 --- a/history/blocks_xcos/GOTOMO.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GotoTagVisibility.xcos b/history/blocks_xcos/GotoTagVisibility.xcos deleted file mode 100644 index d75ad16..0000000 --- a/history/blocks_xcos/GotoTagVisibility.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/GotoTagVisibilityMO.xcos b/history/blocks_xcos/GotoTagVisibilityMO.xcos deleted file mode 100644 index 6898ed6..0000000 --- a/history/blocks_xcos/GotoTagVisibilityMO.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Ground.xcos b/history/blocks_xcos/Ground.xcos deleted file mode 100644 index 1bc7586..0000000 --- a/history/blocks_xcos/Ground.xcos +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Gyrator.xcos b/history/blocks_xcos/Gyrator.xcos deleted file mode 100644 index 774909d..0000000 --- a/history/blocks_xcos/Gyrator.xcos +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/HALT_f.xcos b/history/blocks_xcos/HALT_f.xcos deleted file mode 100644 index 1452cff..0000000 --- a/history/blocks_xcos/HALT_f.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/HYSTHERESIS.xcos b/history/blocks_xcos/HYSTHERESIS.xcos deleted file mode 100644 index 8d30a89..0000000 --- a/history/blocks_xcos/HYSTHERESIS.xcos +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/IFTHEL_f.xcos b/history/blocks_xcos/IFTHEL_f.xcos deleted file mode 100644 index 894d211..0000000 --- a/history/blocks_xcos/IFTHEL_f.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INIMPL_f.xcos b/history/blocks_xcos/INIMPL_f.xcos deleted file mode 100644 index 9e560c1..0000000 --- a/history/blocks_xcos/INIMPL_f.xcos +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INTEGRAL_f.xcos b/history/blocks_xcos/INTEGRAL_f.xcos deleted file mode 100644 index 30bc24e..0000000 --- a/history/blocks_xcos/INTEGRAL_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INTEGRAL_m.xcos b/history/blocks_xcos/INTEGRAL_m.xcos deleted file mode 100644 index 7facf10..0000000 --- a/history/blocks_xcos/INTEGRAL_m.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INTMUL.xcos b/history/blocks_xcos/INTMUL.xcos deleted file mode 100644 index 0bff20e..0000000 --- a/history/blocks_xcos/INTMUL.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INTRP2BLK_f.xcos b/history/blocks_xcos/INTRP2BLK_f.xcos deleted file mode 100644 index f9242c2..0000000 --- a/history/blocks_xcos/INTRP2BLK_f.xcos +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INTRPLBLK_f.xcos b/history/blocks_xcos/INTRPLBLK_f.xcos deleted file mode 100644 index e7b1f49..0000000 --- a/history/blocks_xcos/INTRPLBLK_f.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/INVBLK.xcos b/history/blocks_xcos/INVBLK.xcos deleted file mode 100644 index fc95e77..0000000 --- a/history/blocks_xcos/INVBLK.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/IN_f.xcos b/history/blocks_xcos/IN_f.xcos deleted file mode 100644 index 8373d82..0000000 --- a/history/blocks_xcos/IN_f.xcos +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ISELECT_m.xcos b/history/blocks_xcos/ISELECT_m.xcos deleted file mode 100644 index 51aa0c8..0000000 --- a/history/blocks_xcos/ISELECT_m.xcos +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/IdealTransformer.xcos b/history/blocks_xcos/IdealTransformer.xcos deleted file mode 100644 index 01e17f1..0000000 --- a/history/blocks_xcos/IdealTransformer.xcos +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Inductor.xcos b/history/blocks_xcos/Inductor.xcos deleted file mode 100644 index 96a9d52..0000000 --- a/history/blocks_xcos/Inductor.xcos +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/JKFLIPFLOP.xcos b/history/blocks_xcos/JKFLIPFLOP.xcos deleted file mode 100644 index 54245ca..0000000 --- a/history/blocks_xcos/JKFLIPFLOP.xcos +++ /dev/null @@ -1,3446 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/LOGBLK_f.xcos b/history/blocks_xcos/LOGBLK_f.xcos deleted file mode 100644 index ef2c3d2..0000000 --- a/history/blocks_xcos/LOGBLK_f.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/LOGIC.xcos b/history/blocks_xcos/LOGIC.xcos deleted file mode 100644 index bc40ec5..0000000 --- a/history/blocks_xcos/LOGIC.xcos +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/LOGICAL_OP.xcos b/history/blocks_xcos/LOGICAL_OP.xcos deleted file mode 100644 index 76d9f8c..0000000 --- a/history/blocks_xcos/LOGICAL_OP.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/LOOKUP_f.xcos b/history/blocks_xcos/LOOKUP_f.xcos deleted file mode 100644 index 57aa5ad..0000000 --- a/history/blocks_xcos/LOOKUP_f.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATBKSL.xcos b/history/blocks_xcos/MATBKSL.xcos deleted file mode 100644 index b081c81..0000000 --- a/history/blocks_xcos/MATBKSL.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATCATH.xcos b/history/blocks_xcos/MATCATH.xcos deleted file mode 100644 index 0cf49ef..0000000 --- a/history/blocks_xcos/MATCATH.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATCATV.xcos b/history/blocks_xcos/MATCATV.xcos deleted file mode 100644 index 8e0a2ee..0000000 --- a/history/blocks_xcos/MATCATV.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATDET.xcos b/history/blocks_xcos/MATDET.xcos deleted file mode 100644 index 447c8b6..0000000 --- a/history/blocks_xcos/MATDET.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATDIAG.xcos b/history/blocks_xcos/MATDIAG.xcos deleted file mode 100644 index ce702af..0000000 --- a/history/blocks_xcos/MATDIAG.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATDIV.xcos b/history/blocks_xcos/MATDIV.xcos deleted file mode 100644 index f5f0186..0000000 --- a/history/blocks_xcos/MATDIV.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATEIG.xcos b/history/blocks_xcos/MATEIG.xcos deleted file mode 100644 index 21ab40d..0000000 --- a/history/blocks_xcos/MATEIG.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATEXPM.xcos b/history/blocks_xcos/MATEXPM.xcos deleted file mode 100644 index f03c205..0000000 --- a/history/blocks_xcos/MATEXPM.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATINV.xcos b/history/blocks_xcos/MATINV.xcos deleted file mode 100644 index f6c6fa5..0000000 --- a/history/blocks_xcos/MATINV.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATLU.xcos b/history/blocks_xcos/MATLU.xcos deleted file mode 100644 index 5f1dc60..0000000 --- a/history/blocks_xcos/MATLU.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATMAGPHI.xcos b/history/blocks_xcos/MATMAGPHI.xcos deleted file mode 100644 index 62af843..0000000 --- a/history/blocks_xcos/MATMAGPHI.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATMUL.xcos b/history/blocks_xcos/MATMUL.xcos deleted file mode 100644 index 5f0b2eb..0000000 --- a/history/blocks_xcos/MATMUL.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATPINV.xcos b/history/blocks_xcos/MATPINV.xcos deleted file mode 100644 index c175efe..0000000 --- a/history/blocks_xcos/MATPINV.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATRESH.xcos b/history/blocks_xcos/MATRESH.xcos deleted file mode 100644 index 0b51257..0000000 --- a/history/blocks_xcos/MATRESH.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATSING.xcos b/history/blocks_xcos/MATSING.xcos deleted file mode 100644 index 7dd786d..0000000 --- a/history/blocks_xcos/MATSING.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATSUM.xcos b/history/blocks_xcos/MATSUM.xcos deleted file mode 100644 index 8d15b9c..0000000 --- a/history/blocks_xcos/MATSUM.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATTRAN.xcos b/history/blocks_xcos/MATTRAN.xcos deleted file mode 100644 index 64e5df3..0000000 --- a/history/blocks_xcos/MATTRAN.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATZCONJ.xcos b/history/blocks_xcos/MATZCONJ.xcos deleted file mode 100644 index b31006f..0000000 --- a/history/blocks_xcos/MATZCONJ.xcos +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MATZREIM.xcos b/history/blocks_xcos/MATZREIM.xcos deleted file mode 100644 index e984d49..0000000 --- a/history/blocks_xcos/MATZREIM.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MAXMIN.xcos b/history/blocks_xcos/MAXMIN.xcos deleted file mode 100644 index 3652677..0000000 --- a/history/blocks_xcos/MAXMIN.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MAX_f.xcos b/history/blocks_xcos/MAX_f.xcos deleted file mode 100644 index d89b665..0000000 --- a/history/blocks_xcos/MAX_f.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MBLOCK.xcos b/history/blocks_xcos/MBLOCK.xcos deleted file mode 100644 index 651e9c7..0000000 --- a/history/blocks_xcos/MBLOCK.xcos +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MCLOCK_f.xcos b/history/blocks_xcos/MCLOCK_f.xcos deleted file mode 100644 index 9bc2366..0000000 --- a/history/blocks_xcos/MCLOCK_f.xcos +++ /dev/null @@ -1,1389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MFCLCK_f.xcos b/history/blocks_xcos/MFCLCK_f.xcos deleted file mode 100644 index fb43aa1..0000000 --- a/history/blocks_xcos/MFCLCK_f.xcos +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MIN_f.xcos b/history/blocks_xcos/MIN_f.xcos deleted file mode 100644 index 5846c1e..0000000 --- a/history/blocks_xcos/MIN_f.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MUX.xcos b/history/blocks_xcos/MUX.xcos deleted file mode 100644 index 396cf23..0000000 --- a/history/blocks_xcos/MUX.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/MUX_f.xcos b/history/blocks_xcos/MUX_f.xcos deleted file mode 100644 index 2bc295f..0000000 --- a/history/blocks_xcos/MUX_f.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/M_SWITCH.xcos b/history/blocks_xcos/M_SWITCH.xcos deleted file mode 100644 index c22349d..0000000 --- a/history/blocks_xcos/M_SWITCH.xcos +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/M_freq.xcos b/history/blocks_xcos/M_freq.xcos deleted file mode 100644 index f2d8368..0000000 --- a/history/blocks_xcos/M_freq.xcos +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Modulo_Count.xcos b/history/blocks_xcos/Modulo_Count.xcos deleted file mode 100644 index 5c99ee3..0000000 --- a/history/blocks_xcos/Modulo_Count.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/NEGTOPOS_f.xcos b/history/blocks_xcos/NEGTOPOS_f.xcos deleted file mode 100644 index f8c5072..0000000 --- a/history/blocks_xcos/NEGTOPOS_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/NMOS.xcos b/history/blocks_xcos/NMOS.xcos deleted file mode 100644 index 0016973..0000000 --- a/history/blocks_xcos/NMOS.xcos +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/NPN.xcos b/history/blocks_xcos/NPN.xcos deleted file mode 100644 index 8b1b964..0000000 --- a/history/blocks_xcos/NPN.xcos +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/NRMSOM_f.xcos b/history/blocks_xcos/NRMSOM_f.xcos deleted file mode 100644 index 9ecaea3..0000000 --- a/history/blocks_xcos/NRMSOM_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/OUTIMPL_f.xcos b/history/blocks_xcos/OUTIMPL_f.xcos deleted file mode 100644 index 0a221a4..0000000 --- a/history/blocks_xcos/OUTIMPL_f.xcos +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/OUT_f.xcos b/history/blocks_xcos/OUT_f.xcos deleted file mode 100644 index 5190490..0000000 --- a/history/blocks_xcos/OUT_f.xcos +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/OpAmp.xcos b/history/blocks_xcos/OpAmp.xcos deleted file mode 100644 index 31de573..0000000 --- a/history/blocks_xcos/OpAmp.xcos +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PDE.xcos b/history/blocks_xcos/PDE.xcos deleted file mode 100644 index 897a6ce..0000000 --- a/history/blocks_xcos/PDE.xcos +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PID.xcos b/history/blocks_xcos/PID.xcos deleted file mode 100644 index c7cfc69..0000000 --- a/history/blocks_xcos/PID.xcos +++ /dev/null @@ -1,2403 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PMOS.xcos b/history/blocks_xcos/PMOS.xcos deleted file mode 100644 index c7ba939..0000000 --- a/history/blocks_xcos/PMOS.xcos +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PNP.xcos b/history/blocks_xcos/PNP.xcos deleted file mode 100644 index 4722414..0000000 --- a/history/blocks_xcos/PNP.xcos +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/POSTONEG_f.xcos b/history/blocks_xcos/POSTONEG_f.xcos deleted file mode 100644 index 415d258..0000000 --- a/history/blocks_xcos/POSTONEG_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/POWBLK_f.xcos b/history/blocks_xcos/POWBLK_f.xcos deleted file mode 100644 index 6d01b91..0000000 --- a/history/blocks_xcos/POWBLK_f.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PRODUCT.xcos b/history/blocks_xcos/PRODUCT.xcos deleted file mode 100644 index 8bf5d1a..0000000 --- a/history/blocks_xcos/PRODUCT.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PROD_f.xcos b/history/blocks_xcos/PROD_f.xcos deleted file mode 100644 index 1d1c91e..0000000 --- a/history/blocks_xcos/PROD_f.xcos +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PULSE_SC.xcos b/history/blocks_xcos/PULSE_SC.xcos deleted file mode 100644 index c3bf9ef..0000000 --- a/history/blocks_xcos/PULSE_SC.xcos +++ /dev/null @@ -1,1370 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PerteDP.xcos b/history/blocks_xcos/PerteDP.xcos deleted file mode 100644 index 9ad675d..0000000 --- a/history/blocks_xcos/PerteDP.xcos +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PotentialSensor.xcos b/history/blocks_xcos/PotentialSensor.xcos deleted file mode 100644 index 1b07ac3..0000000 --- a/history/blocks_xcos/PotentialSensor.xcos +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/PuitsP.xcos b/history/blocks_xcos/PuitsP.xcos deleted file mode 100644 index 89d2b51..0000000 --- a/history/blocks_xcos/PuitsP.xcos +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/QUANT_f.xcos b/history/blocks_xcos/QUANT_f.xcos deleted file mode 100644 index 590cf48..0000000 --- a/history/blocks_xcos/QUANT_f.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RAMP.xcos b/history/blocks_xcos/RAMP.xcos deleted file mode 100644 index c79760c..0000000 --- a/history/blocks_xcos/RAMP.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RAND_m.xcos b/history/blocks_xcos/RAND_m.xcos deleted file mode 100644 index 85aee60..0000000 --- a/history/blocks_xcos/RAND_m.xcos +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RATELIMITER.xcos b/history/blocks_xcos/RATELIMITER.xcos deleted file mode 100644 index 3246f1c..0000000 --- a/history/blocks_xcos/RATELIMITER.xcos +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/READAU_f.xcos b/history/blocks_xcos/READAU_f.xcos deleted file mode 100644 index 187c3ac..0000000 --- a/history/blocks_xcos/READAU_f.xcos +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/READC_f.xcos b/history/blocks_xcos/READC_f.xcos deleted file mode 100644 index efc1ec7..0000000 --- a/history/blocks_xcos/READC_f.xcos +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/REGISTER.xcos b/history/blocks_xcos/REGISTER.xcos deleted file mode 100644 index 9fe8ec4..0000000 --- a/history/blocks_xcos/REGISTER.xcos +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RELATIONALOP.xcos b/history/blocks_xcos/RELATIONALOP.xcos deleted file mode 100644 index 5b6e98c..0000000 --- a/history/blocks_xcos/RELATIONALOP.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RELAY_f.xcos b/history/blocks_xcos/RELAY_f.xcos deleted file mode 100644 index d47fc92..0000000 --- a/history/blocks_xcos/RELAY_f.xcos +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RFILE_f.xcos b/history/blocks_xcos/RFILE_f.xcos deleted file mode 100644 index dd332c8..0000000 --- a/history/blocks_xcos/RFILE_f.xcos +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/RICC.xcos b/history/blocks_xcos/RICC.xcos deleted file mode 100644 index 96f099a..0000000 --- a/history/blocks_xcos/RICC.xcos +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ROOTCOEF.xcos b/history/blocks_xcos/ROOTCOEF.xcos deleted file mode 100644 index 2b758f1..0000000 --- a/history/blocks_xcos/ROOTCOEF.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Resistor.xcos b/history/blocks_xcos/Resistor.xcos deleted file mode 100644 index 7a6316d..0000000 --- a/history/blocks_xcos/Resistor.xcos +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SAMPHOLD_m.xcos b/history/blocks_xcos/SAMPHOLD_m.xcos deleted file mode 100644 index 2ade678..0000000 --- a/history/blocks_xcos/SAMPHOLD_m.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SATURATION.xcos b/history/blocks_xcos/SATURATION.xcos deleted file mode 100644 index 8875612..0000000 --- a/history/blocks_xcos/SATURATION.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SAWTOOTH_f.xcos b/history/blocks_xcos/SAWTOOTH_f.xcos deleted file mode 100644 index f896b58..0000000 --- a/history/blocks_xcos/SAWTOOTH_f.xcos +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SCALAR2VECTOR.xcos b/history/blocks_xcos/SCALAR2VECTOR.xcos deleted file mode 100644 index fa04f71..0000000 --- a/history/blocks_xcos/SCALAR2VECTOR.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SELECT_m.xcos b/history/blocks_xcos/SELECT_m.xcos deleted file mode 100644 index 900a228..0000000 --- a/history/blocks_xcos/SELECT_m.xcos +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SELF_SWITCH.xcos b/history/blocks_xcos/SELF_SWITCH.xcos deleted file mode 100644 index b169105..0000000 --- a/history/blocks_xcos/SELF_SWITCH.xcos +++ /dev/null @@ -1,946 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SHIFT.xcos b/history/blocks_xcos/SHIFT.xcos deleted file mode 100644 index a3db871..0000000 --- a/history/blocks_xcos/SHIFT.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SIGNUM.xcos b/history/blocks_xcos/SIGNUM.xcos deleted file mode 100644 index 05fe019..0000000 --- a/history/blocks_xcos/SIGNUM.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SINBLK_f.xcos b/history/blocks_xcos/SINBLK_f.xcos deleted file mode 100644 index fafb5ae..0000000 --- a/history/blocks_xcos/SINBLK_f.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SOM_f.xcos b/history/blocks_xcos/SOM_f.xcos deleted file mode 100644 index 06852e8..0000000 --- a/history/blocks_xcos/SOM_f.xcos +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SQRT.xcos b/history/blocks_xcos/SQRT.xcos deleted file mode 100644 index 05a31c2..0000000 --- a/history/blocks_xcos/SQRT.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SRFLIPFLOP.xcos b/history/blocks_xcos/SRFLIPFLOP.xcos deleted file mode 100644 index 099bc34..0000000 --- a/history/blocks_xcos/SRFLIPFLOP.xcos +++ /dev/null @@ -1,1681 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/STEP_FUNCTION.xcos b/history/blocks_xcos/STEP_FUNCTION.xcos deleted file mode 100644 index 049a3c9..0000000 --- a/history/blocks_xcos/STEP_FUNCTION.xcos +++ /dev/null @@ -1,1118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SUBMAT.xcos b/history/blocks_xcos/SUBMAT.xcos deleted file mode 100644 index 67e00c5..0000000 --- a/history/blocks_xcos/SUBMAT.xcos +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SUMMATION.xcos b/history/blocks_xcos/SUMMATION.xcos deleted file mode 100644 index 3d966eb..0000000 --- a/history/blocks_xcos/SUMMATION.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SUM_f.xcos b/history/blocks_xcos/SUM_f.xcos deleted file mode 100644 index 3333c9d..0000000 --- a/history/blocks_xcos/SUM_f.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SUPER_f.xcos b/history/blocks_xcos/SUPER_f.xcos deleted file mode 100644 index 9cc0734..0000000 --- a/history/blocks_xcos/SUPER_f.xcos +++ /dev/null @@ -1,493 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SWITCH2_m.xcos b/history/blocks_xcos/SWITCH2_m.xcos deleted file mode 100644 index ad8c3ee..0000000 --- a/history/blocks_xcos/SWITCH2_m.xcos +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SWITCH_f.xcos b/history/blocks_xcos/SWITCH_f.xcos deleted file mode 100644 index 28c2409..0000000 --- a/history/blocks_xcos/SWITCH_f.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SampleCLK.xcos b/history/blocks_xcos/SampleCLK.xcos deleted file mode 100644 index 3365aae..0000000 --- a/history/blocks_xcos/SampleCLK.xcos +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Sigbuilder.xcos b/history/blocks_xcos/Sigbuilder.xcos deleted file mode 100644 index b618450..0000000 --- a/history/blocks_xcos/Sigbuilder.xcos +++ /dev/null @@ -1,992 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SineVoltage.xcos b/history/blocks_xcos/SineVoltage.xcos deleted file mode 100644 index 39edb97..0000000 --- a/history/blocks_xcos/SineVoltage.xcos +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/SourceP.xcos b/history/blocks_xcos/SourceP.xcos deleted file mode 100644 index de0932e..0000000 --- a/history/blocks_xcos/SourceP.xcos +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/Switch.xcos b/history/blocks_xcos/Switch.xcos deleted file mode 100644 index 8f1eebb..0000000 --- a/history/blocks_xcos/Switch.xcos +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TANBLK_f.xcos b/history/blocks_xcos/TANBLK_f.xcos deleted file mode 100644 index 1d38569..0000000 --- a/history/blocks_xcos/TANBLK_f.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TCLSS.xcos b/history/blocks_xcos/TCLSS.xcos deleted file mode 100644 index 6112f7e..0000000 --- a/history/blocks_xcos/TCLSS.xcos +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TEXT_f.xcos b/history/blocks_xcos/TEXT_f.xcos deleted file mode 100644 index bda263d..0000000 --- a/history/blocks_xcos/TEXT_f.xcos +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TIME_DELAY.xcos b/history/blocks_xcos/TIME_DELAY.xcos deleted file mode 100644 index f76c91a..0000000 --- a/history/blocks_xcos/TIME_DELAY.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TIME_f.xcos b/history/blocks_xcos/TIME_f.xcos deleted file mode 100644 index 5ccba49..0000000 --- a/history/blocks_xcos/TIME_f.xcos +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TKSCALE.xcos b/history/blocks_xcos/TKSCALE.xcos deleted file mode 100644 index e26401b..0000000 --- a/history/blocks_xcos/TKSCALE.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TOWS_c.xcos b/history/blocks_xcos/TOWS_c.xcos deleted file mode 100644 index 50e5a80..0000000 --- a/history/blocks_xcos/TOWS_c.xcos +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TRASH_f.xcos b/history/blocks_xcos/TRASH_f.xcos deleted file mode 100644 index 9089c92..0000000 --- a/history/blocks_xcos/TRASH_f.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/TrigFun.xcos b/history/blocks_xcos/TrigFun.xcos deleted file mode 100644 index b07db1c..0000000 --- a/history/blocks_xcos/TrigFun.xcos +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VARIABLE_DELAY.xcos b/history/blocks_xcos/VARIABLE_DELAY.xcos deleted file mode 100644 index 1fc7a62..0000000 --- a/history/blocks_xcos/VARIABLE_DELAY.xcos +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VVsourceAC.xcos b/history/blocks_xcos/VVsourceAC.xcos deleted file mode 100644 index ca01231..0000000 --- a/history/blocks_xcos/VVsourceAC.xcos +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VanneReglante.xcos b/history/blocks_xcos/VanneReglante.xcos deleted file mode 100644 index 376e26b..0000000 --- a/history/blocks_xcos/VanneReglante.xcos +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VariableResistor.xcos b/history/blocks_xcos/VariableResistor.xcos deleted file mode 100644 index 0ab3590..0000000 --- a/history/blocks_xcos/VariableResistor.xcos +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VirtualCLK0.xcos b/history/blocks_xcos/VirtualCLK0.xcos deleted file mode 100644 index 0109a7b..0000000 --- a/history/blocks_xcos/VirtualCLK0.xcos +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VoltageSensor.xcos b/history/blocks_xcos/VoltageSensor.xcos deleted file mode 100644 index 589c64d..0000000 --- a/history/blocks_xcos/VoltageSensor.xcos +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/VsourceAC.xcos b/history/blocks_xcos/VsourceAC.xcos deleted file mode 100644 index aa80c9f..0000000 --- a/history/blocks_xcos/VsourceAC.xcos +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/WFILE_f.xcos b/history/blocks_xcos/WFILE_f.xcos deleted file mode 100644 index 194b80e..0000000 --- a/history/blocks_xcos/WFILE_f.xcos +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/WRITEAU_f.xcos b/history/blocks_xcos/WRITEAU_f.xcos deleted file mode 100644 index 9cdac50..0000000 --- a/history/blocks_xcos/WRITEAU_f.xcos +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/WRITEC_f.xcos b/history/blocks_xcos/WRITEC_f.xcos deleted file mode 100644 index 8c51f74..0000000 --- a/history/blocks_xcos/WRITEC_f.xcos +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/ZCROSS_f.xcos b/history/blocks_xcos/ZCROSS_f.xcos deleted file mode 100644 index 038ca84..0000000 --- a/history/blocks_xcos/ZCROSS_f.xcos +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/c_block.xcos b/history/blocks_xcos/c_block.xcos deleted file mode 100644 index 4a4b5e0..0000000 --- a/history/blocks_xcos/c_block.xcos +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/history/blocks_xcos/fortran_block.xcos b/history/blocks_xcos/fortran_block.xcos deleted file mode 100644 index 0bc4378..0000000 --- a/history/blocks_xcos/fortran_block.xcos +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/freq_div.xcos b/history/blocks_xcos/freq_div.xcos deleted file mode 100644 index 0786de2..0000000 --- a/history/blocks_xcos/freq_div.xcos +++ /dev/null @@ -1,1165 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/generic_block3.xcos b/history/blocks_xcos/generic_block3.xcos deleted file mode 100644 index 8261839..0000000 --- a/history/blocks_xcos/generic_block3.xcos +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/blocks_xcos/scifunc_block_m.xcos b/history/blocks_xcos/scifunc_block_m.xcos deleted file mode 100644 index dad27ff..0000000 --- a/history/blocks_xcos/scifunc_block_m.xcos +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/history/data_structures/ABS_VALUE.js b/history/data_structures/ABS_VALUE.js deleted file mode 100644 index ef569e9..0000000 --- a/history/data_structures/ABS_VALUE.js +++ /dev/null @@ -1,20 +0,0 @@ -function ABS_VALUE () { - - - var nu = -1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["absolute_value"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([nu])); - model.out=new ScilabDouble([nu]); - model.nzcross=new ScilabDouble([nu]); - model.nmode=new ScilabDouble([nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string([1])]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/AFFICH_m.js b/history/data_structures/AFFICH_m.js deleted file mode 100644 index ff0b180..0000000 --- a/history/data_structures/AFFICH_m.js +++ /dev/null @@ -1,33 +0,0 @@ -function AFFICH_m () { - - - var font = 1; - - var fontsize = 1; - - var colr = 1; - - var nt = 5; - - var nd = 1; - - var in1 = [1,1]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["affich2"]),new ScilabDouble([4])); - model.in1.push(in1(1,1)); - model.in2.push(in1(1,2)); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1],[0],[0],[1],[1],[0],[zeros(in1(1,1)*in1(1,2),1)]); - model.ipar = new ScilabDouble([font],[fontsize],[colr],[1000],[nt],[nd],[in1(1,1)]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - model.label = new ScilabString([""]); - - var exprs = [[,sci2exp([model.in1,model.in2])],[string(font)],[string(fontsize)],[string(colr)],[string(nt)],[string(nd)],[string(0),]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new AfficheBlock(this.x) -} diff --git a/history/data_structures/ANDBLK.js b/history/data_structures/ANDBLK.js deleted file mode 100644 index 6d88e54..0000000 --- a/history/data_structures/ANDBLK.js +++ /dev/null @@ -1,75 +0,0 @@ -function ANDBLK () { - - - var andlog = ANDLOG_f("define"); - andlog.graphics.orig = new ScilabDouble([194,133]); - andlog.graphics.sz = new ScilabDouble([60,60]); - andlog.graphics.flip = new ScilabBoolean([true]); - andlog.graphics.pout = new ScilabDouble([9]); - andlog.graphics.pein = new ScilabDouble([4],[11]); - - var input_port1 = CLKIN_f("define"); - input_port1.graphics.orig = new ScilabDouble([149,287]); - input_port1.graphics.sz = new ScilabDouble([20,20]); - input_port1.graphics.flip = new ScilabBoolean([true]); - input_port1.graphics.exprs = new ScilabString(["1"]); - input_port1.graphics.peout = new ScilabDouble([4]); - input_port1.model.ipar = new ScilabDouble([1]); - - var output_port = CLKOUT_f("define"); - output_port.graphics.orig = new ScilabDouble([450,83]); - output_port.graphics.sz = new ScilabDouble([20,20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([8]); - output_port.model.ipar = new ScilabDouble([1]); - - var input_port2 = CLKIN_f("define"); - input_port2.graphics.orig = new ScilabDouble([141,330]); - input_port2.graphics.sz = new ScilabDouble([20,20]); - input_port2.graphics.flip = new ScilabBoolean([true]); - input_port2.graphics.exprs = new ScilabString(["2"]); - input_port2.graphics.peout = new ScilabDouble([6]); - input_port2.model.ipar = new ScilabDouble([2]); - - var ifthel = IFTHEL_f("define"); - ifthel.graphics.orig = new ScilabDouble([331,137]); - ifthel.graphics.sz = new ScilabDouble([60,60]); - ifthel.graphics.flip = new ScilabBoolean([true]); - ifthel.graphics.pin = new ScilabDouble([9]); - ifthel.graphics.pein = new ScilabDouble([12]); - ifthel.graphics.peout = new ScilabDouble([8],[0]); - - var split = CLKSPLIT_f("define"); - split.graphics.orig = new ScilabDouble([234],[275.78348]); - split.graphics.pein = new ScilabDouble([6]); - split.graphics.peout = new ScilabDouble([11],[12]); - - var diagram = scicos_diagram(); - diagram.objs.push(andlog); - diagram.objs.push(input_port1); - diagram.objs.push(output_port); - diagram.objs.push(scicos_link({xx: new ScilabDouble([169],[214],[214]),yy: new ScilabDouble([297],[297],[198.71]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1]),to: new ScilabDouble([1,1])})); - diagram.objs.push(input_port2); - diagram.objs.push(scicos_link({xx: new ScilabDouble([161],[234],[234]),yy: new ScilabDouble([340],[340],[275.78]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([5,1]),to: new ScilabDouble([10,1])})); - diagram.objs.push(ifthel); - diagram.objs.push(scicos_link({xx: new ScilabDouble([351],[351],[450]),yy: new ScilabDouble([131.29],[93],[93]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([7,1]),to: new ScilabDouble([3,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([262.57],[322.43]),yy: new ScilabDouble([163],[167]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1]),to: new ScilabDouble([7,1])})); - diagram.objs.push(split); - diagram.objs.push(scicos_link({xx: new ScilabDouble([234],[234]),yy: new ScilabDouble([275.78],[198.71]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([10,1]),to: new ScilabDouble([1,2])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([234],[361],[361]),yy: new ScilabDouble([275.78],[275.78],[202.71]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([10,2]),to: new ScilabDouble([7,1])})); - this.x=scicos_block(); - this.x.gui = new ScilabString(["ANDBLK"]); - this.x.graphics.sz = new ScilabDouble([2,2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pein = new ScilabDouble([0],[0]); - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtin = new ScilabDouble([1],[1]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false,false]); - this.x.model.rpar=diagram; - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ANDLOG_f.js b/history/data_structures/ANDLOG_f.js deleted file mode 100644 index b94c240..0000000 --- a/history/data_structures/ANDLOG_f.js +++ /dev/null @@ -1,15 +0,0 @@ -function ANDLOG_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["andlog"]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1],[1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,3]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/AUTOMAT.js b/history/data_structures/AUTOMAT.js deleted file mode 100644 index 3ceda51..0000000 --- a/history/data_structures/AUTOMAT.js +++ /dev/null @@ -1,40 +0,0 @@ -function AUTOMAT () { - - - var NMode = 2; - - var Minitial = 1; - - var NX = 1; - - var X0 = [0.0]; - - var XP = [[1],[1]]; - - var C1 = [2]; - - var C2 = [1]; - - var exprs = [[string(NMode)],[string(Minitial)],[string(NX)],[sci2exp(X0)],[sci2exp(XP)],[sci2exp(C1)],[sci2exp(C2)]]; - - var ipar = [[NMode],[Minitial],[NX],[XP],[C1],[C2]]; - - var rpar = [X0]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["automat"]),new ScilabDouble([10004])); - model.in1 = new ScilabDouble([2*NX+1],[2*NX+1]); - model.out = new ScilabDouble([2],[2*NX]); - model.state=ones(2*NX,1); - model.nzcross = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.evtout = new ScilabDouble([1]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,true]); - model.ipar=ipar; - model.rpar=rpar; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BACKLASH.js b/history/data_structures/BACKLASH.js deleted file mode 100644 index d407fd7..0000000 --- a/history/data_structures/BACKLASH.js +++ /dev/null @@ -1,18 +0,0 @@ -function BACKLASH () { - - - var exprs = ["0";"1";"1"]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["backlash"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0],[1]); - model.nzcross = new ScilabDouble([2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BARXY.js b/history/data_structures/BARXY.js deleted file mode 100644 index 5c3cb6a..0000000 --- a/history/data_structures/BARXY.js +++ /dev/null @@ -1,27 +0,0 @@ -function BARXY () { - - - var model = scicos_model(); - - var xmin = -15; - - var xmax = 15; - - var ymin = -15; - - var ymax = 15; - model.sim=list(new ScilabString(["BARXY_sim"]),,new ScilabDouble([5])); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true,false]); - model.in1 = new ScilabDouble([-1],[-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([xmin,],[,xmax,],[,ymin,],[,ymax]); - model.ipar = new ScilabDouble([1]); - this.x=new standard_define(new ScilabDouble([2,2]),model,[],[]); - this.x.graphics.in_implicit = new ScilabString(["E",,"E"]); - this.x.graphics.out_implicit = new ScilabDouble(); - this.x.graphics.exprs = new ScilabString(["-15";"15";"-15";"15";"1"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BIGSOM_f.js b/history/data_structures/BIGSOM_f.js deleted file mode 100644 index 69ce1d5..0000000 --- a/history/data_structures/BIGSOM_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function BIGSOM_f () { - - - var sgn = [[1],[1]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["sum"]),new ScilabDouble([2])); - model.in1 = new ScilabDouble([-1],[-1]); - model.out = new ScilabDouble([-1]); - model.rpar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = sci2exp(sgn); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,,exprs,gr_i); - return new BigSom(this.x) -} diff --git a/history/data_structures/BITCLEAR.js b/history/data_structures/BITCLEAR.js deleted file mode 100644 index 3e7aa24..0000000 --- a/history/data_structures/BITCLEAR.js +++ /dev/null @@ -1,21 +0,0 @@ -function BITCLEAR () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["bit_clear_32"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar=list(new ScilabInteger([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(3)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BITSET.js b/history/data_structures/BITSET.js deleted file mode 100644 index ed7bccf..0000000 --- a/history/data_structures/BITSET.js +++ /dev/null @@ -1,21 +0,0 @@ -function BITSET () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["bit_set_32"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.opar=list(new ScilabInteger([0])); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(3)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BOUNCE.js b/history/data_structures/BOUNCE.js deleted file mode 100644 index b2b8ec9..0000000 --- a/history/data_structures/BOUNCE.js +++ /dev/null @@ -1,17 +0,0 @@ -function BOUNCE () { - - - var n = 2; - - var k = 1],[ipar=[]; - - var for i = 1:n; - - var for j = i+1:n; - - var ipar(k) = i; - k=k+1; - ipar(k)=j; - k=k+1; - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BOUNCEXY.js b/history/data_structures/BOUNCEXY.js deleted file mode 100644 index a0b3134..0000000 --- a/history/data_structures/BOUNCEXY.js +++ /dev/null @@ -1,43 +0,0 @@ -function BOUNCEXY () { - - - var win = -1; - - var imode = 1; - - var clrs = [[1],[2]]; - - var siz = [[1],[1]]; - - var xmin = -5; - - var xmax = 5; - - var ymin = 0; - - var ymax = 15; - - var model = scicos_model(); - model.sim=list(new ScilabString(["bouncexy"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-1]); - model.in2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([1],[1]); - model.evtin = new ScilabDouble([1]); - - var z = []; - - var for i = 1:size(clrs,"*"); - - var z(6*(i-1)+1) = 0; - - var z(6*(i-1)+2) = 0; - - var z(6*(i-1)+3) = 2*siz(i); - - var z(6*(i-1)+4) = 2*siz(i); - - var z(6*(i-1)+5) = 0.000; - - var z(6*(i-1)+6) = 64.0*360.000; - return new BasicBlock(this.x) -} diff --git a/history/data_structures/BPLATFORM.js b/history/data_structures/BPLATFORM.js deleted file mode 100644 index a7e7da4..0000000 --- a/history/data_structures/BPLATFORM.js +++ /dev/null @@ -1,32 +0,0 @@ -function BPLATFORM () { - - - var plen = 2; - - var csiz = 2; - - var phi = 0; - - var xmin = -5; - - var xmax = 5; - - var ymin = 0; - - var ymax = 15; - - var model = scicos_model(); - model.sim=list(new ScilabString(["bplatform2"]),new ScilabDouble([5])); - model.in1 = new ScilabDouble([1],[1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.rpar = new ScilabDouble([plen],[csiz],[phi],[xmin],[xmax],[ymin],[ymax]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(model.rpar); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Bache.js b/history/data_structures/Bache.js deleted file mode 100644 index d7d3c4c..0000000 --- a/history/data_structures/Bache.js +++ /dev/null @@ -1,50 +0,0 @@ -function Bache () { - - - var in1 = 2; - - var out = 3; - - var model = scicos_model(); - model.in1 = new ScilabDouble([-(1:in1)']); - model.out = new ScilabDouble([-(1:out)']); - - var Patm = 1.013E5; - - var A = 1; - - var ze1 = 40; - - var ze2 = 0; - - var zs1 = 40; - - var zs2 = 0; - - var z0 = 30; - - var T0 = 290; - - var p_rho = 0; - model.rpar = new ScilabDouble([Patm],[A],[ze1],[ze2],[zs1],[zs2],[z0],[T0],[p_rho]); - model.sim = new ScilabString(["Bache"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Bache"]); - mo.inputs = new ScilabString(["Ce1" "Ce2"]); - mo.outputs = new ScilabString(["Cs1" "Cs2" "yNiveau"]); - mo.parameters=list(new ScilabString(["Patm";"A";"ze1";"ze2";"zs1";"zs2";"z0";"T0";"p_rho"]),[Patm],[A],[ze1],[ze2],[zs1],[zs2],[z0],[T0],[p_rho]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(Patm)],[string(A)],[string(ze1)],[string(ze2)],[string(zs1)],[string(zs2)],[string(z0)],[string(T0)],[string(p_rho)]]; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I";"I"]); - this.x.graphics.out_implicit = new ScilabString(["I";"I";"E"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CANIMXY.js b/history/data_structures/CANIMXY.js deleted file mode 100644 index 0d1c11c..0000000 --- a/history/data_structures/CANIMXY.js +++ /dev/null @@ -1,43 +0,0 @@ -function CANIMXY () { - - - var win = -1; - - var clrs = -4; - - var N = 2; - - var siz = 1; - - var wpos = [[-1],[-1]]; - - var wdim = [[-1],[-1]]; - - var xmin = -15; - - var xmax = 15; - - var ymin = -15; - - var ymax = +15; - - var nbr_curves = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["canimxy"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1]); - model.in2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([1],[1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([xmin],[xmax],[ymin],[ymax]); - model.ipar = new ScilabDouble([win],[1],[N],[clrs],[siz],[0],[...wpos],[...wdim],[nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(nbr_curves);string(clrs);string(siz);string(win);"[]";"[]"],[string(xmin)],[string(xmax)],[string(ymin)],[string(ymax)],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CANIMXY3D.js b/history/data_structures/CANIMXY3D.js deleted file mode 100644 index a1ec5f1..0000000 --- a/history/data_structures/CANIMXY3D.js +++ /dev/null @@ -1,43 +0,0 @@ -function CANIMXY3D () { - - - var win = -1; - - var N = 2; - - var clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - - var siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - - var wpos = [[-1],[-1]]; - - var wdim = [[-1],[-1]]; - - var param3ds = [[50],[280]]; - - var vec_x = [[-15],[15]]; - - var vec_y = [[-15],[15]]; - - var vec_z = [[-15],[15]]; - - var nbr_curves = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["canimxy3d"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1],[1]); - model.evtin = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1],[1],[1]); - model.intyp = new ScilabDouble([1],[1],[1]); - model.rpar = new ScilabDouble([...colon_operator(vec_x,:)],[...vec_y],[vec_z(,)],[...param3ds]); - model.ipar = new ScilabDouble([win],[8],[N],[...colon_operator(clrs,:)],[...siz],[8],[wpos(,)],[...wdim],[nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(nbr_curves);strcat(string(clrs)," ");strcat(string(siz)," ");string(win);"[]";"[]";strcat(string(vec_x)," ");strcat(string(vec_y)," ");strcat(string(vec_z)," ");strcat(string(param3ds)," ")],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CBLOCK.js b/history/data_structures/CBLOCK.js deleted file mode 100644 index 77eb431..0000000 --- a/history/data_structures/CBLOCK.js +++ /dev/null @@ -1,48 +0,0 @@ -function CBLOCK () { - - - var in1 = 1; - - var out = 1; - - var clkin = []; - - var clkout = []; - - var x0 = []; - - var z0 = []; - - var typ = "c"; - - var auto = []; - - var rpar = []; - - var ipar = []; - - var funam = "toto"; - - var ng = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString([" "]),new ScilabDouble([2004])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([out]); - model.evtin=clkin; - model.evtout=clkout; - model.state=x0; - model.dstate=z0; - model.rpar=rpar; - model.ipar=ipar; - model.blocktype=new ScilabString([typ]); - model.firing=auto; - model.dep_ut = new ScilabBoolean([true,false]); - model.nzcross=new ScilabDouble([ng]); - - var label = list([funam,"n",sci2exp(in1),sci2exp(out),sci2exp(clkin),sci2exp(clkout),sci2exp(x0),sci2exp(0),sci2exp(z0),sci2exp(rpar),sci2exp(ipar),sci2exp(auto),"y","n"]',[]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CBLOCK4.js b/history/data_structures/CBLOCK4.js deleted file mode 100644 index c4cfa2c..0000000 --- a/history/data_structures/CBLOCK4.js +++ /dev/null @@ -1,39 +0,0 @@ -function CBLOCK4 () { - - - var funam = "toto"; - - var model = scicos_model(); - model.sim=list(new ScilabString([" "]),new ScilabDouble([2004])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = list([funam; - "n"; - sci2exp([model.in1 model.in2]); - sci2exp(model.intyp); - sci2exp([model.out model.out2]); - sci2exp(model.outtyp); - sci2exp(model.evtin); - sci2exp(model.evtout); - sci2exp(model.state); - sci2exp(model.dstate); - sci2exp(model.odstate); - sci2exp(model.rpar); - sci2exp(model.ipar); - sci2exp(model.opar); - sci2exp(model.nmode); - sci2exp(model.nzcross); - sci2exp(model.firing); - "y"; - "n"],[]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CCS.js b/history/data_structures/CCS.js deleted file mode 100644 index e405427..0000000 --- a/history/data_structures/CCS.js +++ /dev/null @@ -1,30 +0,0 @@ -function CCS () { - - - var ModelName = "CCS"; - - var PrametersValue = []; - - var ParametersName = []; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[2,50,1,0],[,70,98,2,0],[70,2,-2,0]]; - - var PortName = ["Iin";"p";"n"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CEVENTSCOPE.js b/history/data_structures/CEVENTSCOPE.js deleted file mode 100644 index 73a3b7e..0000000 --- a/history/data_structures/CEVENTSCOPE.js +++ /dev/null @@ -1,29 +0,0 @@ -function CEVENTSCOPE () { - - - var nclock = 1; - - var win = -1; - - var clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - - var wdim = [[600],[400]]; - - var wpos = [[-1],[-1]]; - - var per = 30; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cevscpe"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar=new ScilabDouble([per]); - model.ipar = new ScilabDouble([win],[1],[...colon_operator(clrs,nclock)],[wpos(,)],[...wdim]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp(nclock);strcat(sci2exp(clrs(nclock))," ")],[string(win)],[sci2exp([])],[sci2exp(wdim)],[string(per)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CFSCOPE.js b/history/data_structures/CFSCOPE.js deleted file mode 100644 index 4a0c786..0000000 --- a/history/data_structures/CFSCOPE.js +++ /dev/null @@ -1,33 +0,0 @@ -function CFSCOPE () { - - - var win = -1; - - var wdim = [[600],[400]]; - - var wpos = [[-1],[-1]]; - - var clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - - var N = 2; - - var ymin = -15; - - var ymax = +15; - - var per = 30; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cfscope"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0],[ymin],[ymax],[per]); - model.ipar = new ScilabDouble([win],[1],[N],[clrs],[wpos],[wdim],[1],[1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(string(clrs)," ")],[string(win)],[sci2exp([])],[sci2exp(wdim)],[string(ymin)],[string(ymax)],[string(per)],[string(N)],[string([1])]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLINDUMMY_f.js b/history/data_structures/CLINDUMMY_f.js deleted file mode 100644 index 35ca987..0000000 --- a/history/data_structures/CLINDUMMY_f.js +++ /dev/null @@ -1,16 +0,0 @@ -function CLINDUMMY_f () { - - - var x0 = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cdummy"]),new ScilabDouble([4])); - model.state=new ScilabDouble([x0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,true]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLKFROM.js b/history/data_structures/CLKFROM.js deleted file mode 100644 index baa40ec..0000000 --- a/history/data_structures/CLKFROM.js +++ /dev/null @@ -1,16 +0,0 @@ -function CLKFROM () { - - - var model = scicos_model(); - model.sim = new ScilabString(["clkfrom"]); - model.evtout = new ScilabDouble([1]); - model.opar=list("A"); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = "A"; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs," "); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLKGOTO.js b/history/data_structures/CLKGOTO.js deleted file mode 100644 index eede81b..0000000 --- a/history/data_structures/CLKGOTO.js +++ /dev/null @@ -1,17 +0,0 @@ -function CLKGOTO () { - - - var model = scicos_model(); - model.sim = new ScilabString(["clkgoto"]); - model.evtin = new ScilabDouble([1]); - model.opar=list("A"); - model.ipar=int(1); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [["A"],[sci2exp(1)]]; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs," "); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLKGotoTagVisibility.js b/history/data_structures/CLKGotoTagVisibility.js deleted file mode 100644 index 5a164cf..0000000 --- a/history/data_structures/CLKGotoTagVisibility.js +++ /dev/null @@ -1,23 +0,0 @@ -function CLKGotoTagVisibility () { - - - var model = scicos_model(); - model.sim = new ScilabString(["clkgototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = "A"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLKINV_f.js b/history/data_structures/CLKINV_f.js deleted file mode 100644 index aa2d8dc..0000000 --- a/history/data_structures/CLKINV_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function CLKINV_f () { - - - var prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.evtout = new ScilabDouble([1]); - model.ipar=new ScilabDouble([prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(prt); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new EventInBlock(this.x) -} diff --git a/history/data_structures/CLKOUTV_f.js b/history/data_structures/CLKOUTV_f.js deleted file mode 100644 index 32f4ec9..0000000 --- a/history/data_structures/CLKOUTV_f.js +++ /dev/null @@ -1,17 +0,0 @@ -function CLKOUTV_f () { - - - var prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.evtin = new ScilabDouble([1]); - model.ipar=new ScilabDouble([prt]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(prt); - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs," "); - return new EventOutBlock(this.x) -} diff --git a/history/data_structures/CLKSOMV_f.js b/history/data_structures/CLKSOMV_f.js deleted file mode 100644 index 273ebc8..0000000 --- a/history/data_structures/CLKSOMV_f.js +++ /dev/null @@ -1,15 +0,0 @@ -function CLKSOMV_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["sum"]); - model.evtin = new ScilabDouble([1],[1],[1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new RoundBlock(this.x) -} diff --git a/history/data_structures/CLOCK_c.js b/history/data_structures/CLOCK_c.js deleted file mode 100644 index 339191e..0000000 --- a/history/data_structures/CLOCK_c.js +++ /dev/null @@ -1,48 +0,0 @@ -function CLOCK_c () { - - - var evtdly = EVTDLY_c("define"); - evtdly.graphics.orig = new ScilabDouble([320,232]); - evtdly.graphics.sz = new ScilabDouble([40,40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1";"0.1"]); - evtdly.graphics.pein = new ScilabDouble([6]); - evtdly.graphics.peout = new ScilabDouble([3]); - evtdly.model.rpar = new ScilabDouble([0.1],[0.1]); - evtdly.model.firing = new ScilabDouble([0.1]); - - var output_port = CLKOUT_f("define"); - output_port.graphics.orig = new ScilabDouble([399,162]); - output_port.graphics.sz = new ScilabDouble([20,20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1"]); - output_port.graphics.pein = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - - var split = CLKSPLIT_f("define"); - split.graphics.orig = new ScilabDouble([380.71066],[172]); - split.graphics.pein = new ScilabDouble([3]); - split.graphics.peout = new ScilabDouble([5],[6]); - - var gr_i = []; - - var diagram = scicos_diagram(); - diagram.objs.push(output_port); - diagram.objs.push(evtdly); - diagram.objs.push(scicos_link({xx: new ScilabDouble([340],[340],[380.71]),yy: new ScilabDouble([226.29],[172],[172]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1]),to: new ScilabDouble([4,1])})); - diagram.objs.push(split); - diagram.objs.push(scicos_link({xx: new ScilabDouble([380.71],[399]),yy: new ScilabDouble([172],[172]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([4,1]),to: new ScilabDouble([1,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([380.71],[380.71],[340],[340]),yy: new ScilabDouble([172],[302],[302],[277.71]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([4,2]),to: new ScilabDouble([2,1])})); - this.x=scicos_block(); - this.x.gui = new ScilabString(["CLOCK_c"]); - this.x.graphics.sz = new ScilabDouble([2,2]); - this.x.graphics.gr_i=gr_i; - this.x.graphics.peout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.firing = new ScilabBoolean([false]); - this.x.model.dep_ut = new ScilabBoolean([false,false]); - this.x.model.rpar=diagram; - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLR.js b/history/data_structures/CLR.js deleted file mode 100644 index d374d40..0000000 --- a/history/data_structures/CLR.js +++ /dev/null @@ -1,28 +0,0 @@ -function CLR () { - - - var x0 = 0; - - var A = -1; - - var B = 1; - - var C = 1; - - var D = 0; - - var exprs = ["1";"1+s"]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["csslti4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state=new ScilabDouble([x0]); - model.rpar = new ScilabDouble([...colon_operator(A,:)],[...B],[C(,)],[...D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CLSS.js b/history/data_structures/CLSS.js deleted file mode 100644 index d97157a..0000000 --- a/history/data_structures/CLSS.js +++ /dev/null @@ -1,32 +0,0 @@ -function CLSS () { - - - var x0 = 0; - - var A = -1; - - var B = 1; - - var C = 1; - - var D = 0; - - var in1 = 1; - - var out = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["csslti4"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([out]); - model.state=new ScilabDouble([x0]); - model.rpar = new ScilabDouble([...colon_operator(A,:)],[...B],[C(,)],[...D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [[strcat(sci2exp(A))],[strcat(sci2exp(B))],[strcat(sci2exp(C))],[strcat(sci2exp(D))],[strcat(sci2exp(x0))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CMAT3D.js b/history/data_structures/CMAT3D.js deleted file mode 100644 index 0d2fd8d..0000000 --- a/history/data_structures/CMAT3D.js +++ /dev/null @@ -1,35 +0,0 @@ -function CMAT3D () { - - - var cmin = 0; - - var cmax = 100; - - var colormap = jetcolormap(25); - - var size_c = 25; - this.x = new ScilabDouble([-1]); - - var y = -1; - - var size_x = 1; - - var size_y = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cmat3d"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([cmin],[cmax],[size_c],[size_x],[size_y]); - model.rpar = new ScilabDouble([...colormap],[x],[y]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(string(x)," ");strcat(string(y)," ");string("jetcolormap(25)")],[string(cmin)],[string(cmax)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CMATVIEW.js b/history/data_structures/CMATVIEW.js deleted file mode 100644 index 3a03930..0000000 --- a/history/data_structures/CMATVIEW.js +++ /dev/null @@ -1,32 +0,0 @@ -function CMATVIEW () { - - - var cmin = 0; - - var cmax = 100; - - var size_c = 25; - - var colormap = jetcolormap(size_c); - - var alpha_c = 0.24; - - var beta_c = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cmatview"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.ipar = new ScilabDouble([cmin],[cmax],[size_c]); - model.rpar = new ScilabDouble([alpha_c],[beta_c],[...colormap]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string("jetcolormap(25)")],[string(cmin)],[string(cmax)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CMSCOPE.js b/history/data_structures/CMSCOPE.js deleted file mode 100644 index b4d2e3d..0000000 --- a/history/data_structures/CMSCOPE.js +++ /dev/null @@ -1,42 +0,0 @@ -function CMSCOPE () { - - - var win = -1; - - var in1 = [[1],[1]]; - - var wdim = [[-1],[-1]]; - - var wpos = [[-1],[-1]]; - - var clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - - var N = 20; - - var ymin = [[-1],[-5]]; - - var ymax = [[1],[5]]; - - var per = [[30],[30]]; - - var yy = [[...transpose(ymin)],[...transpose(ymax)]]; - - var period = ...transpose(per); - - var model = scicos_model(); - model.sim=list(new ScilabString(["cmscope"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.in2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([1],[1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0],[...period],[...yy]); - model.ipar = new ScilabDouble([win;...colon_operator(size,in1,"*")],[N],[...wpos],[...wdim],[...in1],[clrs(1,sum(in1))]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(string(in1)," ");strcat(string(clrs)," ");string(win);sci2exp([]);sci2exp([]);strcat(string(ymin)," ");strcat(string(ymax)," ");strcat(string(per)," ")],[string(N)],[string(0)],[emptystr()]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONST.js b/history/data_structures/CONST.js deleted file mode 100644 index b34361e..0000000 --- a/history/data_structures/CONST.js +++ /dev/null @@ -1,19 +0,0 @@ -function CONST () { - - - var C = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cstblk4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar=new ScilabDouble([C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = strcat(sci2exp(C)); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONSTRAINT2_c.js b/history/data_structures/CONSTRAINT2_c.js deleted file mode 100644 index d24d40c..0000000 --- a/history/data_structures/CONSTRAINT2_c.js +++ /dev/null @@ -1,24 +0,0 @@ -function CONSTRAINT2_c () { - - - var x0 = [0]; - - var xd0 = [0]; - - var id = [0]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["constraint_c"]),new ScilabDouble([10004])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1],[1]); - model.state = new ScilabDouble([x0],[xd0]); - model.ipar=new ScilabDouble([id]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = list(strcat(sci2exp(x0)),strcat(sci2exp(xd0)),strcat(sci2exp(id))); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONSTRAINT_c.js b/history/data_structures/CONSTRAINT_c.js deleted file mode 100644 index 567ec0f..0000000 --- a/history/data_structures/CONSTRAINT_c.js +++ /dev/null @@ -1,20 +0,0 @@ -function CONSTRAINT_c () { - - - var x0 = [[0],[0]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["constraint_c"]),new ScilabDouble([10004])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.ipar = new ScilabDouble([0]); - model.state=new ScilabDouble([x0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = "0"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONST_f.js b/history/data_structures/CONST_f.js deleted file mode 100644 index 1983ae4..0000000 --- a/history/data_structures/CONST_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function CONST_f () { - - - var C = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cstblk"]),new ScilabDouble([1])); - model.in1 = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar=new ScilabDouble([C]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = strcat(sci2exp(C)); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONST_m.js b/history/data_structures/CONST_m.js deleted file mode 100644 index df53c9a..0000000 --- a/history/data_structures/CONST_m.js +++ /dev/null @@ -1,22 +0,0 @@ -function CONST_m () { - - - var C = [1]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cstblk4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble(); - model.out=size(C,1); - model.in2 = new ScilabDouble(); - model.out2.push(size(C,2)); - model.rpar=new ScilabDouble([C]); - model.opar=list(); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = sci2exp(C); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CONVERT.js b/history/data_structures/CONVERT.js deleted file mode 100644 index 2a467eb..0000000 --- a/history/data_structures/CONVERT.js +++ /dev/null @@ -1,24 +0,0 @@ -function CONVERT () { - - - var sgn = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["convert"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(1)],[sci2exp(3)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/COSBLK_f.js b/history/data_structures/COSBLK_f.js deleted file mode 100644 index bcd2120..0000000 --- a/history/data_structures/COSBLK_f.js +++ /dev/null @@ -1,16 +0,0 @@ -function COSBLK_f () { - - - var in1 = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["cosblk"]); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CSCOPE.js b/history/data_structures/CSCOPE.js deleted file mode 100644 index f67fec9..0000000 --- a/history/data_structures/CSCOPE.js +++ /dev/null @@ -1,35 +0,0 @@ -function CSCOPE () { - - - var win = -1; - - var wdim = [[600],[400]]; - - var wpos = [[-1],[-1]]; - - var clrs = [[1],[3],[5],[7],[9],[11],[13],[15]]; - - var N = 20; - - var ymin = -15; - - var ymax = +15; - - var per = 30; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cscope"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([0],[ymin],[ymax],[per]); - model.ipar = new ScilabDouble([win],[1],[N],[clrs],[wpos],[wdim]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(string(clrs)," ")],[string(win)],[sci2exp([])],[sci2exp(wdim)],[string(ymin)],[string(ymax)],[string(per)],[string(N)],[string(0)'],[emptystr()]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CSCOPXY.js b/history/data_structures/CSCOPXY.js deleted file mode 100644 index 17808c5..0000000 --- a/history/data_structures/CSCOPXY.js +++ /dev/null @@ -1,40 +0,0 @@ -function CSCOPXY () { - - - var win = -1; - - var clrs = 4],[siz=1; - - var wdim = [[600],[400]]; - - var wpos = [[-1],[-1]]; - - var N = 2; - - var xmin = -15; - - var xmax = 15; - - var ymin = -15; - - var ymax = +15; - - var nbr_curves = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cscopxy"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1]); - model.in2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([1],[1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([xmin],[xmax],[ymin],[ymax]); - model.ipar = new ScilabDouble([win],[1],[N],[clrs],[siz],[1],[...wpos],[...wdim],[nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(nbr_curves)],[sci2exp(clrs)],[sci2exp(siz)],[string(win)],[sci2exp([])],[sci2exp(wdim)],[string(xmin)],[string(xmax)],[string(ymin)],[string(ymax)],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CSCOPXY3D.js b/history/data_structures/CSCOPXY3D.js deleted file mode 100644 index 7a91623..0000000 --- a/history/data_structures/CSCOPXY3D.js +++ /dev/null @@ -1,42 +0,0 @@ -function CSCOPXY3D () { - - - var win = -1; - - var clrs = [[1],[2],[3],[4],[5],[6],[7],[13]]; - - var siz = [[1],[1],[1],[1],[1],[1],[1],[1]]; - - var wdim = [[600],[400]]; - - var wpos = [[-1],[-1]]; - - var N = 2; - - var param3ds = [[50],[280]]; - - var vec_x = [[-15],[15]]; - - var vec_y = [[-15],[15]]; - - var vec_z = [[-15],[15]]; - - var nbr_curves = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["cscopxy3d"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1],[1]); - model.in2 = new ScilabDouble([1],[1],[1]); - model.intyp = new ScilabDouble([1],[1],[1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([...colon_operator(vec_x,:)],[...vec_y],[vec_z(,)],[...param3ds]); - model.ipar = new ScilabDouble([win],[8],[N],[...colon_operator(clrs,:)],[...siz],[8],[wpos(,)],[...wdim],[nbr_curves]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(nbr_curves);strcat(string(clrs)," ");strcat(string(siz)," ");string(win);sci2exp([]);sci2exp(wdim);strcat(string(vec_x)," ");strcat(string(vec_y)," ");strcat(string(vec_z)," ");strcat(string(param3ds)," ")],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CUMSUM.js b/history/data_structures/CUMSUM.js deleted file mode 100644 index 6c076cf..0000000 --- a/history/data_structures/CUMSUM.js +++ /dev/null @@ -1,31 +0,0 @@ -function CUMSUM () { - - - var model = scicos_model(); - - var function_name = "cumsum_m"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CURV_f.js b/history/data_structures/CURV_f.js deleted file mode 100644 index 49e00bf..0000000 --- a/history/data_structures/CURV_f.js +++ /dev/null @@ -1,28 +0,0 @@ -function CURV_f () { - - - var xx = [[0],[1],[2]]; - - var yy = [[-5],[5],[0]]; - - var rect = [0,-5,2,5]; - - var axisdata = [[2],[10],[2],[10]]; - - var ipar = [[size(xx,1)],[...axisdata]]; - - var rpar = [[xx],[yy],[...rect]]; - - var model = scicos_model(); - model.sim = new ScilabString(["intplt"]); - model.in1 = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([xx],[yy],[...rect]); - model.ipar = new ScilabDouble([size(xx,1)],[...axisdata]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CVS.js b/history/data_structures/CVS.js deleted file mode 100644 index 5bfb5f9..0000000 --- a/history/data_structures/CVS.js +++ /dev/null @@ -1,30 +0,0 @@ -function CVS () { - - - var ModelName = "CVS"; - - var PrametersValue = []; - - var ParametersName = []; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[2,50,1,0],[,70,98,2,0],[70,2,-2,0]]; - - var PortName = ["vin";"p";"n"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Capacitor.js b/history/data_structures/Capacitor.js deleted file mode 100644 index c83bb8e..0000000 --- a/history/data_structures/Capacitor.js +++ /dev/null @@ -1,28 +0,0 @@ -function Capacitor () { - - - var model = scicos_model(); - - var C = 0.01,v=0; - model.rpar = new ScilabDouble([C],[v]); - model.sim = new ScilabString(["Capacitor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Capacitor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["C"),new ScilabString(["v"]]),list(C,v),new ScilabDouble([0),new ScilabDouble([1]])); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = string([C],[v]); - - var gr_i = []; - this.x=standard_define([2,1.1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ConstantVoltage.js b/history/data_structures/ConstantVoltage.js deleted file mode 100644 index add8be1..0000000 --- a/history/data_structures/ConstantVoltage.js +++ /dev/null @@ -1,27 +0,0 @@ -function ConstantVoltage () { - - - var V = 0.01; - - var model = scicos_model(); - model.rpar=new ScilabDouble([V]); - model.in1 = new ScilabDouble([1],[model.out=1]); - model.sim = new ScilabString(["ConstantVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var mo = modelica(); - mo.model = new ScilabString(["ConstantVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["V"]),list(V)); - model.equations=mo; - - var exprs = string(V); - - var gr_i = []; - this.x=standard_define([1.5,1.1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Counter.js b/history/data_structures/Counter.js deleted file mode 100644 index 9fcff45..0000000 --- a/history/data_structures/Counter.js +++ /dev/null @@ -1,25 +0,0 @@ -function Counter () { - - - var minim = 0; - - var maxim = 2; - - var rule = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["counter"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([rule],[maxim],[minim]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(minim)],[string(maxim)],[string(rule)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/CurrentSensor.js b/history/data_structures/CurrentSensor.js deleted file mode 100644 index 386fa14..0000000 --- a/history/data_structures/CurrentSensor.js +++ /dev/null @@ -1,24 +0,0 @@ -function CurrentSensor () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1],[,1]); - model.sim = new ScilabString(["CurrentSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["CurrentSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n";"i"]); - model.equations=mo; - - var exprs = []; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I";"E"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DEADBAND.js b/history/data_structures/DEADBAND.js deleted file mode 100644 index b5c34e3..0000000 --- a/history/data_structures/DEADBAND.js +++ /dev/null @@ -1,25 +0,0 @@ -function DEADBAND () { - - - var minp = -.5; - - var maxp = .5; - - var rpar = [[maxp],[minp]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["deadband"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar=rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(maxp)],[string(minp)],[string(model.nmode)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DEBUG.js b/history/data_structures/DEBUG.js deleted file mode 100644 index 6d610ad..0000000 --- a/history/data_structures/DEBUG.js +++ /dev/null @@ -1,13 +0,0 @@ -function DEBUG () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["%debug_scicos"]),new ScilabDouble([99])); - model.blocktype = new ScilabString(["d"]); - - var exprs = list("","xcos_debug_gui(flag,block);"); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([8,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DELAYV_f.js b/history/data_structures/DELAYV_f.js deleted file mode 100644 index f262231..0000000 --- a/history/data_structures/DELAYV_f.js +++ /dev/null @@ -1,29 +0,0 @@ -function DELAYV_f () { - - - var nin = 1; - - var z0 = zeros(11,1); - - var zz0 = ...colon_operator(z0,1,$-1); - - var T = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["delayv"]),new ScilabDouble([1])); - model.in1 = new ScilabDouble([nin],[1]); - model.out=new ScilabDouble([nin]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1],[1]); - model.dstate=z0; - model.rpar=T/(size(zz0,"*")); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0,-1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[...colon_operator(string,nin);strcat(string(z0(1,$-1)),";")],[string(T)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DELAY_f.js b/history/data_structures/DELAY_f.js deleted file mode 100644 index 9f2ea31..0000000 --- a/history/data_structures/DELAY_f.js +++ /dev/null @@ -1,72 +0,0 @@ -function DELAY_f () { - - - var evtdly = EVTDLY_f("define"); - evtdly.graphics.orig = new ScilabDouble([243,296]); - evtdly.graphics.sz = new ScilabDouble([40,40]); - evtdly.graphics.flip = new ScilabBoolean([true]); - evtdly.graphics.exprs = new ScilabString(["0.1";"0"]); - evtdly.graphics.pein = new ScilabDouble([10]); - evtdly.graphics.peout = new ScilabDouble([7]); - evtdly.model.rpar = new ScilabDouble([0.1]); - evtdly.model.firing = new ScilabDouble([0]); - - var register = REGISTER_f("define"); - register.graphics.orig = new ScilabDouble([238,195]); - register.graphics.sz = new ScilabDouble([50,50]); - register.graphics.flip = new ScilabBoolean([true]); - register.graphics.exprs = new ScilabString(["0;0;0;0;0;0;0;0;0;0"]); - register.graphics.pin = new ScilabDouble([6]); - register.graphics.pout = new ScilabDouble([5]); - register.graphics.pein = new ScilabDouble([9]); - - var input_port = IN_f("define"); - input_port.graphics.orig = new ScilabDouble([92,210]); - input_port.graphics.sz = new ScilabDouble([20,20]); - input_port.graphics.flip = new ScilabBoolean([true]); - input_port.graphics.exprs = new ScilabString(["1";"1"]); - input_port.graphics.pout = new ScilabDouble([6]); - input_port.model.ipar = new ScilabDouble([1]); - - var output_port = OUT_f("define"); - output_port.graphics.orig = new ScilabDouble([440,210]); - output_port.graphics.sz = new ScilabDouble([20,20]); - output_port.graphics.flip = new ScilabBoolean([true]); - output_port.graphics.exprs = new ScilabString(["1";"1"]); - output_port.graphics.pin = new ScilabDouble([5]); - output_port.model.ipar = new ScilabDouble([1]); - - var split = CLKSPLIT_f("define"); - split.graphics.orig = new ScilabDouble([263],[271.2]); - split.graphics.pein = new ScilabDouble([7]); - split.graphics.peout = new ScilabDouble([9],[10]); - - var diagram = scicos_diagram(); - diagram.objs.push(input_port); - diagram.objs.push(output_port); - diagram.objs.push(register); - diagram.objs.push(evtdly); - diagram.objs.push(scicos_link({xx: new ScilabDouble([296.6],[440]),yy: new ScilabDouble([220],[220]),from: new ScilabDouble([3,1]),to: new ScilabDouble([2,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([112],[229.4]),yy: new ScilabDouble([220],[220]),from: new ScilabDouble([1,1]),to: new ScilabDouble([3,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([263],[263]),yy: new ScilabDouble([290.3],[271.2]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([4,1]),to: new ScilabDouble([8,1])})); - diagram.objs.push(split); - diagram.objs.push(scicos_link({xx: new ScilabDouble([263],[263]),yy: new ScilabDouble([271.2],[250.7]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([8,1]),to: new ScilabDouble([3,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([263],[308.6],[308.6],[263],[263]),yy: new ScilabDouble([271.2],[271.2],[367],[367],[341.7]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([8,2]),to: new ScilabDouble([4,1])})); - this.x=scicos_block(); - this.x.gui = new ScilabString(["DELAY_f"]); - this.x.graphics.sz = new ScilabDouble([2,2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in1 = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false,false]); - this.x.model.rpar=diagram; - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DEMUX.js b/history/data_structures/DEMUX.js deleted file mode 100644 index 083b3ec..0000000 --- a/history/data_structures/DEMUX.js +++ /dev/null @@ -1,20 +0,0 @@ -function DEMUX () { - - - var out = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["multiplex"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([0]); - model.out=-...transpose([1:out]); - model.ipar=new ScilabDouble([out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(out); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DEMUX_f.js b/history/data_structures/DEMUX_f.js deleted file mode 100644 index 161b4a1..0000000 --- a/history/data_structures/DEMUX_f.js +++ /dev/null @@ -1,20 +0,0 @@ -function DEMUX_f () { - - - var out = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["demux"]),new ScilabDouble([1])); - model.in1 = new ScilabDouble([0]); - model.out=-...transpose([1:out]); - model.ipar=new ScilabDouble([out]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(out); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DERIV.js b/history/data_structures/DERIV.js deleted file mode 100644 index 12f3503..0000000 --- a/history/data_structures/DERIV.js +++ /dev/null @@ -1,16 +0,0 @@ -function DERIV () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["deriv"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = []; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DFLIPFLOP.js b/history/data_structures/DFLIPFLOP.js deleted file mode 100644 index ef30761..0000000 --- a/history/data_structures/DFLIPFLOP.js +++ /dev/null @@ -1,97 +0,0 @@ -function DFLIPFLOP () { - - - var scs_m = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["DFLIPFLOP"],tol=[0.0001,0.000001,1.000E-10,100001,0,0],tf=100000,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m.objs.push(scicos_block(gui="CONST_m",graphics=scicos_graphics(orig=[109.62561,263.44465],sz=[20;20],flip=%t,theta=0,exprs="int8(0)",pin=[],pout=6,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("cstblk4_m",4),in1=[],in2=[],intyp=1,out=1,out2=1,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(new ScilabInteger([0])),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[239.98293,378.2166],sz=[60,60],flip=%t,theta=0,exprs=["1";"1"],pin=29,pout=[],pein=22,peout=[16;44],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=1,intyp=-1,out=[],out2=[],outtyp=1,evtin=1,evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=1,nmode=1,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="LOGICAL_OP",graphics=scicos_graphics(orig=[152.88902,260.24498],sz=[60,40],flip=%t,theta=0,exprs=["2";"1";"5";"0"],pin=[11;39],pout=5,pein=[],peout=[],gr_i=[],id="",in_implicit=["E";"E"],out_implicit="E"),model=scicos_model(sim=list("logicalop_i8",4),in1=[-1;-1],in2=[-2;-2],intyp=[5;5],out=-1,out2=-2,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[1;0],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="SAMPHOLD_m",graphics=scicos_graphics(orig=[233.72156,260.24498],sz=[40,40],flip=%t,theta=0,exprs="5",pin=5,pout=33,pein=42,peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("samphold4_m",4),in1=-1,in2=-2,intyp=5,out=-1,out2=-2,outtyp=5,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([221.46044),yy: new ScilabDouble([280.24498),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([4,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([138.19704),yy: new ScilabDouble([273.44465),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([38,1,1])})); - scs_m.objs.push(scicos_block(gui="LOGICAL_OP",graphics=scicos_graphics(orig=[373.24106,309.46812],sz=[60,40],flip=%t,theta=0,exprs=["1";"5";"5";"0"],pin=36,pout=13,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("logicalop_i8",4),in1=-1,in2=-2,intyp=5,out=-1,out2=-2,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[5;0],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[199.48466,398.2166],sz=[20,20],flip=%t,theta=0,exprs="3",pin=[],pout=9,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=3,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([219.48466),yy: new ScilabDouble([408.2166),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([8,1,0]),to: new ScilabDouble([28,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[104.31759,276.91165],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=11,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([124.31759),yy: new ScilabDouble([286.91165),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([10,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[457.40928,320.20131],sz=[20,20],flip=%t,theta=0,exprs="2",pin=13,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([441.81249),yy: new ScilabDouble([329.46812),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([7,1,0]),to: new ScilabDouble([12,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[376.4669,270.83282],sz=[20,20],flip=%t,theta=0,exprs="1",pin=37,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title="Untitled",tol=[0.0001,0.000001,1.000E-10,100001,0,0],tf=100000,context=[],void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="ANDLOG_f",graphics=scicos_graphics(orig=[194,133],sz=[60,60],flip=%t,theta=0,exprs=[],pin=[],pout=9,pein=[4;11],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="andlog",in1=[],in2=[],intyp=1,out=1,out2=[],outtyp=1,evtin=[1;1],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="CLKIN_f",graphics=scicos_graphics(orig=[149,287],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=[],peout=4,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=-1,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="CLKOUT_f",graphics=scicos_graphics(orig=[450,83],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=8,peout=[],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="output",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([169),yy: new ScilabDouble([297),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1]),to: new ScilabDouble([1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKIN_f",graphics=scicos_graphics(orig=[141,330],sz=[20,20],flip=%t,theta=0,exprs="2",pin=[],pout=[],pein=[],peout=6,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="d",firing=-1,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([161),yy: new ScilabDouble([340),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([5,1]),to: new ScilabDouble([10,1])})); - scs_m_1.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[331,137],sz=[60,60],flip=%t,theta=0,exprs=["1";"1"],pin=9,pout=[],pein=12,peout=[8;0],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=1,intyp=-1,out=[],out2=[],outtyp=1,evtin=1,evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=1,nmode=1,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([351),yy: new ScilabDouble([131.29),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([7,1]),to: new ScilabDouble([3,1])})); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([262.57),yy: new ScilabDouble([163),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1]),to: new ScilabDouble([7,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKSPLIT_f",graphics=scicos_graphics(orig=[234;275.78348],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=[],pout=[],pein=6,peout=[11;12],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="split",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[%f,%f,%f],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([234),yy: new ScilabDouble([275.78),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([10,1]),to: new ScilabDouble([1,2])})); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([234),yy: new ScilabDouble([275.78),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([10,2]),to: new ScilabDouble([7,1])})); - scs_m.objs.push(scicos_block(gui="ANDBLK",graphics=scicos_graphics(orig=[233.73039,318.74407],sz=[40,40],flip=%t,theta=0,exprs=[],pin=[],pout=[],pein=[19;16],peout=17,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="csuper",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[1;1],evtout=1,state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=%f,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([259.98293),yy: new ScilabDouble([372.50232),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([15,2,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([253.73039),yy: new ScilabDouble([313.02978),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([15,1,0]),to: new ScilabDouble([41,1,1])})); - scs_m_1.push(tlist(new ScilabString([600,450,0,0,600,450]),props=scicos_params(wpar=,Title=,tol=,tf=30,context=" ",void1=,options=tlist(,list(%t,new ScilabDouble([33)]),,,list(,),),void2=,void3=,doc=list()))); - scs_m_1.objs.push(scicos_block(gui="EDGETRIGGER",graphics=scicos_graphics(orig=[288.58631,257.1131],sz=[60,40],flip=%t,theta=0,exprs="1",pin=5,pout=3,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("edgetrig",4),in1=1,in2=[],intyp=1,out=1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=0,odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=1,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[388.28869,247.1131],sz=[60,60],flip=%t,theta=0,exprs=["0";"0"],pin=3,pout=[],pein=[],peout=[7;0],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=[],intyp=1,out=[],out2=1,outtyp=[],evtin=[],evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([357.15774),yy: new ScilabDouble([277.1131),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m_1.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[240.01488,267.1131],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=5,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=-1,out=-1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([260.01488),yy: new ScilabDouble([277.1131),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([4,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKOUTV_f",graphics=scicos_graphics(orig=[398.28869,181.39881],sz=[20,30],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=7,peout=[],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="output",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([408.28869),yy: new ScilabDouble([241.39881),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([6,1,1])})); - scs_m.objs.push(scicos_block(gui="EDGE_TRIGGER",graphics=scicos_graphics(orig=[133.90637,385.342],sz=[60,40],flip=%t,theta=0,exprs=[],pin=26,pout=[],pein=[],peout=19,gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="csuper",in1=-1,in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([163.90637),yy: new ScilabDouble([379.62771),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([18,1,0]),to: new ScilabDouble([15,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[79.594811,395.47647],sz=[20,20],flip=%t,theta=0,exprs="2",pin=[],pout=23,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.push(tlist(new ScilabString([600,450,0,0,600,450]),props=scicos_params(wpar=,Title=,tol=,tf=30,context=" ",void1=,options=tlist(,list(%t,new ScilabDouble([33)]),,,list(,),),void2=,void3=,doc=list()))); - scs_m_1.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[150.65045,143.82208],sz=[60,60],flip=%t,theta=0,exprs=["0";"0"],pin=6,pout=[],pein=[],peout=[3;4],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="CLKSOMV_f",graphics=scicos_graphics(orig=[169.82143,96.146231],sz=[16.666667,16.666667],flip=%t,theta=0,exprs=[],pin=[],pout=[],pein=[3;4;0],peout=8,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="sum",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[1;1;1],evtout=1,state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=-1,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([170.65045),yy: new ScilabDouble([138.10779),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([190.65045),yy: new ScilabDouble([138.10779),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([1,2,0]),to: new ScilabDouble([2,2,1])})); - scs_m_1.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[102.07902,163.82208],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=6,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=-1,out=-1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([122.07902),yy: new ScilabDouble([173.82208),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([5,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKOUTV_f",graphics=scicos_graphics(orig=[168.15476,38.527183],sz=[20,30],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=8,peout=[],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="output",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([178.15476),yy: new ScilabDouble([98.527183),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([7,1,1])})); - scs_m.objs.push(scicos_block(gui="Extract_Activation",graphics=scicos_graphics(orig=[239.82193,456.57677],sz=[60,40],flip=%t,theta=0,exprs=[],pin=31,pout=[],pein=[],peout=22,gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="csuper",in1=-1,in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([269.82193),yy: new ScilabDouble([450.86248),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([21,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([99.594811),yy: new ScilabDouble([405.47647),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([20,1,0]),to: new ScilabDouble([25,1,1])})); - scs_m.objs.push(scicos_block(gui="SUM_f",graphics=scicos_graphics(orig=[200.5252,469.13173],sz=[16.666667,16.666667],flip=%t,theta=0,exprs=[],pin=[27;0;30],pout=31,pein=[],peout=[],gr_i=[],id="",in_implicit=["E";"E";"E"],out_implicit="E"),model=scicos_model(sim=list("plusblk",2),in1=[-1;-1;-1],in2=[],intyp=1,out=-1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[110.25582;405.42077],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=23,pout=[26;27],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([110.25582),yy: new ScilabDouble([405.42077),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([25,1,0]),to: new ScilabDouble([18,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([110.25582),yy: new ScilabDouble([405.42077),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([25,2,0]),to: new ScilabDouble([24,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[222.54128;408.2166],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=9,pout=[29;30],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([222.54128),yy: new ScilabDouble([408.2166),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([28,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([222.54128),yy: new ScilabDouble([408.2166),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([28,2,0]),to: new ScilabDouble([24,3,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([219.57282),yy: new ScilabDouble([477.46506),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([24,1,0]),to: new ScilabDouble([21,1,1])})); - scs_m.objs.push(scicos_block(gui="SELECT_m",graphics=scicos_graphics(orig=[298.86371,253.57321],sz=[40,40],flip=%t,theta=0,exprs=["5";"2";"1"],pin=[33;40],pout=34,pein=[43;44],peout=[],gr_i=[],id="",in_implicit=["E";"E"],out_implicit="E"),model=scicos_model(sim=list("selector_m",4),in1=[-1;-1],in2=[-2;-2],intyp=[5;5],out=-1,out2=-2,outtyp=5,evtin=[1;1],evtout=[],state=[],dstate=1,odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([282.29299),yy: new ScilabDouble([280.24498),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([4,1,0]),to: new ScilabDouble([32,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([347.43514),yy: new ScilabDouble([273.57321),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([32,1,0]),to: new ScilabDouble([35,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[357.57328,280.83282],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=34,pout=[36;37],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([357.57328),yy: new ScilabDouble([280.83282),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([35,1,0]),to: new ScilabDouble([7,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([357.57328),yy: new ScilabDouble([280.83282),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([35,2,0]),to: new ScilabDouble([14,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[140.34523;273.49157],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=6,pout=[39;40],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([140.34523),yy: new ScilabDouble([273.49157),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([38,1,0]),to: new ScilabDouble([3,2,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([140.34523),yy: new ScilabDouble([273.49157),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([38,2,0]),to: new ScilabDouble([32,2,1])})); - scs_m.objs.push(scicos_block(gui="CLKSPLIT_f",graphics=scicos_graphics(orig=[253.72572;309.29537],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=[],pout=[],pein=17,peout=[42;43],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="split",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[%f,%f,%f],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([253.72572),yy: new ScilabDouble([309.29537),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([41,1,0]),to: new ScilabDouble([4,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([253.72572),yy: new ScilabDouble([309.29537),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([41,2,0]),to: new ScilabDouble([32,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([279.98293),yy: new ScilabDouble([372.50232),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,2,0]),to: new ScilabDouble([32,2,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1],[1],[1]); - model.in2 = new ScilabDouble([1],[1],[1]); - model.out = new ScilabDouble([1],[1]); - model.out2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([5,1,1]); - model.outtyp = new ScilabDouble([5,5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true,false]); - model.rpar=scs_m; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DIFF_f.js b/history/data_structures/DIFF_f.js deleted file mode 100644 index 18b0711..0000000 --- a/history/data_structures/DIFF_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function DIFF_f () { - - - var x0 = [[0],[0]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["diffblk"]),new ScilabDouble([10001])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state=new ScilabDouble([x0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [[strcat(sci2exp(x0(1)))],[strcat(sci2exp(x0(2)))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DLATCH.js b/history/data_structures/DLATCH.js deleted file mode 100644 index f2d9e89..0000000 --- a/history/data_structures/DLATCH.js +++ /dev/null @@ -1,41 +0,0 @@ -function DLATCH () { - - - var scs_m = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["DLATCH"],tol=[0.0001,0.000001,1.000E-10,100001,0,0],tf=100000,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m.objs.push(scicos_block(gui="CONST_m",graphics=scicos_graphics(orig=[109.62561,263.44465],sz=[20;20],flip=%t,theta=0,exprs="int8(0)",pin=[],pout=7,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("cstblk4_m",4),in1=[],in2=[],intyp=1,out=1,out2=1,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(new ScilabInteger([0])),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[233.37693,320.30536],sz=[60,60],flip=%t,theta=0,exprs=["0";"1"],pin=13,pout=[],pein=[],peout=[6;0],gr_i=list(["txt=[''If,in>0'';'','';'',then, , else'']";"xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');"],8),id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=1,intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=1,nmode=1,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="LOGICAL_OP",graphics=scicos_graphics(orig=[152.88902,260.24498],sz=[60,40],flip=%t,theta=0,exprs=["2";"1";"5";"0"],pin=[15;7],pout=5,pein=[],peout=[],gr_i=list("xstringb(orig(1),orig(2),[''Logical,Op,'';OPER],sz(1),sz(2),''fill'');",8),id="",in_implicit=["E";"E"],out_implicit="E"),model=scicos_model(sim=list("logicalop_i8",4),in1=[-1;-1],in2=[-2;-2],intyp=[5;5],out=-1,out2=-2,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[1;0],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="SAMPHOLD_m",graphics=scicos_graphics(orig=[233.72156,260.24498],sz=[40,40],flip=%t,theta=0,exprs="5",pin=5,pout=9,pein=6,peout=[],gr_i=list("xstringb(orig(1),orig(2),''S/H'',sz(1),sz(2),''fill'')",8),id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("samphold4_m",4),in1=-1,in2=-2,intyp=5,out=-1,out2=-2,outtyp=5,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([221.46044),yy: new ScilabDouble([280.24498),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([4,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([253.37693),yy: new ScilabDouble([314.59108),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([4,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([138.19704),yy: new ScilabDouble([273.44465),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([3,2,1])})); - scs_m.objs.push(scicos_block(gui="LOGICAL_OP",graphics=scicos_graphics(orig=[317.46698,309.46812],sz=[60,40],flip=%t,theta=0,exprs=["1";"5";"5";"0"],pin=11,pout=17,pein=[],peout=[],gr_i=list("xstringb(orig(1),orig(2),[''Logical,Op,'';OPER],sz(1),sz(2),''fill'');",8),id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("logicalop_i8",4),in1=-1,in2=-2,intyp=5,out=-1,out2=-2,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[5;0],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([282.29299),yy: new ScilabDouble([280.24498),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([4,1,0]),to: new ScilabDouble([10,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[305.09603,280.83282],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=9,pout=[11;19],pein=[],peout=[],gr_i=list([],8),id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([305.09603),yy: new ScilabDouble([280.83282),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([10,1,0]),to: new ScilabDouble([8,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[184.8055,340.30536],sz=[20,20],flip=%t,theta=0,exprs="2",pin=[],pout=13,pein=[],peout=[],gr_i=list(" ",8),id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([204.8055),yy: new ScilabDouble([350.30536),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([12,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[104.31759,276.91165],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=15,pein=[],peout=[],gr_i=list(" ",8),id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([124.31759),yy: new ScilabDouble([286.91165),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([14,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[406.03841,319.46812],sz=[20,20],flip=%t,theta=0,exprs="2",pin=17,pout=[],pein=[],peout=[],gr_i=list(" ",8),id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([386.03841),yy: new ScilabDouble([329.46812),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([8,1,0]),to: new ScilabDouble([16,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[325.09603,270.83282],sz=[20,20],flip=%t,theta=0,exprs="1",pin=19,pout=[],pein=[],peout=[],gr_i=list(" ",8),id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([305.09603),yy: new ScilabDouble([280.83282),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([10,2,0]),to: new ScilabDouble([18,1,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1],[1]); - model.in2 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1],[1]); - model.out2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([5,-1]); - model.outtyp = new ScilabDouble([5,5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true,false]); - model.rpar=scs_m; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DLR.js b/history/data_structures/DLR.js deleted file mode 100644 index a42f9d9..0000000 --- a/history/data_structures/DLR.js +++ /dev/null @@ -1,29 +0,0 @@ -function DLR () { - - - var x0 = 0; - - var A = -1; - - var B = 1; - - var C = 1; - - var D = 0; - - var exprs = ["1";"1+z"]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["dsslti4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate=...x0; - model.rpar = new ScilabDouble([...colon_operator(A,:)],[...B],[C(,)],[...D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DLRADAPT_f.js b/history/data_structures/DLRADAPT_f.js deleted file mode 100644 index 08e7047..0000000 --- a/history/data_structures/DLRADAPT_f.js +++ /dev/null @@ -1,33 +0,0 @@ -function DLRADAPT_f () { - - - var p = [[0],[1]]; - - var rn = []; - - var rd = [[0.2+0.8*%i,0.2-0.8*%i],[0.3+0.7*%i,0.3-0.7*%i]]; - - var g = [[1],[1]]; - - var last_u = []; - - var last_y = [[0],[0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["dlradp"]); - model.in1 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([last_u],[last_y]); - model.rpar = new ScilabDouble([...colon_operator(p,:)],[real(...rn)],[imag(...rn)],[real(...rd)],[imag(rd(,))],[...g]); - model.ipar = new ScilabDouble([0],[2],[2]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(p)],[sci2exp(rn)],[sci2exp(rd,0)],[sci2exp(g)],[sci2exp(last_u)],[sci2exp(last_y)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DLSS.js b/history/data_structures/DLSS.js deleted file mode 100644 index e946ae2..0000000 --- a/history/data_structures/DLSS.js +++ /dev/null @@ -1,29 +0,0 @@ -function DLSS () { - - - var x0 = 0; - - var A = -1; - - var B = 1; - - var C = 1; - - var D = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["dsslti4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate=...x0; - model.rpar = new ScilabDouble([...colon_operator(A,:)],[...B],[C(,)],[...D]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[strcat(sci2exp(A))],[strcat(sci2exp(B))],[strcat(sci2exp(C))],[strcat(sci2exp(D))],[strcat(sci2exp(x0))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DOLLAR.js b/history/data_structures/DOLLAR.js deleted file mode 100644 index b88da24..0000000 --- a/history/data_structures/DOLLAR.js +++ /dev/null @@ -1,24 +0,0 @@ -function DOLLAR () { - - - var z = 0; - - var inh = 0; - - var in1 = 1; - - var exprs = string([z],[inh]); - - var model = scicos_model(); - model.sim=list(new ScilabString(["dollar4"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([in1]); - model.evtin = new ScilabDouble([1-inh]); - model.dstate=new ScilabDouble([z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DOLLAR_f.js b/history/data_structures/DOLLAR_f.js deleted file mode 100644 index 19d03d4..0000000 --- a/history/data_structures/DOLLAR_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function DOLLAR_f () { - - - var z = 0; - - var inh = 0; - - var in1 = 1; - - var exprs = string([z],[inh]); - - var model = scicos_model(); - model.sim = new ScilabString(["dollar"]); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([in1]); - model.evtin = new ScilabDouble([1-inh]); - model.dstate=new ScilabDouble([z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/DOLLAR_m.js b/history/data_structures/DOLLAR_m.js deleted file mode 100644 index 155f35b..0000000 --- a/history/data_structures/DOLLAR_m.js +++ /dev/null @@ -1,24 +0,0 @@ -function DOLLAR_m () { - - - var z = 0; - - var inh = 0; - - var in1 = 1; - - var exprs = string([z],[inh]); - - var model = scicos_model(); - model.sim=list(new ScilabString(["dollar4"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([in1]); - model.evtin = new ScilabDouble([1-inh]); - model.dstate=new ScilabDouble([z]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Diode.js b/history/data_structures/Diode.js deleted file mode 100644 index 3c2d979..0000000 --- a/history/data_structures/Diode.js +++ /dev/null @@ -1,34 +0,0 @@ -function Diode () { - - - var Ids = 1.e-6; - - var Vt = 0.04; - - var Maxexp = 15; - - var R = 1.e8; - - var model = scicos_model(); - model.rpar = new ScilabDouble([Ids],[Vt],[Maxexp],[R]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.sim = new ScilabString(["Diode"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Diode"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["Ids"),new ScilabString(["Vt"]),new ScilabString(["Maxexp"]),new ScilabString(["R"]]),list(Ids,Vt,Maxexp,R)); - model.equations=mo; - - var exprs = string([Ids],[Vt],[Maxexp],[R]); - - var gr_i = []; - this.x=standard_define([2,1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EDGE_TRIGGER.js b/history/data_structures/EDGE_TRIGGER.js deleted file mode 100644 index 0ca790b..0000000 --- a/history/data_structures/EDGE_TRIGGER.js +++ /dev/null @@ -1,87 +0,0 @@ -function EDGE_TRIGGER () { - - - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(EDGETRIGGER("define")); - scs_m_1.objs.push(IFTHEL_f("define")); - scs_m_1.objs.push(IN_f("define")); - scs_m_1.objs.push(CLKOUTV_f("define")); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs(1); - - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([60,0]); - graphics.sz = new ScilabDouble([60,40]); - graphics.exprs = new ScilabString(["0"]); - model.ipar = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([5]); - graphics.pout = new ScilabDouble([6]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(2); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([160,0]); - graphics.sz = new ScilabDouble([60,40]); - graphics.exprs = new ScilabString(["0";"0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([7],[0]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(3); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([0,10]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([5]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(4); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([170,-60]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([7]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - - var lnk = scs_m_1.objs(5); - lnk.from = new ScilabDouble([3,1,0]); - lnk.to = new ScilabDouble([1,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(6); - lnk.from = new ScilabDouble([1,1,0]); - lnk.to = new ScilabDouble([2,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(7); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([2,1,0]); - lnk.to = new ScilabDouble([4,1,1]); - scs_m_1.objs.push(lnk); - clear blk lnk - model=scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar=scs_m_1; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ENDBLK.js b/history/data_structures/ENDBLK.js deleted file mode 100644 index cc253ef..0000000 --- a/history/data_structures/ENDBLK.js +++ /dev/null @@ -1,13 +0,0 @@ -function ENDBLK () { - - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[-159.096,811.104,-121.216,617.984,1323,1008,331,284,630,480,0,7,1.4],Title="ENDBLK",tol=[0.0001,0.000001,1.000E-10,100001,0,0],tf=100000,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="END_c",graphics=scicos_graphics(orig=[272.104,249.11733],sz=[40,40],flip=%t,theta=0,exprs="1.000E+08",pin=[],pout=[],pein=2,peout=2,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim=list("scicosexit",4),in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=1,state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=1.000E+08,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([292.104),yy: new ScilabDouble([243.40305),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([1,1,1])})); - - var model = scicos_model(sim="csuper",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/END_c.js b/history/data_structures/END_c.js deleted file mode 100644 index 027d6ca..0000000 --- a/history/data_structures/END_c.js +++ /dev/null @@ -1,19 +0,0 @@ -function END_c () { - - - var tf = 100000000; - - var model = scicos_model(); - model.sim=list(new ScilabString(["scicosexit"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.firing=new ScilabDouble([tf]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(tf); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ESELECT_f.js b/history/data_structures/ESELECT_f.js deleted file mode 100644 index 7831538..0000000 --- a/history/data_structures/ESELECT_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function ESELECT_f () { - - - var out = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["eselect"]),new ScilabDouble([-2])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([1]); - model.evtout=ones(out,1); - model.blocktype = new ScilabString(["l"]); - model.firing=-ones(out,1); - model.dep_ut = new ScilabBoolean([true,false]); - model.nmode = new ScilabDouble([0]); - model.nzcross = new ScilabDouble([0]); - - var gr_i = []; - - var exprs = [[string(out)],[string(1)],[string(model.nmode)]]; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EVTDLY_c.js b/history/data_structures/EVTDLY_c.js deleted file mode 100644 index 7ada20f..0000000 --- a/history/data_structures/EVTDLY_c.js +++ /dev/null @@ -1,22 +0,0 @@ -function EVTDLY_c () { - - - var dt = 0.1; - - var ff = 0.0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["evtdly4"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([dt],[ff]); - model.blocktype = new ScilabString(["d"]); - model.firing=new ScilabDouble([ff]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(dt)],[sci2exp(ff)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EVTGEN_f.js b/history/data_structures/EVTGEN_f.js deleted file mode 100644 index dc7754e..0000000 --- a/history/data_structures/EVTGEN_f.js +++ /dev/null @@ -1,18 +0,0 @@ -function EVTGEN_f () { - - - var tt = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing=new ScilabDouble([tt]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(tt); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EVTVARDLY.js b/history/data_structures/EVTVARDLY.js deleted file mode 100644 index 075c318..0000000 --- a/history/data_structures/EVTVARDLY.js +++ /dev/null @@ -1,19 +0,0 @@ -function EVTVARDLY () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["evtvardly"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(model.firing); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXPBLK_m.js b/history/data_structures/EXPBLK_m.js deleted file mode 100644 index 7cfd9af..0000000 --- a/history/data_structures/EXPBLK_m.js +++ /dev/null @@ -1,25 +0,0 @@ -function EXPBLK_m () { - - - var in1 = 1; - - var a = %e; - - var model = scicos_model(); - model.sim=list(new ScilabString(["expblk_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar=new ScilabBoolean([a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = ["%e"]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXPRESSION.js b/history/data_structures/EXPRESSION.js deleted file mode 100644 index aad864c..0000000 --- a/history/data_structures/EXPRESSION.js +++ /dev/null @@ -1,28 +0,0 @@ -function EXPRESSION () { - - - var in1 = [[1],[1]]; - - var out = 1; - - var txt = "(u1>0)*sin(u2)^2"; - deff("%foo(u1,u2)",txt) - - var [%ok1,ipar,rpar,nz] = compile_expr(%foo); - - var model = scicos_model(); - model.sim=list(new ScilabString(["evaluate_expr"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([out]); - model.rpar=rpar; - model.ipar=ipar; - model.nzcross=nz; - model.nmode=nz; - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string(size(in1,"*"));txt;"1"]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXTRACT.js b/history/data_structures/EXTRACT.js deleted file mode 100644 index 71f82b7..0000000 --- a/history/data_structures/EXTRACT.js +++ /dev/null @@ -1,31 +0,0 @@ -function EXTRACT () { - - - var model = scicos_model(); - - var function_name = "extract"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1,1,1,1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp([1])],[sci2exp([1])]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXTRACTBITS.js b/history/data_structures/EXTRACTBITS.js deleted file mode 100644 index a7e621b..0000000 --- a/history/data_structures/EXTRACTBITS.js +++ /dev/null @@ -1,23 +0,0 @@ -function EXTRACTBITS () { - - - var numb = []; - - var model = scicos_model(); - model.sim=list(new ScilabString(["extract_bit_32_UH0"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.ipar = new ScilabDouble([0,numb]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(3)],[sci2exp(1)],[sci2exp(0)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXTRACTOR.js b/history/data_structures/EXTRACTOR.js deleted file mode 100644 index fe8472d..0000000 --- a/history/data_structures/EXTRACTOR.js +++ /dev/null @@ -1,19 +0,0 @@ -function EXTRACTOR () { - - - var ind = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["extractor"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - model.ipar=new ScilabDouble([ind]); - - var exprs = [sci2exp(ind)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/EXTTRI.js b/history/data_structures/EXTTRI.js deleted file mode 100644 index 5702134..0000000 --- a/history/data_structures/EXTTRI.js +++ /dev/null @@ -1,31 +0,0 @@ -function EXTTRI () { - - - var model = scicos_model(); - - var function_name = "extrilz"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Extract_Activation.js b/history/data_structures/Extract_Activation.js deleted file mode 100644 index ed98bf4..0000000 --- a/history/data_structures/Extract_Activation.js +++ /dev/null @@ -1,92 +0,0 @@ -function Extract_Activation () { - - - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(IFTHEL_f("define")); - scs_m_1.objs.push(CLKSOMV_f("define")); - scs_m_1.objs.push(IN_f("define")); - scs_m_1.objs.push(CLKOUTV_f("define")); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs(1); - - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([80,0]); - graphics.sz = new ScilabDouble([60,40]); - graphics.exprs = new ScilabString(["0";"0"]); - model.evtin = new ScilabDouble(); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - graphics.pin = new ScilabDouble([7]); - graphics.peout = new ScilabDouble([5],[6]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(2); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([80,-80]); - graphics.sz = new ScilabDouble([80,40]); - graphics.pein = new ScilabDouble([5],[6]); - graphics.peout = new ScilabDouble([8]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(3); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([0,10]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pout = new ScilabDouble([7]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(4); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([110,-140]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - - var lnk = scs_m_1.objs(5); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([1,1,0]); - lnk.to = new ScilabDouble([2,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(6); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([1,2,0]); - lnk.to = new ScilabDouble([2,2,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(7); - lnk.from = new ScilabDouble([3,1,0]); - lnk.to = new ScilabDouble([1,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(8); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([2,1,0]); - lnk.to = new ScilabDouble([4,1,1]); - scs_m_1.objs.push(lnk); - clear blk lnk - model=scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar=scs_m_1; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/FROM.js b/history/data_structures/FROM.js deleted file mode 100644 index 5a5a591..0000000 --- a/history/data_structures/FROM.js +++ /dev/null @@ -1,23 +0,0 @@ -function FROM () { - - - var model = scicos_model(); - model.sim = new ScilabString(["from"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = ["A"]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs,gr_i); - this.x.graphics.id = new ScilabString(["From"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/FROMMO.js b/history/data_structures/FROMMO.js deleted file mode 100644 index e8573de..0000000 --- a/history/data_structures/FROMMO.js +++ /dev/null @@ -1,27 +0,0 @@ -function FROMMO () { - - - var model = scicos_model(); - model.sim = new ScilabString(["frommo"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar = new ScilabDouble(); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var mo = modelica(); - mo.model = new ScilabString(["frommo"]); - mo.outputs = new ScilabString(["n"]); - - var exprs = ["A"]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs,gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/FROMWSB.js b/history/data_structures/FROMWSB.js deleted file mode 100644 index a610e91..0000000 --- a/history/data_structures/FROMWSB.js +++ /dev/null @@ -1,15 +0,0 @@ -function FROMWSB () { - - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[-159.096,811.104,-121.216,617.984,1323,1008,331,284,630,480,1426,231,1.4],Title="FROMWSB",tol=[0.0001,0.000001,1.000D-10,100001,0,0],tf=100000,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="FROMWS_c",graphics=scicos_graphics(orig=[260.37067,261.584],sz=[70,40],flip=%t,theta=0,exprs=["V";"1";"1";"0"],pin=[],pout=4,pein=2,peout=2,gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("fromws_c",4),in1=[],in2=[],intyp=1,out=-1,out2=-2,outtyp=-1,evtin=1,evtout=1,state=[],dstate=[],odstate=list(),rpar=[],ipar=[1;-31;1;1;0],opar=list(),blocktype="d",firing=0,dep_ut=[%f,%t],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([295.37067),yy: new ScilabDouble([255.86971),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m_1.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[358.9421,271.584],sz=[20,20],flip=%t,theta=0,exprs="1",pin=4,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=-2,intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([338.9421),yy: new ScilabDouble([281.584),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([3,1,1])})); - - var model = scicos_model(sim="csuper",in1=[],in2=[],intyp=1,out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([5,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Flowmeter.js b/history/data_structures/Flowmeter.js deleted file mode 100644 index b17778b..0000000 --- a/history/data_structures/Flowmeter.js +++ /dev/null @@ -1,30 +0,0 @@ -function Flowmeter () { - - - var ModelName = "Flowmeter"; - - var PrametersValue = 1; - - var ParametersName = "Qini"; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[50,105,-1,90],[0,10,2,0],[101,10,-2,0]]; - - var PortName = ["Mesure";"C1";"C2"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GAINBLK.js b/history/data_structures/GAINBLK.js deleted file mode 100644 index c16da52..0000000 --- a/history/data_structures/GAINBLK.js +++ /dev/null @@ -1,25 +0,0 @@ -function GAINBLK () { - - - var gain = 1; - - var in1 = -1],[out=-1; - - var in2 = -2],[out2=-2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["gainblk"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=out; - model.in2.push(new ScilabDouble([in2])); - model.out2.push(out2); - model.rpar=new ScilabDouble([gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [strcat(sci2exp(gain))]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GAINBLK_f.js b/history/data_structures/GAINBLK_f.js deleted file mode 100644 index bb31112..0000000 --- a/history/data_structures/GAINBLK_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function GAINBLK_f () { - - - var gain = 1; - - var in1 = 1],[out=1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in1.push(new ScilabDouble([in1])); - model.out=out; - model.rpar=new ScilabDouble([gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [strcat(sci2exp(gain))]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GAIN_f.js b/history/data_structures/GAIN_f.js deleted file mode 100644 index 0b78d54..0000000 --- a/history/data_structures/GAIN_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function GAIN_f () { - - - var gain = 1],[in1=1],[out=1; - - var model = scicos_model(); - model.sim = new ScilabString(["gain"]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar=new ScilabDouble([gain]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(sci2exp(gain))],[strcat(sci2exp(in1))],[strcat(sci2exp(out))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GENERAL_f.js b/history/data_structures/GENERAL_f.js deleted file mode 100644 index 1db91b0..0000000 --- a/history/data_structures/GENERAL_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function GENERAL_f () { - - - var rpar = [[0],[0],[0],[0]]; - - var in1 = 1; - - var out = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["zcross"]),new ScilabDouble([1])); - model.nzcross=new ScilabDouble([in1]); - model.in1.push(new ScilabDouble([in1])); - model.evtout=ones(out,1); - model.rpar = new ScilabDouble([0],[0],[0],[0]); - model.blocktype = new ScilabString(["z"]); - model.firing=-ones(out,1); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(sci2exp(in1))],[strcat(sci2exp(out))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GENSIN_f.js b/history/data_structures/GENSIN_f.js deleted file mode 100644 index 13638df..0000000 --- a/history/data_structures/GENSIN_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function GENSIN_f () { - - - var rpar = [[1],[1],[0]]; - - var model = scicos_model(); - model.sim = new ScilabString(["gensin"]); - model.in1 = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1],[1],[0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [[string(rpar(1))],[string(rpar(2))],[string(rpar(3))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GENSQR_f.js b/history/data_structures/GENSQR_f.js deleted file mode 100644 index e4d52e1..0000000 --- a/history/data_structures/GENSQR_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function GENSQR_f () { - - - var Amplitude = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["gensqr"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate=new ScilabDouble([Amplitude]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(Amplitude); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GOTO.js b/history/data_structures/GOTO.js deleted file mode 100644 index 9c0c19b..0000000 --- a/history/data_structures/GOTO.js +++ /dev/null @@ -1,23 +0,0 @@ -function GOTO () { - - - var model = scicos_model(); - model.sim = new ScilabString(["goto"]); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar=int(1); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [["A"],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs,gr_i); - this.x.graphics.id = new ScilabString(["Goto"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GOTOMO.js b/history/data_structures/GOTOMO.js deleted file mode 100644 index 70a1907..0000000 --- a/history/data_structures/GOTOMO.js +++ /dev/null @@ -1,27 +0,0 @@ -function GOTOMO () { - - - var model = scicos_model(); - model.sim = new ScilabString(["gotomo"]); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.outtyp = new ScilabDouble([1]); - model.ipar=int(1); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var mo = modelica(); - mo.model = new ScilabString(["gotomo"]); - mo.inputs = new ScilabString(["p"]); - - var exprs = [["A"],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,1]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GotoTagVisibility.js b/history/data_structures/GotoTagVisibility.js deleted file mode 100644 index 27c4d72..0000000 --- a/history/data_structures/GotoTagVisibility.js +++ /dev/null @@ -1,23 +0,0 @@ -function GotoTagVisibility () { - - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibility"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = "A"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/GotoTagVisibilityMO.js b/history/data_structures/GotoTagVisibilityMO.js deleted file mode 100644 index 8ede428..0000000 --- a/history/data_structures/GotoTagVisibilityMO.js +++ /dev/null @@ -1,23 +0,0 @@ -function GotoTagVisibilityMO () { - - - var model = scicos_model(); - model.sim = new ScilabString(["gototagvisibilitymo"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.out = new ScilabDouble(); - model.out2 = new ScilabDouble(); - model.evtin = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.opar=list("A"); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = "A"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Ground.js b/history/data_structures/Ground.js deleted file mode 100644 index 53c0d1a..0000000 --- a/history/data_structures/Ground.js +++ /dev/null @@ -1,23 +0,0 @@ -function Ground () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble(); - model.sim = new ScilabString(["Ground"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Ground"]); - mo.inputs = new ScilabString(["p"]); - model.equations=mo; - - var exprs = ""; - - var gr_i = []; - this.x=standard_define([1,1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new GroundBlock(this.x) -} diff --git a/history/data_structures/Gyrator.js b/history/data_structures/Gyrator.js deleted file mode 100644 index 6e9b7a9..0000000 --- a/history/data_structures/Gyrator.js +++ /dev/null @@ -1,30 +0,0 @@ -function Gyrator () { - - - var ModelName = "Gyrator"; - - var PrametersValue = [[1],[1]]; - - var ParametersName = ["G1";"G2"]; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[2.5,90,2,0],[2.5,10,2,0],[97.5,90,-2,0],[97.5,10,-2,0]]; - - var PortName = ["p1";"n1";"p2";"n2"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/HALT_f.js b/history/data_structures/HALT_f.js deleted file mode 100644 index 7199f8c..0000000 --- a/history/data_structures/HALT_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function HALT_f () { - - - var n = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["hltblk"]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(n); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/HYSTHERESIS.js b/history/data_structures/HYSTHERESIS.js deleted file mode 100644 index 22f72d0..0000000 --- a/history/data_structures/HYSTHERESIS.js +++ /dev/null @@ -1,27 +0,0 @@ -function HYSTHERESIS () { - - - var in1 = 1; - - var ipar = [0]; - - var nzz = 2; - - var rpar = [[1],[0],[1],[0]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["hystheresis"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out = new ScilabDouble([1]); - model.rpar=new ScilabDouble([rpar]); - model.nzcross=new ScilabDouble([nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(rpar)],[string(sign(nzz))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/IFTHEL_f.js b/history/data_structures/IFTHEL_f.js deleted file mode 100644 index 5830a9d..0000000 --- a/history/data_structures/IFTHEL_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function IFTHEL_f () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["ifthel"]),new ScilabDouble([-1])); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1],[1]); - model.blocktype = new ScilabString(["l"]); - model.firing = new ScilabDouble([-1,-1]); - model.dep_ut = new ScilabBoolean([true,false]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - - var gr_i = []; - - var exprs = [[string(model.in1)],[string(model.nmode)]]; - this.x=new standard_define(new ScilabDouble([3,3]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INIMPL_f.js b/history/data_structures/INIMPL_f.js deleted file mode 100644 index 968ebb3..0000000 --- a/history/data_structures/INIMPL_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function INIMPL_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["inimpl"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.ipar = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false,false]); - model.blocktype = new ScilabString(["c"]); - - var mo = modelica(); - mo.model = new ScilabString(["PORT"]); - mo.outputs = new ScilabString(["n"]); - model.equations=mo; - - var prt = 1; - - var exprs = "1"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new ImplicitInBlock(this.x) -} diff --git a/history/data_structures/INTEGRAL_f.js b/history/data_structures/INTEGRAL_f.js deleted file mode 100644 index 70589f4..0000000 --- a/history/data_structures/INTEGRAL_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function INTEGRAL_f () { - - - var x0 = 0; - - var model = scicos_model(); - model.sim = new ScilabString(["integr"]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.state=new ScilabDouble([x0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = strcat(sci2exp(x0)); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INTEGRAL_m.js b/history/data_structures/INTEGRAL_m.js deleted file mode 100644 index 1606b27..0000000 --- a/history/data_structures/INTEGRAL_m.js +++ /dev/null @@ -1,26 +0,0 @@ -function INTEGRAL_m () { - - - var maxp = 1; - - var minp = -1; - - var rpar = []; - - var model = scicos_model(); - model.state = new ScilabDouble([0]); - model.sim=list(new ScilabString(["integral_func"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.rpar=rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = string([0],[0],[0],[maxp],[minp]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INTMUL.js b/history/data_structures/INTMUL.js deleted file mode 100644 index b741d3e..0000000 --- a/history/data_structures/INTMUL.js +++ /dev/null @@ -1,24 +0,0 @@ -function INTMUL () { - - - var sgn = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["matmul_i32"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-2]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2],[-3]); - model.out2 = new ScilabDouble([-3]); - model.intyp = new ScilabDouble([3,3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(3)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INTRP2BLK_f.js b/history/data_structures/INTRP2BLK_f.js deleted file mode 100644 index a70bdec..0000000 --- a/history/data_structures/INTRP2BLK_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function INTRP2BLK_f () { - - - var a = [[0],[1]]; - - var b = [[0],[1]]; - - var c = [[0,1],[1,2]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["intrp2"]),new ScilabDouble([1])); - model.in1 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([a],[b],[...c]); - model.ipar = new ScilabDouble([2],[2]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(sci2exp(a))],[strcat(sci2exp(b))],[strcat(sci2exp(c,0))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INTRPLBLK_f.js b/history/data_structures/INTRPLBLK_f.js deleted file mode 100644 index 4cfc3f4..0000000 --- a/history/data_structures/INTRPLBLK_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function INTRPLBLK_f () { - - - var a = [[0],[1]]; - - var b = [[0],[1]]; - - var model = scicos_model(); - model.sim = new ScilabString(["intrpl"]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([a],[b]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[strcat(sci2exp(a))],[strcat(sci2exp(b))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/INVBLK.js b/history/data_structures/INVBLK.js deleted file mode 100644 index f99b5c7..0000000 --- a/history/data_structures/INVBLK.js +++ /dev/null @@ -1,18 +0,0 @@ -function INVBLK () { - - - var in1 = -1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["invblk4"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = " "; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/IN_f.js b/history/data_structures/IN_f.js deleted file mode 100644 index 8b39f0b..0000000 --- a/history/data_structures/IN_f.js +++ /dev/null @@ -1,20 +0,0 @@ -function IN_f () { - - - var prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["input"]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = sci2exp(prt); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new ExplicitInBlock(this.x) -} diff --git a/history/data_structures/ISELECT_m.js b/history/data_structures/ISELECT_m.js deleted file mode 100644 index 63322de..0000000 --- a/history/data_structures/ISELECT_m.js +++ /dev/null @@ -1,31 +0,0 @@ -function ISELECT_m () { - - - var z0 = 1; - - var nout = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["selector_m"]),new ScilabDouble([4])); - model.out = new ScilabDouble([-1],[-1]); - model.out2 = new ScilabDouble([-2],[-2]); - model.outtyp = new ScilabDouble([1]); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin=ones(nout,1); - model.dstate=new ScilabDouble([z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(1)],[sci2exp(nout)],[sci2exp(z0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/IdealTransformer.js b/history/data_structures/IdealTransformer.js deleted file mode 100644 index 54d38f7..0000000 --- a/history/data_structures/IdealTransformer.js +++ /dev/null @@ -1,30 +0,0 @@ -function IdealTransformer () { - - - var ModelName = "IdealTransformer"; - - var PrametersValue = [1]; - - var ParametersName = ["N"]; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[2.5,90,2,0],[2.5,10,2,0],[97.5,90,-2,0],[97.5,10,-2,0]]; - - var PortName = ["p1";"n1";"p2";"n2"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Inductor.js b/history/data_structures/Inductor.js deleted file mode 100644 index 470b8db..0000000 --- a/history/data_structures/Inductor.js +++ /dev/null @@ -1,28 +0,0 @@ -function Inductor () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - var L = 1.d-5; - model.rpar=new ScilabDouble([L]); - model.sim = new ScilabString(["Inductor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Inductor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["L"]),list(L)); - model.equations=mo; - - var exprs = string(L); - - var gr_i = []; - this.x=standard_define([2,0.9],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/JKFLIPFLOP.js b/history/data_structures/JKFLIPFLOP.js deleted file mode 100644 index 7de61c4..0000000 --- a/history/data_structures/JKFLIPFLOP.js +++ /dev/null @@ -1,53 +0,0 @@ -function JKFLIPFLOP () { - - - var scs_m = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["JKFLIPFLOP"],tol=[0.0001;0.000001;1.000E-10;100001;0;0;0],tf=60,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m.objs.push(scicos_block(gui="DOLLAR_m",graphics=scicos_graphics(orig=[299.96961,261.584],sz=[40,40],flip=%f,theta=0,exprs=["int8(0)";"1"],pin=7,pout=5,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("dollar4_m",4),in1=1,in2=1,intyp=5,out=1,out2=1,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(new ScilabInteger([0])),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["EDGE_TRIGGER","./"],tol=[0.0001;0.000001;1.000E-10;100001;0;0;0],tf=30,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="EDGETRIGGER",graphics=scicos_graphics(orig=[288.58631,257.1131],sz=[60,40],flip=%t,theta=0,exprs="-1",pin=5,pout=3,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("edgetrig",4),in1=1,in2=[],intyp=1,out=1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=0,odstate=list(),rpar=[],ipar=-1,opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=1,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="IFTHEL_f",graphics=scicos_graphics(orig=[388.28869,247.1131],sz=[60,60],flip=%t,theta=0,exprs=["0";"0"],pin=3,pout=[],pein=[],peout=[7;0],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim=list("ifthel",-1),in1=1,in2=[],intyp=1,out=[],out2=1,outtyp=[],evtin=[],evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="l",firing=[-1,-1],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([357.15774),yy: new ScilabDouble([277.1131),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m_1.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[240.01488,267.1131],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=5,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([260.01488),yy: new ScilabDouble([277.1131),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([4,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKOUTV_f",graphics=scicos_graphics(orig=[398.28869,181.39881],sz=[20,30],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=7,peout=[],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="output",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([408.28869),yy: new ScilabDouble([241.39881),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([6,1,1])})); - scs_m.objs.push(scicos_block(gui="EDGE_TRIGGER",graphics=scicos_graphics(orig=[292.52452,323.54888],sz=[60,40],flip=%t,theta=0,exprs=[],pin=14,pout=[],pein=[],peout=8,gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="csuper",in1=-1,in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="LOGIC",graphics=scicos_graphics(orig=[302.79613,202.52782],sz=[40,40],flip=%t,theta=0,exprs=["[0;1;1;1;0;0;1;0]";"0"],pin=[5;16;18],pout=4,pein=8,peout=[],gr_i=[],id="",in_implicit=["E";"E";"E"],out_implicit="E"),model=scicos_model(sim=list("logic",4),in1=[1;1;1],in2=[1;1;1],intyp=[5;5;5],out=1,out2=1,outtyp=5,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(new ScilabInteger([[0;1;1;1;0;0;1;0]])),blocktype="c",firing=%f,dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([351.36756),yy: new ScilabDouble([222.52782),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([10,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([291.39818),yy: new ScilabDouble([281.584),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[368.82793,243.45067],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=11,pout=[7;20],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([368.82793),yy: new ScilabDouble([243.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([6,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([322.52452),yy: new ScilabDouble([317.8346),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m.objs.push(scicos_block(gui="LOGICAL_OP",graphics=scicos_graphics(orig=[377.63217,159.25363],sz=[60,40],flip=%t,theta=0,exprs=["1";"5";"5";"0"],pin=12,pout=22,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("logicalop_i8",4),in1=-1,in2=-2,intyp=5,out=-1,out2=-2,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[5;0],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[368.82793;223.06473],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=4,pout=[11;12],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([368.82793),yy: new ScilabDouble([223.06473),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([10,1,0]),to: new ScilabDouble([6,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([368.82793),yy: new ScilabDouble([223.06473),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([10,2,0]),to: new ScilabDouble([9,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[243.95309,333.54888],sz=[20,20],flip=%t,theta=0,exprs="2",pin=[],pout=14,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([263.95309),yy: new ScilabDouble([343.54888),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([13,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[254.2247,212.52782],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=16,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([274.2247),yy: new ScilabDouble([222.52782),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([15,1,0]),to: new ScilabDouble([3,2,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[254.2247,202.52782],sz=[20,20],flip=%t,theta=0,exprs="3",pin=[],pout=18,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=3,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([274.2247),yy: new ScilabDouble([212.52782),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([17,1,0]),to: new ScilabDouble([3,3,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[388.82793,233.45067],sz=[20,20],flip=%t,theta=0,exprs="1",pin=20,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([368.82793),yy: new ScilabDouble([243.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([6,2,0]),to: new ScilabDouble([19,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[466.2036,169.25363],sz=[20,20],flip=%t,theta=0,exprs="2",pin=22,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([446.2036),yy: new ScilabDouble([179.25363),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([9,1,0]),to: new ScilabDouble([21,1,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1],[1],[1]); - model.in2 = new ScilabDouble([1],[1],[1]); - model.out = new ScilabDouble([1],[1]); - model.out2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([5,1,5]); - model.outtyp = new ScilabDouble([5,5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true,false]); - model.rpar=scs_m; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/LOGBLK_f.js b/history/data_structures/LOGBLK_f.js deleted file mode 100644 index 728dc8a..0000000 --- a/history/data_structures/LOGBLK_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function LOGBLK_f () { - - - var in1 = 1; - - var a = %e; - - var model = scicos_model(); - model.sim = new ScilabString(["logblk"]); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar=new ScilabBoolean([a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = "%e"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/LOGIC.js b/history/data_structures/LOGIC.js deleted file mode 100644 index 453ecae..0000000 --- a/history/data_structures/LOGIC.js +++ /dev/null @@ -1,25 +0,0 @@ -function LOGIC () { - - - var mat = [[0],[0],[0],[1]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["logic"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1]); - model.in2 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.intyp = new ScilabDouble([5,5]); - model.outtyp = new ScilabDouble([5]); - model.opar=list(new ScilabInteger([mat])); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(mat)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/LOGICAL_OP.js b/history/data_structures/LOGICAL_OP.js deleted file mode 100644 index 5c50e07..0000000 --- a/history/data_structures/LOGICAL_OP.js +++ /dev/null @@ -1,23 +0,0 @@ -function LOGICAL_OP () { - - - var in1 = [[-1],[-1]]; - - var ipar = [0]; - - var nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["logicalop"]),new ScilabDouble([4])); - model.in1.push(in1); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(nin)],[string(ipar)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/LOOKUP_f.js b/history/data_structures/LOOKUP_f.js deleted file mode 100644 index b31e361..0000000 --- a/history/data_structures/LOOKUP_f.js +++ /dev/null @@ -1,15 +0,0 @@ -function LOOKUP_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["lookup"]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-2],[-1],[1],[2],[-1],[1],[-1],[1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATBKSL.js b/history/data_structures/MATBKSL.js deleted file mode 100644 index 94b0ede..0000000 --- a/history/data_structures/MATBKSL.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATBKSL () { - - - var model = scicos_model(); - - var function_name = "mat_bksl"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1],[-1]); - model.in2 = new ScilabDouble([-2],[-3]); - model.intyp = new ScilabDouble([1,1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-3]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATCATH.js b/history/data_structures/MATCATH.js deleted file mode 100644 index 07beb4e..0000000 --- a/history/data_structures/MATCATH.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATCATH () { - - - var model = scicos_model(); - - var function_name = "mat_cath"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1],[-1]); - model.in2 = new ScilabDouble([-2],[-3]); - model.intyp = new ScilabDouble([1,1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([0]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(2)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATCATV.js b/history/data_structures/MATCATV.js deleted file mode 100644 index 4fd6959..0000000 --- a/history/data_structures/MATCATV.js +++ /dev/null @@ -1,33 +0,0 @@ -function MATCATV () { - - - var l1 = [[2],[2]]; - - var model = scicos_model(); - - var function_name = "mat_catv"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in2 = new ScilabDouble([-1],[-1]); - model.in1 = new ScilabDouble([-2],[-3]); - model.intyp = new ScilabDouble([-1,-1]); - model.out = new ScilabDouble([0]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(2)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATDET.js b/history/data_structures/MATDET.js deleted file mode 100644 index 8912194..0000000 --- a/history/data_structures/MATDET.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATDET () { - - - var model = scicos_model(); - - var function_name = "mat_det"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATDIAG.js b/history/data_structures/MATDIAG.js deleted file mode 100644 index 0bdf382..0000000 --- a/history/data_structures/MATDIAG.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATDIAG () { - - - var model = scicos_model(); - - var function_name = "mat_diag"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATDIV.js b/history/data_structures/MATDIV.js deleted file mode 100644 index 73f1f36..0000000 --- a/history/data_structures/MATDIV.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATDIV () { - - - var model = scicos_model(); - - var function_name = "mat_div"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1],[-2]); - model.in2 = new ScilabDouble([-3],[-3]); - model.intyp = new ScilabDouble([1,1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATEIG.js b/history/data_structures/MATEIG.js deleted file mode 100644 index c23df30..0000000 --- a/history/data_structures/MATEIG.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATEIG () { - - - var model = scicos_model(); - - var function_name = "mat_vps"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATEXPM.js b/history/data_structures/MATEXPM.js deleted file mode 100644 index 70734bd..0000000 --- a/history/data_structures/MATEXPM.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATEXPM () { - - - var model = scicos_model(); - - var function_name = "mat_expm"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATINV.js b/history/data_structures/MATINV.js deleted file mode 100644 index 8b45697..0000000 --- a/history/data_structures/MATINV.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATINV () { - - - var model = scicos_model(); - - var function_name = "mat_inv"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATLU.js b/history/data_structures/MATLU.js deleted file mode 100644 index 6cc94e6..0000000 --- a/history/data_structures/MATLU.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATLU () { - - - var model = scicos_model(); - - var function_name = "mat_lu"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1],[-1]); - model.out2 = new ScilabDouble([-1],[-1]); - model.outtyp = new ScilabDouble([1,1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = sci2exp(1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATMAGPHI.js b/history/data_structures/MATMAGPHI.js deleted file mode 100644 index c13d1dc..0000000 --- a/history/data_structures/MATMAGPHI.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATMAGPHI () { - - - var model = scicos_model(); - - var function_name = "matz_abs"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1],[-1]); - model.out2 = new ScilabDouble([-2],[-2]); - model.outtyp = new ScilabDouble([1,1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATMUL.js b/history/data_structures/MATMUL.js deleted file mode 100644 index 42af695..0000000 --- a/history/data_structures/MATMUL.js +++ /dev/null @@ -1,18 +0,0 @@ -function MATMUL () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["matmul_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-2]); - model.in2 = new ScilabDouble([-2],[-3]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-3]); - model.dep_ut = new ScilabBoolean([true,false]); - model.ipar = new ScilabDouble([1]); - - var label = [sci2exp(model.ipar)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATPINV.js b/history/data_structures/MATPINV.js deleted file mode 100644 index 27baace..0000000 --- a/history/data_structures/MATPINV.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATPINV () { - - - var model = scicos_model(); - - var function_name = "mat_pinv"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATRESH.js b/history/data_structures/MATRESH.js deleted file mode 100644 index 53b1871..0000000 --- a/history/data_structures/MATRESH.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATRESH () { - - - var model = scicos_model(); - - var function_name = "mat_reshape"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp([1,1])],[sci2exp([1,1])]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATSING.js b/history/data_structures/MATSING.js deleted file mode 100644 index 7b1f072..0000000 --- a/history/data_structures/MATSING.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATSING () { - - - var model = scicos_model(); - - var function_name = "mat_sing"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATSUM.js b/history/data_structures/MATSUM.js deleted file mode 100644 index 43f7b3b..0000000 --- a/history/data_structures/MATSUM.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATSUM () { - - - var model = scicos_model(); - - var function_name = "mat_sum"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATTRAN.js b/history/data_structures/MATTRAN.js deleted file mode 100644 index a3a0493..0000000 --- a/history/data_structures/MATTRAN.js +++ /dev/null @@ -1,17 +0,0 @@ -function MATTRAN () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["mattran_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATZCONJ.js b/history/data_structures/MATZCONJ.js deleted file mode 100644 index efb04cb..0000000 --- a/history/data_structures/MATZCONJ.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATZCONJ () { - - - var model = scicos_model(); - - var function_name = "matz_conj"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([2]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = []; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MATZREIM.js b/history/data_structures/MATZREIM.js deleted file mode 100644 index 327d303..0000000 --- a/history/data_structures/MATZREIM.js +++ /dev/null @@ -1,31 +0,0 @@ -function MATZREIM () { - - - var model = scicos_model(); - - var function_name = "matz_reim"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([2]); - model.out = new ScilabDouble([-1],[-1]); - model.out2 = new ScilabDouble([-2],[-2]); - model.outtyp = new ScilabDouble([1,1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = sci2exp(1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MAXMIN.js b/history/data_structures/MAXMIN.js deleted file mode 100644 index 903a053..0000000 --- a/history/data_structures/MAXMIN.js +++ /dev/null @@ -1,18 +0,0 @@ -function MAXMIN () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["minmax"]),new ScilabDouble([4])); - model.out = new ScilabDouble([1]); - model.in1 = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - model.ipar = new ScilabDouble([0]); - - var exprs = [string([2,1,1]')]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - this.x.graphics.style = new ScilabString(["MAXMIN;displayedLabel=MAX"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MAX_f.js b/history/data_structures/MAX_f.js deleted file mode 100644 index 3623dc1..0000000 --- a/history/data_structures/MAX_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function MAX_f () { - - - var in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["maxblk"]); - model.in1.push(new ScilabDouble([in1])); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0],[0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = " "; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MBLOCK.js b/history/data_structures/MBLOCK.js deleted file mode 100644 index ce63569..0000000 --- a/history/data_structures/MBLOCK.js +++ /dev/null @@ -1,30 +0,0 @@ -function MBLOCK () { - - - var in1 = ["u1"]; - - var intype = ["I"]; - - var out = ["y1";"y2"]; - - var outtype = ["I";"E"]; - - var param = ["R";"L"]; - - var paramv = list(0.1,.0001); - - var pprop = [[0],[0]]; - - var nameF = "generic"; - - var exprs = ...colon_operator(tlist,["MBLOCK","in","intype","out","outtype","param","paramv","pprop","nameF","funtxt"],sci2exp(...in1),sci2exp(...intype),sci2exp(...out),sci2exp(...outtype),sci2exp(...param),list(string(0.1),string(.0001)),sci2exp(pprop(,)),nameF,[]); - - var model = scicos_model(); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - model.rpar = new ScilabDouble(); - - var for i = 1:lstsize(paramv); - model.rpar = new ScilabDouble([model.rpar],[paramv(i)(:)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MCLOCK_f.js b/history/data_structures/MCLOCK_f.js deleted file mode 100644 index 0a94924..0000000 --- a/history/data_structures/MCLOCK_f.js +++ /dev/null @@ -1,81 +0,0 @@ -function MCLOCK_f () { - - - var nn = 2; - - var dt = 0.1; - - var exprs = [[string(dt)],[string(nn)]]; - - var mfclck = MFCLCK_f("define"); - mfclck.graphics.orig = new ScilabDouble([334,199]); - mfclck.graphics.sz = new ScilabDouble([40,40]); - mfclck.graphics.flip = new ScilabBoolean([true]); - mfclck.graphics.exprs=exprs; - mfclck.graphics.pein = new ScilabDouble([12]); - mfclck.graphics.peout = new ScilabDouble([4],[3]); - mfclck.model.rpar = new ScilabDouble([0.1]); - mfclck.model.ipar=new ScilabDouble([nn]); - mfclck.model.firing = new ScilabDouble([-1,0]); - - var clksom = CLKSOM_f("define"); - clksom.graphics.orig = new ScilabDouble([457,161]); - clksom.graphics.sz = new ScilabDouble([16.666667,16.666667]); - clksom.graphics.flip = new ScilabBoolean([true]); - clksom.graphics.exprs = new ScilabString(["0.1";"0.1"]); - clksom.graphics.pein = new ScilabDouble([4],[9],[0]); - clksom.graphics.peout = new ScilabDouble([5]); - - var output_port1 = CLKOUT_f("define"); - output_port1.graphics.orig = new ScilabDouble([509,261]); - output_port1.graphics.sz = new ScilabDouble([20,20]); - output_port1.graphics.flip = new ScilabBoolean([true]); - output_port1.graphics.exprs = new ScilabString(["1"]); - output_port1.graphics.pein = new ScilabDouble([10]); - output_port1.model.ipar = new ScilabDouble([1]); - - var output_port2 = CLKOUT_f("define"); - output_port2.graphics.orig = new ScilabDouble([509,142]); - output_port2.graphics.sz = new ScilabDouble([20,20]); - output_port2.graphics.flip = new ScilabBoolean([true]); - output_port2.graphics.exprs = new ScilabString(["2"]); - output_port2.graphics.pein = new ScilabDouble([13]); - output_port2.model.ipar = new ScilabDouble([2]); - - var split1 = CLKSPLIT_f("define"); - split1.graphics.orig = new ScilabDouble([411.92504],[169.33333]); - split1.graphics.pein = new ScilabDouble([3]); - split1.graphics.peout = new ScilabDouble([9],[10]); - - var split2 = CLKSPLIT_f("define"); - split2.graphics.orig = new ScilabDouble([482.45315],[169.33333]); - split2.graphics.pein = new ScilabDouble([5]); - split2.graphics.peout = new ScilabDouble([12],[13]); - - var gr_i = []; - - var diagram = scicos_diagram(); - diagram.objs.push(mfclck); - diagram.objs.push(clksom); - diagram.objs.push(scicos_link({xx: new ScilabDouble([360.7],[360.7],[411.9]),yy: new ScilabDouble([193.3],[169.3],[169.3]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([1,2]),to: new ScilabDouble([8,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([347.3],[347.3],[461.8],[461.8]),yy: new ScilabDouble([193.3],[155.5],[155.5],[161]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([1,1]),to: new ScilabDouble([2,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([468.9],[482.5]),yy: new ScilabDouble([169.3],[169.3]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([2,1]),to: new ScilabDouble([11,1])})); - diagram.objs.push(output_port1); - diagram.objs.push(output_port2); - diagram.objs.push(split1); - diagram.objs.push(scicos_link({xx: new ScilabDouble([411.9],[457]),yy: new ScilabDouble([169.3],[169.3]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([8,1]),to: new ScilabDouble([2,2])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([411.9],[411.9],[509]),yy: new ScilabDouble([169.3],[271],[271]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([8,2]),to: new ScilabDouble([6,1])})); - diagram.objs.push(split2); - diagram.objs.push(scicos_link({xx: new ScilabDouble([482.5],[489.6],[489.6],[354],[354]),yy: new ScilabDouble([169.3],[169.3],[338.3],[338.3],[244.7]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([11,1]),to: new ScilabDouble([1,1])})); - diagram.objs.push(scicos_link({xx: new ScilabDouble([482.4],[482.4],[509]),yy: new ScilabDouble([169.3],[152],[152]),ct: new ScilabDouble([10,-1]),from: new ScilabDouble([11,2]),to: new ScilabDouble([7,1])})); - this.x=scicos_block(); - this.x.gui = new ScilabString(["MCLOCK_f"]); - this.x.graphics.sz = new ScilabDouble([3,2]); - this.x.graphics.gr_i=gr_i; - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.evtout = new ScilabDouble([1],[1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.rpar=diagram; - this.x.graphics.peout = new ScilabDouble([0],[0]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MFCLCK_f.js b/history/data_structures/MFCLCK_f.js deleted file mode 100644 index e7124f9..0000000 --- a/history/data_structures/MFCLCK_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function MFCLCK_f () { - - - var nn = 2; - - var dt = 0.1; - - var model = scicos_model(); - model.sim = new ScilabString(["mfclck"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1],[1]); - model.dstate = new ScilabDouble([0]); - model.rpar=new ScilabDouble([dt]); - model.ipar=new ScilabDouble([nn]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1,0]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(dt)],[string(nn)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MIN_f.js b/history/data_structures/MIN_f.js deleted file mode 100644 index c71bfb9..0000000 --- a/history/data_structures/MIN_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function MIN_f () { - - - var in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["minblk"]); - model.in1.push(new ScilabDouble([in1])); - model.out = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0],[0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = sci2exp(in1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MUX.js b/history/data_structures/MUX.js deleted file mode 100644 index 5481f69..0000000 --- a/history/data_structures/MUX.js +++ /dev/null @@ -1,19 +0,0 @@ -function MUX () { - - - var in1 = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["multiplex"]),new ScilabDouble([4])); - model.in1.push(-...transpose([1:in1])); - model.out = new ScilabDouble([0]); - model.ipar=new ScilabDouble([in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(in1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/MUX_f.js b/history/data_structures/MUX_f.js deleted file mode 100644 index 05e2343..0000000 --- a/history/data_structures/MUX_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function MUX_f () { - - - var in1 = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["mux"]),new ScilabDouble([1])); - model.in1.push(-...transpose([1:in1])); - model.out = new ScilabDouble([0]); - model.ipar=new ScilabDouble([in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(in1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([0.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/M_SWITCH.js b/history/data_structures/M_SWITCH.js deleted file mode 100644 index e53c664..0000000 --- a/history/data_structures/M_SWITCH.js +++ /dev/null @@ -1,23 +0,0 @@ -function M_SWITCH () { - - - var in1 = [[1],[-1],[-1]]; - - var ipar = [[1],[3]]; - - var nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["mswitch"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([in1])); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(nin)],[string(ipar)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/M_freq.js b/history/data_structures/M_freq.js deleted file mode 100644 index 0ab9467..0000000 --- a/history/data_structures/M_freq.js +++ /dev/null @@ -1,19 +0,0 @@ -function M_freq () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["m_frequ"]),new ScilabDouble([4])); - model.evtout = new ScilabDouble([1],[1],[1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.opar=list(new ScilabDouble([1),new ScilabDouble([1]),new ScilabDouble([0]]),new ScilabDouble([1),new ScilabDouble([1]),new ScilabDouble([1]]),new ScilabDouble([1),new ScilabDouble([3]),new ScilabDouble([2]]),new ScilabDouble([1]),new ScilabDouble([0]),new ScilabDouble([0])); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([0,-1,-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp([1],[2])],[sci2exp([0],[0])]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Modulo_Count.js b/history/data_structures/Modulo_Count.js deleted file mode 100644 index 62db6ad..0000000 --- a/history/data_structures/Modulo_Count.js +++ /dev/null @@ -1,22 +0,0 @@ -function Modulo_Count () { - - - var ini_c = 0; - - var base = 3; - - var model = scicos_model(); - model.sim=list(new ScilabString(["modulo_count"]),new ScilabDouble([4])); - model.evtin = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.dstate=new ScilabDouble([ini_c]); - model.ipar=new ScilabDouble([base]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(ini_c)],[string(base)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/NEGTOPOS_f.js b/history/data_structures/NEGTOPOS_f.js deleted file mode 100644 index e0e40d4..0000000 --- a/history/data_structures/NEGTOPOS_f.js +++ /dev/null @@ -1,17 +0,0 @@ -function NEGTOPOS_f () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["zcross"]),new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in1 = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1],[-1],[0],[-1]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/NMOS.js b/history/data_structures/NMOS.js deleted file mode 100644 index 350c46c..0000000 --- a/history/data_structures/NMOS.js +++ /dev/null @@ -1,43 +0,0 @@ -function NMOS () { - - - var model = scicos_model(); - - var W = 20.e-6; - - var L = 6.e-6; - - var Beta = 0.041e-3; - - var Vt = 0.8; - - var K2 = 1.144; - - var K5 = 0.7311; - - var dW = -2.5e-6; - - var dL = -1.5e-6; - - var RDS = 1.e+7; - model.sim = new ScilabString(["NMOS"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["NMOS"]); - mo.outputs = new ScilabString(["D";"B";"S"]); - mo.inputs = new ScilabString(["G"]); - mo.parameters=list(new ScilabString(["W";"L";"Beta";"Vt";"K2";"K5";"dW";"dL";"RDS"]),[W],[L],[Beta],[Vt],[K2],[K5],[dW],[dL],[RDS]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(W)],[string(L)],[string(Beta)],[string(Vt)],[string(K2)],[string(K5)],[string(dW)],[string(dL)],[string(RDS)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I";"I";"I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/NPN.js b/history/data_structures/NPN.js deleted file mode 100644 index 843e410..0000000 --- a/history/data_structures/NPN.js +++ /dev/null @@ -1,30 +0,0 @@ -function NPN () { - - - var ModelName = "NPN"; - - var PrametersValue = [[50],[0.1],[0],[0.02],[1.200D-10],[5.000D-09],[1.000D-12],[4.000D-13],[5.000D-13],[0.8],[0.4],[0.8],[0.333],[1.000D-15],[1.000D-15],[0.02585],[40]]; - - var ParametersName = ["Bf";"Br";"Is";"Vak";"Tauf";"Taur";"Ccs";"Cje";"Cjc";"Phie";"Me";"Phic";"Mc";"Gbc";"Gbe";"Vt";"EMinMax"]; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[100,90,-2,0],[,0,50,2,0],[,100,10,-2,0]]; - - var PortName = ["C";"B";"E"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/NRMSOM_f.js b/history/data_structures/NRMSOM_f.js deleted file mode 100644 index f13e210..0000000 --- a/history/data_structures/NRMSOM_f.js +++ /dev/null @@ -1,20 +0,0 @@ -function NRMSOM_f () { - - - var in1 = [[-1],[-1]]; - - var nin = 2; - - var model = scicos_model(); - model.sim = new ScilabString(["junk"]); - model.in1.push(in1); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string(nin)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([.2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/OUTIMPL_f.js b/history/data_structures/OUTIMPL_f.js deleted file mode 100644 index 5d4ce64..0000000 --- a/history/data_structures/OUTIMPL_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function OUTIMPL_f () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - - var prt = 1; - model.sim = new ScilabString(["outimpl"]); - model.ipar = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var mo = modelica(); - mo.model = new ScilabString(["PORT"]); - mo.inputs = new ScilabString(["n"]); - model.equations=mo; - - var exprs = "1"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new ImplicitOutBlock(this.x) -} diff --git a/history/data_structures/OUT_f.js b/history/data_structures/OUT_f.js deleted file mode 100644 index 56eaea2..0000000 --- a/history/data_structures/OUT_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function OUT_f () { - - - var n = -1; - - var prt = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["output"]); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([prt]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = string(prt); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new ExplicitOutBlock(this.x) -} diff --git a/history/data_structures/OpAmp.js b/history/data_structures/OpAmp.js deleted file mode 100644 index 120a0f6..0000000 --- a/history/data_structures/OpAmp.js +++ /dev/null @@ -1,30 +0,0 @@ -function OpAmp () { - - - var S = []; - - var Z = []; - - var model = scicos_model(); - model.sim = new ScilabString(["OpAmp"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model=model.sim; - mo.inputs = new ScilabString(["in_p";"in_n"]); - mo.outputs = new ScilabString(["out"]); - mo.parameters=list(S,Z); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - model.rpar=Z; - - var exprs = string(Z); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,5]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I";"I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PDE.js b/history/data_structures/PDE.js deleted file mode 100644 index 263c715..0000000 --- a/history/data_structures/PDE.js +++ /dev/null @@ -1,19 +0,0 @@ -function PDE () { - - - var model = scicos_model(); - model.state=zeros(10,1); - model.sim=list(new ScilabString(["PDE"]),new ScilabDouble([0])); - model.in1 = new ScilabDouble([1],[1],[1],[1],[1]); - model.out = new ScilabDouble([10],[0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var params_pde = tlist(["paramspde";"a";"b";"txt_exp";"check_op1";"a1";"b1";"check_op2";"a2";"b2";"check_op3";"a3";"b3";"check_op4";"a4";"b4";"check_op5";"a5";"b5";"check_op6";"a6";"b6";"check_op7";"a7";"b7";"discr_cst";"discr_non_cst";"signe";"rad_automatique";"rad_manuel";"methode";"ord1";"ord2";"ord3";"degre";"nnode";"txt_pas";"CI";"dCI";"CLa";"CLa_exp";"CLb";"CLb_exp";"points"],"","","","0","","IN_EDP1(t)","0","","IN_EDP2(t)","0","","IN_EDP3(t)","0","","IN_EDP4(t)","0","","IN_EDP5(t)","0","","IN_EDP6(t)","0","","IN_EDP7(t)","0","0","0","0","0","0","","","","","","","","","0","IN_CL1(t)","0","IN_CL2(t)",""); - - var label = list(params_pde,[],""); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,3]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PID.js b/history/data_structures/PID.js deleted file mode 100644 index e3dd59e..0000000 --- a/history/data_structures/PID.js +++ /dev/null @@ -1,43 +0,0 @@ -function PID () { - - - var scs_m = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["PID"],tol=[0.0001,0.000001,1.000E-10,100001,0,0],tf=100000,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m.objs.push(scicos_block(gui="INTEGRAL_m",graphics=scicos_graphics(orig=[318.304,183.11733],sz=[40,40],flip=%t,theta=0,exprs=["0";"0";"0";"1";"-1"],pin=7,pout=9,pein=[],peout=[],gr_i=[],id="1/s",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("integral_func",4),in1=1,in2=1,intyp=1,out=1,out2=1,outtyp=1,evtin=[],evtout=[],state=0,dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%f,%t],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="SUMMATION",graphics=scicos_graphics(orig=[387.97067,172.85067],sz=[40,60],flip=%t,theta=0,exprs=["1";"[1;1;1]"],pin=[10;9;11],pout=19,pein=[],peout=[],gr_i=[],id="",in_implicit=["E";"E";"E"],out_implicit="E"),model=scicos_model(sim=list("summation",4),in1=[-1;-1;-1],in2=[-2;-2;-2],intyp=[1;1;1],out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[1;1;1],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="GAINBLK",graphics=scicos_graphics(orig=[321.23733,235.91733],sz=[40,40],flip=%t,theta=0,exprs="1",pin=17,pout=10,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("gainblk",4),in1=-1,in2=-2,intyp=1,out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=1,ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="DERIV",graphics=scicos_graphics(orig=[319.03733,135.45067],sz=[40,40],flip=%t,theta=0,exprs=[],pin=8,pout=11,pein=[],peout=[],gr_i=[],id="s",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("deriv",4),in1=-1,in2=-2,intyp=1,out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="x",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="GAINBLK",graphics=scicos_graphics(orig=[255.23733,183.11733],sz=[40,40],flip=%t,theta=0,exprs="1",pin=13,pout=7,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("gainblk",4),in1=-1,in2=-2,intyp=1,out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=1,ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_block(gui="GAINBLK",graphics=scicos_graphics(orig=[255.23733,135.45067],sz=[40,40],flip=%t,theta=0,exprs="1",pin=14,pout=8,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("gainblk",4),in1=-1,in2=-2,intyp=1,out=-1,out2=-2,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=1,ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([303.80876),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([5,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([303.80876),yy: new ScilabDouble([155.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([6,1,0]),to: new ScilabDouble([4,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([366.87543),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([2,2,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([369.80876),yy: new ScilabDouble([255.91733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([367.60876),yy: new ScilabDouble([155.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([4,1,0]),to: new ScilabDouble([2,3,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[234.704;203.11733],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=16,pout=[13;14],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([234.704),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([12,1,0]),to: new ScilabDouble([5,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([234.704),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([12,2,0]),to: new ScilabDouble([6,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[233.97067;203.11733],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=21,pout=[16;17],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([233.97067),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([15,1,0]),to: new ScilabDouble([12,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([233.97067),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([15,2,0]),to: new ScilabDouble([3,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[456.5421,192.85067],sz=[20,20],flip=%t,theta=0,exprs="1",pin=19,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([436.5421),yy: new ScilabDouble([202.85067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([18,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[193.97067,193.11733],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=21,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([213.97067),yy: new ScilabDouble([203.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([20,1,0]),to: new ScilabDouble([15,1,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([false,false]); - model.rpar=scs_m; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PMOS.js b/history/data_structures/PMOS.js deleted file mode 100644 index 5a9ff67..0000000 --- a/history/data_structures/PMOS.js +++ /dev/null @@ -1,43 +0,0 @@ -function PMOS () { - - - var model = scicos_model(); - - var W = 50.0e-6; - - var L = 6.0e-6; - - var Beta = 0.0105e-3; - - var Vt = -1; - - var K2 = 0.41; - - var K5 = 0.839; - - var dW = -2.5e-6; - - var dL = -2.1e-6; - - var RDS = 1.e+7; - model.sim = new ScilabString(["PMOS"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["PMOS"]); - mo.outputs = new ScilabString(["D";"B";"S"]); - mo.inputs = new ScilabString(["G"]); - mo.parameters=list(new ScilabString(["W";"L";"Beta";"Vt";"K2";"K5";"dW";"dL";"RDS"]),[W],[L],[Beta],[Vt],[K2],[K5],[dW],[dL],[RDS]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(W)],[string(L)],[string(Beta)],[string(Vt)],[string(K2)],[string(K5)],[string(dW)],[string(dL)],[string(RDS)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I";"I";"I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PNP.js b/history/data_structures/PNP.js deleted file mode 100644 index b9108e6..0000000 --- a/history/data_structures/PNP.js +++ /dev/null @@ -1,30 +0,0 @@ -function PNP () { - - - var ModelName = "PNP"; - - var PrametersValue = [[50],[0.1],[0],[0.02],[1.200D-10],[5.000D-09],[1.000D-12],[4.000D-13],[5.000D-13],[0.8],[0.4],[0.8],[0.333],[1.000D-15],[1.000D-15],[0.02585],[40]]; - - var ParametersName = ["Bf";"Br";"Is";"Vak";"Tauf";"Taur";"Ccs";"Cje";"Cjc";"Phie";"Me";"Phic";"Mc";"Gbc";"Gbe";"Vt";"EMinMax"]; - - var model = scicos_model(); - - var Typein = []; - - var Typeout = []; - - var MI = []; - - var MO = []; - - var P = [[100,90,-2,0],[0,50,2,0],[100,10,-2,0]]; - - var PortName = ["C";"B";"E"]; - - var for i = 1:size(P,"r"); - - var if P(i,3) = =1, then; - Typein = new ScilabDouble([Typein;,"E"]); - MI = new ScilabDouble([MI],[PortName(i)]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/POSTONEG_f.js b/history/data_structures/POSTONEG_f.js deleted file mode 100644 index 53c941b..0000000 --- a/history/data_structures/POSTONEG_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function POSTONEG_f () { - - - var rpar = [[-1],[-1],[-1],[0]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["zcross"]),new ScilabDouble([1])); - model.nzcross = new ScilabDouble([1]); - model.in1 = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1],[-1],[-1],[0]); - model.blocktype = new ScilabString(["z"]); - model.dep_ut = new ScilabBoolean([true,false]); - model.firing = new ScilabDouble([-1]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/POWBLK_f.js b/history/data_structures/POWBLK_f.js deleted file mode 100644 index fe907b7..0000000 --- a/history/data_structures/POWBLK_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function POWBLK_f () { - - - var in1 = 1; - - var a = 1.5; - - var model = scicos_model(); - model.sim = new ScilabString(["powblk"]); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar=new ScilabDouble([a]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = string(a); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PRODUCT.js b/history/data_structures/PRODUCT.js deleted file mode 100644 index 3fc6a08..0000000 --- a/history/data_structures/PRODUCT.js +++ /dev/null @@ -1,19 +0,0 @@ -function PRODUCT () { - - - var sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["product"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-1]); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = sci2exp(sgn); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,,exprs,gr_i); - return new Product(this.x) -} diff --git a/history/data_structures/PROD_f.js b/history/data_structures/PROD_f.js deleted file mode 100644 index 5e1f69b..0000000 --- a/history/data_structures/PROD_f.js +++ /dev/null @@ -1,12 +0,0 @@ -function PROD_f () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["prod"]),new ScilabDouble([2])); - model.in1 = new ScilabDouble([-1],[-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - this.x=new standard_define(new ScilabDouble([1,1]),model,[],[]); - return new RoundBlock(this.x) -} diff --git a/history/data_structures/PULSE_SC.js b/history/data_structures/PULSE_SC.js deleted file mode 100644 index ba73528..0000000 --- a/history/data_structures/PULSE_SC.js +++ /dev/null @@ -1,57 +0,0 @@ -function PULSE_SC () { - - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[-162.7581,435.54369,67.607292,416.67644,827,479,0,15,827,480,715,167,1.4],Title=["SuperBlock","/home/fady/Scicos_examples/"],tol=[0.0001;0.000001;1.000D-10;100001;0;0;0],tf=10,context=["E2=E+W/100*F"; - "if (W<0 | W>100) then error(''Width must be between 0 and 100'');end"; - - var "if (E2 > = F),then,error,(''Offset,must,be,lower,than,(frequency*(1-Width/100))'');,end"],void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="CONST_m",graphics=scicos_graphics(orig=[30.801202,158.91733],sz=[40,40],flip=%t,theta=0,exprs="A",pin=[],pout=5,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("cstblk4_m",4),in1=[],in2=[],intyp=1,out=1,out2=1,outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(1),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="Ground_g",graphics=scicos_graphics(orig=[31.534535,215.384],sz=[40,40],flip=%t,theta=0,exprs=[],pin=[],pout=4,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("cstblk4_m",4),in1=[],in2=[],intyp=1,out=1,out2=1,outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(0),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="SELECT_m",graphics=scicos_graphics(orig=[106.00652,186.09381],sz=[40,40],flip=%t,theta=0,exprs=["-1";"2";"1"],pin=[4;5],pout=11,pein=[9;8],peout=[],gr_i=[],id="",in_implicit=["E";"E"],out_implicit="E"),model=scicos_model(sim=list("selector_m",4),in1=[-1;-1],in2=[-2;-2],intyp=[-1;-1],out=-1,out2=-2,outtyp=-1,evtin=[1;1],evtout=[],state=[],dstate=1,odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([80.105964),yy: new ScilabDouble([235.384),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([79.372631),yy: new ScilabDouble([178.91733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([3,2,1])})); - scs_m_1.objs.push(scicos_block(gui="SampleCLK",graphics=scicos_graphics(orig=[82.349744,274.21741],sz=[60,40],flip=%t,theta=0,exprs=["F";"E2"],pin=[],pout=[],pein=[],peout=9,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="sampleclk",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=[1;0.4],ipar=[],opar=list(),blocktype="d",firing=-1,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_block(gui="SampleCLK",graphics=scicos_graphics(orig=[160.48879,274.21741],sz=[60,40],flip=%t,theta=0,exprs=["F";"E"],pin=[],pout=[],pein=[],peout=8,gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="sampleclk",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=[1;0.1],ipar=[],opar=list(),blocktype="d",firing=-1,dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([190.48879),yy: new ScilabDouble([274.21741),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([7,1,0]),to: new ScilabDouble([3,2,1])})); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([112.34974),yy: new ScilabDouble([274.21741),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([6,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m_1.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[174.57795,196.09381],sz=[20,20],flip=%t,theta=0,exprs="1",pin=11,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=-2,intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([154.57795),yy: new ScilabDouble([206.09381),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([10,1,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([-1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.odstate=list(); - model.rpar=scs_m_1; - model.ipar = new ScilabDouble([1]); - model.opar=list(); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - model.label = new ScilabString([""]); - model.nzcross = new ScilabDouble([0]); - model.nmode = new ScilabDouble([0]); - model.equations=list(); - - var E = 0.1; - - var W = 30; - - var F = 1; - - var A = 1; - - var exprs = [sci2exp(E)sci2exp(W)sci2exp(F)sci2exp(A)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PerteDP.js b/history/data_structures/PerteDP.js deleted file mode 100644 index b1b5616..0000000 --- a/history/data_structures/PerteDP.js +++ /dev/null @@ -1,40 +0,0 @@ -function PerteDP () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - var L = 10; - - var D = 0.2; - - var lambda = 0.03; - - var z1 = 0; - - var z2 = 0; - - var p_rho = 0; - model.rpar = new ScilabDouble([L],[D],[lambda],[z1],[z2],[p_rho]); - model.sim = new ScilabString(["PerteDP"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["PerteDP"]); - mo.inputs = new ScilabString(["C1"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters=list(new ScilabString(["L";"D";"lambda";"z1";"z2";"p_rho"]),[L],[D],[lambda],[z1],[z2],[p_rho]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(L)],[string(D)],[string(lambda)],[string(z1)],[string(z2)],[string(p_rho)]]; - - var gr_i = []; - this.x=standard_define([2,1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PotentialSensor.js b/history/data_structures/PotentialSensor.js deleted file mode 100644 index 1edfa55..0000000 --- a/history/data_structures/PotentialSensor.js +++ /dev/null @@ -1,23 +0,0 @@ -function PotentialSensor () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar = new ScilabDouble(); - model.sim = new ScilabString(["PotentialSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["PotentialSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["v"]); - model.equations=mo; - - var gr_i = []; - this.x=standard_define([2,2],model,"",list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/PuitsP.js b/history/data_structures/PuitsP.js deleted file mode 100644 index 550acd9..0000000 --- a/history/data_structures/PuitsP.js +++ /dev/null @@ -1,31 +0,0 @@ -function PuitsP () { - - - var model = scicos_model(); - - var P0 = 100000; - - var T0 = 290; - - var H0 = 100000; - - var option_temperature = 1; - model.rpar = new ScilabDouble([P0],[T0],[H0],[option_temperature]); - model.sim = new ScilabString(["Puits"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Puits"]); - mo.inputs = new ScilabString(["C"]); - mo.parameters=list(new ScilabString(["P0";"T0";"H0";"option_temperature"]),[P0],[T0],[H0],[option_temperature]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - - var exprs = [[string(P0)],[string(T0)],[string(H0)],[string(option_temperature)]]; - - var gr_i = []; - this.x=standard_define([2.5,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/QUANT_f.js b/history/data_structures/QUANT_f.js deleted file mode 100644 index 02d0830..0000000 --- a/history/data_structures/QUANT_f.js +++ /dev/null @@ -1,22 +0,0 @@ -function QUANT_f () { - - - var pas = 0.1; - - var meth = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["qzrnd"]); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.rpar=new ScilabDouble([pas]); - model.ipar=new ScilabDouble([meth]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(pas)],[string(meth)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RAMP.js b/history/data_structures/RAMP.js deleted file mode 100644 index 3ff9355..0000000 --- a/history/data_structures/RAMP.js +++ /dev/null @@ -1,27 +0,0 @@ -function RAMP () { - - - var slope = 0; - - var iout = 0; - - var stt = 0; - - var rpar = [[slope],[stt],[iout]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["ramp"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.rpar=rpar; - model.blocktype = new ScilabString(["c"]); - model.nmode = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [string(rpar)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RAND_m.js b/history/data_structures/RAND_m.js deleted file mode 100644 index f017471..0000000 --- a/history/data_structures/RAND_m.js +++ /dev/null @@ -1,39 +0,0 @@ -function RAND_m () { - - - var a = 0; - - var b = 1; - - var dt = 0; - - var flag = 0; - - var function_name = "rndblk_m"; - - var funtyp = 4; - - var model = scicos_model(); - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble(); - model.in2 = new ScilabDouble(); - model.intyp = new ScilabDouble(); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble([int(rand()*(10^7-1))],[0*...a]); - model.rpar = new ScilabDouble([...a,...b]); - model.ipar=new ScilabDouble([flag]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp(1)],[string(flag)],[sci2exp([a])],[sci2exp([b])],[sci2exp([model.dstate(1),int(rand()*(10^7-1))])]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RATELIMITER.js b/history/data_structures/RATELIMITER.js deleted file mode 100644 index 3c859f8..0000000 --- a/history/data_structures/RATELIMITER.js +++ /dev/null @@ -1,23 +0,0 @@ -function RATELIMITER () { - - - var minp = -1; - - var maxp = 1; - - var rpar = [[maxp],[minp]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["ratelimiter"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar=rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(maxp)],[string(minp)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/READAU_f.js b/history/data_structures/READAU_f.js deleted file mode 100644 index a7ef985..0000000 --- a/history/data_structures/READAU_f.js +++ /dev/null @@ -1,40 +0,0 @@ -function READAU_f () { - - - var frmt = "uc,"; - - var fname = "test.au"; - - var lunit = 0; - - var N = 20; - - var M = 1; - - var tmask = []; - - var swap = 0; - - var offset = 1; - - var outmask = 1; - - var ievt = 0; - - var nout = size(outmask,"*"); - - var model = scicos_model(); - model.sim=list(new ScilabString(["readau"]),new ScilabDouble([2])); - model.out=nout; - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([1],[1],[lunit],[zeros(N*M,1)]); - model.ipar = new ScilabDouble([length(fname)],[_str2code(frmt)],[ievt],[N],[M],[swap],[offset],[_str2code(fname)],[tmask],[outmask]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[fname],[string(N)],[string(swap)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/READC_f.js b/history/data_structures/READC_f.js deleted file mode 100644 index cc406db..0000000 --- a/history/data_structures/READC_f.js +++ /dev/null @@ -1,46 +0,0 @@ -function READC_f () { - - - var frmt = "d, "; - - var fname = "foo"; - - var lunit = 0; - - var N = 20; - - var M = 1; - - var rpar = []; - - var tmask = 0; - - var swap = 0; - - var offset = 1; - - var outmask = 1; - - var ievt = 0; - - var nout = size(outmask,"*"); - - var ipar = [[,length(fname)],[,_str2code(frmt)],[,ievt],[,N],[,M],[,swap],[offset],[,_str2code(fname)],[,tmask],[,outmask,]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["readc"]),new ScilabDouble([2])); - model.out=nout; - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.dstate = new ScilabDouble([1],[,1],[,lunit],[,zeros(N*M,1)]); - model.ipar = new ScilabDouble([,length(fname)],[,_str2code(frmt)],[,ievt],[,N],[,M],[,swap],[,offset],[_str2code(fname)],[,tmask],[,outmask,]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[,"[]"],[,sci2exp(outmask)],[,fname],[,frmt],[,string(M)],[,string(N)],[,string(offset)],[string(swap),]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/REGISTER.js b/history/data_structures/REGISTER.js deleted file mode 100644 index 6b9b247..0000000 --- a/history/data_structures/REGISTER.js +++ /dev/null @@ -1,20 +0,0 @@ -function REGISTER () { - - - var z0 = zeros(10,1); - - var model = scicos_model(); - model.sim=list(new ScilabString(["delay4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate=z0; - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = strcat(string(z0),,";"); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RELATIONALOP.js b/history/data_structures/RELATIONALOP.js deleted file mode 100644 index 72fd81c..0000000 --- a/history/data_structures/RELATIONALOP.js +++ /dev/null @@ -1,22 +0,0 @@ -function RELATIONALOP () { - - - var ipar = [2]; - - var label = "<"; - - var model = scicos_model(); - model.sim=list(new ScilabString(["relationalop"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - model.ipar=new ScilabDouble([ipar]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(ipar)],[string(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - this.x.graphics.style = new ScilabString(["fontSize=13;fontStyle=1;displayedLabel="+label]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RELAY_f.js b/history/data_structures/RELAY_f.js deleted file mode 100644 index 56000db..0000000 --- a/history/data_structures/RELAY_f.js +++ /dev/null @@ -1,25 +0,0 @@ -function RELAY_f () { - - - var i0 = 0; - - var in1 = [[-1],[-1]]; - - var nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["relay"]),new ScilabDouble([2])); - model.in1.push(in1); - model.out = new ScilabDouble([-1]); - model.evtin=ones(in1); - model.dstate=new ScilabDouble([i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,true]); - - var exprs = [[string(nin)],[string(i0+1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RFILE_f.js b/history/data_structures/RFILE_f.js deleted file mode 100644 index 10fbc93..0000000 --- a/history/data_structures/RFILE_f.js +++ /dev/null @@ -1,40 +0,0 @@ -function RFILE_f () { - - - var out = 1; - - var nout = sum(out); - - var frmt = "(7(e10.3,1x))"; - - var fname = "foo"; - - var lunit = 0; - - var N = 2; - - var rpar = []; - - var tmask = 0; - - var outmask = 1; - - var ipar = [[,length(fname)],[length(frmt)],[0],[N],[,_str2code(fname)],[_str2code(frmt)],[,tmask],[outmask,]]; - - var dstate = [[1],[,1],[,lunit],[,zeros((nout)*N,,1)]]; - - var model = scicos_model(); - model.sim = new ScilabString(["readf"]); - model.out=nout; - model.evtin = new ScilabDouble([1]); - model.dstate=new ScilabDouble([dstate]); - model.ipar = new ScilabDouble([,length(fname)],[length(frmt)],[0],[N],[,_str2code(fname)],[_str2code(frmt)],[,tmask],[outmask,]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp([])],[sci2exp(outmask)],[fname],[frmt],[string(N)],[sci2exp(out)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/RICC.js b/history/data_structures/RICC.js deleted file mode 100644 index 1eaf89b..0000000 --- a/history/data_structures/RICC.js +++ /dev/null @@ -1,31 +0,0 @@ -function RICC () { - - - var model = scicos_model(); - - var function_name = "ricc_m"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1],[-1],[-1]); - model.in2 = new ScilabDouble([-1],[-1],[-1]); - model.intyp = new ScilabDouble([1,1,1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1],[1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ROOTCOEF.js b/history/data_structures/ROOTCOEF.js deleted file mode 100644 index df1eaad..0000000 --- a/history/data_structures/ROOTCOEF.js +++ /dev/null @@ -1,31 +0,0 @@ -function ROOTCOEF () { - - - var model = scicos_model(); - - var function_name = "root_coef"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Resistor.js b/history/data_structures/Resistor.js deleted file mode 100644 index 10b72c3..0000000 --- a/history/data_structures/Resistor.js +++ /dev/null @@ -1,28 +0,0 @@ -function Resistor () { - - - var model = scicos_model(); - - var R = 0.01; - model.rpar=new ScilabDouble([R]); - model.sim = new ScilabString(["resistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Resistor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["R"]),list(R)); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = string(R); - - var gr_i = []; - this.x=standard_define([2,1],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SAMPHOLD_m.js b/history/data_structures/SAMPHOLD_m.js deleted file mode 100644 index 0a52809..0000000 --- a/history/data_structures/SAMPHOLD_m.js +++ /dev/null @@ -1,21 +0,0 @@ -function SAMPHOLD_m () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["samphold4_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SATURATION.js b/history/data_structures/SATURATION.js deleted file mode 100644 index 37a218a..0000000 --- a/history/data_structures/SATURATION.js +++ /dev/null @@ -1,25 +0,0 @@ -function SATURATION () { - - - var minp = -1; - - var maxp = 1; - - var rpar = [[maxp],[minp]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["satur"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([1]); - model.nzcross = new ScilabDouble([2]); - model.nmode = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar=rpar; - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[string(maxp)],[string(minp)],[string(model.nmode)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SAWTOOTH_f.js b/history/data_structures/SAWTOOTH_f.js deleted file mode 100644 index fcbe8e6..0000000 --- a/history/data_structures/SAWTOOTH_f.js +++ /dev/null @@ -1,17 +0,0 @@ -function SAWTOOTH_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["sawtth"]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = " "; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SCALAR2VECTOR.js b/history/data_structures/SCALAR2VECTOR.js deleted file mode 100644 index 67c696c..0000000 --- a/history/data_structures/SCALAR2VECTOR.js +++ /dev/null @@ -1,18 +0,0 @@ -function SCALAR2VECTOR () { - - - var nout = -1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["scalar2vector"]),new ScilabDouble([4])); - model.out=new ScilabDouble([nout]); - model.in1 = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string([nout])]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SELECT_m.js b/history/data_structures/SELECT_m.js deleted file mode 100644 index e4970c8..0000000 --- a/history/data_structures/SELECT_m.js +++ /dev/null @@ -1,31 +0,0 @@ -function SELECT_m () { - - - var z0 = 1; - - var nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["selector_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-1]); - model.in2 = new ScilabDouble([-2],[-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble(); - model.firing = new ScilabDouble(); - model.evtin=ones(nin,1); - model.dstate=new ScilabDouble([z0]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(1)],[sci2exp(nin)],[sci2exp(z0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SELF_SWITCH.js b/history/data_structures/SELF_SWITCH.js deleted file mode 100644 index 0966f74..0000000 --- a/history/data_structures/SELF_SWITCH.js +++ /dev/null @@ -1,24 +0,0 @@ -function SELF_SWITCH () { - - - var stateOpen = %t; - this.x=scicos_block(); - this.x.gui = new ScilabString(["SELF_SWITCH"]); - this.x.graphics.sz = new ScilabDouble([2,2]); - this.x.graphics.gr_i = new ScilabDouble(); - this.x.graphics.pin = new ScilabDouble([0]); - this.x.graphics.pout = new ScilabDouble([0]); - this.x.model.sim = new ScilabString(["csuper"]); - this.x.model.in1 = new ScilabDouble([1]); - this.x.model.out = new ScilabDouble([1]); - this.x.model.blocktype = new ScilabString(["h"]); - this.x.model.dep_ut = new ScilabBoolean([false,false]); - this.x.model.rpar=genSwitchInnerDiagram(stateOpen); - this.x.model.opar=list(stateOpen); - this.x.graphics.in_implicit = new ScilabString(["E"]); - this.x.graphics.in_style = new ScilabString([""]); - this.x.graphics.out_implicit = new ScilabString(["E"]); - this.x.graphics.out_style = new ScilabString([""]); - this.x.graphics.style = new ScilabString(["SELF_SWITCH_OFF"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SHIFT.js b/history/data_structures/SHIFT.js deleted file mode 100644 index 9d94041..0000000 --- a/history/data_structures/SHIFT.js +++ /dev/null @@ -1,26 +0,0 @@ -function SHIFT () { - - - var sgn = [[0],[0]]; - - var OPER = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["shift_32_LA"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.out2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([3]); - model.outtyp = new ScilabDouble([3]); - model.rpar = new ScilabDouble(); - model.ipar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(3)],[sci2exp(0)],[sci2exp(0)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SIGNUM.js b/history/data_structures/SIGNUM.js deleted file mode 100644 index 39133f5..0000000 --- a/history/data_structures/SIGNUM.js +++ /dev/null @@ -1,20 +0,0 @@ -function SIGNUM () { - - - var nu = -1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["signum"]),new ScilabDouble([4])); - model.in1.push(new ScilabDouble([nu])); - model.out=new ScilabDouble([nu]); - model.nzcross=new ScilabDouble([nu]); - model.nmode=new ScilabDouble([nu]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string([1])]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SINBLK_f.js b/history/data_structures/SINBLK_f.js deleted file mode 100644 index eda3ed0..0000000 --- a/history/data_structures/SINBLK_f.js +++ /dev/null @@ -1,16 +0,0 @@ -function SINBLK_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["sinblk"]); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = " "; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SOM_f.js b/history/data_structures/SOM_f.js deleted file mode 100644 index d17adbe..0000000 --- a/history/data_structures/SOM_f.js +++ /dev/null @@ -1,19 +0,0 @@ -function SOM_f () { - - - var sgn = [[1],[1],[1]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["sum"]),new ScilabDouble([2])); - model.in1 = new ScilabDouble([-1],[-1],[-1]); - model.out = new ScilabDouble([-1]); - model.rpar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(1)],[sci2exp(sgn)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SQRT.js b/history/data_structures/SQRT.js deleted file mode 100644 index 9988080..0000000 --- a/history/data_structures/SQRT.js +++ /dev/null @@ -1,19 +0,0 @@ -function SQRT () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["mat_sqrt"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [sci2exp(1)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SRFLIPFLOP.js b/history/data_structures/SRFLIPFLOP.js deleted file mode 100644 index ae291fd..0000000 --- a/history/data_structures/SRFLIPFLOP.js +++ /dev/null @@ -1,44 +0,0 @@ -function SRFLIPFLOP () { - - - var scs_m = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["SRFLIPFLOP"],tol=[0.0001;0.000001;1.000E-10;100001;0;0;0],tf=60,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m.objs.push(scicos_block(gui="LOGIC",graphics=scicos_graphics(orig=[298.504,201.45067],sz=[40,40],flip=%t,theta=0,exprs=["[0,1;1,0;1,0;1,0;0,1;0,1;0,0;0,0]";"1"],pin=[4;10;12],pout=[3;8],pein=[],peout=[],gr_i=[],id="",in_implicit=["E";"E";"E"],out_implicit=["E";"E"]),model=scicos_model(sim=list("logic",4),in1=[1],[1],[1],in2=[1],[1],[1],intyp=[5],[5],[5],out=[1],[1],out2=[1],[1],outtyp=[5],[5],evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(int8([0,1); - 1,0; - 1,0; - 1,0; - 0,1; - 0,1; - 0,0; - - var 0,0])),blocktype = "c",firing=%f,dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list()); - scs_m.objs.push(scicos_block(gui="DOLLAR_m",graphics=scicos_graphics(orig=[299.23733,254.25067],sz=[40,40],flip=%f,theta=0,exprs=["int8(0)";"1"],pin=6,pout=4,pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit="E"),model=scicos_model(sim=list("dollar4_m",4),in1=1,in2=1,intyp=5,out=1,out2=1,outtyp=5,evtin=[],evtout=[],state=[],dstate=[],odstate=list(new ScilabInteger([0])),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([347.07543),yy: new ScilabDouble([228.11733),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([5,1,1])})); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([290.6659),yy: new ScilabDouble([274.25067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([2,1,0]),to: new ScilabDouble([1,1,1])})); - scs_m.objs.push(scicos_block(gui="SPLIT_f",graphics=scicos_graphics(orig=[363.03733,248.584],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=3,pout=[6;14],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=["E";"E";"E"]),model=scicos_model(sim="lsplit",in1=-1,in2=[],intyp=1,out=[-1;-1;-1],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="c",firing=[],dep_ut=[%t,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([363.03733),yy: new ScilabDouble([248.584),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([5,1,0]),to: new ScilabDouble([2,1,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[367.07543,204.784],sz=[20,20],flip=%t,theta=0,exprs="2",pin=8,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([347.07543),yy: new ScilabDouble([214.784),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,2,0]),to: new ScilabDouble([7,1,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[249.93257,211.45067],sz=[20,20],flip=%t,theta=0,exprs="1",pin=[],pout=10,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([269.93257),yy: new ScilabDouble([221.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([9,1,0]),to: new ScilabDouble([1,2,1])})); - scs_m.objs.push(scicos_block(gui="IN_f",graphics=scicos_graphics(orig=[249.93257,201.45067],sz=[20,20],flip=%t,theta=0,exprs="2",pin=[],pout=12,pein=[],peout=[],gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim="input",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=-1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=2,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([269.93257),yy: new ScilabDouble([211.45067),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([11,1,0]),to: new ScilabDouble([1,3,1])})); - scs_m.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[383.03733,238.584],sz=[20,20],flip=%t,theta=0,exprs="1",pin=14,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=[],intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m.objs.push(scicos_link({xx: new ScilabDouble([363.03733),yy: new ScilabDouble([248.584),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([5,2,0]),to: new ScilabDouble([13,1,1])})); - - var model = scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.in1 = new ScilabDouble([1],[1]); - model.in2 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1],[1]); - model.out2 = new ScilabDouble([1],[1]); - model.intyp = new ScilabDouble([5,5]); - model.outtyp = new ScilabDouble([5,5]); - model.blocktype = new ScilabString(["h"]); - model.firing = new ScilabBoolean([false]); - model.dep_ut = new ScilabBoolean([true,false]); - model.rpar=scs_m; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/STEP_FUNCTION.js b/history/data_structures/STEP_FUNCTION.js deleted file mode 100644 index 483a4c2..0000000 --- a/history/data_structures/STEP_FUNCTION.js +++ /dev/null @@ -1,57 +0,0 @@ -function STEP_FUNCTION () { - - - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(STEP("define")); - scs_m_1.objs.push(OUT_f("define")); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs(1); - - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([0,0]); - graphics.sz = new ScilabDouble([40,40]); - graphics.pein = new ScilabDouble([4]); - graphics.peout = new ScilabDouble([4]); - graphics.pout = new ScilabDouble([3]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(2); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([80,10]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([3]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - - var lnk = scs_m_1.objs(3); - lnk.from = new ScilabDouble([1,1,0]); - lnk.to = new ScilabDouble([2,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(4); - lnk.xx = new ScilabDouble([0,20, -20,-20,20,1]); - lnk.yy = new ScilabDouble([0,-20,-20, 60,60,1]); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([1,1,0]); - lnk.to = new ScilabDouble([1,1,1]); - scs_m_1.objs.push(lnk); - clear blk lnk - model=scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.rpar=scs_m_1; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SUBMAT.js b/history/data_structures/SUBMAT.js deleted file mode 100644 index b8cea53..0000000 --- a/history/data_structures/SUBMAT.js +++ /dev/null @@ -1,31 +0,0 @@ -function SUBMAT () { - - - var model = scicos_model(); - - var function_name = "submat"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([1],[1],[1],[1]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[sci2exp(1)],[sci2exp(1)],[sci2exp(1)],[sci2exp(1)],[sci2exp(1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2.5,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SUMMATION.js b/history/data_structures/SUMMATION.js deleted file mode 100644 index 4c7fe1b..0000000 --- a/history/data_structures/SUMMATION.js +++ /dev/null @@ -1,21 +0,0 @@ -function SUMMATION () { - - - var sgn = [[1],[-1]]; - - var model = scicos_model(); - model.sim=list(new ScilabString(["summation"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[-1]); - model.out = new ScilabDouble([-1]); - model.in2 = new ScilabDouble([-2],[-2]); - model.out2 = new ScilabDouble([-2]); - model.ipar=new ScilabDouble([sgn]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = sci2exp(sgn); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,3]),model,,exprs,gr_i); - return new Summation(this.x) -} diff --git a/history/data_structures/SUM_f.js b/history/data_structures/SUM_f.js deleted file mode 100644 index 2497a34..0000000 --- a/history/data_structures/SUM_f.js +++ /dev/null @@ -1,16 +0,0 @@ -function SUM_f () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["plusblk"]),new ScilabDouble([2])); - model.in1 = new ScilabDouble([-1],[-1],[-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var gr_i = []; - - var exprs = []; - this.x=new standard_define(new ScilabDouble([1,1]),model,exprs,gr_i); - return new RoundBlock(this.x) -} diff --git a/history/data_structures/SUPER_f.js b/history/data_structures/SUPER_f.js deleted file mode 100644 index 5ed120a..0000000 --- a/history/data_structures/SUPER_f.js +++ /dev/null @@ -1,28 +0,0 @@ -function SUPER_f () { - - - var scs = scicos_diagram(); - scs.props.title = new ScilabString(["Super,Block"]); - - var in1 = IN_f("define"); - in1.graphics.orig = new ScilabDouble([40,,40]); - in1.graphics.sz = new ScilabDouble([20,,20]); - - var out = OUT_f("define"); - out.graphics.orig = new ScilabDouble([240,,40]); - out.graphics.sz = new ScilabDouble([20,,20]); - scs.objs.push(in1); - scs.objs.push(out); - - var model = scicos_model(); - model.sim = new ScilabString(["super"]); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.rpar=scs; - model.blocktype = new ScilabString(["h"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new SuperBlock(this.x) -} diff --git a/history/data_structures/SWITCH2_m.js b/history/data_structures/SWITCH2_m.js deleted file mode 100644 index 4c1934a..0000000 --- a/history/data_structures/SWITCH2_m.js +++ /dev/null @@ -1,30 +0,0 @@ -function SWITCH2_m () { - - - var ipar = [0]; - - var nzz = 1; - - var rpar = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["switch2_m"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1],[1],[-1]); - model.in2 = new ScilabDouble([-2],[1],[-2]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([-1]); - model.out2 = new ScilabDouble([-2]); - model.outtyp = new ScilabDouble([1]); - model.ipar=new ScilabDouble([ipar]); - model.rpar=new ScilabDouble([rpar]); - model.nzcross=new ScilabDouble([nzz]); - model.nmode = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(1)],[string(ipar)],[string(rpar)],[string(nzz)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SWITCH_f.js b/history/data_structures/SWITCH_f.js deleted file mode 100644 index f9a4f5e..0000000 --- a/history/data_structures/SWITCH_f.js +++ /dev/null @@ -1,24 +0,0 @@ -function SWITCH_f () { - - - var i0 = 0; - - var in1 = [[-1],[-1]]; - - var nin = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["switchn"]),new ScilabDouble([2])); - model.in1.push(in1); - model.out = new ScilabDouble([-1]); - model.ipar=new ScilabDouble([i0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,true]); - - var exprs = [[string(nin)],[string(i0+1)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SampleCLK.js b/history/data_structures/SampleCLK.js deleted file mode 100644 index 51bf28a..0000000 --- a/history/data_structures/SampleCLK.js +++ /dev/null @@ -1,15 +0,0 @@ -function SampleCLK () { - - - var model = scicos_model(); - model.sim = new ScilabString(["sampleclk"]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([1,0]); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp(1)],[sci2exp(0)]]; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs," "); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Sigbuilder.js b/history/data_structures/Sigbuilder.js deleted file mode 100644 index a4c176c..0000000 --- a/history/data_structures/Sigbuilder.js +++ /dev/null @@ -1,19 +0,0 @@ -function Sigbuilder () { - - - var scs_m_1 = scicos_diagram(version="scicos4.2",props=scicos_params(wpar=[600,450,0,0,600,450],Title=["Sigbuilder","./"],tol=[0.0001;0.000001;1.000D-10;100001;0;0;0],tf=100,context=" ",void1=[],options=tlist(["scsopt","3D","Background","Link","ID","Cmap"],list(%t,33),[8,1],[1,5],list([5,1],[4,1]),[0.8,0.8,0.8]),void2=[],void3=[],doc=list())); - scs_m_1.objs.push(scicos_block(gui="CURVE_c",graphics=scicos_graphics(orig=[329.63473,606.18517],sz=[40,40],flip=%t,theta=0,exprs=["3";"[0,1,2]";"[10,20,-30]";"y";"n"],pin=[],pout=6,pein=4,peout=2,gr_i=[],id="",in_implicit=[],out_implicit="E"),model=scicos_model(sim=list("curve_c",4),in1=[],in2=[],intyp=1,out=1,out2=[],outtyp=1,evtin=1,evtout=1,state=[],dstate=[],odstate=list(),rpar=[0;1;2;10;20;-30],ipar=[3;3;1],opar=list(),blocktype="c",firing=0,dep_ut=[%f,%t],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([349.63473),yy: new ScilabDouble([600.47089),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([3,1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKSPLIT_f",graphics=scicos_graphics(orig=[349.49528;565.10704],sz=[0.3333333,0.3333333],flip=%t,theta=0,exprs=[],pin=[],pout=[],pein=2,peout=[8;4],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="split",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[1;1],state=[],dstate=[],odstate=list(),rpar=[],ipar=[],opar=list(),blocktype="d",firing=[%f,%f,%f],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([349.49528),yy: new ScilabDouble([565.10704),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([3,2,0]),to: new ScilabDouble([1,1,1])})); - scs_m_1.objs.push(scicos_block(gui="OUT_f",graphics=scicos_graphics(orig=[398.20616,616.18517],sz=[20,20],flip=%t,theta=0,exprs="1",pin=6,pout=[],pein=[],peout=[],gr_i=[],id="",in_implicit="E",out_implicit=[]),model=scicos_model(sim="output",in1=-1,in2=-2,intyp=-1,out=[],out2=[],outtyp=1,evtin=[],evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="c",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([378.20616),yy: new ScilabDouble([626.18517),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([1,1]),from: new ScilabDouble([1,1,0]),to: new ScilabDouble([5,1,1])})); - scs_m_1.objs.push(scicos_block(gui="CLKOUTV_f",graphics=scicos_graphics(orig=[339.49528,505.10704],sz=[20,30],flip=%t,theta=0,exprs="1",pin=[],pout=[],pein=8,peout=[],gr_i=[],id="",in_implicit=[],out_implicit=[]),model=scicos_model(sim="output",in1=[],in2=[],intyp=1,out=[],out2=[],outtyp=1,evtin=1,evtout=[],state=[],dstate=[],odstate=list(),rpar=[],ipar=1,opar=list(),blocktype="d",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()),doc=list())); - scs_m_1.objs.push(scicos_link({xx: new ScilabDouble([349.49528),yy: new ScilabDouble([565.10704),thick: new ScilabDouble([0,0]),ct: new ScilabDouble([5,-1]),from: new ScilabDouble([3,1,0]),to: new ScilabDouble([7,1,1])})); - - var model = scicos_model(sim="csuper",in1=[],in2=[],intyp=1,out=-1,out2=[],outtyp=1,evtin=[],evtout=1,state=[],dstate=[],odstate=list(),rpar=scs_m_1,ipar=[],opar=list(),blocktype="h",firing=[],dep_ut=[%f,%f],label="",nzcross=0,nmode=0,equations=list()); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SineVoltage.js b/history/data_structures/SineVoltage.js deleted file mode 100644 index 99e8b10..0000000 --- a/history/data_structures/SineVoltage.js +++ /dev/null @@ -1,36 +0,0 @@ -function SineVoltage () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - var V = 1; - - var ph = 0; - - var frq = 1; - - var offset = 0; - - var start = 0; - model.rpar = new ScilabDouble([V],[ph],[frq],[offset],[start]); - model.sim = new ScilabString(["SineVoltage"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["SineVoltage"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["V";"phase";"freqHz";"offset";"startTime"]),list(V,ph,frq,offset,start)); - model.equations=mo; - - var exprs = [[string(V)],[string(ph)],[string(frq)],[string(offset)],[string(start)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/SourceP.js b/history/data_structures/SourceP.js deleted file mode 100644 index fa2cd52..0000000 --- a/history/data_structures/SourceP.js +++ /dev/null @@ -1,33 +0,0 @@ -function SourceP () { - - - var model = scicos_model(); - - var P0 = 300000; - - var T0 = 290; - - var H0 = 100000; - - var option_temperature = 1; - model.rpar = new ScilabDouble([P0],[T0],[H0],[option_temperature]); - model.sim = new ScilabString(["Source"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["Source"]); - mo.inputs = new ScilabDouble(); - mo.outputs = new ScilabString(["C"]); - mo.parameters=list(new ScilabString(["P0";"T0";"H0";"option_temperature"]),[P0],[T0],[H0],[option_temperature]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(P0)],[string(T0)],[string(H0)],[string(option_temperature)]]; - - var gr_i = []; - this.x=standard_define([2.5,2],model,exprs,list(gr_i,0)); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/Switch.js b/history/data_structures/Switch.js deleted file mode 100644 index 3b7d196..0000000 --- a/history/data_structures/Switch.js +++ /dev/null @@ -1,34 +0,0 @@ -function Switch () { - - - var model = scicos_model(); - - var Ron = 0.01; - - var Roff = 1e5; - - var S = ["Ron";"Roff"]; - - var Z = eval(S); - model.sim = new ScilabString(["Switch"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model=model.sim; - mo.inputs = new ScilabString(["p";"inp"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(S,Z); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - model.rpar=Z; - - var exprs = string(Z); - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I";"E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TANBLK_f.js b/history/data_structures/TANBLK_f.js deleted file mode 100644 index e20343a..0000000 --- a/history/data_structures/TANBLK_f.js +++ /dev/null @@ -1,18 +0,0 @@ -function TANBLK_f () { - - - var in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["tanblk"]); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([in1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = sci2exp(in1); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TCLSS.js b/history/data_structures/TCLSS.js deleted file mode 100644 index f472447..0000000 --- a/history/data_structures/TCLSS.js +++ /dev/null @@ -1,27 +0,0 @@ -function TCLSS () { - - - var x0 = 0],[A=0],[B=1],[C=1],[D=0; - - var in1 = 1; - - var nx = size(x0,"*"); - - var out = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["tcslti4"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([in1],[nx]); - model.out=new ScilabDouble([out]); - model.evtin = new ScilabDouble([1]); - model.state=new ScilabDouble([x0]); - model.rpar = new ScilabDouble([...colon_operator(A,:)],[...B],[C(,)],[...D]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [[strcat(sci2exp(A))],[strcat(sci2exp(B))],[strcat(sci2exp(C))],[strcat(sci2exp(D))],[strcat(sci2exp(x0))]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TEXT_f.js b/history/data_structures/TEXT_f.js deleted file mode 100644 index 4ca293e..0000000 --- a/history/data_structures/TEXT_f.js +++ /dev/null @@ -1,21 +0,0 @@ -function TEXT_f () { - - - var font = 2; - - var siz = 1; - - var model = scicos_model(); - model.sim = new ScilabString(["text"]); - model.rpar = new ScilabString(["Text"]); - model.ipar = new ScilabDouble([font],[siz]); - - var exprs = [["Text"],[string(font)],[,string(siz)]]; - - var graphics = scicos_graphics(); - graphics.orig = new ScilabDouble([0,0]); - graphics.sz = new ScilabDouble([2,1]); - graphics.exprs=new ScilabString([exprs]); - this.x=mlist(new ScilabString(["Text","graphics","model","void","gui"]),graphics,model,new ScilabString([" "]),new ScilabString(["TEXT_f"])); - return new TextBlock(this.x) -} diff --git a/history/data_structures/TIME_DELAY.js b/history/data_structures/TIME_DELAY.js deleted file mode 100644 index 82a1e99..0000000 --- a/history/data_structures/TIME_DELAY.js +++ /dev/null @@ -1,26 +0,0 @@ -function TIME_DELAY () { - - - var nin = 1; - - var T = 1; - - var init = 0; - - var N = 1024; - - var model = scicos_model(); - model.sim=list(new ScilabString(["time_delay"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([nin]); - model.out=new ScilabDouble([nin]); - model.rpar = new ScilabDouble([T,init]); - model.ipar=new ScilabDouble([N]); - model.blocktype = new ScilabString(["x"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var exprs = [[string(T)],[string(init)],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3.5,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TIME_f.js b/history/data_structures/TIME_f.js deleted file mode 100644 index 69d4312..0000000 --- a/history/data_structures/TIME_f.js +++ /dev/null @@ -1,13 +0,0 @@ -function TIME_f () { - - - var model = scicos_model(); - model.sim = new ScilabString(["timblk"]); - model.out = new ScilabDouble([1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([false,true]); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TKSCALE.js b/history/data_structures/TKSCALE.js deleted file mode 100644 index 5c7bd8e..0000000 --- a/history/data_structures/TKSCALE.js +++ /dev/null @@ -1,23 +0,0 @@ -function TKSCALE () { - - - var a = -10; - - var b = 10; - - var f = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["tkscaleblk"]),new ScilabDouble([5])); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble([1]); - model.rpar = new ScilabDouble([a],[b],[f]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[sci2exp(a)],[sci2exp(b)],[sci2exp(f)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TOWS_c.js b/history/data_structures/TOWS_c.js deleted file mode 100644 index 6094f11..0000000 --- a/history/data_structures/TOWS_c.js +++ /dev/null @@ -1,31 +0,0 @@ -function TOWS_c () { - - - var nu = -1; - - var nz = 128; - - var varnam = "A"; - - var herit = 0; - - var model = scicos_model(); - model.sim=list(new ScilabString(["tows_c"]),,new ScilabDouble([4])); - model.in1 = new ScilabDouble([nu]); - model.in2 = new ScilabDouble([-2]); - model.intyp = new ScilabDouble([-1]); - model.out = new ScilabDouble(); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([nz],[,length(varnam)],[,ascii(varnam)']); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([false,false]); - - var gr_i = []; - - var exprs = [[string(nz)],[,string(varnam)],[,string(herit)]]; - this.x=new standard_define(new ScilabDouble([4,2]),,model,,exprs,,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TRASH_f.js b/history/data_structures/TRASH_f.js deleted file mode 100644 index c9e4ac4..0000000 --- a/history/data_structures/TRASH_f.js +++ /dev/null @@ -1,18 +0,0 @@ -function TRASH_f () { - - - var in1 = -1; - - var model = scicos_model(); - model.sim = new ScilabString(["trash"]); - model.in1.push(new ScilabDouble([in1])); - model.evtin = new ScilabDouble([1]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = " "; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/TrigFun.js b/history/data_structures/TrigFun.js deleted file mode 100644 index 736a8c2..0000000 --- a/history/data_structures/TrigFun.js +++ /dev/null @@ -1,16 +0,0 @@ -function TrigFun () { - - - var model = scicos_model(); - model.sim=list(new ScilabString(["sin_blk"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([-1]); - model.out = new ScilabDouble([-1]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = "sin"; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VARIABLE_DELAY.js b/history/data_structures/VARIABLE_DELAY.js deleted file mode 100644 index 81d29f1..0000000 --- a/history/data_structures/VARIABLE_DELAY.js +++ /dev/null @@ -1,26 +0,0 @@ -function VARIABLE_DELAY () { - - - var nin = 1; - - var T = 1; - - var init = 0; - - var N = 1024; - - var model = scicos_model(); - model.sim=list(new ScilabString(["variable_delay"]),new ScilabDouble([4])); - model.in1 = new ScilabDouble([nin],[1]); - model.out=new ScilabDouble([nin]); - model.rpar = new ScilabDouble([T,init]); - model.ipar=new ScilabDouble([N]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = [[string(T)],[string(init)],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VVsourceAC.js b/history/data_structures/VVsourceAC.js deleted file mode 100644 index 78dcc38..0000000 --- a/history/data_structures/VVsourceAC.js +++ /dev/null @@ -1,30 +0,0 @@ -function VVsourceAC () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - - var VA = 220; - - var FR = 50; - model.rpar = new ScilabDouble([FR]); - model.sim = new ScilabString(["VVsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["VVsourceAC"]); - mo.inputs = new ScilabString(["p","VA"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["f"]),list(FR)); - model.equations=mo; - - var exprs = [string(FR)]; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I","E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VanneReglante.js b/history/data_structures/VanneReglante.js deleted file mode 100644 index 8e3dc25..0000000 --- a/history/data_structures/VanneReglante.js +++ /dev/null @@ -1,32 +0,0 @@ -function VanneReglante () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1],[1]); - model.out = new ScilabDouble([1]); - - var Cvmax = 8005.42; - - var p_rho = 0; - model.rpar = new ScilabDouble([Cvmax],[p_rho]); - model.sim = new ScilabString(["VanneReglante"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["VanneReglante"]); - mo.inputs = new ScilabString(["C1" "Ouv"]); - mo.outputs = new ScilabString(["C2"]); - mo.parameters=list(new ScilabString(["Cvmax";"p_rho"]),[Cvmax],[p_rho]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = [[string(Cvmax)],[string(p_rho)]]; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I";"E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VariableResistor.js b/history/data_structures/VariableResistor.js deleted file mode 100644 index bfb7914..0000000 --- a/history/data_structures/VariableResistor.js +++ /dev/null @@ -1,24 +0,0 @@ -function VariableResistor () { - - - var model = scicos_model(); - model.sim = new ScilabString(["VariableResistor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["VariableResistor"]); - mo.inputs = new ScilabString(["p","R"]); - mo.outputs = new ScilabString(["n"]); - model.equations=mo; - model.in1.push(ones(size(mo.inputs,"*"),1)); - model.out=ones(size(mo.outputs,"*"),1); - - var exprs = []; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I","E"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VirtualCLK0.js b/history/data_structures/VirtualCLK0.js deleted file mode 100644 index 82fa621..0000000 --- a/history/data_structures/VirtualCLK0.js +++ /dev/null @@ -1,16 +0,0 @@ -function VirtualCLK0 () { - - - var model = scicos_model(); - model.sim = new ScilabString(["vrtclk0"]); - model.evtin = new ScilabDouble([1]); - model.opar=list(); - model.ipar = new ScilabDouble(); - model.blocktype = new ScilabString(["d"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([false,false]); - - var exprs = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs," "); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/VoltageSensor.js b/history/data_structures/VoltageSensor.js deleted file mode 100644 index 3eab08a..0000000 --- a/history/data_structures/VoltageSensor.js +++ /dev/null @@ -1,24 +0,0 @@ -function VoltageSensor () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1],[,1]); - model.sim = new ScilabString(["VoltageSensor"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["VoltageSensor"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n";"v"]); - model.equations=mo; - - var exprs = []; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I";"E"]); - return new VoltageSensorBlock(this.x) -} diff --git a/history/data_structures/VsourceAC.js b/history/data_structures/VsourceAC.js deleted file mode 100644 index fa02afd..0000000 --- a/history/data_structures/VsourceAC.js +++ /dev/null @@ -1,30 +0,0 @@ -function VsourceAC () { - - - var model = scicos_model(); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - - var VA = 220; - - var FR = 50; - model.rpar = new ScilabDouble([VA],[FR]); - model.sim = new ScilabString(["VsourceAC"]); - model.blocktype = new ScilabString(["c"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var mo = modelica(); - mo.model = new ScilabString(["VsourceAC"]); - mo.inputs = new ScilabString(["p"]); - mo.outputs = new ScilabString(["n"]); - mo.parameters=list(new ScilabString(["VA";"f"]),list(VA,FR)); - model.equations=mo; - - var exprs = [[string(VA)],[string(FR)]]; - - var gr_i = []; - this.x=standard_define([2,2],model,exprs,list(gr_i,0)); - this.x.graphics.in_implicit = new ScilabString(["I"]); - this.x.graphics.out_implicit = new ScilabString(["I"]); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/WFILE_f.js b/history/data_structures/WFILE_f.js deleted file mode 100644 index 7e9a4ed..0000000 --- a/history/data_structures/WFILE_f.js +++ /dev/null @@ -1,30 +0,0 @@ -function WFILE_f () { - - - var in1 = 1; - - var nin = sum(in1); - - var frmt = "(7(e10.3,1x))"; - - var fname = "foo"; - - var lunit = 0; - - var N = 2; - - var model = scicos_model(); - model.sim = new ScilabString(["writef"]); - model.in1.push(new ScilabDouble([in1])); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1],[lunit],[zeros((nin+1)*N,1)]); - model.ipar = new ScilabDouble([length(fname)],[length(frmt)],[0],[N],[_str2code(fname)],[_str2code(frmt)]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(in1)],[fname],[frmt],[string(N)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/WRITEAU_f.js b/history/data_structures/WRITEAU_f.js deleted file mode 100644 index d831faf..0000000 --- a/history/data_structures/WRITEAU_f.js +++ /dev/null @@ -1,32 +0,0 @@ -function WRITEAU_f () { - - - var in1 = 1; - - var nin = sum(in1); - - var frmt = "uc,"; - - var fname = "/dev/audio"; - - var swap = 0; - - var lunit = 0; - - var N = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["writeau"]),new ScilabDouble([2])); - model.in1.push(new ScilabDouble([in1])); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1],[lunit],[zeros((nin+1)*N,1)]); - model.ipar = new ScilabDouble([length(fname)],[_str2code(frmt)],[N],[swap],[_str2code(fname)]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [string(N)string(swap)]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/WRITEC_f.js b/history/data_structures/WRITEC_f.js deleted file mode 100644 index 3f8f785..0000000 --- a/history/data_structures/WRITEC_f.js +++ /dev/null @@ -1,32 +0,0 @@ -function WRITEC_f () { - - - var in1 = 1; - - var nin = sum(in1); - - var frmt = "c, "; - - var fname = "foo"; - - var swap = 0; - - var lunit = 0; - - var N = 2; - - var model = scicos_model(); - model.sim=list(new ScilabString(["writec"]),new ScilabDouble([2])); - model.in1.push(new ScilabDouble([in1])); - model.evtin = new ScilabDouble([1]); - model.dstate = new ScilabDouble([-1],[lunit],[zeros((nin+1)*N,1)]); - model.ipar = new ScilabDouble([length(fname)],[_str2code(frmt)],[N],[swap],[_str2code(fname)]); - model.blocktype = new ScilabString(["d"]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = [[sci2exp(in1)],[fname],[frmt],[string(N)string(swap)]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/ZCROSS_f.js b/history/data_structures/ZCROSS_f.js deleted file mode 100644 index de4b8d9..0000000 --- a/history/data_structures/ZCROSS_f.js +++ /dev/null @@ -1,23 +0,0 @@ -function ZCROSS_f () { - - - var rpar = [[-1],[-1],[0],[0]]; - - var in1 = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["zcross"]),new ScilabDouble([1])); - model.in1.push(new ScilabDouble([in1])); - model.nzcross=new ScilabDouble([in1]); - model.evtout = new ScilabDouble([1]); - model.rpar = new ScilabDouble([-1],[-1],[0],[0]); - model.blocktype = new ScilabString(["z"]); - model.firing = new ScilabDouble([-1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = strcat(sci2exp(in1)); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([2,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/c_block.js b/history/data_structures/c_block.js deleted file mode 100644 index 97c9cae..0000000 --- a/history/data_structures/c_block.js +++ /dev/null @@ -1,43 +0,0 @@ -function c_block () { - - - var in1 = 1; - - var out = 1; - - var clkin = []; - - var clkout = []; - - var x0 = []; - - var z0 = []; - - var typ = "c"; - - var auto = []; - - var rpar = []; - - var funam = "toto"; - - var model = scicos_model(); - model.sim=list(new ScilabString([" "]),new ScilabDouble([2001])); - model.in1.push(new ScilabDouble([in1])); - model.out=new ScilabDouble([out]); - model.evtin=clkin; - model.evtout=clkout; - model.state=x0; - model.dstate=z0; - model.rpar=rpar; - model.ipar = new ScilabDouble([0]); - model.blocktype=new ScilabString([typ]); - model.firing=auto; - model.dep_ut = new ScilabBoolean([true,false]); - - var label = list([sci2exp(in1)],[sci2exp(out)],[ strcat(sci2exp(rpar))],[funam],list([])); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/fortran_block.js b/history/data_structures/fortran_block.js deleted file mode 100644 index 5abf2b0..0000000 --- a/history/data_structures/fortran_block.js +++ /dev/null @@ -1,25 +0,0 @@ -function fortran_block () { - - - var model = scicos_model(); - model.sim=list(new ScilabString([" "]),new ScilabDouble([1001])); - model.in1 = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.evtin = new ScilabDouble(); - model.evtout = new ScilabDouble(); - model.state = new ScilabDouble(); - model.dstate = new ScilabDouble(); - model.rpar = new ScilabDouble(); - model.ipar = new ScilabDouble([0]); - model.blocktype = new ScilabString(["c"]); - model.firing = new ScilabDouble(); - model.dep_ut = new ScilabBoolean([true,false]); - - var funam = "forty"; - - var label = list([sci2exp(model.in1)],[sci2exp(model.out)],[strcat(sci2exp(model.rpar))],[funam],list([])); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/freq_div.js b/history/data_structures/freq_div.js deleted file mode 100644 index 47bdf8a..0000000 --- a/history/data_structures/freq_div.js +++ /dev/null @@ -1,113 +0,0 @@ -function freq_div () { - - - var scs_m_1 = scicos_diagram(); - scs_m_1.objs.push(Modulo_Count("define")); - scs_m_1.objs.push(CLKINV_f("define")); - scs_m_1.objs.push(CLKOUTV_f("define")); - scs_m_1.objs.push(IFTHEL_f("define")); - scs_m_1.objs.push(CLKSPLIT_f("define")); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - scs_m_1.objs.push(scicos_link({})); - - var blk = scs_m_1.objs(1); - - var graphics = blk.graphics; - - var model = blk.model; - graphics.orig = new ScilabDouble([0,-100]); - graphics.sz = new ScilabDouble([60,40]); - graphics.exprs = new ScilabString(["0";"3"]); - model.dstate = new ScilabDouble([3]); - model.ipar = new ScilabDouble([3]); - graphics.pout = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([10]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(2); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([120,0]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.peout = new ScilabDouble([6]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(3); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([130,-160]); - graphics.sz = new ScilabDouble([20,20]); - graphics.exprs = new ScilabString(["1"]); - model.ipar = new ScilabDouble([1]); - graphics.pein = new ScilabDouble([8]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(4); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([100,-100]); - graphics.sz = new ScilabDouble([60,40]); - graphics.exprs = new ScilabString(["1";"0"]); - model.ipar = new ScilabDouble([1]); - graphics.pin = new ScilabDouble([7]); - graphics.pein = new ScilabDouble([9]); - graphics.peout = new ScilabDouble([0],[8]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - blk=scs_m_1.objs(5); - graphics=blk.graphics; - model=blk.model; - graphics.orig = new ScilabDouble([127,-33]); - graphics.sz = new ScilabDouble([7,7]); - graphics.pein = new ScilabDouble([6]); - graphics.peout = new ScilabDouble([9],[10]); - blk.graphics=graphics; - blk.model=model; - scs_m_1.objs.push(blk); - - var lnk = scs_m_1.objs(6); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([2,1,0]); - lnk.to = new ScilabDouble([5,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(7); - lnk.from = new ScilabDouble([1,1,0]); - lnk.to = new ScilabDouble([4,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(8); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([4,2,0]); - lnk.to = new ScilabDouble([3,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(9); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([5,1,0]); - lnk.to = new ScilabDouble([4,1,1]); - scs_m_1.objs.push(lnk); - lnk=scs_m_1.objs(10); - lnk.xx = new ScilabDouble([0,30,1]); - lnk.yy = new ScilabDouble([0,-30,1]); - lnk.ct = new ScilabDouble([5,-1]); - lnk.from = new ScilabDouble([5,2,0]); - lnk.to = new ScilabDouble([1,1,1]); - scs_m_1.objs.push(lnk); - clear blk lnk - model=scicos_model(); - model.sim = new ScilabString(["csuper"]); - model.evtin = new ScilabDouble([1]); - model.evtout = new ScilabDouble([1]); - model.rpar=scs_m_1; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([3,2]),model,[],gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/generic_block3.js b/history/data_structures/generic_block3.js deleted file mode 100644 index 82804f0..0000000 --- a/history/data_structures/generic_block3.js +++ /dev/null @@ -1,23 +0,0 @@ -function generic_block3 () { - - - var model = scicos_model(); - - var function_name = "sinblk"; - - var funtyp = 4; - model.sim=list(function_name,funtyp); - model.in1 = new ScilabDouble([1]); - model.in2 = new ScilabDouble([1]); - model.intyp = new ScilabDouble([1]); - model.out = new ScilabDouble([1]); - model.out2 = new ScilabDouble([1]); - model.outtyp = new ScilabDouble([1]); - model.dep_ut = new ScilabBoolean([true,false]); - - var label = [[function_name;sci2exp(funtyp);sci2exp([model.in1,model.in2]);sci2exp(model.intyp);sci2exp([model.out,model.out2])sci2exp(model.outtyp);sci2exp(model.evtin);sci2exp(model.evtout);sci2exp(model.state);sci2exp(model.dstate);sci2exp(model.odstate);sci2exp(model.rpar);sci2exp(model.ipar);sci2exp(model.opar);sci2exp(model.nmode);sci2exp(model.nzcross);sci2exp(model.firing);"y";"n"]]; - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,label,gr_i); - return new BasicBlock(this.x) -} diff --git a/history/data_structures/scifunc_block_m.js b/history/data_structures/scifunc_block_m.js deleted file mode 100644 index 20d082c..0000000 --- a/history/data_structures/scifunc_block_m.js +++ /dev/null @@ -1,51 +0,0 @@ -function scifunc_block_m () { - - - var in1 = 1; - - var out = 1; - - var clkin = []; - - var clkout = []; - - var x0 = []; - - var z0 = []; - - var typ = "c"; - - var auto = []; - - var rpar = []; - - var it = 1; - - var model = scicos_model(); - model.sim=list(new ScilabString(["scifunc"]),new ScilabDouble([3])); - model.in1.push(new ScilabDouble([in1])); - model.in2.push(new ScilabDouble([in1])); - model.intyp=new ScilabDouble([it]); - model.out=new ScilabDouble([out]); - model.out2.push(new ScilabDouble([out])); - model.outtyp=new ScilabDouble([it]); - model.evtin=clkin; - model.evtout=clkout; - model.state=x0; - model.dstate=z0; - model.rpar=rpar; - model.ipar = new ScilabDouble([0]); - model.opar=list(); - model.blocktype=new ScilabString([typ]); - model.firing=auto; - model.dep_ut = new ScilabBoolean([true,false]); - - var exprs = list([sci2exp([in1,in1])],[sci2exp([out,out])],[sci2exp(clkin)],[sci2exp(clkout); - strcat(sci2exp(x0));strcat(sci2exp(z0)); - - var strcat(sci2exp(rpar));sci2exp(auto);sci2exp(0)],list("y1 = sin(u1)"," "," ","y1=sin(u1)"," "," "," ")); - - var gr_i = []; - this.x=new standard_define(new ScilabDouble([4,2]),model,exprs,gr_i); - return new BasicBlock(this.x) -} diff --git a/images/ScilabExecute.png b/images/ScilabExecute.png deleted file mode 100644 index a7de0fe..0000000 Binary files a/images/ScilabExecute.png and /dev/null differ diff --git a/images/add.png b/images/add.png deleted file mode 100644 index bf5f8ed..0000000 Binary files a/images/add.png and /dev/null differ diff --git a/images/button.gif b/images/button.gif deleted file mode 100644 index ad55cab..0000000 Binary files a/images/button.gif and /dev/null differ diff --git a/images/camera.png b/images/camera.png deleted file mode 100644 index aecc94d..0000000 Binary files a/images/camera.png and /dev/null differ diff --git a/images/check.png b/images/check.png deleted file mode 100644 index ce81bce..0000000 Binary files a/images/check.png and /dev/null differ diff --git a/images/close.gif b/images/close.gif deleted file mode 100644 index 1069e94..0000000 Binary files a/images/close.gif and /dev/null differ diff --git a/images/close.png b/images/close.png deleted file mode 100644 index 4de4396..0000000 Binary files a/images/close.png and /dev/null differ diff --git a/images/collapsed.gif b/images/collapsed.gif deleted file mode 100644 index 0276444..0000000 Binary files a/images/collapsed.gif and /dev/null differ diff --git a/images/connector.gif b/images/connector.gif deleted file mode 100644 index 326e061..0000000 Binary files a/images/connector.gif and /dev/null differ diff --git a/images/copy.png b/images/copy.png deleted file mode 100644 index a987d43..0000000 Binary files a/images/copy.png and /dev/null differ diff --git a/images/cut.png b/images/cut.png deleted file mode 100644 index 52bf944..0000000 Binary files a/images/cut.png and /dev/null differ diff --git a/images/delete2.png b/images/delete2.png deleted file mode 100644 index be78c61..0000000 Binary files a/images/delete2.png and /dev/null differ diff --git a/images/dot.gif b/images/dot.gif deleted file mode 100644 index 08b9947..0000000 Binary files a/images/dot.gif and /dev/null differ diff --git a/images/draw-brush.png b/images/draw-brush.png deleted file mode 100644 index 4bb955f..0000000 Binary files a/images/draw-brush.png and /dev/null differ diff --git a/images/edit.png b/images/edit.png deleted file mode 100644 index 8c3ac14..0000000 Binary files a/images/edit.png and /dev/null differ diff --git a/images/error.gif b/images/error.gif deleted file mode 100644 index 14e1aee..0000000 Binary files a/images/error.gif and /dev/null differ diff --git a/images/expanded.gif b/images/expanded.gif deleted file mode 100644 index 3767b0b..0000000 Binary files a/images/expanded.gif and /dev/null differ diff --git a/images/export1.png b/images/export1.png deleted file mode 100644 index b8a01b8..0000000 Binary files a/images/export1.png and /dev/null differ diff --git a/images/fit_to_size.png b/images/fit_to_size.png deleted file mode 100644 index 4de46b0..0000000 Binary files a/images/fit_to_size.png and /dev/null differ diff --git a/images/flip.png b/images/flip.png deleted file mode 100644 index 6dbbb5e..0000000 Binary files a/images/flip.png and /dev/null differ diff --git a/images/gear.gif b/images/gear.gif deleted file mode 100644 index 30310d6..0000000 Binary files a/images/gear.gif and /dev/null differ diff --git a/images/gradient_background.jpg b/images/gradient_background.jpg deleted file mode 100644 index 7dbf35b..0000000 Binary files a/images/gradient_background.jpg and /dev/null differ diff --git a/images/green-dot.gif b/images/green-dot.gif deleted file mode 100644 index acaf7b2..0000000 Binary files a/images/green-dot.gif and /dev/null differ diff --git a/images/grid.gif b/images/grid.gif deleted file mode 100644 index a82a20d..0000000 Binary files a/images/grid.gif and /dev/null differ diff --git a/images/group.png b/images/group.png deleted file mode 100644 index 585ad79..0000000 Binary files a/images/group.png and /dev/null differ diff --git a/images/key.png b/images/key.png deleted file mode 100644 index e66758a..0000000 Binary files a/images/key.png and /dev/null differ diff --git a/images/loading.gif b/images/loading.gif deleted file mode 100644 index 7bb834d..0000000 Binary files a/images/loading.gif and /dev/null differ diff --git a/images/maximize.gif b/images/maximize.gif deleted file mode 100644 index e27cf3e..0000000 Binary files a/images/maximize.gif and /dev/null differ diff --git a/images/minimize.gif b/images/minimize.gif deleted file mode 100644 index 1e95e7c..0000000 Binary files a/images/minimize.gif and /dev/null differ diff --git a/images/mirror.png b/images/mirror.png deleted file mode 100644 index 2676528..0000000 Binary files a/images/mirror.png and /dev/null differ diff --git a/images/navigate_minus.png b/images/navigate_minus.png deleted file mode 100644 index 71edaf9..0000000 Binary files a/images/navigate_minus.png and /dev/null differ diff --git a/images/navigate_plus.png b/images/navigate_plus.png deleted file mode 100644 index b5b7e87..0000000 Binary files a/images/navigate_plus.png and /dev/null differ diff --git a/images/normalize.gif b/images/normalize.gif deleted file mode 100644 index 34a8d30..0000000 Binary files a/images/normalize.gif and /dev/null differ diff --git a/images/paste.png b/images/paste.png deleted file mode 100644 index fd628d9..0000000 Binary files a/images/paste.png and /dev/null differ diff --git a/images/plus.png b/images/plus.png deleted file mode 100644 index 24a84bb..0000000 Binary files a/images/plus.png and /dev/null differ diff --git a/images/point.gif b/images/point.gif deleted file mode 100644 index 9074c39..0000000 Binary files a/images/point.gif and /dev/null differ diff --git a/images/press32.png b/images/press32.png deleted file mode 100644 index f00e3f7..0000000 Binary files a/images/press32.png and /dev/null differ diff --git a/images/print32.png b/images/print32.png deleted file mode 100644 index 0cca86c..0000000 Binary files a/images/print32.png and /dev/null differ diff --git a/images/printer.png b/images/printer.png deleted file mode 100644 index 6004816..0000000 Binary files a/images/printer.png and /dev/null differ diff --git a/images/redo.png b/images/redo.png deleted file mode 100644 index 3eae59c..0000000 Binary files a/images/redo.png and /dev/null differ diff --git a/images/resize.gif b/images/resize.gif deleted file mode 100644 index ff558db..0000000 Binary files a/images/resize.gif and /dev/null differ diff --git a/images/rotate.png b/images/rotate.png deleted file mode 100644 index 60ab412..0000000 Binary files a/images/rotate.png and /dev/null differ diff --git a/images/selectall.png b/images/selectall.png deleted file mode 100644 index f4b0b19..0000000 Binary files a/images/selectall.png and /dev/null differ diff --git a/images/separator.gif b/images/separator.gif deleted file mode 100644 index 5c1b895..0000000 Binary files a/images/separator.gif and /dev/null differ diff --git a/images/setup.png b/images/setup.png deleted file mode 100644 index 68f916c..0000000 Binary files a/images/setup.png and /dev/null differ diff --git a/images/sidebar_bg.gif b/images/sidebar_bg.gif deleted file mode 100644 index 67e8244..0000000 Binary files a/images/sidebar_bg.gif and /dev/null differ diff --git a/images/spacer.gif b/images/spacer.gif deleted file mode 100644 index 35d42e8..0000000 Binary files a/images/spacer.gif and /dev/null differ diff --git a/images/submenu.gif b/images/submenu.gif deleted file mode 100644 index ffe7617..0000000 Binary files a/images/submenu.gif and /dev/null differ diff --git a/images/superblock.png b/images/superblock.png deleted file mode 100644 index 35c6be3..0000000 Binary files a/images/superblock.png and /dev/null differ diff --git a/images/toolbar_bg.gif b/images/toolbar_bg.gif deleted file mode 100644 index 87b9374..0000000 Binary files a/images/toolbar_bg.gif and /dev/null differ diff --git a/images/transparent.gif b/images/transparent.gif deleted file mode 100644 index 76040f2..0000000 Binary files a/images/transparent.gif and /dev/null differ diff --git a/images/undo.png b/images/undo.png deleted file mode 100644 index 4ba0ffb..0000000 Binary files a/images/undo.png and /dev/null differ diff --git a/images/view_1_1.png b/images/view_1_1.png deleted file mode 100644 index 88657a1..0000000 Binary files a/images/view_1_1.png and /dev/null differ diff --git a/images/view_1_132.png b/images/view_1_132.png deleted file mode 100644 index e9a1b72..0000000 Binary files a/images/view_1_132.png and /dev/null differ diff --git a/images/view_next.png b/images/view_next.png deleted file mode 100644 index b4094f0..0000000 Binary files a/images/view_next.png and /dev/null differ diff --git a/images/view_previous.png b/images/view_previous.png deleted file mode 100644 index b385b44..0000000 Binary files a/images/view_previous.png and /dev/null differ diff --git a/images/warning.gif b/images/warning.gif deleted file mode 100644 index 705235f..0000000 Binary files a/images/warning.gif and /dev/null differ diff --git a/images/warning.png b/images/warning.png deleted file mode 100644 index 2f78789..0000000 Binary files a/images/warning.png and /dev/null differ diff --git a/images/window-title.gif b/images/window-title.gif deleted file mode 100644 index 231def8..0000000 Binary files a/images/window-title.gif and /dev/null differ diff --git a/images/window.gif b/images/window.gif deleted file mode 100644 index 6631c4f..0000000 Binary files a/images/window.gif and /dev/null differ diff --git a/images/wires-grid.gif b/images/wires-grid.gif deleted file mode 100644 index ad888a2..0000000 Binary files a/images/wires-grid.gif and /dev/null differ diff --git a/images/zoom_in.png b/images/zoom_in.png deleted file mode 100644 index ad6abb9..0000000 Binary files a/images/zoom_in.png and /dev/null differ diff --git a/images/zoom_in32.png b/images/zoom_in32.png deleted file mode 100644 index 438ff0f..0000000 Binary files a/images/zoom_in32.png and /dev/null differ diff --git a/images/zoom_out.png b/images/zoom_out.png deleted file mode 100644 index 0566f26..0000000 Binary files a/images/zoom_out.png and /dev/null differ diff --git a/images/zoom_out32.png b/images/zoom_out32.png deleted file mode 100644 index 8edb765..0000000 Binary files a/images/zoom_out32.png and /dev/null differ diff --git a/index.html b/index.html deleted file mode 100644 index f61f726..0000000 --- a/index.html +++ /dev/null @@ -1,3391 +0,0 @@ - - - - - - Xcos - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - - - - - - - - \ No newline at end of file diff --git a/jquery/LICENSE.txt b/jquery/LICENSE.txt deleted file mode 100644 index 5a3cc20..0000000 --- a/jquery/LICENSE.txt +++ /dev/null @@ -1,341 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/jquery/README.html b/jquery/README.html deleted file mode 100644 index e527472..0000000 --- a/jquery/README.html +++ /dev/null @@ -1,71 +0,0 @@ - - -Farbtastic: jQuery color picker plug-in - -

Farbtastic: jQuery color picker plug-in

-

Farbtastic is a jQuery plug-in that can add one or more color picker widgets into a page. Each widget is then linked to an existing element (e.g. a text field) and will update the element's value when a color is selected.

- -

Farbtastic uses layered transparent PNGs to render a saturation/luminance gradient inside of a hue circle. No Flash or pixel-sized divs are used.

- -

Farbtastic was written by Steven Wittens and is licensed under the GPL.

- -

Basic Usage

-
    -
  1. Include farbtastic.js and farbtastic.css in your HTML:
    -
    <script type="text/javascript" src="farbtastic.js"></script>
    <link rel="stylesheet" href="farbtastic.css" type="text/css" />
    -
  2. -
  3. Add a placeholder div and a text field to your HTML, and give each an ID:
    -
    <form><input type="text" id="color" name="color" value="#123456" /></form>
    <div id="colorpicker"></div>
    -
  4. -
  5. Add a ready() handler to the document which initializes the color picker and link it to the text field with the following syntax:
    -
    <script type="text/javascript">
      $(document).ready(function() {
        $('#colorpicker').farbtastic('#color');
      });
    </script>
    -
  6. -
-

See demo1.html and demo2.html for an example (jquery.js is not included!).

-

Styling

-

The color picker is a block-level element and is 195x195 pixels large. You can control the position by styling your placeholder (e.g. floating it).

-

Note that the black/white gradients inside wheel.png and mask.png were generated programmatically and cannot be recreated easily in an image editing program.

-

Advanced Usage

-

jQuery Method

-
-
$(...).farbtastic()
-$(...).farbtastic(callback)
-
This creates color pickers in the selected objects. callback is optional and can be a:

-
    -
  • DOM Node, jQuery object or jQuery selector: the color picker will be linked to the selected element(s) by syncing the value (for form elements) and color (all elements).
  • -
  • Function: this function will be called whenever the user chooses a different color.
-
-

Object

-
-
$.farbtastic(placeholder)
-$.farbtastic(placeholder, callback)
-
-
Invoking $.farbtastic(placeholder) is the same as using $(placeholder).farbtastic() except that the Farbtastic object is returned instead of the jQuery object. This allows you to use the Farbtastic methods and properties below.

-

Note that there is only one Farbtastic object per placeholder. If you call $.farbtastic(placeholder) twice with the same placeholder, you will get the same object back each time.

-

The optional callback argument behaves exactly as for the jQuery method.
-

-
- - -

Methods

-
-
.linkTo(callback)
-
Allows you to set a new callback. Any existing callbacks are removed. See above for the meaning of callback.
-
.setColor(string)
-
Sets the picker color to the given color in hex representation.
-
.setColor([h, s, l])
-
Sets the picker color to the given color in normalized HSL (0..1 scale).
-
-

Properties

-
-
.linked
-
The elements (jQuery object) or callback function this picker is linked to.
-
.color
-
Current color in hex representation.
-
.hsl
-
Current color in normalized HSL.
-
-
- - \ No newline at end of file diff --git a/jquery/farbtastic.css b/jquery/farbtastic.css deleted file mode 100644 index 48161fb..0000000 --- a/jquery/farbtastic.css +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Farbtastic Color Picker 1.2 - * © 2008 Steven Wittens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -.farbtastic { - position: relative; -} -.farbtastic * { - position: absolute; - cursor: crosshair; -} -.farbtastic, .farbtastic .wheel { - width: 195px; - height: 195px; -} -.farbtastic .color, .farbtastic .overlay { - top: 47px; - left: 47px; - width: 101px; - height: 101px; -} -.farbtastic .wheel { - background: url(wheel.png) no-repeat; - width: 195px; - height: 195px; -} -.farbtastic .overlay { - background: url(mask.png) no-repeat; -} -.farbtastic .marker { - width: 17px; - height: 17px; - margin: -8px 0 0 -8px; - overflow: hidden; - background: url(marker.png) no-repeat; -} - diff --git a/jquery/farbtastic.js b/jquery/farbtastic.js deleted file mode 100644 index 8463cb7..0000000 --- a/jquery/farbtastic.js +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Farbtastic Color Picker 1.2 - * © 2008 Steven Wittens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -jQuery.fn.farbtastic = function (callback) { - $.farbtastic(this, callback); - return this; -}; - -jQuery.farbtastic = function (container, callback) { - var container = $(container).get(0); - return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); -} - -jQuery._farbtastic = function (container, callback) { - // Store farbtastic object - var fb = this; - - // Insert markup - $(container).html('
'); - var e = $('.farbtastic', container); - fb.wheel = $('.wheel', container).get(0); - // Dimensions - fb.radius = 84; - fb.square = 100; - fb.width = 194; - - // Fix background PNGs in IE6 - if (navigator.appVersion.match(/MSIE [0-6]\./)) { - $('*', e).each(function () { - if (this.currentStyle.backgroundImage != 'none') { - var image = this.currentStyle.backgroundImage; - image = this.currentStyle.backgroundImage.substring(5, image.length - 2); - $(this).css({ - 'backgroundImage': 'none', - 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" - }); - } - }); - } - - /** - * Link to the given element(s) or callback. - */ - fb.linkTo = function (callback) { - // Unbind previous nodes - if (typeof fb.callback == 'object') { - $(fb.callback).unbind('keyup', fb.updateValue); - } - - // Reset color - fb.color = null; - - // Bind callback or elements - if (typeof callback == 'function') { - fb.callback = callback; - } - else if (typeof callback == 'object' || typeof callback == 'string') { - fb.callback = $(callback); - fb.callback.bind('keyup', fb.updateValue); - if (fb.callback.get(0).value) { - fb.setColor(fb.callback.get(0).value); - } - } - return this; - } - fb.updateValue = function (event) { - if (this.value && this.value != fb.color) { - fb.setColor(this.value); - } - } - - /** - * Change color with HTML syntax #123456 - */ - fb.setColor = function (color) { - var unpack = fb.unpack(color); - if (fb.color != color && unpack) { - fb.color = color; - fb.rgb = unpack; - fb.hsl = fb.RGBToHSL(fb.rgb); - fb.updateDisplay(); - } - return this; - } - - /** - * Change color with HSL triplet [0..1, 0..1, 0..1] - */ - fb.setHSL = function (hsl) { - fb.hsl = hsl; - fb.rgb = fb.HSLToRGB(hsl); - fb.color = fb.pack(fb.rgb); - fb.updateDisplay(); - return this; - } - - ///////////////////////////////////////////////////// - - /** - * Retrieve the coordinates of the given event relative to the center - * of the widget. - */ - fb.widgetCoords = function (event) { - var x, y; - var el = event.target || event.srcElement; - var reference = fb.wheel; - - if (typeof event.offsetX != 'undefined') { - // Use offset coordinates and find common offsetParent - var pos = { x: event.offsetX, y: event.offsetY }; - - // Send the coordinates upwards through the offsetParent chain. - var e = el; - while (e) { - e.mouseX = pos.x; - e.mouseY = pos.y; - pos.x += e.offsetLeft; - pos.y += e.offsetTop; - e = e.offsetParent; - } - - // Look for the coordinates starting from the wheel widget. - var e = reference; - var offset = { x: 0, y: 0 } - while (e) { - if (typeof e.mouseX != 'undefined') { - x = e.mouseX - offset.x; - y = e.mouseY - offset.y; - break; - } - offset.x += e.offsetLeft; - offset.y += e.offsetTop; - e = e.offsetParent; - } - - // Reset stored coordinates - e = el; - while (e) { - e.mouseX = undefined; - e.mouseY = undefined; - e = e.offsetParent; - } - } - else { - // Use absolute coordinates - var pos = fb.absolutePosition(reference); - x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x; - y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y; - } - // Subtract distance to middle - return { x: x - fb.width / 2, y: y - fb.width / 2 }; - } - - /** - * Mousedown handler - */ - fb.mousedown = function (event) { - // Capture mouse - if (!document.dragging) { - $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); - document.dragging = true; - } - - // Check which area is being dragged - var pos = fb.widgetCoords(event); - fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; - - // Process - fb.mousemove(event); - return false; - } - - /** - * Mousemove handler - */ - fb.mousemove = function (event) { - // Get coordinates relative to color picker center - var pos = fb.widgetCoords(event); - - // Set new HSL parameters - if (fb.circleDrag) { - var hue = Math.atan2(pos.x, -pos.y) / 6.28; - if (hue < 0) hue += 1; - fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); - } - else { - var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); - var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); - fb.setHSL([fb.hsl[0], sat, lum]); - } - return false; - } - - /** - * Mouseup handler - */ - fb.mouseup = function () { - // Uncapture mouse - $(document).unbind('mousemove', fb.mousemove); - $(document).unbind('mouseup', fb.mouseup); - document.dragging = false; - } - - /** - * Update the markers and styles - */ - fb.updateDisplay = function () { - // Markers - var angle = fb.hsl[0] * 6.28; - $('.h-marker', e).css({ - left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', - top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' - }); - - $('.sl-marker', e).css({ - left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', - top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' - }); - - // Saturation/Luminance gradient - $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); - - // Linked elements or callback - if (typeof fb.callback == 'object') { - // Set background/foreground color - $(fb.callback).css({ - backgroundColor: fb.color, - color: fb.hsl[2] > 0.5 ? '#000' : '#fff' - }); - - // Change linked value - $(fb.callback).each(function() { - if (this.value && this.value != fb.color) { - this.value = fb.color; - } - }); - } - else if (typeof fb.callback == 'function') { - fb.callback.call(fb, fb.color); - } - } - - /** - * Get absolute position of element - */ - fb.absolutePosition = function (el) { - var r = { x: el.offsetLeft, y: el.offsetTop }; - // Resolve relative to offsetParent - if (el.offsetParent) { - var tmp = fb.absolutePosition(el.offsetParent); - r.x += tmp.x; - r.y += tmp.y; - } - return r; - }; - - /* Various color utility functions */ - fb.pack = function (rgb) { - var r = Math.round(rgb[0] * 255); - var g = Math.round(rgb[1] * 255); - var b = Math.round(rgb[2] * 255); - return '#' + (r < 16 ? '0' : '') + r.toString(16) + - (g < 16 ? '0' : '') + g.toString(16) + - (b < 16 ? '0' : '') + b.toString(16); - } - - fb.unpack = function (color) { - if (color.length == 7) { - return [parseInt('0x' + color.substring(1, 3)) / 255, - parseInt('0x' + color.substring(3, 5)) / 255, - parseInt('0x' + color.substring(5, 7)) / 255]; - } - else if (color.length == 4) { - return [parseInt('0x' + color.substring(1, 2)) / 15, - parseInt('0x' + color.substring(2, 3)) / 15, - parseInt('0x' + color.substring(3, 4)) / 15]; - } - } - - fb.HSLToRGB = function (hsl) { - var m1, m2, r, g, b; - var h = hsl[0], s = hsl[1], l = hsl[2]; - m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; - m1 = l * 2 - m2; - return [this.hueToRGB(m1, m2, h+0.33333), - this.hueToRGB(m1, m2, h), - this.hueToRGB(m1, m2, h-0.33333)]; - } - - fb.hueToRGB = function (m1, m2, h) { - h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); - if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; - if (h * 2 < 1) return m2; - if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; - return m1; - } - - fb.RGBToHSL = function (rgb) { - var min, max, delta, h, s, l; - var r = rgb[0], g = rgb[1], b = rgb[2]; - min = Math.min(r, Math.min(g, b)); - max = Math.max(r, Math.max(g, b)); - delta = max - min; - l = (min + max) / 2; - s = 0; - if (l > 0 && l < 1) { - s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); - } - h = 0; - if (delta > 0) { - if (max == r && max != g) h += (g - b) / delta; - if (max == g && max != b) h += (2 + (b - r) / delta); - if (max == b && max != r) h += (4 + (r - g) / delta); - h /= 6; - } - return [h, s, l]; - } - - // Install mousedown handler (the others are set on the document on-demand) - $('*', e).mousedown(fb.mousedown); - - // Init color - fb.setColor('#c24747'); - - // Set linked elements/callback - if (callback) { - fb.linkTo(callback); - } -} \ No newline at end of file diff --git a/jquery/images/ui-bg_flat_75_ffffff_40x100.png b/jquery/images/ui-bg_flat_75_ffffff_40x100.png deleted file mode 100644 index ac8b229..0000000 Binary files a/jquery/images/ui-bg_flat_75_ffffff_40x100.png and /dev/null differ diff --git a/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png b/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png deleted file mode 100644 index 86c2baa..0000000 Binary files a/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png and /dev/null differ diff --git a/jquery/images/ui-icons_888888_256x240.png b/jquery/images/ui-icons_888888_256x240.png deleted file mode 100644 index 5ba708c..0000000 Binary files a/jquery/images/ui-icons_888888_256x240.png and /dev/null differ diff --git a/jquery/jquery-1.8.2.js b/jquery/jquery-1.8.2.js deleted file mode 100644 index 12c7797..0000000 --- a/jquery/jquery-1.8.2.js +++ /dev/null @@ -1,9440 +0,0 @@ -/*! - * jQuery JavaScript Library v1.8.2 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time) - */ -(function( window, undefined ) { -var - // A central reference to the root jQuery(document) - rootjQuery, - - // The deferred used on DOM ready - readyList, - - // Use the correct document accordingly with window argument (sandbox) - document = window.document, - location = window.location, - navigator = window.navigator, - - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - - // Map over the $ in case of overwrite - _$ = window.$, - - // Save a reference to some core methods - core_push = Array.prototype.push, - core_slice = Array.prototype.slice, - core_indexOf = Array.prototype.indexOf, - core_toString = Object.prototype.toString, - core_hasOwn = Object.prototype.hasOwnProperty, - core_trim = String.prototype.trim, - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Used for matching numbers - core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, - - // Used for detecting and trimming whitespace - core_rnotwhite = /\S/, - core_rspace = /\s+/, - - // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, - rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return ( letter + "" ).toUpperCase(); - }, - - // The ready event handler and self cleanup method - DOMContentLoaded = function() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - } else if ( document.readyState === "complete" ) { - // we're here because readyState === "complete" in oldIE - // which is good enough for us to call the dom ready! - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); - } - }, - - // [[Class]] -> type pairs - class2type = {}; - -jQuery.fn = jQuery.prototype = { - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem, ret, doc; - - // Handle $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - doc = ( context && context.nodeType ? context.ownerDocument || context : document ); - - // scripts is true for back-compat - selector = jQuery.parseHTML( match[1], doc, true ); - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { - this.attr.call( selector, context, true ); - } - - return jQuery.merge( this, selector ); - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The current version of jQuery being used - jquery: "1.8.2", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return core_slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if ( name === "find" ) { - ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; - } else if ( name ) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; - }, - - eq: function( i ) { - i = +i; - return i === -1 ? - this.slice( i ) : - this.slice( i, i + 1 ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - slice: function() { - return this.pushStack( core_slice.apply( this, arguments ), - "slice", core_slice.call(arguments).join(",") ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: core_push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready, 1 ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger("ready").off("ready"); - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - isWindow: function( obj ) { - return obj != null && obj == obj.window; - }, - - isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - - type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ core_toString.call(obj) ] || "object"; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - // Not own constructor property must be Object - if ( obj.constructor && - !core_hasOwn.call(obj, "constructor") && - !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || core_hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - var name; - for ( name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw new Error( msg ); - }, - - // data: string of html - // context (optional): If specified, the fragment will be created in this context, defaults to document - // scripts (optional): If true, will include scripts passed in the html string - parseHTML: function( data, context, scripts ) { - var parsed; - if ( !data || typeof data !== "string" ) { - return null; - } - if ( typeof context === "boolean" ) { - scripts = context; - context = 0; - } - context = context || document; - - // Single tag - if ( (parsed = rsingleTag.exec( data )) ) { - return [ context.createElement( parsed[1] ) ]; - } - - parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); - return jQuery.merge( [], - (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); - }, - - parseJSON: function( data ) { - if ( !data || typeof data !== "string") { - return null; - } - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return ( new Function( "return " + data ) )(); - - } - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - if ( !data || typeof data !== "string" ) { - return null; - } - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && core_rnotwhite.test( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - // args is for internal usage only - each: function( obj, callback, args ) { - var name, - i = 0, - length = obj.length, - isObj = length === undefined || jQuery.isFunction( obj ); - - if ( args ) { - if ( isObj ) { - for ( name in obj ) { - if ( callback.apply( obj[ name ], args ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.apply( obj[ i++ ], args ) === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isObj ) { - for ( name in obj ) { - if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { - break; - } - } - } - } - - return obj; - }, - - // Use native String.trim function wherever possible - trim: core_trim && !core_trim.call("\uFEFF\xA0") ? - function( text ) { - return text == null ? - "" : - core_trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var type, - ret = results || []; - - if ( arr != null ) { - // The window, strings (and functions) also have 'length' - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - type = jQuery.type( arr ); - - if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { - core_push.call( ret, arr ); - } else { - jQuery.merge( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( core_indexOf ) { - return core_indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var l = second.length, - i = first.length, - j = 0; - - if ( typeof l === "number" ) { - for ( ; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var retVal, - ret = [], - i = 0, - length = elems.length; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, key, - ret = [], - i = 0, - length = elems.length, - // jquery objects are treated as arrays - isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( key in elems ) { - value = callback( elems[ key ], key, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return ret.concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var tmp, args, proxy; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = core_slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - access: function( elems, fn, key, value, chainable, emptyGet, pass ) { - var exec, - bulk = key == null, - i = 0, - length = elems.length; - - // Sets many values - if ( key && typeof key === "object" ) { - for ( i in key ) { - jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); - } - chainable = 1; - - // Sets one value - } else if ( value !== undefined ) { - // Optionally, function values get executed if exec is true - exec = pass === undefined && jQuery.isFunction( value ); - - if ( bulk ) { - // Bulk operations only iterate when executing function values - if ( exec ) { - exec = fn; - fn = function( elem, key, value ) { - return exec.call( jQuery( elem ), value ); - }; - - // Otherwise they run against the entire set - } else { - fn.call( elems, value ); - fn = null; - } - } - - if ( fn ) { - for (; i < length; i++ ) { - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); - } - } - - chainable = 1; - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[0], key ) : emptyGet; - }, - - now: function() { - return ( new Date() ).getTime(); - } -}); - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready, 1 ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else { - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", DOMContentLoaded ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch(e) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch(e) { - return setTimeout( doScrollCheck, 50 ); - } - - // and execute any waiting functions - jQuery.ready(); - } - })(); - } - } - } - return readyList.promise( obj ); -}; - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); -// String to Object options format cache -var optionsCache = {}; - -// Convert String-formatted options into Object-formatted ones and store in cache -function createOptions( options ) { - var object = optionsCache[ options ] = {}; - jQuery.each( options.split( core_rspace ), function( _, flag ) { - object[ flag ] = true; - }); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - ( optionsCache[ options ] || createOptions( options ) ) : - jQuery.extend( {}, options ); - - var // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function( data ) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - if ( list ) { - if ( stack ) { - if ( stack.length ) { - fire( stack.shift() ); - } - } else if ( memory ) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - // First, we save the current length - var start = list.length; - (function add( args ) { - jQuery.each( args, function( _, arg ) { - var type = jQuery.type( arg ); - if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { - list.push( arg ); - } else if ( arg && arg.length && type !== "string" ) { - // Inspect recursively - add( arg ); - } - }); - })( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if ( memory ) { - firingStart = start; - fire( memory ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - jQuery.each( arguments, function( _, arg ) { - var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - // Handle firing indexes - if ( firing ) { - if ( index <= firingLength ) { - firingLength--; - } - if ( index <= firingIndex ) { - firingIndex--; - } - } - } - }); - } - return this; - }, - // Control if a given callback is in the list - has: function( fn ) { - return jQuery.inArray( fn, list ) > -1; - }, - // Remove all callbacks from the list - empty: function() { - list = []; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - if ( list && ( !fired || stack ) ) { - if ( firing ) { - stack.push( args ); - } else { - fire( args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; -jQuery.extend({ - - Deferred: function( func ) { - var tuples = [ - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred(function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var action = tuple[ 0 ], - fn = fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? - function() { - var returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); - } - } : - newDefer[ action ] - ); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - - // Handle state - if ( stateString ) { - list.add(function() { - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } - - // deferred[ resolve | reject | notify ] = list.fire - deferred[ tuple[0] ] = list.fire; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = core_slice.call( arguments ), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, - - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; - if( values === progressValues ) { - deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ) - .progress( updateFunc( i, progressContexts, progressValues ) ); - } else { - --remaining; - } - } - } - - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); - } - - return deferred.promise(); - } -}); -jQuery.support = (function() { - - var support, - all, - a, - select, - opt, - input, - fragment, - eventName, - i, - isSupported, - clickFn, - div = document.createElement("div"); - - // Preliminary tests - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; - - all = div.getElementsByTagName("*"); - a = div.getElementsByTagName("a")[ 0 ]; - a.style.cssText = "top:1px;float:left;opacity:.5"; - - // Can't get basic test support - if ( !all || !all.length ) { - return {}; - } - - // First batch of supports tests - select = document.createElement("select"); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName("input")[ 0 ]; - - support = { - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: ( div.firstChild.nodeType === 3 ), - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: ( a.getAttribute("href") === "/a" ), - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.5/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: ( input.value === "on" ), - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // Tests for enctype support on a form(#6743) - enctype: !!document.createElement("form").enctype, - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", - - // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode - boxModel: ( document.compatMode === "CSS1Compat" ), - - // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true, - boxSizingReliable: true, - pixelPosition: false - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", clickFn = function() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - }); - div.cloneNode( true ).fireEvent("onclick"); - div.detachEvent( "onclick", clickFn ); - } - - // Check if a radio maintains its value - // after being appended to the DOM - input = document.createElement("input"); - input.value = "t"; - input.setAttribute( "type", "radio" ); - support.radioValue = input.value === "t"; - - input.setAttribute( "checked", "checked" ); - - // #11217 - WebKit loses check when the name is after the checked attribute - input.setAttribute( "name", "t" ); - - div.appendChild( input ); - fragment = document.createDocumentFragment(); - fragment.appendChild( div.lastChild ); - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - fragment.removeChild( input ); - fragment.appendChild( div ); - - // Technique from Juriy Zaytsev - // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP - if ( div.attachEvent ) { - for ( i in { - submit: true, - change: true, - focusin: true - }) { - eventName = "on" + i; - isSupported = ( eventName in div ); - if ( !isSupported ) { - div.setAttribute( eventName, "return;" ); - isSupported = ( typeof div[ eventName ] === "function" ); - } - support[ i + "Bubbles" ] = isSupported; - } - } - - // Run tests that need a body at doc ready - jQuery(function() { - var container, div, tds, marginDiv, - divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", - body = document.getElementsByTagName("body")[0]; - - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } - - container = document.createElement("div"); - container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; - body.insertBefore( container, body.firstChild ); - - // Construct the test element - div = document.createElement("div"); - container.appendChild( div ); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE <= 8 fail this test) - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - - // Check box-sizing and margin behavior - div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; - support.boxSizing = ( div.offsetWidth === 4 ); - support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); - - // NOTE: To any future maintainer, we've window.getComputedStyle - // because jsdom on node.js will break without it. - if ( window.getComputedStyle ) { - support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; - support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - marginDiv = document.createElement("div"); - marginDiv.style.cssText = div.style.cssText = divReset; - marginDiv.style.marginRight = marginDiv.style.width = "0"; - div.style.width = "1px"; - div.appendChild( marginDiv ); - support.reliableMarginRight = - !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); - } - - if ( typeof div.style.zoom !== "undefined" ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.innerHTML = ""; - div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = "block"; - div.style.overflow = "visible"; - div.innerHTML = "
"; - div.firstChild.style.width = "5px"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - - container.style.zoom = 1; - } - - // Null elements to avoid leaks in IE - body.removeChild( container ); - container = div = tds = marginDiv = null; - }); - - // Null elements to avoid leaks in IE - fragment.removeChild( div ); - all = a = select = opt = input = fragment = div = null; - - return support; -})(); -var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, - rmultiDash = /([A-Z])/g; - -jQuery.extend({ - cache: {}, - - deletedIds: [], - - // Remove at next major release (1.9/2.0) - uuid: 0, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( getByName ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; - }, - - removeData: function( elem, name, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, i, l, - - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split(" "); - } - } - } - - for ( i = 0, l = name.length; i < l; i++ ) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } - - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); - - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - } else if ( jQuery.support.deleteExpando || cache != cache.window ) { - delete cache[ id ]; - - // When all else fails, null - } else { - cache[ id ] = null; - } - }, - - // For internal use only. - _data: function( elem, name, data ) { - return jQuery.data( elem, name, data, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; - - // nodes accept data unless otherwise specified; rejection can be conditional - return !noData || noData !== true && elem.getAttribute("classid") === noData; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var parts, part, attr, name, l, - elem = this[0], - i = 0, - data = null; - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); - - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - attr = elem.attributes; - for ( l = attr.length; i < l; i++ ) { - name = attr[i].name; - - if ( !name.indexOf( "data-" ) ) { - name = jQuery.camelCase( name.substring(5) ); - - dataAttr( elem, name, data[ name ] ); - } - } - jQuery._data( elem, "parsedAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - parts = key.split( ".", 2 ); - parts[1] = parts[1] ? "." + parts[1] : ""; - part = parts[1] + "!"; - - return jQuery.access( this, function( value ) { - - if ( value === undefined ) { - data = this.triggerHandler( "getData" + part, [ parts[0] ] ); - - // Try to fetch any internally stored data first - if ( data === undefined && elem ) { - data = jQuery.data( elem, key ); - data = dataAttr( elem, key, data ); - } - - return data === undefined && parts[1] ? - this.data( parts[0] ) : - data; - } - - parts[1] = value; - this.each(function() { - var self = jQuery( this ); - - self.triggerHandler( "setData" + part, parts ); - jQuery.data( this, key, value ); - self.triggerHandler( "changeData" + part, parts ); - }); - }, null, value, arguments.length > 1, null, false ); - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} -jQuery.extend({ - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray(data) ) { - queue = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // not intended for public consumption - generates a queueHooks object, or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks("once memory").add(function() { - jQuery.removeData( elem, type + "queue", true ); - jQuery.removeData( elem, key, true ); - }) - }); - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[0], type ); - } - - return data === undefined ? - this : - this.each(function() { - var queue = jQuery.queue( this, type, data ); - - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -}); -var nodeHook, boolHook, fixSpecified, - rclass = /[\t\r\n]/g, - rreturn = /\r/g, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea|)$/i, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - var classNames, i, l, elem, - setClass, c, cl; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call(this, j, this.className) ); - }); - } - - if ( value && typeof value === "string" ) { - classNames = value.split( core_rspace ); - - for ( i = 0, l = this.length; i < l; i++ ) { - elem = this[ i ]; - - if ( elem.nodeType === 1 ) { - if ( !elem.className && classNames.length === 1 ) { - elem.className = value; - - } else { - setClass = " " + elem.className + " "; - - for ( c = 0, cl = classNames.length; c < cl; c++ ) { - if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) { - setClass += classNames[ c ] + " "; - } - } - elem.className = jQuery.trim( setClass ); - } - } - } - } - - return this; - }, - - removeClass: function( value ) { - var removes, className, elem, c, cl, i, l; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call(this, j, this.className) ); - }); - } - if ( (value && typeof value === "string") || value === undefined ) { - removes = ( value || "" ).split( core_rspace ); - - for ( i = 0, l = this.length; i < l; i++ ) { - elem = this[ i ]; - if ( elem.nodeType === 1 && elem.className ) { - - className = (" " + elem.className + " ").replace( rclass, " " ); - - // loop over each item in the removal list - for ( c = 0, cl = removes.length; c < cl; c++ ) { - // Remove until there is nothing to remove, - while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) { - className = className.replace( " " + removes[ c ] + " " , " " ); - } - } - elem.className = value ? jQuery.trim( className ) : ""; - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.split( core_rspace ); - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space separated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - } else if ( type === "undefined" || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // toggle whole className - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var hooks, ret, isFunction, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return; - } - - isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var val, - self = jQuery(this); - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, self.val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function( elem ) { - var value, i, max, option, - index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if ( index < 0 ) { - return null; - } - - // Loop through all the selected options - i = one ? index : 0; - max = one ? index + 1 : options.length; - for ( ; i < max; i++ ) { - option = options[ i ]; - - // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - // Fixes Bug #2551 -- select.val() broken in IE after form.reset() - if ( one && !values.length && options.length ) { - return jQuery( options[ index ] ).val(); - } - - return values; - }, - - set: function( elem, value ) { - var values = jQuery.makeArray( value ); - - jQuery(elem).find("option").each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 - attrFn: {}, - - attr: function( elem, name, value, pass ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { - return jQuery( elem )[ name ]( value ); - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === "undefined" ) { - return jQuery.prop( elem, name, value ); - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( notxml ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - return; - - } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, value + "" ); - return value; - } - - } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - - ret = elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return ret === null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var propName, attrNames, name, isBool, - i = 0; - - if ( value && elem.nodeType === 1 ) { - - attrNames = value.split( core_rspace ); - - for ( ; i < attrNames.length; i++ ) { - name = attrNames[ i ]; - - if ( name ) { - propName = jQuery.propFix[ name ] || name; - isBool = rboolean.test( name ); - - // See #9699 for explanation of this approach (setting first, then removal) - // Do not do this for boolean attributes (see #10870) - if ( !isBool ) { - jQuery.attr( elem, name, "" ); - } - elem.removeAttribute( getSetAttribute ? name : propName ); - - // Set corresponding property to false for boolean attributes - if ( isBool && propName in elem ) { - elem[ propName ] = false; - } - } - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to it's default in case type is set after value - // This is for element creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - }, - // Use the value property for back compat - // Use the nodeHook for button elements in IE6/7 (#1954) - value: { - get: function( elem, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.get( elem, name ); - } - return name in elem ? - elem.value : - null; - }, - set: function( elem, value, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.set( elem, value, name ); - } - // Does not return so that setAttribute is also used - elem.value = value; - } - } - }, - - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - return ( elem[ name ] = value ); - } - - } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabindex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - } - } -}); - -// Hook for boolean attributes -boolHook = { - get: function( elem, name ) { - // Align boolean attributes with corresponding properties - // Fall back to attribute presence where some booleans are not supported - var attrNode, - property = jQuery.prop( elem, name ); - return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - var propName; - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if ( propName in elem ) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = true; - } - - elem.setAttribute( name, name.toLowerCase() ); - } - return name; - } -}; - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - fixSpecified = { - name: true, - id: true, - coords: true - }; - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = jQuery.valHooks.button = { - get: function( elem, name ) { - var ret; - ret = elem.getAttributeNode( name ); - return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ? - ret.value : - undefined; - }, - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - ret = document.createAttribute( name ); - elem.setAttributeNode( ret ); - } - return ( ret.value = value + "" ); - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }); - }); - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function( elem, value, name ) { - if ( value === "" ) { - value = "false"; - } - nodeHook.set( elem, value, name ); - } - }; -} - - -// Some attributes require a special call on IE -if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - get: function( elem ) { - var ret = elem.getAttribute( name, 2 ); - return ret === null ? undefined : ret; - } - }); - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = value + "" ); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }); -} - -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - -// Radios and checkboxes getter/setter -if ( !jQuery.support.checkOn ) { - jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - get: function( elem ) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); -} -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); - } - } - }); -}); -var rformElems = /^(?:textarea|input|select)$/i, - rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, - rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - hoverHack = function( events ) { - return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); - }; - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - add: function( elem, types, handler, data, selector ) { - - var elemData, eventHandle, events, - t, tns, type, namespaces, handleObj, - handleObjIn, handlers, special; - - // Don't attach events to noData or text/comment nodes (allow plain objects tho) - if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - events = elemData.events; - if ( !events ) { - elemData.events = events = {}; - } - eventHandle = elemData.handle; - if ( !eventHandle ) { - elemData.handle = eventHandle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = jQuery.trim( hoverHack(types) ).split( " " ); - for ( t = 0; t < types.length; t++ ) { - - tns = rtypenamespace.exec( types[t] ) || []; - type = tns[1]; - namespaces = ( tns[2] || "" ).split( "." ).sort(); - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: tns[1], - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); - - // Init the event handler queue if we're the first - handlers = events[ type ]; - if ( !handlers ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - global: {}, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - - var t, tns, type, origType, namespaces, origCount, - j, events, special, eventType, handleObj, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); - - if ( !elemData || !(events = elemData.events) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = jQuery.trim( hoverHack( types || "" ) ).split(" "); - for ( t = 0; t < types.length; t++ ) { - tns = rtypenamespace.exec( types[t] ) || []; - type = origType = tns[1]; - namespaces = tns[2]; - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector? special.delegateType : special.bindType ) || type; - eventType = events[ type ] || []; - origCount = eventType.length; - namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; - - // Remove matching events - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !namespaces || namespaces.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - eventType.splice( j--, 1 ); - - if ( handleObj.selector ) { - eventType.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( eventType.length === 0 && origCount !== eventType.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery.removeData( elem, "events", true ); - } - }, - - // Events that are safe to short-circuit if no handlers are attached. - // Native DOM events should not be added, they may have inline handlers. - customEvent: { - "getData": true, - "setData": true, - "changeData": true - }, - - trigger: function( event, data, elem, onlyHandlers ) { - // Don't do events on text and comment nodes - if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { - return; - } - - // Event object or event type - var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType, - type = event.type || event, - namespaces = []; - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf( "!" ) >= 0 ) { - // Exclusive events trigger only for the exact event (no namespaces) - type = type.slice(0, -1); - exclusive = true; - } - - if ( type.indexOf( "." ) >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - - if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { - // No jQuery handlers for this event type, and it can't have inline handlers - return; - } - - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event( type, event ) : - // Just the event type (string) - new jQuery.Event( type ); - - event.type = type; - event.isTrigger = true; - event.exclusive = exclusive; - event.namespace = namespaces.join( "." ); - event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; - ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; - - // Handle a global trigger - if ( !elem ) { - - // TODO: Stop taunting the data cache; remove global events and always attach to document - cache = jQuery.cache; - for ( i in cache ) { - if ( cache[ i ].events && cache[ i ].events[ type ] ) { - jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); - } - } - return; - } - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data != null ? jQuery.makeArray( data ) : []; - data.unshift( event ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - eventPath = [[ elem, special.bindType || type ]]; - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; - for ( old = elem; cur; cur = cur.parentNode ) { - eventPath.push([ cur, bubbleType ]); - old = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( old === (elem.ownerDocument || document) ) { - eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); - } - } - - // Fire handlers on the event path - for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { - - cur = eventPath[i][0]; - event.type = eventPath[i][1]; - - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - // Note that this is a bare JS function and not a jQuery handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && - !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - // IE<9 dies on focus/blur to hidden element (#1486) - if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; - - if ( old ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - elem[ type ](); - jQuery.event.triggered = undefined; - - if ( old ) { - elem[ ontype ] = old; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event || window.event ); - - var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related, - handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), - delegateCount = handlers.delegateCount, - args = core_slice.call( arguments ), - run_all = !event.exclusive && !event.namespace, - special = jQuery.event.special[ event.type ] || {}, - handlerQueue = []; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers that should run if there are delegated events - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && !(event.button && event.type === "click") ) { - - for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { - - // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.disabled !== true || event.type !== "click" ) { - selMatch = {}; - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - - if ( selMatch[ sel ] === undefined ) { - selMatch[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) >= 0 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( selMatch[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, matches: matches }); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if ( handlers.length > delegateCount ) { - handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); - } - - // Run delegates first; they may want to stop propagation beneath us - for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { - matched = handlerQueue[ i ]; - event.currentTarget = matched.elem; - - for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { - handleObj = matched.matches[ j ]; - - // Triggered event must either 1) be non-exclusive and have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { - - event.data = handleObj.data; - event.handleObj = handleObj; - - ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) - .apply( matched.elem, args ); - - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** - props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var eventDoc, doc, body, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, - originalEvent = event, - fixHook = jQuery.event.fixHooks[ event.type ] || {}, - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = jQuery.Event( originalEvent ); - - for ( i = copy.length; i; ) { - prop = copy[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Target should not be a text node (#504, Safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) - event.metaKey = !!event.metaKey; - - return fixHook.filter? fixHook.filter( event, originalEvent ) : event; - }, - - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - - focus: { - delegateType: "focusin" - }, - blur: { - delegateType: "focusout" - }, - - beforeunload: { - setup: function( data, namespaces, eventHandle ) { - // We only want to do this special case on windows - if ( jQuery.isWindow( this ) ) { - this.onbeforeunload = eventHandle; - } - }, - - teardown: function( namespaces, eventHandle ) { - if ( this.onbeforeunload === eventHandle ) { - this.onbeforeunload = null; - } - } - } - }, - - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { type: type, - isSimulated: true, - originalEvent: {} - } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -// Some plugins are using, but it's undocumented/deprecated and will be removed. -// The 1.7 special event interface should provide all the hooks needed now. -jQuery.event.handle = jQuery.event.dispatch; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - var name = "on" + type; - - if ( elem.detachEvent ) { - - // #8545, #7054, preventing memory leaks for custom events in IE6-8 – - // detachEvent needed property on element, by name of that event, to properly expose it to GC - if ( typeof elem[ name ] === "undefined" ) { - elem[ name ] = null; - } - - elem.detachEvent( name, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - - // if preventDefault exists run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - // if stopPropagation exists run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj, - selector = handleObj.selector; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -}); - -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !jQuery._data( form, "_submit_attached" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submit_bubble = true; - }); - jQuery._data( form, "_submit_attached", true ); - } - }); - // return undefined since we don't need an event listener - }, - - postDispatch: function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( event._submit_bubble ) { - delete event._submit_bubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - } - }, - - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; - } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; - } - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event, true ); - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - jQuery._data( elem, "_change_attached", true ); - } - }); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return !rformElems.test( this.nodeName ); - } - }; -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - }); -} - -jQuery.fn.extend({ - - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var origFn, type; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { // && selector != null - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } - - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on( types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); - }, - - bind: function( types, data, fn ) { - return this.on( types, null, data, fn ); - }, - unbind: function( types, fn ) { - return this.off( types, null, fn ); - }, - - live: function( types, data, fn ) { - jQuery( this.context ).on( types, this.selector, data, fn ); - return this; - }, - die: function( types, fn ) { - jQuery( this.context ).off( types, this.selector || "**", fn ); - return this; - }, - - delegate: function( selector, types, data, fn ) { - return this.on( types, selector, data, fn ); - }, - undelegate: function( selector, types, fn ) { - // ( namespace ) or ( selector, types [, fn] ) - return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - if ( this[0] ) { - return jQuery.event.trigger( type, data, this[0], true ); - } - }, - - toggle: function( fn ) { - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; - - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while ( i < args.length ) { - args[ i++ ].guid = guid; - } - - return this.click( toggler ); - }, - - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); - -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - if ( fn == null ) { - fn = data; - data = null; - } - - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); - }; - - if ( rkeyEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; - } - - if ( rmouseEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; - } -}); -/*! - * Sizzle CSS Selector Engine - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license - * http://sizzlejs.com/ - */ -(function( window, undefined ) { - -var cachedruns, - assertGetIdNotName, - Expr, - getText, - isXML, - contains, - compile, - sortOrder, - hasDuplicate, - outermostContext, - - baseHasDuplicate = true, - strundefined = "undefined", - - expando = ( "sizcache" + Math.random() ).replace( ".", "" ), - - Token = String, - document = window.document, - docElem = document.documentElement, - dirruns = 0, - done = 0, - pop = [].pop, - push = [].push, - slice = [].slice, - // Use a stripped-down indexOf if a native one is unavailable - indexOf = [].indexOf || function( elem ) { - var i = 0, - len = this.length; - for ( ; i < len; i++ ) { - if ( this[i] === elem ) { - return i; - } - } - return -1; - }, - - // Augment a function for special use by Sizzle - markFunction = function( fn, value ) { - fn[ expando ] = value == null || value; - return fn; - }, - - createCache = function() { - var cache = {}, - keys = []; - - return markFunction(function( key, value ) { - // Only keep the most recent entries - if ( keys.push( key ) > Expr.cacheLength ) { - delete cache[ keys.shift() ]; - } - - return (cache[ key ] = value); - }, cache ); - }, - - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - - // Regex - - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors) - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace( "w", "w#" ), - - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors - operators = "([*^$|!~]?=)", - attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + - "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - - // Prefer arguments not in parens/brackets, - // then attribute selectors and non-pseudos (denoted by :), - // then anything else - // These preferences are here to reduce the number of selectors - // needing tokenize in the PSEUDO preFilter - pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)", - - // For matchExpr.POS and matchExpr.needsContext - pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + - "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), - rpseudo = new RegExp( pseudos ), - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, - - rnot = /^:not/, - rsibling = /[\x20\t\r\n\f]*[+~]/, - rendsWithNot = /:not\($/, - - rheader = /h\d/i, - rinputs = /input|select|textarea|button/i, - - rbackslash = /\\(?!\\)/g, - - matchExpr = { - "ID": new RegExp( "^#(" + characterEncoding + ")" ), - "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), - "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), - "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "POS": new RegExp( pos, "i" ), - "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - // For use in libraries implementing .is() - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" ) - }, - - // Support - - // Used for testing something on an element - assert = function( fn ) { - var div = document.createElement("div"); - - try { - return fn( div ); - } catch (e) { - return false; - } finally { - // release memory in IE - div = null; - } - }, - - // Check if getElementsByTagName("*") returns only elements - assertTagNameNoComments = assert(function( div ) { - div.appendChild( document.createComment("") ); - return !div.getElementsByTagName("*").length; - }), - - // Check if getAttribute returns normalized href attributes - assertHrefNotNormalized = assert(function( div ) { - div.innerHTML = ""; - return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && - div.firstChild.getAttribute("href") === "#"; - }), - - // Check if attributes should be retrieved by attribute nodes - assertAttributes = assert(function( div ) { - div.innerHTML = ""; - var type = typeof div.lastChild.getAttribute("multiple"); - // IE8 returns a string for some attributes even when not present - return type !== "boolean" && type !== "string"; - }), - - // Check if getElementsByClassName can be trusted - assertUsableClassName = assert(function( div ) { - // Opera can't find a second classname (in 9.6) - div.innerHTML = ""; - if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { - return false; - } - - // Safari 3.2 caches class attributes and doesn't catch changes - div.lastChild.className = "e"; - return div.getElementsByClassName("e").length === 2; - }), - - // Check if getElementById returns elements by name - // Check if getElementsByName privileges form controls or returns elements by ID - assertUsableName = assert(function( div ) { - // Inject content - div.id = expando + 0; - div.innerHTML = "
"; - docElem.insertBefore( div, docElem.firstChild ); - - // Test - var pass = document.getElementsByName && - // buggy browsers will return fewer than the correct 2 - document.getElementsByName( expando ).length === 2 + - // buggy browsers will return more than the correct 0 - document.getElementsByName( expando + 0 ).length; - assertGetIdNotName = !document.getElementById( expando ); - - // Cleanup - docElem.removeChild( div ); - - return pass; - }); - -// If slice is not available, provide a backup -try { - slice.call( docElem.childNodes, 0 )[0].nodeType; -} catch ( e ) { - slice = function( i ) { - var elem, - results = []; - for ( ; (elem = this[i]); i++ ) { - results.push( elem ); - } - return results; - }; -} - -function Sizzle( selector, context, results, seed ) { - results = results || []; - context = context || document; - var match, elem, xml, m, - nodeType = context.nodeType; - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - if ( nodeType !== 1 && nodeType !== 9 ) { - return []; - } - - xml = isXML( context ); - - if ( !xml && !seed ) { - if ( (match = rquickExpr.exec( selector )) ) { - // Speed-up: Sizzle("#ID") - if ( (m = match[1]) ) { - if ( nodeType === 9 ) { - elem = context.getElementById( m ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - } else { - // Context is not a document - if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && - contains( context, elem ) && elem.id === m ) { - results.push( elem ); - return results; - } - } - - // Speed-up: Sizzle("TAG") - } else if ( match[2] ) { - push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); - return results; - - // Speed-up: Sizzle(".CLASS") - } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) { - push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); - return results; - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed, xml ); -} - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, null, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - return Sizzle( expr, null, null, [ elem ] ).length > 0; -}; - -// Returns a function to use in pseudos for input types -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -// Returns a function to use in pseudos for buttons -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; - }; -} - -// Returns a function to use in pseudos for positionals -function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { - argument = +argument; - return markFunction(function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); -} - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( nodeType ) { - if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (see #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - } else { - - // If no nodeType, this is expected to be an array - for ( ; (node = elem[i]); i++ ) { - // Do not traverse comment nodes - ret += getText( node ); - } - } - return ret; -}; - -isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -// Element contains another -contains = Sizzle.contains = docElem.contains ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) ); - } : - docElem.compareDocumentPosition ? - function( a, b ) { - return b && !!( a.compareDocumentPosition( b ) & 16 ); - } : - function( a, b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - return false; - }; - -Sizzle.attr = function( elem, name ) { - var val, - xml = isXML( elem ); - - if ( !xml ) { - name = name.toLowerCase(); - } - if ( (val = Expr.attrHandle[ name ]) ) { - return val( elem ); - } - if ( xml || assertAttributes ) { - return elem.getAttribute( name ); - } - val = elem.getAttributeNode( name ); - return val ? - typeof elem[ name ] === "boolean" ? - elem[ name ] ? name : null : - val.specified ? val.value : null : - null; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - // IE6/7 return a modified href - attrHandle: assertHrefNotNormalized ? - {} : - { - "href": function( elem ) { - return elem.getAttribute( "href", 2 ); - }, - "type": function( elem ) { - return elem.getAttribute("type"); - } - }, - - find: { - "ID": assertGetIdNotName ? - function( id, context, xml ) { - if ( typeof context.getElementById !== strundefined && !xml ) { - var m = context.getElementById( id ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - } : - function( id, context, xml ) { - if ( typeof context.getElementById !== strundefined && !xml ) { - var m = context.getElementById( id ); - - return m ? - m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? - [m] : - undefined : - []; - } - }, - - "TAG": assertTagNameNoComments ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== strundefined ) { - return context.getElementsByTagName( tag ); - } - } : - function( tag, context ) { - var results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - var elem, - tmp = [], - i = 0; - - for ( ; (elem = results[i]); i++ ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }, - - "NAME": assertUsableName && function( tag, context ) { - if ( typeof context.getElementsByName !== strundefined ) { - return context.getElementsByName( name ); - } - }, - - "CLASS": assertUsableClassName && function( className, context, xml ) { - if ( typeof context.getElementsByClassName !== strundefined && !xml ) { - return context.getElementsByClassName( className ); - } - } - }, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[1] = match[1].replace( rbackslash, "" ); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" ); - - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 3 xn-component of xn+y argument ([+-]?\d*n|) - 4 sign of xn-component - 5 x of xn-component - 6 sign of y-component - 7 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if ( match[1] === "nth" ) { - // nth-child requires argument - if ( !match[2] ) { - Sizzle.error( match[0] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) ); - match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" ); - - // other types prohibit arguments - } else if ( match[2] ) { - Sizzle.error( match[0] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var unquoted, excess; - if ( matchExpr["CHILD"].test( match[0] ) ) { - return null; - } - - if ( match[3] ) { - match[2] = match[3]; - } else if ( (unquoted = match[4]) ) { - // Only check arguments that contain a pseudo - if ( rpseudo.test(unquoted) && - // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - - // excess is a negative index - unquoted = unquoted.slice( 0, excess ); - match[0] = match[0].slice( 0, excess ); - } - match[2] = unquoted; - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - "ID": assertGetIdNotName ? - function( id ) { - id = id.replace( rbackslash, "" ); - return function( elem ) { - return elem.getAttribute("id") === id; - }; - } : - function( id ) { - id = id.replace( rbackslash, "" ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); - return node && node.value === id; - }; - }, - - "TAG": function( nodeName ) { - if ( nodeName === "*" ) { - return function() { return true; }; - } - nodeName = nodeName.replace( rbackslash, "" ).toLowerCase(); - - return function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ expando ][ className ]; - if ( !pattern ) { - pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") ); - } - return function( elem ) { - return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); - }; - }, - - "ATTR": function( name, operator, check ) { - return function( elem, context ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.substr( result.length - check.length ) === check : - operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" : - false; - }; - }, - - "CHILD": function( type, argument, first, last ) { - - if ( type === "nth" ) { - return function( elem ) { - var node, diff, - parent = elem.parentNode; - - if ( first === 1 && last === 0 ) { - return true; - } - - if ( parent ) { - diff = 0; - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - diff++; - if ( elem === node ) { - break; - } - } - } - } - - // Incorporate the offset (or cast to NaN), then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - }; - } - - return function( elem ) { - var node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } - - node = elem; - - /* falls through */ - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - return true; - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf.call( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); - } - }) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - "not": markFunction(function( selector ) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function( elem, context, xml ) { - input[0] = elem; - matcher( input, null, xml, results ); - return !results.pop(); - }; - }), - - "has": markFunction(function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - }), - - "contains": markFunction(function( text ) { - return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; - }; - }), - - "enabled": function( elem ) { - return elem.disabled === false; - }, - - "disabled": function( elem ) { - return elem.disabled === true; - }, - - "checked": function( elem ) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); - }, - - "selected": function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); - }, - - "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), - // not comment, processing instructions, or others - // Thanks to Diego Perini for the nodeName shortcut - // Greater than "@" means alpha characters (specifically not starting with "#" or "?") - var nodeType; - elem = elem.firstChild; - while ( elem ) { - if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) { - return false; - } - elem = elem.nextSibling; - } - return true; - }, - - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "text": function( elem ) { - var type, attr; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && - (type = elem.type) === "text" && - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type ); - }, - - // Input types - "radio": createInputPseudo("radio"), - "checkbox": createInputPseudo("checkbox"), - "file": createInputPseudo("file"), - "password": createInputPseudo("password"), - "image": createInputPseudo("image"), - - "submit": createButtonPseudo("submit"), - "reset": createButtonPseudo("reset"), - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "focus": function( elem ) { - var doc = elem.ownerDocument; - return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href); - }, - - "active": function( elem ) { - return elem === elem.ownerDocument.activeElement; - }, - - // Positional types - "first": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ 0 ]; - }), - - "last": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ length - 1 ]; - }), - - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - }), - - "even": createPositionalPseudo(function( matchIndexes, length, argument ) { - for ( var i = 0; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "odd": createPositionalPseudo(function( matchIndexes, length, argument ) { - for ( var i = 1; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { - for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }) - } -}; - -function siblingCheck( a, b, ret ) { - if ( a === b ) { - return ret; - } - - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; -} - -sortOrder = docElem.compareDocumentPosition ? - function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - return ( !a.compareDocumentPosition || !b.compareDocumentPosition ? - a.compareDocumentPosition : - a.compareDocumentPosition(b) & 4 - ) ? -1 : 1; - } : - function( a, b ) { - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } - - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // If the nodes are siblings (or identical) we can do a quick check - if ( aup === bup ) { - return siblingCheck( a, b ); - - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; - - } else if ( !bup ) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } - - cur = bup; - - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - -// Always assume the presence of duplicates if sort doesn't -// pass them to our comparison function (as in Google Chrome). -[0, 0].sort( sortOrder ); -baseHasDuplicate = !hasDuplicate; - -// Document sorting and removing duplicates -Sizzle.uniqueSort = function( results ) { - var elem, - i = 1; - - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( ; (elem = results[i]); i++ ) { - if ( elem === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } - } - - return results; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -function tokenize( selector, parseOnly ) { - var matched, match, tokens, type, soFar, groups, preFilters, - cached = tokenCache[ expando ][ selector ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { - if ( match ) { - soFar = soFar.slice( match[0].length ); - } - groups.push( tokens = [] ); - } - - matched = false; - - // Combinators - if ( (match = rcombinators.exec( soFar )) ) { - tokens.push( matched = new Token( match.shift() ) ); - soFar = soFar.slice( matched.length ); - - // Cast descendant combinators to space - matched.type = match[0].replace( rtrim, " " ); - } - - // Filters - for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - // The last two arguments here are (context, xml) for backCompat - (match = preFilters[ type ]( match, document, true ))) ) { - - tokens.push( matched = new Token( match.shift() ) ); - soFar = soFar.slice( matched.length ); - matched.type = type; - matched.matches = match; - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - checkNonElements = base && combinator.dir === "parentNode", - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { - if ( checkNonElements || elem.nodeType === 1 ) { - return matcher( elem, context, xml ); - } - } - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching - if ( !xml ) { - var cache, - dirkey = dirruns + " " + doneName + " ", - cachedkey = dirkey + cachedruns; - while ( (elem = elem[ dir ]) ) { - if ( checkNonElements || elem.nodeType === 1 ) { - if ( (cache = elem[ expando ]) === cachedkey ) { - return elem.sizset; - } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) { - if ( elem.sizset ) { - return elem; - } - } else { - elem[ expando ] = cachedkey; - if ( matcher( elem, context, xml ) ) { - elem.sizset = true; - return elem; - } - elem.sizset = false; - } - } - } - } else { - while ( (elem = elem[ dir ]) ) { - if ( checkNonElements || elem.nodeType === 1 ) { - if ( matcher( elem, context, xml ) ) { - return elem; - } - } - } - } - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[0]; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction(function( seed, results, context, xml ) { - // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones - if ( seed && postFinder ) { - return; - } - - var i, elem, postFilterIn, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - postFilterIn = condense( matcherOut, postMap ); - postFilter( postFilterIn, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = postFilterIn.length; - while ( i-- ) { - if ( (elem = postFilterIn[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - // Keep seed and results synchronized - if ( seed ) { - // Ignore postFinder because it can't coexist with seed - i = preFilter && matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) ) { - seed[ preMap[i] ] = !(results[ preMap[i] ] = elem); - } - } - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - }); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf.call( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - } ]; - - for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; - } else { - // The concatenated values are (context, xml) for backCompat - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), - j < len && tokens.join("") - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - var bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, expandContext ) { - var elem, j, matcher, - setMatched = [], - matchedCount = 0, - i = "0", - unmatched = seed && [], - outermost = expandContext != null, - contextBackup = outermostContext, - // We must always have either seed elements or context - elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), - // Nested matchers should use non-integer dirruns - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E); - - if ( outermost ) { - outermostContext = context !== document && context; - cachedruns = superMatcher.el; - } - - // Add elements passing elementMatchers directly to results - for ( ; (elem = elems[i]) != null; i++ ) { - if ( byElement && elem ) { - for ( j = 0; (matcher = elementMatchers[j]); j++ ) { - if ( matcher( elem, context, xml ) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - cachedruns = ++superMatcher.el; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // Apply set filters to unmatched elements - matchedCount += i; - if ( bySet && i !== matchedCount ) { - for ( j = 0; (matcher = setMatchers[j]); j++ ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - superMatcher.el = 0; - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ expando ][ selector ]; - - if ( !cached ) { - // Generate a function of recursive functions that can be used to check each element - if ( !group ) { - group = tokenize( selector ); - } - i = group.length; - while ( i-- ) { - cached = matcherFromTokens( group[i] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); - } - return cached; -}; - -function multipleContexts( selector, contexts, results, seed ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results, seed ); - } - return results; -} - -function select( selector, context, results, seed, xml ) { - var i, tokens, token, type, find, - match = tokenize( selector ), - j = match.length; - - if ( !seed ) { - // Try to minimize operations if there is only one group - if ( match.length === 1 ) { - - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - context.nodeType === 9 && !xml && - Expr.relative[ tokens[1].type ] ) { - - context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0]; - if ( !context ) { - return results; - } - - selector = selector.slice( tokens.shift().length ); - } - - // Fetch a seed set for right-to-left matching - for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) { - token = tokens[i]; - - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( rbackslash, "" ), - rsibling.test( tokens[0].type ) && context.parentNode || context, - xml - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && tokens.join(""); - if ( !selector ) { - push.apply( results, slice.call( seed, 0 ) ); - return results; - } - - break; - } - } - } - } - } - - // Compile and execute a filtering function - // Provide `match` to avoid retokenization if we modified the selector above - compile( selector, match )( - seed, - context, - xml, - results, - rsibling.test( selector ) - ); - return results; -} - -if ( document.querySelectorAll ) { - (function() { - var disconnectedMatch, - oldSelect = select, - rescape = /'|\\/g, - rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, - - // qSa(:focus) reports false when true (Chrome 21), - // A support test would require too much code (would include document ready) - rbuggyQSA = [":focus"], - - // matchesSelector(:focus) reports false when true (Chrome 21), - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - // A support test would require too much code (would include document ready) - // just skip matchesSelector for :active - rbuggyMatches = [ ":active", ":focus" ], - matches = docElem.matchesSelector || - docElem.mozMatchesSelector || - docElem.webkitMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector; - - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function( div ) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explictly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - div.innerHTML = ""; - - // IE8 - Some boolean attributes are not treated correctly - if ( !div.querySelectorAll("[selected]").length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here (do not put tests after this one) - if ( !div.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); - } - }); - - assert(function( div ) { - - // Opera 10-12/IE9 - ^= $= *= and empty values - // Should not select anything - div.innerHTML = "

"; - if ( div.querySelectorAll("[test^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here (do not put tests after this one) - div.innerHTML = ""; - if ( !div.querySelectorAll(":enabled").length ) { - rbuggyQSA.push(":enabled", ":disabled"); - } - }); - - // rbuggyQSA always contains :focus, so no need for a length check - rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); - - select = function( selector, context, results, seed, xml ) { - // Only use querySelectorAll when not filtering, - // when this is not xml, - // and when no QSA bugs apply - if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { - var groups, i, - old = true, - nid = expando, - newContext = context, - newSelector = context.nodeType === 9 && selector; - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - groups = tokenize( selector ); - - if ( (old = context.getAttribute("id")) ) { - nid = old.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", nid ); - } - nid = "[id='" + nid + "'] "; - - i = groups.length; - while ( i-- ) { - groups[i] = nid + groups[i].join(""); - } - newContext = rsibling.test( selector ) && context.parentNode || context; - newSelector = groups.join(","); - } - - if ( newSelector ) { - try { - push.apply( results, slice.call( newContext.querySelectorAll( - newSelector - ), 0 ) ); - return results; - } catch(qsaError) { - } finally { - if ( !old ) { - context.removeAttribute("id"); - } - } - } - } - - return oldSelect( selector, context, results, seed, xml ); - }; - - if ( matches ) { - assert(function( div ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - disconnectedMatch = matches.call( div, "div" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - try { - matches.call( div, "[test!='']:sizzle" ); - rbuggyMatches.push( "!=", pseudos ); - } catch ( e ) {} - }); - - // rbuggyMatches always contains :active and :focus, so no need for a length check - rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") ); - - Sizzle.matchesSelector = function( elem, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); - - // rbuggyMatches always contains :active, so no need for an existence check - if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) { - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch(e) {} - } - - return Sizzle( expr, null, null, [ elem ] ).length > 0; - }; - } - })(); -} - -// Deprecated -Expr.pseudos["nth"] = Expr.pseudos["eq"]; - -// Back-compat -function setFilters() {} -Expr.filters = setFilters.prototype = Expr.pseudos; -Expr.setFilters = new setFilters(); - -// Override sizzle attribute retrieval -Sizzle.attr = jQuery.attr; -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.pseudos; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})( window ); -var runtil = /Until$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - isSimple = /^.[^:#\[\.,]*$/, - rneedsContext = jQuery.expr.match.needsContext, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var i, l, length, n, r, ret, - self = this; - - if ( typeof selector !== "string" ) { - return jQuery( selector ).filter(function() { - for ( i = 0, l = self.length; i < l; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }); - } - - ret = this.pushStack( "", "find", selector ); - - for ( i = 0, l = this.length; i < l; i++ ) { - length = ret.length; - jQuery.find( selector, this[i], ret ); - - if ( i > 0 ) { - // Make sure that the results are unique - for ( n = length; n < ret.length; n++ ) { - for ( r = 0; r < length; r++ ) { - if ( ret[r] === ret[n] ) { - ret.splice(n--, 1); - break; - } - } - } - } - } - - return ret; - }, - - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; - - return this.filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false), "not", selector); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true), "filter", selector ); - }, - - is: function( selector ) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - rneedsContext.test( selector ) ? - jQuery( selector, this.context ).index( this[0] ) >= 0 : - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - ret = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( ; i < l; i++ ) { - cur = this[i]; - - while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - } - cur = cur.parentNode; - } - } - - ret = ret.length > 1 ? jQuery.unique( ret ) : ret; - - return this.pushStack( ret, "closest", selectors ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); - } -}); - -jQuery.fn.andSelf = jQuery.fn.addBack; - -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). -function isDisconnected( node ) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; -} - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - - return cur; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - - if ( this.length > 1 && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret, name, core_slice.call( arguments ).join(",") ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem, i ) { - return ( elem === qualifier ) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem, i ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; - }); -} -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - -var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + - "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", - rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rtbody = /]", "i"), - rcheckableType = /^(?:checkbox|radio)$/, - // checked="checked" or checked - rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, - rscriptType = /\/(java|ecma)script/i, - rcleanScript = /^\s*\s*$/g, - wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
", "
" ], - thead: [ 1, "", "
" ], - tr: [ 2, "", "
" ], - td: [ 3, "", "
" ], - col: [ 2, "", "
" ], - area: [ 1, "", "" ], - _default: [ 0, "", "" ] - }, - safeFragment = createSafeFragment( document ), - fragmentDiv = safeFragment.appendChild( document.createElement("div") ); - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, -// unless wrapped in a div with non-breaking characters in front of it. -if ( !jQuery.support.htmlSerialize ) { - wrapMap._default = [ 1, "X
", "
" ]; -} - -jQuery.fn.extend({ - text: function( value ) { - return jQuery.access( this, function( value ) { - return value === undefined ? - jQuery.text( this ) : - this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); - }, null, value, arguments.length ); - }, - - wrapAll: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapAll( html.call(this, i) ); - }); - } - - if ( this[0] ) { - // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); - - if ( this[0].parentNode ) { - wrap.insertBefore( this[0] ); - } - - wrap.map(function() { - var elem = this; - - while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { - elem = elem.firstChild; - } - - return elem; - }).append( this ); - } - - return this; - }, - - wrapInner: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapInner( html.call(this, i) ); - }); - } - - return this.each(function() { - var self = jQuery( this ), - contents = self.contents(); - - if ( contents.length ) { - contents.wrapAll( html ); - - } else { - self.append( html ); - } - }); - }, - - wrap: function( html ) { - var isFunction = jQuery.isFunction( html ); - - return this.each(function(i) { - jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); - }); - }, - - unwrap: function() { - return this.parent().each(function() { - if ( !jQuery.nodeName( this, "body" ) ) { - jQuery( this ).replaceWith( this.childNodes ); - } - }).end(); - }, - - append: function() { - return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 ) { - this.appendChild( elem ); - } - }); - }, - - prepend: function() { - return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 ) { - this.insertBefore( elem, this.firstChild ); - } - }); - }, - - before: function() { - if ( !isDisconnected( this[0] ) ) { - return this.domManip(arguments, false, function( elem ) { - this.parentNode.insertBefore( elem, this ); - }); - } - - if ( arguments.length ) { - var set = jQuery.clean( arguments ); - return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); - } - }, - - after: function() { - if ( !isDisconnected( this[0] ) ) { - return this.domManip(arguments, false, function( elem ) { - this.parentNode.insertBefore( elem, this.nextSibling ); - }); - } - - if ( arguments.length ) { - var set = jQuery.clean( arguments ); - return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); - } - }, - - // keepData is for internal use only--do not document - remove: function( selector, keepData ) { - var elem, - i = 0; - - for ( ; (elem = this[i]) != null; i++ ) { - if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { - if ( !keepData && elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName("*") ); - jQuery.cleanData( [ elem ] ); - } - - if ( elem.parentNode ) { - elem.parentNode.removeChild( elem ); - } - } - } - - return this; - }, - - empty: function() { - var elem, - i = 0; - - for ( ; (elem = this[i]) != null; i++ ) { - // Remove element nodes and prevent memory leaks - if ( elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName("*") ); - } - - // Remove any remaining nodes - while ( elem.firstChild ) { - elem.removeChild( elem.firstChild ); - } - } - - return this; - }, - - clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map( function () { - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - }); - }, - - html: function( value ) { - return jQuery.access( this, function( value ) { - var elem = this[0] || {}, - i = 0, - l = this.length; - - if ( value === undefined ) { - return elem.nodeType === 1 ? - elem.innerHTML.replace( rinlinejQuery, "" ) : - undefined; - } - - // See if we can take a shortcut and just use innerHTML - if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && - ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { - - value = value.replace( rxhtmlTag, "<$1>" ); - - try { - for (; i < l; i++ ) { - // Remove element nodes and prevent memory leaks - elem = this[i] || {}; - if ( elem.nodeType === 1 ) { - jQuery.cleanData( elem.getElementsByTagName( "*" ) ); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch(e) {} - } - - if ( elem ) { - this.empty().append( value ); - } - }, null, value, arguments.length ); - }, - - replaceWith: function( value ) { - if ( !isDisconnected( this[0] ) ) { - // Make sure that the elements are removed from the DOM before they are inserted - // this can help fix replacing a parent with child elements - if ( jQuery.isFunction( value ) ) { - return this.each(function(i) { - var self = jQuery(this), old = self.html(); - self.replaceWith( value.call( this, i, old ) ); - }); - } - - if ( typeof value !== "string" ) { - value = jQuery( value ).detach(); - } - - return this.each(function() { - var next = this.nextSibling, - parent = this.parentNode; - - jQuery( this ).remove(); - - if ( next ) { - jQuery(next).before( value ); - } else { - jQuery(parent).append( value ); - } - }); - } - - return this.length ? - this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : - this; - }, - - detach: function( selector ) { - return this.remove( selector, true ); - }, - - domManip: function( args, table, callback ) { - - // Flatten any nested arrays - args = [].concat.apply( [], args ); - - var results, first, fragment, iNoClone, - i = 0, - value = args[0], - scripts = [], - l = this.length; - - // We can't cloneNode fragments that contain checked, in WebKit - if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) { - return this.each(function() { - jQuery(this).domManip( args, table, callback ); - }); - } - - if ( jQuery.isFunction(value) ) { - return this.each(function(i) { - var self = jQuery(this); - args[0] = value.call( this, i, table ? self.html() : undefined ); - self.domManip( args, table, callback ); - }); - } - - if ( this[0] ) { - results = jQuery.buildFragment( args, this, scripts ); - fragment = results.fragment; - first = fragment.firstChild; - - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } - - if ( first ) { - table = table && jQuery.nodeName( first, "tr" ); - - // Use the original fragment for the last item instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - // Fragments from the fragment cache must always be cloned and never used in place. - for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) { - callback.call( - table && jQuery.nodeName( this[i], "table" ) ? - findOrAppend( this[i], "tbody" ) : - this[i], - i === iNoClone ? - fragment : - jQuery.clone( fragment, true, true ) - ); - } - } - - // Fix #11809: Avoid leaking memory - fragment = first = null; - - if ( scripts.length ) { - jQuery.each( scripts, function( i, elem ) { - if ( elem.src ) { - if ( jQuery.ajax ) { - jQuery.ajax({ - url: elem.src, - type: "GET", - dataType: "script", - async: false, - global: false, - "throws": true - }); - } else { - jQuery.error("no ajax"); - } - } else { - jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) ); - } - - if ( elem.parentNode ) { - elem.parentNode.removeChild( elem ); - } - }); - } - } - - return this; - } -}); - -function findOrAppend( elem, tag ) { - return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); -} - -function cloneCopyEvent( src, dest ) { - - if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { - return; - } - - var type, i, l, - oldData = jQuery._data( src ), - curData = jQuery._data( dest, oldData ), - events = oldData.events; - - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } - } - } - - // make the cloned public data object a copy from the original - if ( curData.data ) { - curData.data = jQuery.extend( {}, curData.data ); - } -} - -function cloneFixAttributes( src, dest ) { - var nodeName; - - // We do not need to do anything for non-Elements - if ( dest.nodeType !== 1 ) { - return; - } - - // clearAttributes removes the attributes, which we don't want, - // but also removes the attachEvent events, which we *do* want - if ( dest.clearAttributes ) { - dest.clearAttributes(); - } - - // mergeAttributes, in contrast, only merges back on the - // original attributes, not the events - if ( dest.mergeAttributes ) { - dest.mergeAttributes( src ); - } - - nodeName = dest.nodeName.toLowerCase(); - - if ( nodeName === "object" ) { - // IE6-10 improperly clones children of object elements using classid. - // IE10 throws NoModificationAllowedError if parent is null, #12132. - if ( dest.parentNode ) { - dest.outerHTML = src.outerHTML; - } - - // This path appears unavoidable for IE9. When cloning an object - // element in IE9, the outerHTML strategy above is not sufficient. - // If the src has innerHTML and the destination does not, - // copy the src.innerHTML into the dest.innerHTML. #10324 - if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) { - dest.innerHTML = src.innerHTML; - } - - } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { - // IE6-8 fails to persist the checked state of a cloned checkbox - // or radio button. Worse, IE6-7 fail to give the cloned element - // a checked appearance if the defaultChecked value isn't also set - - dest.defaultChecked = dest.checked = src.checked; - - // IE6-7 get confused and end up setting the value of a cloned - // checkbox/radio button to an empty string instead of "on" - if ( dest.value !== src.value ) { - dest.value = src.value; - } - - // IE6-8 fails to return the selected option to the default selected - // state when cloning options - } else if ( nodeName === "option" ) { - dest.selected = src.defaultSelected; - - // IE6-8 fails to set the defaultValue to the correct value when - // cloning other types of input fields - } else if ( nodeName === "input" || nodeName === "textarea" ) { - dest.defaultValue = src.defaultValue; - - // IE blanks contents when cloning scripts - } else if ( nodeName === "script" && dest.text !== src.text ) { - dest.text = src.text; - } - - // Event data gets referenced instead of copied if the expando - // gets copied too - dest.removeAttribute( jQuery.expando ); -} - -jQuery.buildFragment = function( args, context, scripts ) { - var fragment, cacheable, cachehit, - first = args[ 0 ]; - - // Set context from what may come in as undefined or a jQuery collection or a node - // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & - // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception - context = context || document; - context = !context.nodeType && context[0] || context; - context = context.ownerDocument || context; - - // Only cache "small" (1/2 KB) HTML strings that are associated with the main document - // Cloning options loses the selected state, so don't cache them - // IE 6 doesn't like it when you put or elements in a fragment - // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache - // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 - if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document && - first.charAt(0) === "<" && !rnocache.test( first ) && - (jQuery.support.checkClone || !rchecked.test( first )) && - (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { - - // Mark cacheable and look for a hit - cacheable = true; - fragment = jQuery.fragments[ first ]; - cachehit = fragment !== undefined; - } - - if ( !fragment ) { - fragment = context.createDocumentFragment(); - jQuery.clean( args, context, fragment, scripts ); - - // Update the cache, but only store false - // unless this is a second parsing of the same content - if ( cacheable ) { - jQuery.fragments[ first ] = cachehit && fragment; - } - } - - return { fragment: fragment, cacheable: cacheable }; -}; - -jQuery.fragments = {}; - -jQuery.each({ - appendTo: "append", - prependTo: "prepend", - insertBefore: "before", - insertAfter: "after", - replaceAll: "replaceWith" -}, function( name, original ) { - jQuery.fn[ name ] = function( selector ) { - var elems, - i = 0, - ret = [], - insert = jQuery( selector ), - l = insert.length, - parent = this.length === 1 && this[0].parentNode; - - if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) { - insert[ original ]( this[0] ); - return this; - } else { - for ( ; i < l; i++ ) { - elems = ( i > 0 ? this.clone(true) : this ).get(); - jQuery( insert[i] )[ original ]( elems ); - ret = ret.concat( elems ); - } - - return this.pushStack( ret, name, insert.selector ); - } - }; -}); - -function getAll( elem ) { - if ( typeof elem.getElementsByTagName !== "undefined" ) { - return elem.getElementsByTagName( "*" ); - - } else if ( typeof elem.querySelectorAll !== "undefined" ) { - return elem.querySelectorAll( "*" ); - - } else { - return []; - } -} - -// Used in clean, fixes the defaultChecked property -function fixDefaultChecked( elem ) { - if ( rcheckableType.test( elem.type ) ) { - elem.defaultChecked = elem.checked; - } -} - -jQuery.extend({ - clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var srcElements, - destElements, - i, - clone; - - if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { - clone = elem.cloneNode( true ); - - // IE<=8 does not properly clone detached, unknown element nodes - } else { - fragmentDiv.innerHTML = elem.outerHTML; - fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); - } - - if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && - (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { - // IE copies events bound via attachEvent when using cloneNode. - // Calling detachEvent on the clone will also remove the events - // from the original. In order to get around this, we use some - // proprietary methods to clear the events. Thanks to MooTools - // guys for this hotness. - - cloneFixAttributes( elem, clone ); - - // Using Sizzle here is crazy slow, so we use getElementsByTagName instead - srcElements = getAll( elem ); - destElements = getAll( clone ); - - // Weird iteration because IE will replace the length property - // with an element if you are cloning the body and one of the - // elements on the page has a name or id of "length" - for ( i = 0; srcElements[i]; ++i ) { - // Ensure that the destination node is not null; Fixes #9587 - if ( destElements[i] ) { - cloneFixAttributes( srcElements[i], destElements[i] ); - } - } - } - - // Copy the events from the original to the clone - if ( dataAndEvents ) { - cloneCopyEvent( elem, clone ); - - if ( deepDataAndEvents ) { - srcElements = getAll( elem ); - destElements = getAll( clone ); - - for ( i = 0; srcElements[i]; ++i ) { - cloneCopyEvent( srcElements[i], destElements[i] ); - } - } - } - - srcElements = destElements = null; - - // Return the cloned set - return clone; - }, - - clean: function( elems, context, fragment, scripts ) { - var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags, - safe = context === document && safeFragment, - ret = []; - - // Ensure that context is a document - if ( !context || typeof context.createDocumentFragment === "undefined" ) { - context = document; - } - - // Use the already-created safe fragment if context permits - for ( i = 0; (elem = elems[i]) != null; i++ ) { - if ( typeof elem === "number" ) { - elem += ""; - } - - if ( !elem ) { - continue; - } - - // Convert html string into DOM nodes - if ( typeof elem === "string" ) { - if ( !rhtml.test( elem ) ) { - elem = context.createTextNode( elem ); - } else { - // Ensure a safe container in which to render the html - safe = safe || createSafeFragment( context ); - div = context.createElement("div"); - safe.appendChild( div ); - - // Fix "XHTML"-style tags in all browsers - elem = elem.replace(rxhtmlTag, "<$1>"); - - // Go to html and back, then peel off extra wrappers - tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); - wrap = wrapMap[ tag ] || wrapMap._default; - depth = wrap[0]; - div.innerHTML = wrap[1] + elem + wrap[2]; - - // Move to the right depth - while ( depth-- ) { - div = div.lastChild; - } - - // Remove IE's autoinserted from table fragments - if ( !jQuery.support.tbody ) { - - // String was a , *may* have spurious - hasBody = rtbody.test(elem); - tbody = tag === "table" && !hasBody ? - div.firstChild && div.firstChild.childNodes : - - // String was a bare or - wrap[1] === "
" && !hasBody ? - div.childNodes : - []; - - for ( j = tbody.length - 1; j >= 0 ; --j ) { - if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { - tbody[ j ].parentNode.removeChild( tbody[ j ] ); - } - } - } - - // IE completely kills leading whitespace when innerHTML is used - if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { - div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); - } - - elem = div.childNodes; - - // Take out of fragment container (we need a fresh div each time) - div.parentNode.removeChild( div ); - } - } - - if ( elem.nodeType ) { - ret.push( elem ); - } else { - jQuery.merge( ret, elem ); - } - } - - // Fix #11356: Clear elements from safeFragment - if ( div ) { - elem = div = safe = null; - } - - // Reset defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - if ( !jQuery.support.appendChecked ) { - for ( i = 0; (elem = ret[i]) != null; i++ ) { - if ( jQuery.nodeName( elem, "input" ) ) { - fixDefaultChecked( elem ); - } else if ( typeof elem.getElementsByTagName !== "undefined" ) { - jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); - } - } - } - - // Append elements to a provided document fragment - if ( fragment ) { - // Special handling of each script element - handleScript = function( elem ) { - // Check if we consider it executable - if ( !elem.type || rscriptType.test( elem.type ) ) { - // Detach the script and store it in the scripts array (if provided) or the fragment - // Return truthy to indicate that it has been handled - return scripts ? - scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : - fragment.appendChild( elem ); - } - }; - - for ( i = 0; (elem = ret[i]) != null; i++ ) { - // Check if we're done after handling an executable script - if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { - // Append to fragment and handle embedded scripts - fragment.appendChild( elem ); - if ( typeof elem.getElementsByTagName !== "undefined" ) { - // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration - jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); - - // Splice the scripts into ret after their former ancestor and advance our index beyond them - ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); - i += jsTags.length; - } - } - } - } - - return ret; - }, - - cleanData: function( elems, /* internal */ acceptData ) { - var data, id, elem, type, - i = 0, - internalKey = jQuery.expando, - cache = jQuery.cache, - deleteExpando = jQuery.support.deleteExpando, - special = jQuery.event.special; - - for ( ; (elem = elems[i]) != null; i++ ) { - - if ( acceptData || jQuery.acceptData( elem ) ) { - - id = elem[ internalKey ]; - data = id && cache[ id ]; - - if ( data ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } - } - } - - // Remove cache only if it was not already removed by jQuery.event.remove - if ( cache[ id ] ) { - - delete cache[ id ]; - - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( deleteExpando ) { - delete elem[ internalKey ]; - - } else if ( elem.removeAttribute ) { - elem.removeAttribute( internalKey ); - - } else { - elem[ internalKey ] = null; - } - - jQuery.deletedIds.push( id ); - } - } - } - } - } -}); -// Limit scope pollution from any deprecated API -(function() { - -var matched, browser; - -// Use of jQuery.browser is frowned upon. -// More details: http://api.jquery.com/jQuery.browser -// jQuery.uaMatch maintained for back-compat -jQuery.uaMatch = function( ua ) { - ua = ua.toLowerCase(); - - var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || - /(webkit)[ \/]([\w.]+)/.exec( ua ) || - /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || - /(msie) ([\w.]+)/.exec( ua ) || - ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || - []; - - return { - browser: match[ 1 ] || "", - version: match[ 2 ] || "0" - }; -}; - -matched = jQuery.uaMatch( navigator.userAgent ); -browser = {}; - -if ( matched.browser ) { - browser[ matched.browser ] = true; - browser.version = matched.version; -} - -// Chrome is Webkit, but Webkit is also Safari. -if ( browser.chrome ) { - browser.webkit = true; -} else if ( browser.webkit ) { - browser.safari = true; -} - -jQuery.browser = browser; - -jQuery.sub = function() { - function jQuerySub( selector, context ) { - return new jQuerySub.fn.init( selector, context ); - } - jQuery.extend( true, jQuerySub, this ); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { - context = jQuerySub( context ); - } - - return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - return jQuerySub; -}; - -})(); -var curCSS, iframe, iframeDoc, - ralpha = /alpha\([^)]*\)/i, - ropacity = /opacity=([^)]*)/, - rposition = /^(top|right|bottom|left)$/, - // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" - // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display - rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rmargin = /^margin/, - rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), - rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), - rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ), - elemdisplay = {}, - - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssNormalTransform = { - letterSpacing: 0, - fontWeight: 400 - }, - - cssExpand = [ "Top", "Right", "Bottom", "Left" ], - cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], - - eventsToggle = jQuery.fn.toggle; - -// return a css property mapped to a potentially vendor prefixed property -function vendorPropName( style, name ) { - - // shortcut for names that are not vendor prefixed - if ( name in style ) { - return name; - } - - // check for vendor prefixed names - var capName = name.charAt(0).toUpperCase() + name.slice(1), - origName = name, - i = cssPrefixes.length; - - while ( i-- ) { - name = cssPrefixes[ i ] + capName; - if ( name in style ) { - return name; - } - } - - return origName; -} - -function isHidden( elem, el ) { - elem = el || elem; - return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); -} - -function showHide( elements, show ) { - var elem, display, - values = [], - index = 0, - length = elements.length; - - for ( ; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - values[ index ] = jQuery._data( elem, "olddisplay" ); - if ( show ) { - // Reset the inline display of this element to learn if it is - // being hidden by cascaded rules or not - if ( !values[ index ] && elem.style.display === "none" ) { - elem.style.display = ""; - } - - // Set elements which have been overridden with display: none - // in a stylesheet to whatever the default browser style is - // for such an element - if ( elem.style.display === "" && isHidden( elem ) ) { - values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); - } - } else { - display = curCSS( elem, "display" ); - - if ( !values[ index ] && display !== "none" ) { - jQuery._data( elem, "olddisplay", display ); - } - } - } - - // Set the display of most of the elements in a second loop - // to avoid the constant reflow - for ( index = 0; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - if ( !show || elem.style.display === "none" || elem.style.display === "" ) { - elem.style.display = show ? values[ index ] || "" : "none"; - } - } - - return elements; -} - -jQuery.fn.extend({ - css: function( name, value ) { - return jQuery.access( this, function( elem, name, value ) { - return value !== undefined ? - jQuery.style( elem, name, value ) : - jQuery.css( elem, name ); - }, name, value, arguments.length > 1 ); - }, - show: function() { - return showHide( this, true ); - }, - hide: function() { - return showHide( this ); - }, - toggle: function( state, fn2 ) { - var bool = typeof state === "boolean"; - - if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { - return eventsToggle.apply( this, arguments ); - } - - return this.each(function() { - if ( bool ? state : isHidden( this ) ) { - jQuery( this ).show(); - } else { - jQuery( this ).hide(); - } - }); - } -}); - -jQuery.extend({ - // Add in style property hooks for overriding the default - // behavior of getting and setting a style property - cssHooks: { - opacity: { - get: function( elem, computed ) { - if ( computed ) { - // We should always get a number back from opacity - var ret = curCSS( elem, "opacity" ); - return ret === "" ? "1" : ret; - - } - } - } - }, - - // Exclude the following css properties to add px - cssNumber: { - "fillOpacity": true, - "fontWeight": true, - "lineHeight": true, - "opacity": true, - "orphans": true, - "widows": true, - "zIndex": true, - "zoom": true - }, - - // Add in properties whose names you wish to fix before - // setting or getting the value - cssProps: { - // normalize float css property - "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" - }, - - // Get and set the style property on a DOM Node - style: function( elem, name, value, extra ) { - // Don't set styles on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { - return; - } - - // Make sure that we're working with the right name - var ret, type, hooks, - origName = jQuery.camelCase( name ), - style = elem.style; - - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // Check if we're setting a value - if ( value !== undefined ) { - type = typeof value; - - // convert relative number strings (+= or -=) to relative numbers. #7345 - if ( type === "string" && (ret = rrelNum.exec( value )) ) { - value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); - // Fixes bug #9237 - type = "number"; - } - - // Make sure that NaN and null values aren't set. See: #7116 - if ( value == null || type === "number" && isNaN( value ) ) { - return; - } - - // If a number was passed in, add 'px' to the (except for certain CSS properties) - if ( type === "number" && !jQuery.cssNumber[ origName ] ) { - value += "px"; - } - - // If a hook was provided, use that value, otherwise just set the specified value - if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { - // Wrapped to prevent IE from throwing errors when 'invalid' values are provided - // Fixes bug #5509 - try { - style[ name ] = value; - } catch(e) {} - } - - } else { - // If a hook was provided get the non-computed value from there - if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { - return ret; - } - - // Otherwise just get the value from the style object - return style[ name ]; - } - }, - - css: function( elem, name, numeric, extra ) { - var val, num, hooks, - origName = jQuery.camelCase( name ); - - // Make sure that we're working with the right name - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // If a hook was provided get the computed value from there - if ( hooks && "get" in hooks ) { - val = hooks.get( elem, true, extra ); - } - - // Otherwise, if a way to get the computed value exists, use that - if ( val === undefined ) { - val = curCSS( elem, name ); - } - - //convert "normal" to computed value - if ( val === "normal" && name in cssNormalTransform ) { - val = cssNormalTransform[ name ]; - } - - // Return, converting to number if forced or a qualifier was provided and val looks numeric - if ( numeric || extra !== undefined ) { - num = parseFloat( val ); - return numeric || jQuery.isNumeric( num ) ? num || 0 : val; - } - return val; - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations - swap: function( elem, options, callback ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.call( elem ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; - } -}); - -// NOTE: To any future maintainer, we've window.getComputedStyle -// because jsdom on node.js will break without it. -if ( window.getComputedStyle ) { - curCSS = function( elem, name ) { - var ret, width, minWidth, maxWidth, - computed = window.getComputedStyle( elem, null ), - style = elem.style; - - if ( computed ) { - - ret = computed[ name ]; - if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { - ret = jQuery.style( elem, name ); - } - - // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right - // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels - // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values - if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { - width = style.width; - minWidth = style.minWidth; - maxWidth = style.maxWidth; - - style.minWidth = style.maxWidth = style.width = ret; - ret = computed.width; - - style.width = width; - style.minWidth = minWidth; - style.maxWidth = maxWidth; - } - } - - return ret; - }; -} else if ( document.documentElement.currentStyle ) { - curCSS = function( elem, name ) { - var left, rsLeft, - ret = elem.currentStyle && elem.currentStyle[ name ], - style = elem.style; - - // Avoid setting ret to empty string here - // so we don't default to auto - if ( ret == null && style && style[ name ] ) { - ret = style[ name ]; - } - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - // but not position css attributes, as those are proportional to the parent element instead - // and we can't measure the parent instead because it might trigger a "stacking dolls" problem - if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { - - // Remember the original values - left = style.left; - rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; - - // Put in the new values to get a computed value out - if ( rsLeft ) { - elem.runtimeStyle.left = elem.currentStyle.left; - } - style.left = name === "fontSize" ? "1em" : ret; - ret = style.pixelLeft + "px"; - - // Revert the changed values - style.left = left; - if ( rsLeft ) { - elem.runtimeStyle.left = rsLeft; - } - } - - return ret === "" ? "auto" : ret; - }; -} - -function setPositiveNumber( elem, value, subtract ) { - var matches = rnumsplit.exec( value ); - return matches ? - Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : - value; -} - -function augmentWidthOrHeight( elem, name, extra, isBorderBox ) { - var i = extra === ( isBorderBox ? "border" : "content" ) ? - // If we already have the right measurement, avoid augmentation - 4 : - // Otherwise initialize for horizontal or vertical properties - name === "width" ? 1 : 0, - - val = 0; - - for ( ; i < 4; i += 2 ) { - // both box models exclude margin, so add it if we want it - if ( extra === "margin" ) { - // we use jQuery.css instead of curCSS here - // because of the reliableMarginRight CSS hook! - val += jQuery.css( elem, extra + cssExpand[ i ], true ); - } - - // From this point on we use curCSS for maximum performance (relevant in animations) - if ( isBorderBox ) { - // border-box includes padding, so remove it if we want content - if ( extra === "content" ) { - val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; - } - - // at this point, extra isn't border nor margin, so remove border - if ( extra !== "margin" ) { - val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; - } - } else { - // at this point, extra isn't content, so add padding - val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; - - // at this point, extra isn't content nor padding, so add border - if ( extra !== "padding" ) { - val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; - } - } - } - - return val; -} - -function getWidthOrHeight( elem, name, extra ) { - - // Start with offset property, which is equivalent to the border-box value - var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, - valueIsBorderBox = true, - isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"; - - // some non-html elements return undefined for offsetWidth, so check for null/undefined - // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 - // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 - if ( val <= 0 || val == null ) { - // Fall back to computed then uncomputed css if necessary - val = curCSS( elem, name ); - if ( val < 0 || val == null ) { - val = elem.style[ name ]; - } - - // Computed unit is not pixels. Stop here and return. - if ( rnumnonpx.test(val) ) { - return val; - } - - // we need the check for style in case a browser which returns unreliable values - // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); - - // Normalize "", auto, and prepare for extra - val = parseFloat( val ) || 0; - } - - // use the active box-sizing model to add/subtract irrelevant styles - return ( val + - augmentWidthOrHeight( - elem, - name, - extra || ( isBorderBox ? "border" : "content" ), - valueIsBorderBox - ) - ) + "px"; -} - - -// Try to determine the default display value of an element -function css_defaultDisplay( nodeName ) { - if ( elemdisplay[ nodeName ] ) { - return elemdisplay[ nodeName ]; - } - - var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ), - display = elem.css("display"); - elem.remove(); - - // If the simple way fails, - // get element's real default display by attaching it to a temp iframe - if ( display === "none" || display === "" ) { - // Use the already-created iframe if possible - iframe = document.body.appendChild( - iframe || jQuery.extend( document.createElement("iframe"), { - frameBorder: 0, - width: 0, - height: 0 - }) - ); - - // Create a cacheable copy of the iframe document on first call. - // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML - // document to it; WebKit & Firefox won't allow reusing the iframe document. - if ( !iframeDoc || !iframe.createElement ) { - iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; - iframeDoc.write(""); - iframeDoc.close(); - } - - elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) ); - - display = curCSS( elem, "display" ); - document.body.removeChild( iframe ); - } - - // Store the correct default display - elemdisplay[ nodeName ] = display; - - return display; -} - -jQuery.each([ "height", "width" ], function( i, name ) { - jQuery.cssHooks[ name ] = { - get: function( elem, computed, extra ) { - if ( computed ) { - // certain elements can have dimension info if we invisibly show them - // however, it must have a current display style that would benefit from this - if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { - return jQuery.swap( elem, cssShow, function() { - return getWidthOrHeight( elem, name, extra ); - }); - } else { - return getWidthOrHeight( elem, name, extra ); - } - } - }, - - set: function( elem, value, extra ) { - return setPositiveNumber( elem, value, extra ? - augmentWidthOrHeight( - elem, - name, - extra, - jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" - ) : 0 - ); - } - }; -}); - -if ( !jQuery.support.opacity ) { - jQuery.cssHooks.opacity = { - get: function( elem, computed ) { - // IE uses filters for opacity - return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? - ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : - computed ? "1" : ""; - }, - - set: function( elem, value ) { - var style = elem.style, - currentStyle = elem.currentStyle, - opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", - filter = currentStyle && currentStyle.filter || style.filter || ""; - - // IE has trouble with opacity if it does not have layout - // Force it by setting the zoom level - style.zoom = 1; - - // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 - if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && - style.removeAttribute ) { - - // Setting style.filter to null, "" & " " still leave "filter:" in the cssText - // if "filter:" is present at all, clearType is disabled, we want to avoid this - // style.removeAttribute is IE Only, but so apparently is this code path... - style.removeAttribute( "filter" ); - - // if there there is no filter style applied in a css rule, we are done - if ( currentStyle && !currentStyle.filter ) { - return; - } - } - - // otherwise, set new filter values - style.filter = ralpha.test( filter ) ? - filter.replace( ralpha, opacity ) : - filter + " " + opacity; - } - }; -} - -// These hooks cannot be added until DOM ready because the support test -// for it is not run until after DOM ready -jQuery(function() { - if ( !jQuery.support.reliableMarginRight ) { - jQuery.cssHooks.marginRight = { - get: function( elem, computed ) { - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - // Work around by temporarily setting element display to inline-block - return jQuery.swap( elem, { "display": "inline-block" }, function() { - if ( computed ) { - return curCSS( elem, "marginRight" ); - } - }); - } - }; - } - - // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 - // getComputedStyle returns percent when specified for top/left/bottom/right - // rather than make the css module depend on the offset module, we just check for it here - if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { - jQuery.each( [ "top", "left" ], function( i, prop ) { - jQuery.cssHooks[ prop ] = { - get: function( elem, computed ) { - if ( computed ) { - var ret = curCSS( elem, prop ); - // if curCSS returns percentage, fallback to offset - return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; - } - } - }; - }); - } - -}); - -if ( jQuery.expr && jQuery.expr.filters ) { - jQuery.expr.filters.hidden = function( elem ) { - return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none"); - }; - - jQuery.expr.filters.visible = function( elem ) { - return !jQuery.expr.filters.hidden( elem ); - }; -} - -// These hooks are used by animate to expand properties -jQuery.each({ - margin: "", - padding: "", - border: "Width" -}, function( prefix, suffix ) { - jQuery.cssHooks[ prefix + suffix ] = { - expand: function( value ) { - var i, - - // assumes a single number if not a string - parts = typeof value === "string" ? value.split(" ") : [ value ], - expanded = {}; - - for ( i = 0; i < 4; i++ ) { - expanded[ prefix + cssExpand[ i ] + suffix ] = - parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; - } - - return expanded; - } - }; - - if ( !rmargin.test( prefix ) ) { - jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; - } -}); -var r20 = /%20/g, - rbracket = /\[\]$/, - rCRLF = /\r?\n/g, - rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, - rselectTextarea = /^(?:select|textarea)/i; - -jQuery.fn.extend({ - serialize: function() { - return jQuery.param( this.serializeArray() ); - }, - serializeArray: function() { - return this.map(function(){ - return this.elements ? jQuery.makeArray( this.elements ) : this; - }) - .filter(function(){ - return this.name && !this.disabled && - ( this.checked || rselectTextarea.test( this.nodeName ) || - rinput.test( this.type ) ); - }) - .map(function( i, elem ){ - var val = jQuery( this ).val(); - - return val == null ? - null : - jQuery.isArray( val ) ? - jQuery.map( val, function( val, i ){ - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - }) : - { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; - }).get(); - } -}); - -//Serialize an array of form elements or a set of -//key/values into a query string -jQuery.param = function( a, traditional ) { - var prefix, - s = [], - add = function( key, value ) { - // If value is a function, invoke it and return its value - value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); - s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); - }; - - // Set traditional to true for jQuery <= 1.3.2 behavior. - if ( traditional === undefined ) { - traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; - } - - // If an array was passed in, assume that it is an array of form elements. - if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { - // Serialize the form elements - jQuery.each( a, function() { - add( this.name, this.value ); - }); - - } else { - // If traditional, encode the "old" way (the way 1.3.2 or older - // did it), otherwise encode params recursively. - for ( prefix in a ) { - buildParams( prefix, a[ prefix ], traditional, add ); - } - } - - // Return the resulting serialization - return s.join( "&" ).replace( r20, "+" ); -}; - -function buildParams( prefix, obj, traditional, add ) { - var name; - - if ( jQuery.isArray( obj ) ) { - // Serialize array item. - jQuery.each( obj, function( i, v ) { - if ( traditional || rbracket.test( prefix ) ) { - // Treat each array item as a scalar. - add( prefix, v ); - - } else { - // If array item is non-scalar (array or object), encode its - // numeric index to resolve deserialization ambiguity issues. - // Note that rack (as of 1.0.0) can't currently deserialize - // nested arrays properly, and attempting to do so may cause - // a server error. Possible fixes are to modify rack's - // deserialization algorithm or to provide an option or flag - // to force array serialization to be shallow. - buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); - } - }); - - } else if ( !traditional && jQuery.type( obj ) === "object" ) { - // Serialize object item. - for ( name in obj ) { - buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); - } - - } else { - // Serialize scalar item. - add( prefix, obj ); - } -} -var - // Document location - ajaxLocParts, - ajaxLocation, - - rhash = /#.*$/, - rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL - // #7653, #8125, #8152: local protocol detection - rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, - rnoContent = /^(?:GET|HEAD)$/, - rprotocol = /^\/\//, - rquery = /\?/, - rscript = /)<[^<]*)*<\/script>/gi, - rts = /([?&])_=[^&]*/, - rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, - - // Keep a copy of the old load method - _load = jQuery.fn.load, - - /* Prefilters - * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) - * 2) These are called: - * - BEFORE asking for a transport - * - AFTER param serialization (s.data is a string if s.processData is true) - * 3) key is the dataType - * 4) the catchall symbol "*" can be used - * 5) execution will start with transport dataType and THEN continue down to "*" if needed - */ - prefilters = {}, - - /* Transports bindings - * 1) key is the dataType - * 2) the catchall symbol "*" can be used - * 3) selection will start with transport dataType and THEN go to "*" if needed - */ - transports = {}, - - // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression - allTypes = ["*/"] + ["*"]; - -// #8138, IE may throw an exception when accessing -// a field from window.location if document.domain has been set -try { - ajaxLocation = location.href; -} catch( e ) { - // Use the href attribute of an A element - // since IE will modify it given document.location - ajaxLocation = document.createElement( "a" ); - ajaxLocation.href = ""; - ajaxLocation = ajaxLocation.href; -} - -// Segment location into parts -ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; - -// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport -function addToPrefiltersOrTransports( structure ) { - - // dataTypeExpression is optional and defaults to "*" - return function( dataTypeExpression, func ) { - - if ( typeof dataTypeExpression !== "string" ) { - func = dataTypeExpression; - dataTypeExpression = "*"; - } - - var dataType, list, placeBefore, - dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), - i = 0, - length = dataTypes.length; - - if ( jQuery.isFunction( func ) ) { - // For each dataType in the dataTypeExpression - for ( ; i < length; i++ ) { - dataType = dataTypes[ i ]; - // We control if we're asked to add before - // any existing element - placeBefore = /^\+/.test( dataType ); - if ( placeBefore ) { - dataType = dataType.substr( 1 ) || "*"; - } - list = structure[ dataType ] = structure[ dataType ] || []; - // then we add to the structure accordingly - list[ placeBefore ? "unshift" : "push" ]( func ); - } - } - }; -} - -// Base inspection function for prefilters and transports -function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, - dataType /* internal */, inspected /* internal */ ) { - - dataType = dataType || options.dataTypes[ 0 ]; - inspected = inspected || {}; - - inspected[ dataType ] = true; - - var selection, - list = structure[ dataType ], - i = 0, - length = list ? list.length : 0, - executeOnly = ( structure === prefilters ); - - for ( ; i < length && ( executeOnly || !selection ); i++ ) { - selection = list[ i ]( options, originalOptions, jqXHR ); - // If we got redirected to another dataType - // we try there if executing only and not done already - if ( typeof selection === "string" ) { - if ( !executeOnly || inspected[ selection ] ) { - selection = undefined; - } else { - options.dataTypes.unshift( selection ); - selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jqXHR, selection, inspected ); - } - } - } - // If we're only executing or nothing was selected - // we try the catchall dataType if not done already - if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { - selection = inspectPrefiltersOrTransports( - structure, options, originalOptions, jqXHR, "*", inspected ); - } - // unnecessary when only executing (prefilters) - // but it'll be ignored by the caller in that case - return selection; -} - -// A special extend for ajax options -// that takes "flat" options (not to be deep extended) -// Fixes #9887 -function ajaxExtend( target, src ) { - var key, deep, - flatOptions = jQuery.ajaxSettings.flatOptions || {}; - for ( key in src ) { - if ( src[ key ] !== undefined ) { - ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; - } - } - if ( deep ) { - jQuery.extend( true, target, deep ); - } -} - -jQuery.fn.load = function( url, params, callback ) { - if ( typeof url !== "string" && _load ) { - return _load.apply( this, arguments ); - } - - // Don't do a request if no elements are being requested - if ( !this.length ) { - return this; - } - - var selector, type, response, - self = this, - off = url.indexOf(" "); - - if ( off >= 0 ) { - selector = url.slice( off, url.length ); - url = url.slice( 0, off ); - } - - // If it's a function - if ( jQuery.isFunction( params ) ) { - - // We assume that it's the callback - callback = params; - params = undefined; - - // Otherwise, build a param string - } else if ( params && typeof params === "object" ) { - type = "POST"; - } - - // Request the remote document - jQuery.ajax({ - url: url, - - // if "type" variable is undefined, then "GET" method will be used - type: type, - dataType: "html", - data: params, - complete: function( jqXHR, status ) { - if ( callback ) { - self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); - } - } - }).done(function( responseText ) { - - // Save response for use in complete callback - response = arguments; - - // See if a selector was specified - self.html( selector ? - - // Create a dummy div to hold the results - jQuery("
") - - // inject the contents of the document in, removing the scripts - // to avoid any 'Permission Denied' errors in IE - .append( responseText.replace( rscript, "" ) ) - - // Locate the specified elements - .find( selector ) : - - // If not, just inject the full result - responseText ); - - }); - - return this; -}; - -// Attach a bunch of functions for handling common AJAX events -jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ - jQuery.fn[ o ] = function( f ){ - return this.on( o, f ); - }; -}); - -jQuery.each( [ "get", "post" ], function( i, method ) { - jQuery[ method ] = function( url, data, callback, type ) { - // shift arguments if data argument was omitted - if ( jQuery.isFunction( data ) ) { - type = type || callback; - callback = data; - data = undefined; - } - - return jQuery.ajax({ - type: method, - url: url, - data: data, - success: callback, - dataType: type - }); - }; -}); - -jQuery.extend({ - - getScript: function( url, callback ) { - return jQuery.get( url, undefined, callback, "script" ); - }, - - getJSON: function( url, data, callback ) { - return jQuery.get( url, data, callback, "json" ); - }, - - // Creates a full fledged settings object into target - // with both ajaxSettings and settings fields. - // If target is omitted, writes into ajaxSettings. - ajaxSetup: function( target, settings ) { - if ( settings ) { - // Building a settings object - ajaxExtend( target, jQuery.ajaxSettings ); - } else { - // Extending ajaxSettings - settings = target; - target = jQuery.ajaxSettings; - } - ajaxExtend( target, settings ); - return target; - }, - - ajaxSettings: { - url: ajaxLocation, - isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), - global: true, - type: "GET", - contentType: "application/x-www-form-urlencoded; charset=UTF-8", - processData: true, - async: true, - /* - timeout: 0, - data: null, - dataType: null, - username: null, - password: null, - cache: null, - throws: false, - traditional: false, - headers: {}, - */ - - accepts: { - xml: "application/xml, text/xml", - html: "text/html", - text: "text/plain", - json: "application/json, text/javascript", - "*": allTypes - }, - - contents: { - xml: /xml/, - html: /html/, - json: /json/ - }, - - responseFields: { - xml: "responseXML", - text: "responseText" - }, - - // List of data converters - // 1) key format is "source_type destination_type" (a single space in-between) - // 2) the catchall symbol "*" can be used for source_type - converters: { - - // Convert anything to text - "* text": window.String, - - // Text to html (true = no transformation) - "text html": true, - - // Evaluate text as a json expression - "text json": jQuery.parseJSON, - - // Parse text as xml - "text xml": jQuery.parseXML - }, - - // For options that shouldn't be deep extended: - // you can add your own custom options here if - // and when you create one that shouldn't be - // deep extended (see ajaxExtend) - flatOptions: { - context: true, - url: true - } - }, - - ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), - ajaxTransport: addToPrefiltersOrTransports( transports ), - - // Main method - ajax: function( url, options ) { - - // If url is an object, simulate pre-1.5 signature - if ( typeof url === "object" ) { - options = url; - url = undefined; - } - - // Force options to be an object - options = options || {}; - - var // ifModified key - ifModifiedKey, - // Response headers - responseHeadersString, - responseHeaders, - // transport - transport, - // timeout handle - timeoutTimer, - // Cross-domain detection vars - parts, - // To know if global events are to be dispatched - fireGlobals, - // Loop variable - i, - // Create the final options object - s = jQuery.ajaxSetup( {}, options ), - // Callbacks context - callbackContext = s.context || s, - // Context for global events - // It's the callbackContext if one was provided in the options - // and if it's a DOM node or a jQuery collection - globalEventContext = callbackContext !== s && - ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? - jQuery( callbackContext ) : jQuery.event, - // Deferreds - deferred = jQuery.Deferred(), - completeDeferred = jQuery.Callbacks( "once memory" ), - // Status-dependent callbacks - statusCode = s.statusCode || {}, - // Headers (they are sent all at once) - requestHeaders = {}, - requestHeadersNames = {}, - // The jqXHR state - state = 0, - // Default abort message - strAbort = "canceled", - // Fake xhr - jqXHR = { - - readyState: 0, - - // Caches the header - setRequestHeader: function( name, value ) { - if ( !state ) { - var lname = name.toLowerCase(); - name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; - requestHeaders[ name ] = value; - } - return this; - }, - - // Raw string - getAllResponseHeaders: function() { - return state === 2 ? responseHeadersString : null; - }, - - // Builds headers hashtable if needed - getResponseHeader: function( key ) { - var match; - if ( state === 2 ) { - if ( !responseHeaders ) { - responseHeaders = {}; - while( ( match = rheaders.exec( responseHeadersString ) ) ) { - responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; - } - } - match = responseHeaders[ key.toLowerCase() ]; - } - return match === undefined ? null : match; - }, - - // Overrides response content-type header - overrideMimeType: function( type ) { - if ( !state ) { - s.mimeType = type; - } - return this; - }, - - // Cancel the request - abort: function( statusText ) { - statusText = statusText || strAbort; - if ( transport ) { - transport.abort( statusText ); - } - done( 0, statusText ); - return this; - } - }; - - // Callback for when everything is done - // It is defined here because jslint complains if it is declared - // at the end of the function (which would be more logical and readable) - function done( status, nativeStatusText, responses, headers ) { - var isSuccess, success, error, response, modified, - statusText = nativeStatusText; - - // Called once - if ( state === 2 ) { - return; - } - - // State is "done" now - state = 2; - - // Clear timeout if it exists - if ( timeoutTimer ) { - clearTimeout( timeoutTimer ); - } - - // Dereference transport for early garbage collection - // (no matter how long the jqXHR object will be used) - transport = undefined; - - // Cache response headers - responseHeadersString = headers || ""; - - // Set readyState - jqXHR.readyState = status > 0 ? 4 : 0; - - // Get response data - if ( responses ) { - response = ajaxHandleResponses( s, jqXHR, responses ); - } - - // If successful, handle type chaining - if ( status >= 200 && status < 300 || status === 304 ) { - - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. - if ( s.ifModified ) { - - modified = jqXHR.getResponseHeader("Last-Modified"); - if ( modified ) { - jQuery.lastModified[ ifModifiedKey ] = modified; - } - modified = jqXHR.getResponseHeader("Etag"); - if ( modified ) { - jQuery.etag[ ifModifiedKey ] = modified; - } - } - - // If not modified - if ( status === 304 ) { - - statusText = "notmodified"; - isSuccess = true; - - // If we have data - } else { - - isSuccess = ajaxConvert( s, response ); - statusText = isSuccess.state; - success = isSuccess.data; - error = isSuccess.error; - isSuccess = !error; - } - } else { - // We extract error from statusText - // then normalize statusText and status for non-aborts - error = statusText; - if ( !statusText || status ) { - statusText = "error"; - if ( status < 0 ) { - status = 0; - } - } - } - - // Set data for the fake xhr object - jqXHR.status = status; - jqXHR.statusText = ( nativeStatusText || statusText ) + ""; - - // Success/Error - if ( isSuccess ) { - deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); - } else { - deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); - } - - // Status-dependent callbacks - jqXHR.statusCode( statusCode ); - statusCode = undefined; - - if ( fireGlobals ) { - globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), - [ jqXHR, s, isSuccess ? success : error ] ); - } - - // Complete - completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); - - if ( fireGlobals ) { - globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); - // Handle the global AJAX counter - if ( !( --jQuery.active ) ) { - jQuery.event.trigger( "ajaxStop" ); - } - } - } - - // Attach deferreds - deferred.promise( jqXHR ); - jqXHR.success = jqXHR.done; - jqXHR.error = jqXHR.fail; - jqXHR.complete = completeDeferred.add; - - // Status-dependent callbacks - jqXHR.statusCode = function( map ) { - if ( map ) { - var tmp; - if ( state < 2 ) { - for ( tmp in map ) { - statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; - } - } else { - tmp = map[ jqXHR.status ]; - jqXHR.always( tmp ); - } - } - return this; - }; - - // Remove hash character (#7531: and string promotion) - // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) - // We also use the url parameter if available - s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); - - // Extract dataTypes list - s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); - - // A cross-domain request is in order when we have a protocol:host:port mismatch - if ( s.crossDomain == null ) { - parts = rurl.exec( s.url.toLowerCase() ) || false; - s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !== - ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ); - } - - // Convert data if not already a string - if ( s.data && s.processData && typeof s.data !== "string" ) { - s.data = jQuery.param( s.data, s.traditional ); - } - - // Apply prefilters - inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); - - // If request was aborted inside a prefilter, stop there - if ( state === 2 ) { - return jqXHR; - } - - // We can fire global events as of now if asked to - fireGlobals = s.global; - - // Uppercase the type - s.type = s.type.toUpperCase(); - - // Determine if request has content - s.hasContent = !rnoContent.test( s.type ); - - // Watch for a new set of requests - if ( fireGlobals && jQuery.active++ === 0 ) { - jQuery.event.trigger( "ajaxStart" ); - } - - // More options handling for requests with no content - if ( !s.hasContent ) { - - // If data is available, append data to url - if ( s.data ) { - s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; - // #9682: remove data so that it's not used in an eventual retry - delete s.data; - } - - // Get ifModifiedKey before adding the anti-cache parameter - ifModifiedKey = s.url; - - // Add anti-cache in url if needed - if ( s.cache === false ) { - - var ts = jQuery.now(), - // try replacing _= if it is there - ret = s.url.replace( rts, "$1_=" + ts ); - - // if nothing was replaced, add timestamp to the end - s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); - } - } - - // Set the correct header, if data is being sent - if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { - jqXHR.setRequestHeader( "Content-Type", s.contentType ); - } - - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. - if ( s.ifModified ) { - ifModifiedKey = ifModifiedKey || s.url; - if ( jQuery.lastModified[ ifModifiedKey ] ) { - jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); - } - if ( jQuery.etag[ ifModifiedKey ] ) { - jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); - } - } - - // Set the Accepts header for the server, depending on the dataType - jqXHR.setRequestHeader( - "Accept", - s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? - s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : - s.accepts[ "*" ] - ); - - // Check for headers option - for ( i in s.headers ) { - jqXHR.setRequestHeader( i, s.headers[ i ] ); - } - - // Allow custom headers/mimetypes and early abort - if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { - // Abort if not done already and return - return jqXHR.abort(); - - } - - // aborting is no longer a cancellation - strAbort = "abort"; - - // Install callbacks on deferreds - for ( i in { success: 1, error: 1, complete: 1 } ) { - jqXHR[ i ]( s[ i ] ); - } - - // Get transport - transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); - - // If no transport, we auto-abort - if ( !transport ) { - done( -1, "No Transport" ); - } else { - jqXHR.readyState = 1; - // Send global event - if ( fireGlobals ) { - globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); - } - // Timeout - if ( s.async && s.timeout > 0 ) { - timeoutTimer = setTimeout( function(){ - jqXHR.abort( "timeout" ); - }, s.timeout ); - } - - try { - state = 1; - transport.send( requestHeaders, done ); - } catch (e) { - // Propagate exception as error if not done - if ( state < 2 ) { - done( -1, e ); - // Simply rethrow otherwise - } else { - throw e; - } - } - } - - return jqXHR; - }, - - // Counter for holding the number of active queries - active: 0, - - // Last-Modified header cache for next request - lastModified: {}, - etag: {} - -}); - -/* Handles responses to an ajax request: - * - sets all responseXXX fields accordingly - * - finds the right dataType (mediates between content-type and expected dataType) - * - returns the corresponding response - */ -function ajaxHandleResponses( s, jqXHR, responses ) { - - var ct, type, finalDataType, firstDataType, - contents = s.contents, - dataTypes = s.dataTypes, - responseFields = s.responseFields; - - // Fill responseXXX fields - for ( type in responseFields ) { - if ( type in responses ) { - jqXHR[ responseFields[type] ] = responses[ type ]; - } - } - - // Remove auto dataType and get content-type in the process - while( dataTypes[ 0 ] === "*" ) { - dataTypes.shift(); - if ( ct === undefined ) { - ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); - } - } - - // Check if we're dealing with a known content-type - if ( ct ) { - for ( type in contents ) { - if ( contents[ type ] && contents[ type ].test( ct ) ) { - dataTypes.unshift( type ); - break; - } - } - } - - // Check to see if we have a response for the expected dataType - if ( dataTypes[ 0 ] in responses ) { - finalDataType = dataTypes[ 0 ]; - } else { - // Try convertible dataTypes - for ( type in responses ) { - if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { - finalDataType = type; - break; - } - if ( !firstDataType ) { - firstDataType = type; - } - } - // Or just use first one - finalDataType = finalDataType || firstDataType; - } - - // If we found a dataType - // We add the dataType to the list if needed - // and return the corresponding response - if ( finalDataType ) { - if ( finalDataType !== dataTypes[ 0 ] ) { - dataTypes.unshift( finalDataType ); - } - return responses[ finalDataType ]; - } -} - -// Chain conversions given the request and the original response -function ajaxConvert( s, response ) { - - var conv, conv2, current, tmp, - // Work with a copy of dataTypes in case we need to modify it for conversion - dataTypes = s.dataTypes.slice(), - prev = dataTypes[ 0 ], - converters = {}, - i = 0; - - // Apply the dataFilter if provided - if ( s.dataFilter ) { - response = s.dataFilter( response, s.dataType ); - } - - // Create converters map with lowercased keys - if ( dataTypes[ 1 ] ) { - for ( conv in s.converters ) { - converters[ conv.toLowerCase() ] = s.converters[ conv ]; - } - } - - // Convert to each sequential dataType, tolerating list modification - for ( ; (current = dataTypes[++i]); ) { - - // There's only work to do if current dataType is non-auto - if ( current !== "*" ) { - - // Convert response if prev dataType is non-auto and differs from current - if ( prev !== "*" && prev !== current ) { - - // Seek a direct converter - conv = converters[ prev + " " + current ] || converters[ "* " + current ]; - - // If none found, seek a pair - if ( !conv ) { - for ( conv2 in converters ) { - - // If conv2 outputs current - tmp = conv2.split(" "); - if ( tmp[ 1 ] === current ) { - - // If prev can be converted to accepted input - conv = converters[ prev + " " + tmp[ 0 ] ] || - converters[ "* " + tmp[ 0 ] ]; - if ( conv ) { - // Condense equivalence converters - if ( conv === true ) { - conv = converters[ conv2 ]; - - // Otherwise, insert the intermediate dataType - } else if ( converters[ conv2 ] !== true ) { - current = tmp[ 0 ]; - dataTypes.splice( i--, 0, current ); - } - - break; - } - } - } - } - - // Apply converter (if not an equivalence) - if ( conv !== true ) { - - // Unless errors are allowed to bubble, catch and return them - if ( conv && s["throws"] ) { - response = conv( response ); - } else { - try { - response = conv( response ); - } catch ( e ) { - return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; - } - } - } - } - - // Update prev for next iteration - prev = current; - } - } - - return { state: "success", data: response }; -} -var oldCallbacks = [], - rquestion = /\?/, - rjsonp = /(=)\?(?=&|$)|\?\?/, - nonce = jQuery.now(); - -// Default jsonp settings -jQuery.ajaxSetup({ - jsonp: "callback", - jsonpCallback: function() { - var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); - this[ callback ] = true; - return callback; - } -}); - -// Detect, normalize options and install callbacks for jsonp requests -jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { - - var callbackName, overwritten, responseContainer, - data = s.data, - url = s.url, - hasCallback = s.jsonp !== false, - replaceInUrl = hasCallback && rjsonp.test( url ), - replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && - !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && - rjsonp.test( data ); - - // Handle iff the expected data type is "jsonp" or we have a parameter to set - if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { - - // Get callback name, remembering preexisting value associated with it - callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? - s.jsonpCallback() : - s.jsonpCallback; - overwritten = window[ callbackName ]; - - // Insert callback into url or form data - if ( replaceInUrl ) { - s.url = url.replace( rjsonp, "$1" + callbackName ); - } else if ( replaceInData ) { - s.data = data.replace( rjsonp, "$1" + callbackName ); - } else if ( hasCallback ) { - s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; - } - - // Use data converter to retrieve json after script execution - s.converters["script json"] = function() { - if ( !responseContainer ) { - jQuery.error( callbackName + " was not called" ); - } - return responseContainer[ 0 ]; - }; - - // force json dataType - s.dataTypes[ 0 ] = "json"; - - // Install callback - window[ callbackName ] = function() { - responseContainer = arguments; - }; - - // Clean-up function (fires after converters) - jqXHR.always(function() { - // Restore preexisting value - window[ callbackName ] = overwritten; - - // Save back as free - if ( s[ callbackName ] ) { - // make sure that re-using the options doesn't screw things around - s.jsonpCallback = originalSettings.jsonpCallback; - - // save the callback name for future use - oldCallbacks.push( callbackName ); - } - - // Call if it was a function and we have a response - if ( responseContainer && jQuery.isFunction( overwritten ) ) { - overwritten( responseContainer[ 0 ] ); - } - - responseContainer = overwritten = undefined; - }); - - // Delegate to script - return "script"; - } -}); -// Install script dataType -jQuery.ajaxSetup({ - accepts: { - script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" - }, - contents: { - script: /javascript|ecmascript/ - }, - converters: { - "text script": function( text ) { - jQuery.globalEval( text ); - return text; - } - } -}); - -// Handle cache's special case and global -jQuery.ajaxPrefilter( "script", function( s ) { - if ( s.cache === undefined ) { - s.cache = false; - } - if ( s.crossDomain ) { - s.type = "GET"; - s.global = false; - } -}); - -// Bind script tag hack transport -jQuery.ajaxTransport( "script", function(s) { - - // This transport only deals with cross domain requests - if ( s.crossDomain ) { - - var script, - head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; - - return { - - send: function( _, callback ) { - - script = document.createElement( "script" ); - - script.async = "async"; - - if ( s.scriptCharset ) { - script.charset = s.scriptCharset; - } - - script.src = s.url; - - // Attach handlers for all browsers - script.onload = script.onreadystatechange = function( _, isAbort ) { - - if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { - - // Handle memory leak in IE - script.onload = script.onreadystatechange = null; - - // Remove the script - if ( head && script.parentNode ) { - head.removeChild( script ); - } - - // Dereference the script - script = undefined; - - // Callback if not abort - if ( !isAbort ) { - callback( 200, "success" ); - } - } - }; - // Use insertBefore instead of appendChild to circumvent an IE6 bug. - // This arises when a base node is used (#2709 and #4378). - head.insertBefore( script, head.firstChild ); - }, - - abort: function() { - if ( script ) { - script.onload( 0, 1 ); - } - } - }; - } -}); -var xhrCallbacks, - // #5280: Internet Explorer will keep connections alive if we don't abort on unload - xhrOnUnloadAbort = window.ActiveXObject ? function() { - // Abort all pending requests - for ( var key in xhrCallbacks ) { - xhrCallbacks[ key ]( 0, 1 ); - } - } : false, - xhrId = 0; - -// Functions to create xhrs -function createStandardXHR() { - try { - return new window.XMLHttpRequest(); - } catch( e ) {} -} - -function createActiveXHR() { - try { - return new window.ActiveXObject( "Microsoft.XMLHTTP" ); - } catch( e ) {} -} - -// Create the request object -// (This is still attached to ajaxSettings for backward compatibility) -jQuery.ajaxSettings.xhr = window.ActiveXObject ? - /* Microsoft failed to properly - * implement the XMLHttpRequest in IE7 (can't request local files), - * so we use the ActiveXObject when it is available - * Additionally XMLHttpRequest can be disabled in IE7/IE8 so - * we need a fallback. - */ - function() { - return !this.isLocal && createStandardXHR() || createActiveXHR(); - } : - // For all other browsers, use the standard XMLHttpRequest object - createStandardXHR; - -// Determine support properties -(function( xhr ) { - jQuery.extend( jQuery.support, { - ajax: !!xhr, - cors: !!xhr && ( "withCredentials" in xhr ) - }); -})( jQuery.ajaxSettings.xhr() ); - -// Create transport if the browser can provide an xhr -if ( jQuery.support.ajax ) { - - jQuery.ajaxTransport(function( s ) { - // Cross domain only allowed if supported through XMLHttpRequest - if ( !s.crossDomain || jQuery.support.cors ) { - - var callback; - - return { - send: function( headers, complete ) { - - // Get a new xhr - var handle, i, - xhr = s.xhr(); - - // Open the socket - // Passing null username, generates a login popup on Opera (#2865) - if ( s.username ) { - xhr.open( s.type, s.url, s.async, s.username, s.password ); - } else { - xhr.open( s.type, s.url, s.async ); - } - - // Apply custom fields if provided - if ( s.xhrFields ) { - for ( i in s.xhrFields ) { - xhr[ i ] = s.xhrFields[ i ]; - } - } - - // Override mime type if needed - if ( s.mimeType && xhr.overrideMimeType ) { - xhr.overrideMimeType( s.mimeType ); - } - - // X-Requested-With header - // For cross-domain requests, seeing as conditions for a preflight are - // akin to a jigsaw puzzle, we simply never set it to be sure. - // (it can always be set on a per-request basis or even using ajaxSetup) - // For same-domain requests, won't change header if already provided. - if ( !s.crossDomain && !headers["X-Requested-With"] ) { - headers[ "X-Requested-With" ] = "XMLHttpRequest"; - } - - // Need an extra try/catch for cross domain requests in Firefox 3 - try { - for ( i in headers ) { - xhr.setRequestHeader( i, headers[ i ] ); - } - } catch( _ ) {} - - // Do send the request - // This may raise an exception which is actually - // handled in jQuery.ajax (so no try/catch here) - xhr.send( ( s.hasContent && s.data ) || null ); - - // Listener - callback = function( _, isAbort ) { - - var status, - statusText, - responseHeaders, - responses, - xml; - - // Firefox throws exceptions when accessing properties - // of an xhr when a network error occurred - // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) - try { - - // Was never called and is aborted or complete - if ( callback && ( isAbort || xhr.readyState === 4 ) ) { - - // Only called once - callback = undefined; - - // Do not keep as active anymore - if ( handle ) { - xhr.onreadystatechange = jQuery.noop; - if ( xhrOnUnloadAbort ) { - delete xhrCallbacks[ handle ]; - } - } - - // If it's an abort - if ( isAbort ) { - // Abort it manually if needed - if ( xhr.readyState !== 4 ) { - xhr.abort(); - } - } else { - status = xhr.status; - responseHeaders = xhr.getAllResponseHeaders(); - responses = {}; - xml = xhr.responseXML; - - // Construct response list - if ( xml && xml.documentElement /* #4958 */ ) { - responses.xml = xml; - } - - // When requesting binary data, IE6-9 will throw an exception - // on any attempt to access responseText (#11426) - try { - responses.text = xhr.responseText; - } catch( _ ) { - } - - // Firefox throws an exception when accessing - // statusText for faulty cross-domain requests - try { - statusText = xhr.statusText; - } catch( e ) { - // We normalize with Webkit giving an empty statusText - statusText = ""; - } - - // Filter status for non standard behaviors - - // If the request is local and we have data: assume a success - // (success with no data won't get notified, that's the best we - // can do given current implementations) - if ( !status && s.isLocal && !s.crossDomain ) { - status = responses.text ? 200 : 404; - // IE - #1450: sometimes returns 1223 when it should be 204 - } else if ( status === 1223 ) { - status = 204; - } - } - } - } catch( firefoxAccessException ) { - if ( !isAbort ) { - complete( -1, firefoxAccessException ); - } - } - - // Call complete if needed - if ( responses ) { - complete( status, statusText, responses, responseHeaders ); - } - }; - - if ( !s.async ) { - // if we're in sync mode we fire the callback - callback(); - } else if ( xhr.readyState === 4 ) { - // (IE6 & IE7) if it's in cache and has been - // retrieved directly we need to fire the callback - setTimeout( callback, 0 ); - } else { - handle = ++xhrId; - if ( xhrOnUnloadAbort ) { - // Create the active xhrs callbacks list if needed - // and attach the unload handler - if ( !xhrCallbacks ) { - xhrCallbacks = {}; - jQuery( window ).unload( xhrOnUnloadAbort ); - } - // Add to list of active xhrs callbacks - xhrCallbacks[ handle ] = callback; - } - xhr.onreadystatechange = callback; - } - }, - - abort: function() { - if ( callback ) { - callback(0,1); - } - } - }; - } - }); -} -var fxNow, timerId, - rfxtypes = /^(?:toggle|show|hide)$/, - rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), - rrun = /queueHooks$/, - animationPrefilters = [ defaultPrefilter ], - tweeners = { - "*": [function( prop, value ) { - var end, unit, - tween = this.createTween( prop, value ), - parts = rfxnum.exec( value ), - target = tween.cur(), - start = +target || 0, - scale = 1, - maxIterations = 20; - - if ( parts ) { - end = +parts[2]; - unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" ); - - // We need to compute starting value - if ( unit !== "px" && start ) { - // Iteratively approximate from a nonzero starting point - // Prefer the current property, because this process will be trivial if it uses the same units - // Fallback to end or a simple constant - start = jQuery.css( tween.elem, prop, true ) || end || 1; - - do { - // If previous iteration zeroed out, double until we get *something* - // Use a string for doubling factor so we don't accidentally see scale as unchanged below - scale = scale || ".5"; - - // Adjust and apply - start = start / scale; - jQuery.style( tween.elem, prop, start + unit ); - - // Update scale, tolerating zero or NaN from tween.cur() - // And breaking the loop if scale is unchanged or perfect, or if we've just had enough - } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); - } - - tween.unit = unit; - tween.start = start; - // If a +=/-= token was provided, we're doing a relative animation - tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; - } - return tween; - }] - }; - -// Animations created synchronously will run synchronously -function createFxNow() { - setTimeout(function() { - fxNow = undefined; - }, 0 ); - return ( fxNow = jQuery.now() ); -} - -function createTweens( animation, props ) { - jQuery.each( props, function( prop, value ) { - var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), - index = 0, - length = collection.length; - for ( ; index < length; index++ ) { - if ( collection[ index ].call( animation, prop, value ) ) { - - // we're done with this property - return; - } - } - }); -} - -function Animation( elem, properties, options ) { - var result, - index = 0, - tweenerIndex = 0, - length = animationPrefilters.length, - deferred = jQuery.Deferred().always( function() { - // don't match elem in the :animated selector - delete tick.elem; - }), - tick = function() { - var currentTime = fxNow || createFxNow(), - remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), - percent = 1 - ( remaining / animation.duration || 0 ), - index = 0, - length = animation.tweens.length; - - for ( ; index < length ; index++ ) { - animation.tweens[ index ].run( percent ); - } - - deferred.notifyWith( elem, [ animation, percent, remaining ]); - - if ( percent < 1 && length ) { - return remaining; - } else { - deferred.resolveWith( elem, [ animation ] ); - return false; - } - }, - animation = deferred.promise({ - elem: elem, - props: jQuery.extend( {}, properties ), - opts: jQuery.extend( true, { specialEasing: {} }, options ), - originalProperties: properties, - originalOptions: options, - startTime: fxNow || createFxNow(), - duration: options.duration, - tweens: [], - createTween: function( prop, end, easing ) { - var tween = jQuery.Tween( elem, animation.opts, prop, end, - animation.opts.specialEasing[ prop ] || animation.opts.easing ); - animation.tweens.push( tween ); - return tween; - }, - stop: function( gotoEnd ) { - var index = 0, - // if we are going to the end, we want to run all the tweens - // otherwise we skip this part - length = gotoEnd ? animation.tweens.length : 0; - - for ( ; index < length ; index++ ) { - animation.tweens[ index ].run( 1 ); - } - - // resolve when we played the last frame - // otherwise, reject - if ( gotoEnd ) { - deferred.resolveWith( elem, [ animation, gotoEnd ] ); - } else { - deferred.rejectWith( elem, [ animation, gotoEnd ] ); - } - return this; - } - }), - props = animation.props; - - propFilter( props, animation.opts.specialEasing ); - - for ( ; index < length ; index++ ) { - result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); - if ( result ) { - return result; - } - } - - createTweens( animation, props ); - - if ( jQuery.isFunction( animation.opts.start ) ) { - animation.opts.start.call( elem, animation ); - } - - jQuery.fx.timer( - jQuery.extend( tick, { - anim: animation, - queue: animation.opts.queue, - elem: elem - }) - ); - - // attach callbacks from options - return animation.progress( animation.opts.progress ) - .done( animation.opts.done, animation.opts.complete ) - .fail( animation.opts.fail ) - .always( animation.opts.always ); -} - -function propFilter( props, specialEasing ) { - var index, name, easing, value, hooks; - - // camelCase, specialEasing and expand cssHook pass - for ( index in props ) { - name = jQuery.camelCase( index ); - easing = specialEasing[ name ]; - value = props[ index ]; - if ( jQuery.isArray( value ) ) { - easing = value[ 1 ]; - value = props[ index ] = value[ 0 ]; - } - - if ( index !== name ) { - props[ name ] = value; - delete props[ index ]; - } - - hooks = jQuery.cssHooks[ name ]; - if ( hooks && "expand" in hooks ) { - value = hooks.expand( value ); - delete props[ name ]; - - // not quite $.extend, this wont overwrite keys already present. - // also - reusing 'index' from above because we have the correct "name" - for ( index in value ) { - if ( !( index in props ) ) { - props[ index ] = value[ index ]; - specialEasing[ index ] = easing; - } - } - } else { - specialEasing[ name ] = easing; - } - } -} - -jQuery.Animation = jQuery.extend( Animation, { - - tweener: function( props, callback ) { - if ( jQuery.isFunction( props ) ) { - callback = props; - props = [ "*" ]; - } else { - props = props.split(" "); - } - - var prop, - index = 0, - length = props.length; - - for ( ; index < length ; index++ ) { - prop = props[ index ]; - tweeners[ prop ] = tweeners[ prop ] || []; - tweeners[ prop ].unshift( callback ); - } - }, - - prefilter: function( callback, prepend ) { - if ( prepend ) { - animationPrefilters.unshift( callback ); - } else { - animationPrefilters.push( callback ); - } - } -}); - -function defaultPrefilter( elem, props, opts ) { - var index, prop, value, length, dataShow, tween, hooks, oldfire, - anim = this, - style = elem.style, - orig = {}, - handled = [], - hidden = elem.nodeType && isHidden( elem ); - - // handle queue: false promises - if ( !opts.queue ) { - hooks = jQuery._queueHooks( elem, "fx" ); - if ( hooks.unqueued == null ) { - hooks.unqueued = 0; - oldfire = hooks.empty.fire; - hooks.empty.fire = function() { - if ( !hooks.unqueued ) { - oldfire(); - } - }; - } - hooks.unqueued++; - - anim.always(function() { - // doing this makes sure that the complete handler will be called - // before this completes - anim.always(function() { - hooks.unqueued--; - if ( !jQuery.queue( elem, "fx" ).length ) { - hooks.empty.fire(); - } - }); - }); - } - - // height/width overflow pass - if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { - // Make sure that nothing sneaks out - // Record all 3 overflow attributes because IE does not - // change the overflow attribute when overflowX and - // overflowY are set to the same value - opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; - - // Set display property to inline-block for height/width - // animations on inline elements that are having width/height animated - if ( jQuery.css( elem, "display" ) === "inline" && - jQuery.css( elem, "float" ) === "none" ) { - - // inline-level elements accept inline-block; - // block-level elements need to be inline with layout - if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { - style.display = "inline-block"; - - } else { - style.zoom = 1; - } - } - } - - if ( opts.overflow ) { - style.overflow = "hidden"; - if ( !jQuery.support.shrinkWrapBlocks ) { - anim.done(function() { - style.overflow = opts.overflow[ 0 ]; - style.overflowX = opts.overflow[ 1 ]; - style.overflowY = opts.overflow[ 2 ]; - }); - } - } - - - // show/hide pass - for ( index in props ) { - value = props[ index ]; - if ( rfxtypes.exec( value ) ) { - delete props[ index ]; - if ( value === ( hidden ? "hide" : "show" ) ) { - continue; - } - handled.push( index ); - } - } - - length = handled.length; - if ( length ) { - dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); - if ( hidden ) { - jQuery( elem ).show(); - } else { - anim.done(function() { - jQuery( elem ).hide(); - }); - } - anim.done(function() { - var prop; - jQuery.removeData( elem, "fxshow", true ); - for ( prop in orig ) { - jQuery.style( elem, prop, orig[ prop ] ); - } - }); - for ( index = 0 ; index < length ; index++ ) { - prop = handled[ index ]; - tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 ); - orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop ); - - if ( !( prop in dataShow ) ) { - dataShow[ prop ] = tween.start; - if ( hidden ) { - tween.end = tween.start; - tween.start = prop === "width" || prop === "height" ? 1 : 0; - } - } - } - } -} - -function Tween( elem, options, prop, end, easing ) { - return new Tween.prototype.init( elem, options, prop, end, easing ); -} -jQuery.Tween = Tween; - -Tween.prototype = { - constructor: Tween, - init: function( elem, options, prop, end, easing, unit ) { - this.elem = elem; - this.prop = prop; - this.easing = easing || "swing"; - this.options = options; - this.start = this.now = this.cur(); - this.end = end; - this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); - }, - cur: function() { - var hooks = Tween.propHooks[ this.prop ]; - - return hooks && hooks.get ? - hooks.get( this ) : - Tween.propHooks._default.get( this ); - }, - run: function( percent ) { - var eased, - hooks = Tween.propHooks[ this.prop ]; - - if ( this.options.duration ) { - this.pos = eased = jQuery.easing[ this.easing ]( - percent, this.options.duration * percent, 0, 1, this.options.duration - ); - } else { - this.pos = eased = percent; - } - this.now = ( this.end - this.start ) * eased + this.start; - - if ( this.options.step ) { - this.options.step.call( this.elem, this.now, this ); - } - - if ( hooks && hooks.set ) { - hooks.set( this ); - } else { - Tween.propHooks._default.set( this ); - } - return this; - } -}; - -Tween.prototype.init.prototype = Tween.prototype; - -Tween.propHooks = { - _default: { - get: function( tween ) { - var result; - - if ( tween.elem[ tween.prop ] != null && - (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { - return tween.elem[ tween.prop ]; - } - - // passing any value as a 4th parameter to .css will automatically - // attempt a parseFloat and fallback to a string if the parse fails - // so, simple values such as "10px" are parsed to Float. - // complex values such as "rotate(1rad)" are returned as is. - result = jQuery.css( tween.elem, tween.prop, false, "" ); - // Empty strings, null, undefined and "auto" are converted to 0. - return !result || result === "auto" ? 0 : result; - }, - set: function( tween ) { - // use step hook for back compat - use cssHook if its there - use .style if its - // available and use plain properties where available - if ( jQuery.fx.step[ tween.prop ] ) { - jQuery.fx.step[ tween.prop ]( tween ); - } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { - jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); - } else { - tween.elem[ tween.prop ] = tween.now; - } - } - } -}; - -// Remove in 2.0 - this supports IE8's panic based approach -// to setting things on disconnected nodes - -Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { - set: function( tween ) { - if ( tween.elem.nodeType && tween.elem.parentNode ) { - tween.elem[ tween.prop ] = tween.now; - } - } -}; - -jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { - var cssFn = jQuery.fn[ name ]; - jQuery.fn[ name ] = function( speed, easing, callback ) { - return speed == null || typeof speed === "boolean" || - // special check for .toggle( handler, handler, ... ) - ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ? - cssFn.apply( this, arguments ) : - this.animate( genFx( name, true ), speed, easing, callback ); - }; -}); - -jQuery.fn.extend({ - fadeTo: function( speed, to, easing, callback ) { - - // show any hidden elements after setting opacity to 0 - return this.filter( isHidden ).css( "opacity", 0 ).show() - - // animate to the value specified - .end().animate({ opacity: to }, speed, easing, callback ); - }, - animate: function( prop, speed, easing, callback ) { - var empty = jQuery.isEmptyObject( prop ), - optall = jQuery.speed( speed, easing, callback ), - doAnimation = function() { - // Operate on a copy of prop so per-property easing won't be lost - var anim = Animation( this, jQuery.extend( {}, prop ), optall ); - - // Empty animations resolve immediately - if ( empty ) { - anim.stop( true ); - } - }; - - return empty || optall.queue === false ? - this.each( doAnimation ) : - this.queue( optall.queue, doAnimation ); - }, - stop: function( type, clearQueue, gotoEnd ) { - var stopQueue = function( hooks ) { - var stop = hooks.stop; - delete hooks.stop; - stop( gotoEnd ); - }; - - if ( typeof type !== "string" ) { - gotoEnd = clearQueue; - clearQueue = type; - type = undefined; - } - if ( clearQueue && type !== false ) { - this.queue( type || "fx", [] ); - } - - return this.each(function() { - var dequeue = true, - index = type != null && type + "queueHooks", - timers = jQuery.timers, - data = jQuery._data( this ); - - if ( index ) { - if ( data[ index ] && data[ index ].stop ) { - stopQueue( data[ index ] ); - } - } else { - for ( index in data ) { - if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { - stopQueue( data[ index ] ); - } - } - } - - for ( index = timers.length; index--; ) { - if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { - timers[ index ].anim.stop( gotoEnd ); - dequeue = false; - timers.splice( index, 1 ); - } - } - - // start the next in the queue if the last step wasn't forced - // timers currently will call their complete callbacks, which will dequeue - // but only if they were gotoEnd - if ( dequeue || !gotoEnd ) { - jQuery.dequeue( this, type ); - } - }); - } -}); - -// Generate parameters to create a standard animation -function genFx( type, includeWidth ) { - var which, - attrs = { height: type }, - i = 0; - - // if we include width, step value is 1 to do all cssExpand values, - // if we don't include width, step value is 2 to skip over Left and Right - includeWidth = includeWidth? 1 : 0; - for( ; i < 4 ; i += 2 - includeWidth ) { - which = cssExpand[ i ]; - attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; - } - - if ( includeWidth ) { - attrs.opacity = attrs.width = type; - } - - return attrs; -} - -// Generate shortcuts for custom animations -jQuery.each({ - slideDown: genFx("show"), - slideUp: genFx("hide"), - slideToggle: genFx("toggle"), - fadeIn: { opacity: "show" }, - fadeOut: { opacity: "hide" }, - fadeToggle: { opacity: "toggle" } -}, function( name, props ) { - jQuery.fn[ name ] = function( speed, easing, callback ) { - return this.animate( props, speed, easing, callback ); - }; -}); - -jQuery.speed = function( speed, easing, fn ) { - var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { - complete: fn || !fn && easing || - jQuery.isFunction( speed ) && speed, - duration: speed, - easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing - }; - - opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : - opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; - - // normalize opt.queue - true/undefined/null -> "fx" - if ( opt.queue == null || opt.queue === true ) { - opt.queue = "fx"; - } - - // Queueing - opt.old = opt.complete; - - opt.complete = function() { - if ( jQuery.isFunction( opt.old ) ) { - opt.old.call( this ); - } - - if ( opt.queue ) { - jQuery.dequeue( this, opt.queue ); - } - }; - - return opt; -}; - -jQuery.easing = { - linear: function( p ) { - return p; - }, - swing: function( p ) { - return 0.5 - Math.cos( p*Math.PI ) / 2; - } -}; - -jQuery.timers = []; -jQuery.fx = Tween.prototype.init; -jQuery.fx.tick = function() { - var timer, - timers = jQuery.timers, - i = 0; - - for ( ; i < timers.length; i++ ) { - timer = timers[ i ]; - // Checks the timer has not already been removed - if ( !timer() && timers[ i ] === timer ) { - timers.splice( i--, 1 ); - } - } - - if ( !timers.length ) { - jQuery.fx.stop(); - } -}; - -jQuery.fx.timer = function( timer ) { - if ( timer() && jQuery.timers.push( timer ) && !timerId ) { - timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); - } -}; - -jQuery.fx.interval = 13; - -jQuery.fx.stop = function() { - clearInterval( timerId ); - timerId = null; -}; - -jQuery.fx.speeds = { - slow: 600, - fast: 200, - // Default speed - _default: 400 -}; - -// Back Compat <1.8 extension point -jQuery.fx.step = {}; - -if ( jQuery.expr && jQuery.expr.filters ) { - jQuery.expr.filters.animated = function( elem ) { - return jQuery.grep(jQuery.timers, function( fn ) { - return elem === fn.elem; - }).length; - }; -} -var rroot = /^(?:body|html)$/i; - -jQuery.fn.offset = function( options ) { - if ( arguments.length ) { - return options === undefined ? - this : - this.each(function( i ) { - jQuery.offset.setOffset( this, options, i ); - }); - } - - var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, - box = { top: 0, left: 0 }, - elem = this[ 0 ], - doc = elem && elem.ownerDocument; - - if ( !doc ) { - return; - } - - if ( (body = doc.body) === elem ) { - return jQuery.offset.bodyOffset( elem ); - } - - docElem = doc.documentElement; - - // Make sure it's not a disconnected DOM node - if ( !jQuery.contains( docElem, elem ) ) { - return box; - } - - // If we don't have gBCR, just use 0,0 rather than error - // BlackBerry 5, iOS 3 (original iPhone) - if ( typeof elem.getBoundingClientRect !== "undefined" ) { - box = elem.getBoundingClientRect(); - } - win = getWindow( doc ); - clientTop = docElem.clientTop || body.clientTop || 0; - clientLeft = docElem.clientLeft || body.clientLeft || 0; - scrollTop = win.pageYOffset || docElem.scrollTop; - scrollLeft = win.pageXOffset || docElem.scrollLeft; - return { - top: box.top + scrollTop - clientTop, - left: box.left + scrollLeft - clientLeft - }; -}; - -jQuery.offset = { - - bodyOffset: function( body ) { - var top = body.offsetTop, - left = body.offsetLeft; - - if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { - top += parseFloat( jQuery.css(body, "marginTop") ) || 0; - left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; - } - - return { top: top, left: left }; - }, - - setOffset: function( elem, options, i ) { - var position = jQuery.css( elem, "position" ); - - // set position first, in-case top/left are set even on static elem - if ( position === "static" ) { - elem.style.position = "relative"; - } - - var curElem = jQuery( elem ), - curOffset = curElem.offset(), - curCSSTop = jQuery.css( elem, "top" ), - curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, - props = {}, curPosition = {}, curTop, curLeft; - - // need to be able to calculate position if either top or left is auto and position is either absolute or fixed - if ( calculatePosition ) { - curPosition = curElem.position(); - curTop = curPosition.top; - curLeft = curPosition.left; - } else { - curTop = parseFloat( curCSSTop ) || 0; - curLeft = parseFloat( curCSSLeft ) || 0; - } - - if ( jQuery.isFunction( options ) ) { - options = options.call( elem, i, curOffset ); - } - - if ( options.top != null ) { - props.top = ( options.top - curOffset.top ) + curTop; - } - if ( options.left != null ) { - props.left = ( options.left - curOffset.left ) + curLeft; - } - - if ( "using" in options ) { - options.using.call( elem, props ); - } else { - curElem.css( props ); - } - } -}; - - -jQuery.fn.extend({ - - position: function() { - if ( !this[0] ) { - return; - } - - var elem = this[0], - - // Get *real* offsetParent - offsetParent = this.offsetParent(), - - // Get correct offsets - offset = this.offset(), - parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); - - // Subtract element margins - // note: when an element has margin: auto the offsetLeft and marginLeft - // are the same in Safari causing offset.left to incorrectly be 0 - offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; - offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; - - // Add offsetParent borders - parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; - parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; - - // Subtract the two offsets - return { - top: offset.top - parentOffset.top, - left: offset.left - parentOffset.left - }; - }, - - offsetParent: function() { - return this.map(function() { - var offsetParent = this.offsetParent || document.body; - while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { - offsetParent = offsetParent.offsetParent; - } - return offsetParent || document.body; - }); - } -}); - - -// Create scrollLeft and scrollTop methods -jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { - var top = /Y/.test( prop ); - - jQuery.fn[ method ] = function( val ) { - return jQuery.access( this, function( elem, method, val ) { - var win = getWindow( elem ); - - if ( val === undefined ) { - return win ? (prop in win) ? win[ prop ] : - win.document.documentElement[ method ] : - elem[ method ]; - } - - if ( win ) { - win.scrollTo( - !top ? val : jQuery( win ).scrollLeft(), - top ? val : jQuery( win ).scrollTop() - ); - - } else { - elem[ method ] = val; - } - }, method, val, arguments.length, null ); - }; -}); - -function getWindow( elem ) { - return jQuery.isWindow( elem ) ? - elem : - elem.nodeType === 9 ? - elem.defaultView || elem.parentWindow : - false; -} -// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods -jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { - jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { - // margin is only for outerHeight, outerWidth - jQuery.fn[ funcName ] = function( margin, value ) { - var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), - extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); - - return jQuery.access( this, function( elem, type, value ) { - var doc; - - if ( jQuery.isWindow( elem ) ) { - // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there - // isn't a whole lot we can do. See pull request at this URL for discussion: - // https://github.com/jquery/jquery/pull/764 - return elem.document.documentElement[ "client" + name ]; - } - - // Get document width or height - if ( elem.nodeType === 9 ) { - doc = elem.documentElement; - - // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest - // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. - return Math.max( - elem.body[ "scroll" + name ], doc[ "scroll" + name ], - elem.body[ "offset" + name ], doc[ "offset" + name ], - doc[ "client" + name ] - ); - } - - return value === undefined ? - // Get width or height on the element, requesting but not forcing parseFloat - jQuery.css( elem, type, value, extra ) : - - // Set width or height on the element - jQuery.style( elem, type, value, extra ); - }, type, chainable ? margin : undefined, chainable, null ); - }; - }); -}); -// Expose jQuery to the global object -window.jQuery = window.$ = jQuery; - -// Expose jQuery as an AMD module, but only for AMD loaders that -// understand the issues with loading multiple versions of jQuery -// in a page that all might call define(). The loader will indicate -// they have special allowances for multiple jQuery versions by -// specifying define.amd.jQuery = true. Register as a named module, -// since jQuery can be concatenated with other files that may use define, -// but not use a proper concatenation script that understands anonymous -// AMD modules. A named AMD is safest and most robust way to register. -// Lowercase jquery is used because AMD module names are derived from -// file names, and jQuery is normally delivered in a lowercase file name. -// Do this after creating the global so that if an AMD module wants to call -// noConflict to hide this version of jQuery, it will work. -if ( typeof define === "function" && define.amd && define.amd.jQuery ) { - define( "jquery", [], function () { return jQuery; } ); -} - -})( window ); diff --git a/jquery/jquery-ui.css b/jquery/jquery-ui.css deleted file mode 100644 index a76b9ab..0000000 --- a/jquery/jquery-ui.css +++ /dev/null @@ -1,470 +0,0 @@ -/*! jQuery UI - v1.9.0 - 2012-10-05 -* http://jqueryui.com -* Includes: jquery.ui.core.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css -* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } -.ui-helper-clearfix:after { clear: both; } -.ui-helper-clearfix { zoom: 1; } -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - -.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; } -.ui-accordion .ui-accordion-icons { padding-left: 2.2em; } -.ui-accordion .ui-accordion-noicons { padding-left: .7em; } -.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; } -.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } -.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; } - -.ui-autocomplete { position: absolute; cursor: default; } - -/* workarounds */ -* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ - -.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ -.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; } -.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ -button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ -.ui-button-icons-only { width: 3.4em; } -button.ui-button-icons-only { width: 3.7em; } - -/*button text element */ -.ui-button .ui-button-text { display: block; line-height: 1.4; } -.ui-button-text-only .ui-button-text { padding: .4em 1em; } -.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } -.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } -.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } -.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } -/* no icon support for input elements, provide padding by default */ -input.ui-button { padding: .4em 1em; } - -/*button icon element(s) */ -.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } -.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } -.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } -.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } -.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } - -/*button sets*/ -.ui-buttonset { margin-right: 7px; } -.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } - -/* workarounds */ -button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ - -.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -} -.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } -.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } -.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } -.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } -.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } -.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } -.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } -.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } -.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } -.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } -.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } -.ui-draggable .ui-dialog-titlebar { cursor: move; } - -.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; } -.ui-menu .ui-menu { margin-top: -3px; position: absolute; } -.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; } -.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; } -.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; } -.ui-menu .ui-menu-item a.ui-state-focus, -.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; } - -.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; } -.ui-menu .ui-state-disabled a { cursor: default; } - -/* icon support */ -.ui-menu-icons { position: relative; } -.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; } - -/* left-aligned */ -.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; } - -/* right-aligned */ -.ui-menu .ui-menu-icon { position: static; float: right; } - -.ui-progressbar { height:2em; text-align: left; overflow: hidden; } -.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } -.ui-resizable { position: relative;} -.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; } -.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } -.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } -.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } -.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } -.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } -.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } -.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } -.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } -.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} -.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } - -.ui-slider { position: relative; text-align: left; } -.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } -.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } - -.ui-slider-horizontal { height: .8em; } -.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } -.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } -.ui-slider-horizontal .ui-slider-range-min { left: 0; } -.ui-slider-horizontal .ui-slider-range-max { right: 0; } - -.ui-slider-vertical { width: .8em; height: 100px; } -.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } -.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } -.ui-slider-vertical .ui-slider-range-min { bottom: 0; } -.ui-slider-vertical .ui-slider-range-max { top: 0; } -.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; } -.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; } -.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; z-index: 100; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; } -.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */ -.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */ -.ui-spinner-up { top: 0; } -.ui-spinner-down { bottom: 0; } - -/* TR overrides */ -span.ui-spinner { background: none; } -.ui-spinner .ui-icon-triangle-1-s { - /* need to fix icons sprite */ - background-position:-65px -16px; -} - -.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } - -.ui-tooltip { - padding:8px; - position:absolute; - z-index:9999; - -o-box-shadow: 0 0 5px #aaa; - -moz-box-shadow: 0 0 5px #aaa; - -webkit-box-shadow: 0 0 5px #aaa; - box-shadow: 0 0 5px #aaa; -} -/* Fades and background-images don't work well together in IE6, drop the image */ -* html .ui-tooltip { - background-image: none; -} -body .ui-tooltip { border-width:2px; } - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1.1em/*{fsDefault}*/; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1em; } -.ui-widget-content { border: 1px solid #aaaaaa/*{borderColorContent}*/; background: #ffffff/*{bgColorContent}*/ url(images/ui-bg_flat_75_ffffff_40x100.png)/*{bgImgUrlContent}*/ 50%/*{bgContentXPos}*/ 50%/*{bgContentYPos}*/ repeat-x/*{bgContentRepeat}*/; color: #222222/*{fcContent}*/; } -.ui-widget-content a { color: #222222/*{fcContent}*/; } -.ui-widget-header { border: 1px solid #aaaaaa/*{borderColorHeader}*/; background: #cccccc/*{bgColorHeader}*/ url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)/*{bgImgUrlHeader}*/ 50%/*{bgHeaderXPos}*/ 50%/*{bgHeaderYPos}*/ repeat-x/*{bgHeaderRepeat}*/; color: #222222/*{fcHeader}*/; font-weight: bold; } -.ui-widget-header a { color: #222222/*{fcHeader}*/; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(images/ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555/*{fcDefault}*/; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999/*{borderColorHover}*/; background: #dadada/*{bgColorHover}*/ url(images/ui-bg_glass_75_dadada_1x400.png)/*{bgImgUrlHover}*/ 50%/*{bgHoverXPos}*/ 50%/*{bgHoverYPos}*/ repeat-x/*{bgHoverRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcHover}*/; } -.ui-state-hover a, .ui-state-hover a:hover { color: #212121/*{fcHover}*/; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa/*{borderColorActive}*/; background: #ffffff/*{bgColorActive}*/ url(images/ui-bg_glass_65_ffffff_1x400.png)/*{bgImgUrlActive}*/ 50%/*{bgActiveXPos}*/ 50%/*{bgActiveYPos}*/ repeat-x/*{bgActiveRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcActive}*/; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121/*{fcActive}*/; text-decoration: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1/*{borderColorHighlight}*/; background: #fbf9ee/*{bgColorHighlight}*/ url(images/ui-bg_glass_55_fbf9ee_1x400.png)/*{bgImgUrlHighlight}*/ 50%/*{bgHighlightXPos}*/ 50%/*{bgHighlightYPos}*/ repeat-x/*{bgHighlightRepeat}*/; color: #363636/*{fcHighlight}*/; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636/*{fcHighlight}*/; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a/*{borderColorError}*/; background: #fef1ec/*{bgColorError}*/ url(images/ui-bg_glass_95_fef1ec_1x400.png)/*{bgImgUrlError}*/ 50%/*{bgErrorXPos}*/ 50%/*{bgErrorYPos}*/ repeat-x/*{bgErrorRepeat}*/; color: #cd0a0a/*{fcError}*/; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a/*{fcError}*/; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a/*{fcError}*/; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsHeader}*/; } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png)/*{iconsDefault}*/; } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsHover}*/; } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsActive}*/; } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png)/*{iconsHighlight}*/; } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png)/*{iconsError}*/; } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px/*{cornerRadius}*/; -webkit-border-top-left-radius: 4px/*{cornerRadius}*/; -khtml-border-top-left-radius: 4px/*{cornerRadius}*/; border-top-left-radius: 4px/*{cornerRadius}*/; } -.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px/*{cornerRadius}*/; -webkit-border-top-right-radius: 4px/*{cornerRadius}*/; -khtml-border-top-right-radius: 4px/*{cornerRadius}*/; border-top-right-radius: 4px/*{cornerRadius}*/; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px/*{cornerRadius}*/; -webkit-border-bottom-left-radius: 4px/*{cornerRadius}*/; -khtml-border-bottom-left-radius: 4px/*{cornerRadius}*/; border-bottom-left-radius: 4px/*{cornerRadius}*/; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px/*{cornerRadius}*/; -webkit-border-bottom-right-radius: 4px/*{cornerRadius}*/; -khtml-border-bottom-right-radius: 4px/*{cornerRadius}*/; border-bottom-right-radius: 4px/*{cornerRadius}*/; } - -/* Overlays */ -.ui-widget-overlay { background: #aaaaaa/*{bgColorOverlay}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlOverlay}*/ 50%/*{bgOverlayXPos}*/ 50%/*{bgOverlayYPos}*/ repeat-x/*{bgOverlayRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityOverlay}*/; } -.ui-widget-shadow { margin: -8px/*{offsetTopShadow}*/ 0 0 -8px/*{offsetLeftShadow}*/; padding: 8px/*{thicknessShadow}*/; background: #aaaaaa/*{bgColorShadow}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlShadow}*/ 50%/*{bgShadowXPos}*/ 50%/*{bgShadowYPos}*/ repeat-x/*{bgShadowRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityShadow}*/; -moz-border-radius: 8px/*{cornerRadiusShadow}*/; -khtml-border-radius: 8px/*{cornerRadiusShadow}*/; -webkit-border-radius: 8px/*{cornerRadiusShadow}*/; border-radius: 8px/*{cornerRadiusShadow}*/; } \ No newline at end of file diff --git a/jquery/marker.png b/jquery/marker.png deleted file mode 100644 index 3929bbb..0000000 Binary files a/jquery/marker.png and /dev/null differ diff --git a/jquery/mask.png b/jquery/mask.png deleted file mode 100644 index b0a4d40..0000000 Binary files a/jquery/mask.png and /dev/null differ diff --git a/jquery/wheel.png b/jquery/wheel.png deleted file mode 100644 index 97b343d..0000000 Binary files a/jquery/wheel.png and /dev/null differ diff --git a/math.js b/math.js deleted file mode 100644 index 26bb8a3..0000000 --- a/math.js +++ /dev/null @@ -1,53091 +0,0 @@ -/** - * math.js - * https://github.com/josdejong/mathjs - * - * Math.js is an extensive math library for JavaScript and Node.js, - * It features real and complex numbers, units, matrices, a large set of - * mathematical functions, and a flexible expression parser. - * - * @version 3.2.1 - * @date 2016-04-26 - * - * @license - * Copyright (C) 2013-2016 Jos de Jong - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["math"] = factory(); - else - root["math"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - var core = __webpack_require__(1); - - /** - * math.js factory function. Creates a new instance of math.js - * - * @param {Object} [config] Available configuration options: - * {number} epsilon - * Minimum relative difference between two - * compared values, used by all comparison functions. - * {string} matrix - * A string 'matrix' (default) or 'array'. - * {string} number - * A string 'number' (default), 'bignumber', or - * 'fraction' - * {number} precision - * The number of significant digits for BigNumbers. - * Not applicable for Numbers. - * {boolean} predictable - * Predictable output type of functions. When true, - * output type depends only on the input types. When - * false (default), output type can vary depending - * on input values. For example `math.sqrt(-2)` - * returns `NaN` when predictable is false, and - * returns `complex('2i')` when true. - */ - function create (config) { - // create a new math.js instance - var math = core.create(config); - math.create = create; - - // import data types, functions, constants, expression parser, etc. - math['import'](__webpack_require__(13)); - - return math; - } - - // return a new instance of math.js - module.exports = create(); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(2); - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - var isFactory = __webpack_require__(3).isFactory; - var deepExtend = __webpack_require__(3).deepExtend; - var typedFactory = __webpack_require__(4); - var emitter = __webpack_require__(8); - - var importFactory = __webpack_require__(10); - var configFactory = __webpack_require__(12); - - /** - * Math.js core. Creates a new, empty math.js instance - * @param {Object} [options] Available options: - * {number} epsilon - * Minimum relative difference between two - * compared values, used by all comparison functions. - * {string} matrix - * A string 'Matrix' (default) or 'Array'. - * {string} number - * A string 'number' (default), 'BigNumber', or 'Fraction' - * {number} precision - * The number of significant digits for BigNumbers. - * Not applicable for Numbers. - * {boolean} predictable - * Predictable output type of functions. When true, - * output type depends only on the input types. When - * false (default), output type can vary depending - * on input values. For example `math.sqrt(-2)` - * returns `NaN` when predictable is false, and - * returns `complex('2i')` when true. - * @returns {Object} Returns a bare-bone math.js instance containing - * functions: - * - `import` to add new functions - * - `config` to change configuration - * - `on`, `off`, `once`, `emit` for events - */ - exports.create = function create (options) { - // simple test for ES5 support - if (typeof Object.create !== 'function') { - throw new Error('ES5 not supported by this JavaScript engine. ' + - 'Please load the es5-shim and es5-sham library for compatibility.'); - } - - // cached factories and instances - var factories = []; - var instances = []; - - // create a namespace for the mathjs instance, and attach emitter functions - var math = emitter.mixin({}); - math.type = {}; - math.expression = { - transform: Object.create(math) - }; - - // create a new typed instance - math.typed = typedFactory.create(math.type); - - // create configuration options. These are private - var _config = { - // minimum relative difference between two compared values, - // used by all comparison functions - epsilon: 1e-12, - - // type of default matrix output. Choose 'matrix' (default) or 'array' - matrix: 'Matrix', - - // type of default number output. Choose 'number' (default) 'BigNumber', or 'Fraction - number: 'number', - - // number of significant digits in BigNumbers - precision: 64, - - // predictable output type of functions. When true, output type depends only - // on the input types. When false (default), output type can vary depending - // on input values. For example `math.sqrt(-2)` returns `NaN` when - // predictable is false, and returns `complex('2i')` when true. - predictable: false - }; - - /** - * Load a function or data type from a factory. - * If the function or data type already exists, the existing instance is - * returned. - * @param {{type: string, name: string, factory: Function}} factory - * @returns {*} - */ - function load (factory) { - if (!isFactory(factory)) { - throw new Error('Factory object with properties `type`, `name`, and `factory` expected'); - } - - var index = factories.indexOf(factory); - var instance; - if (index === -1) { - // doesn't yet exist - if (factory.math === true) { - // pass with math namespace - instance = factory.factory(math.type, _config, load, math.typed, math); - } - else { - instance = factory.factory(math.type, _config, load, math.typed); - } - - // append to the cache - factories.push(factory); - instances.push(instance); - } - else { - // already existing function, return the cached instance - instance = instances[index]; - } - - return instance; - } - - // load the import and config functions - math['import'] = load(importFactory); - math['config'] = load(configFactory); - - // apply options - if (options) { - math.config(options); - } - - return math; - }; - - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Clone an object - * - * clone(x) - * - * Can clone any primitive type, array, and object. - * If x has a function clone, this function will be invoked to clone the object. - * - * @param {*} x - * @return {*} clone - */ - exports.clone = function clone(x) { - var type = typeof x; - - // immutable primitive types - if (type === 'number' || type === 'string' || type === 'boolean' || - x === null || x === undefined) { - return x; - } - - // use clone function of the object when available - if (typeof x.clone === 'function') { - return x.clone(); - } - - // array - if (Array.isArray(x)) { - return x.map(function (value) { - return clone(value); - }); - } - - if (x instanceof Number) return new Number(x.valueOf()); - if (x instanceof String) return new String(x.valueOf()); - if (x instanceof Boolean) return new Boolean(x.valueOf()); - if (x instanceof Date) return new Date(x.valueOf()); - if (x && x.isBigNumber === true) return x; // bignumbers are immutable - if (x instanceof RegExp) throw new TypeError('Cannot clone ' + x); // TODO: clone a RegExp - - // object - var m = {}; - for (var key in x) { - if (x.hasOwnProperty(key)) { - m[key] = clone(x[key]); - } - } - return m; - }; - - /** - * Extend object a with the properties of object b - * @param {Object} a - * @param {Object} b - * @return {Object} a - */ - exports.extend = function(a, b) { - for (var prop in b) { - if (b.hasOwnProperty(prop)) { - a[prop] = b[prop]; - } - } - return a; - }; - - /** - * Deep extend an object a with the properties of object b - * @param {Object} a - * @param {Object} b - * @returns {Object} - */ - exports.deepExtend = function deepExtend (a, b) { - // TODO: add support for Arrays to deepExtend - if (Array.isArray(b)) { - throw new TypeError('Arrays are not supported by deepExtend'); - } - - for (var prop in b) { - if (b.hasOwnProperty(prop)) { - if (b[prop] && b[prop].constructor === Object) { - if (a[prop] === undefined) { - a[prop] = {}; - } - if (a[prop].constructor === Object) { - deepExtend(a[prop], b[prop]); - } - else { - a[prop] = b[prop]; - } - } else if (Array.isArray(b[prop])) { - throw new TypeError('Arrays are not supported by deepExtend'); - } else { - a[prop] = b[prop]; - } - } - } - return a; - }; - - /** - * Deep test equality of all fields in two pairs of arrays or objects. - * @param {Array | Object} a - * @param {Array | Object} b - * @returns {boolean} - */ - exports.deepEqual = function deepEqual (a, b) { - var prop, i, len; - if (Array.isArray(a)) { - if (!Array.isArray(b)) { - return false; - } - - if (a.length != b.length) { - return false; - } - - for (i = 0, len = a.length; i < len; i++) { - if (!exports.deepEqual(a[i], b[i])) { - return false; - } - } - return true; - } - else if (a instanceof Object) { - if (Array.isArray(b) || !(b instanceof Object)) { - return false; - } - - for (prop in a) { - //noinspection JSUnfilteredForInLoop - if (!exports.deepEqual(a[prop], b[prop])) { - return false; - } - } - for (prop in b) { - //noinspection JSUnfilteredForInLoop - if (!exports.deepEqual(a[prop], b[prop])) { - return false; - } - } - return true; - } - else { - return (typeof a === typeof b) && (a == b); - } - }; - - /** - * Test whether the current JavaScript engine supports Object.defineProperty - * @returns {boolean} returns true if supported - */ - exports.canDefineProperty = function () { - // test needed for broken IE8 implementation - try { - if (Object.defineProperty) { - Object.defineProperty({}, 'x', { get: function () {} }); - return true; - } - } catch (e) {} - - return false; - }; - - /** - * Attach a lazy loading property to a constant. - * The given function `fn` is called once when the property is first requested. - * On older browsers (15 digits - if (digits(x) > 15) { - throw new TypeError('Cannot implicitly convert a number with >15 significant digits to BigNumber ' + - '(value: ' + x + '). ' + - 'Use function bignumber(x) to convert to BigNumber.'); - } - return new type.BigNumber(x); - } - }, { - from: 'number', - to: 'Complex', - convert: function (x) { - return new type.Complex(x, 0); - } - }, { - from: 'number', - to: 'string', - convert: function (x) { - return x + ''; - } - }, { - from: 'BigNumber', - to: 'Complex', - convert: function (x) { - return new type.Complex(x.toNumber(), 0); - } - }, { - from: 'Fraction', - to: 'Complex', - convert: function (x) { - return new type.Complex(x.valueOf(), 0); - } - }, { - from: 'number', - to: 'Fraction', - convert: function (x) { - if (digits(x) > 15) { - throw new TypeError('Cannot implicitly convert a number with >15 significant digits to Fraction ' + - '(value: ' + x + '). ' + - 'Use function fraction(x) to convert to Fraction.'); - } - return new type.Fraction(x); - } - }, { - // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))` - // from: 'Fraction', - // to: 'number', - // convert: function (x) { - // return x.valueOf(); - // } - //}, { - from: 'string', - to: 'number', - convert: function (x) { - var n = Number(x); - if (isNaN(n)) { - throw new Error('Cannot convert "' + x + '" to a number'); - } - return n; - } - }, { - from: 'boolean', - to: 'number', - convert: function (x) { - return +x; - } - }, { - from: 'boolean', - to: 'BigNumber', - convert: function (x) { - return new type.BigNumber(+x); - } - }, { - from: 'boolean', - to: 'Fraction', - convert: function (x) { - return new type.Fraction(+x); - } - }, { - from: 'boolean', - to: 'string', - convert: function (x) { - return +x; - } - }, { - from: 'null', - to: 'number', - convert: function () { - return 0; - } - }, { - from: 'null', - to: 'string', - convert: function () { - return 'null'; - } - }, { - from: 'null', - to: 'BigNumber', - convert: function () { - return new type.BigNumber(0); - } - }, { - from: 'null', - to: 'Fraction', - convert: function () { - return new type.Fraction(0); - } - }, { - from: 'Array', - to: 'Matrix', - convert: function (array) { - // TODO: how to decide on the right type of matrix to create? - return new type.DenseMatrix(array); - } - }, { - from: 'Matrix', - to: 'Array', - convert: function (matrix) { - return matrix.valueOf(); - } - } - ]; - - return typed; - }; - - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** - * typed-function - * - * Type checking for JavaScript functions - * - * https://github.com/josdejong/typed-function - */ - 'use strict'; - - (function (root, factory) { - if (true) { - // AMD. Register as an anonymous module. - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof exports === 'object') { - // OldNode. Does not work with strict CommonJS, but - // only CommonJS-like environments that support module.exports, - // like OldNode. - module.exports = factory(); - } else { - // Browser globals (root is window) - root.typed = factory(); - } - }(this, function () { - // factory function to create a new instance of typed-function - // TODO: allow passing configuration, types, tests via the factory function - function create() { - /** - * Get a type test function for a specific data type - * @param {string} name Name of a data type like 'number' or 'string' - * @returns {Function(obj: *) : boolean} Returns a type testing function. - * Throws an error for an unknown type. - */ - function getTypeTest(name) { - var test; - for (var i = 0; i < typed.types.length; i++) { - var entry = typed.types[i]; - if (entry.name === name) { - test = entry.test; - break; - } - } - - if (!test) { - var hint; - for (i = 0; i < typed.types.length; i++) { - entry = typed.types[i]; - if (entry.name.toLowerCase() == name.toLowerCase()) { - hint = entry.name; - break; - } - } - - throw new Error('Unknown type "' + name + '"' + - (hint ? ('. Did you mean "' + hint + '"?') : '')); - } - return test; - } - - /** - * Retrieve the function name from a set of functions, and check - * whether the name of all functions match (if given) - * @param {Array.} fns - */ - function getName (fns) { - var name = ''; - - for (var i = 0; i < fns.length; i++) { - var fn = fns[i]; - - // merge function name when this is a typed function - if (fn.signatures && fn.name != '') { - if (name == '') { - name = fn.name; - } - else if (name != fn.name) { - var err = new Error('Function names do not match (expected: ' + name + ', actual: ' + fn.name + ')'); - err.data = { - actual: fn.name, - expected: name - }; - throw err; - } - } - } - - return name; - } - - /** - * Create an ArgumentsError. Creates messages like: - * - * Unexpected type of argument (expected: ..., actual: ..., index: ...) - * Too few arguments (expected: ..., index: ...) - * Too many arguments (expected: ..., actual: ...) - * - * @param {String} fn Function name - * @param {number} argCount Number of arguments - * @param {Number} index Current argument index - * @param {*} actual Current argument - * @param {string} [expected] An optional, comma separated string with - * expected types on given index - * @extends Error - */ - function createError(fn, argCount, index, actual, expected) { - var actualType = getTypeOf(actual); - var _expected = expected ? expected.split(',') : null; - var _fn = (fn || 'unnamed'); - var anyType = _expected && contains(_expected, 'any'); - var message; - var data = { - fn: fn, - index: index, - actual: actual, - expected: _expected - }; - - if (_expected) { - if (argCount > index && !anyType) { - // unexpected type - message = 'Unexpected type of argument in function ' + _fn + - ' (expected: ' + _expected.join(' or ') + ', actual: ' + actualType + ', index: ' + index + ')'; - } - else { - // too few arguments - message = 'Too few arguments in function ' + _fn + - ' (expected: ' + _expected.join(' or ') + ', index: ' + index + ')'; - } - } - else { - // too many arguments - message = 'Too many arguments in function ' + _fn + - ' (expected: ' + index + ', actual: ' + argCount + ')' - } - - var err = new TypeError(message); - err.data = data; - return err; - } - - /** - * Collection with function references (local shortcuts to functions) - * @constructor - * @param {string} [name='refs'] Optional name for the refs, used to generate - * JavaScript code - */ - function Refs(name) { - this.name = name || 'refs'; - this.categories = {}; - } - - /** - * Add a function reference. - * @param {Function} fn - * @param {string} [category='fn'] A function category, like 'fn' or 'signature' - * @returns {string} Returns the function name, for example 'fn0' or 'signature2' - */ - Refs.prototype.add = function (fn, category) { - var cat = category || 'fn'; - if (!this.categories[cat]) this.categories[cat] = []; - - var index = this.categories[cat].indexOf(fn); - if (index == -1) { - index = this.categories[cat].length; - this.categories[cat].push(fn); - } - - return cat + index; - }; - - /** - * Create code lines for all function references - * @returns {string} Returns the code containing all function references - */ - Refs.prototype.toCode = function () { - var code = []; - var path = this.name + '.categories'; - var categories = this.categories; - - for (var cat in categories) { - if (categories.hasOwnProperty(cat)) { - var category = categories[cat]; - - for (var i = 0; i < category.length; i++) { - code.push('var ' + cat + i + ' = ' + path + '[\'' + cat + '\'][' + i + '];'); - } - } - } - - return code.join('\n'); - }; - - /** - * A function parameter - * @param {string | string[] | Param} types A parameter type like 'string', - * 'number | boolean' - * @param {boolean} [varArgs=false] Variable arguments if true - * @constructor - */ - function Param(types, varArgs) { - // parse the types, can be a string with types separated by pipe characters | - if (typeof types === 'string') { - // parse variable arguments operator (ellipses '...number') - var _types = types.trim(); - var _varArgs = _types.substr(0, 3) === '...'; - if (_varArgs) { - _types = _types.substr(3); - } - if (_types === '') { - this.types = ['any']; - } - else { - this.types = _types.split('|'); - for (var i = 0; i < this.types.length; i++) { - this.types[i] = this.types[i].trim(); - } - } - } - else if (Array.isArray(types)) { - this.types = types; - } - else if (types instanceof Param) { - return types.clone(); - } - else { - throw new Error('String or Array expected'); - } - - // can hold a type to which to convert when handling this parameter - this.conversions = []; - // TODO: implement better API for conversions, be able to add conversions via constructor (support a new type Object?) - - // variable arguments - this.varArgs = _varArgs || varArgs || false; - - // check for any type arguments - this.anyType = this.types.indexOf('any') !== -1; - } - - /** - * Order Params - * any type ('any') will be ordered last, and object as second last (as other - * types may be an object as well, like Array). - * - * @param {Param} a - * @param {Param} b - * @returns {number} Returns 1 if a > b, -1 if a < b, and else 0. - */ - Param.compare = function (a, b) { - // TODO: simplify parameter comparison, it's a mess - if (a.anyType) return 1; - if (b.anyType) return -1; - - if (contains(a.types, 'Object')) return 1; - if (contains(b.types, 'Object')) return -1; - - if (a.hasConversions()) { - if (b.hasConversions()) { - var i, ac, bc; - - for (i = 0; i < a.conversions.length; i++) { - if (a.conversions[i] !== undefined) { - ac = a.conversions[i]; - break; - } - } - - for (i = 0; i < b.conversions.length; i++) { - if (b.conversions[i] !== undefined) { - bc = b.conversions[i]; - break; - } - } - - return typed.conversions.indexOf(ac) - typed.conversions.indexOf(bc); - } - else { - return 1; - } - } - else { - if (b.hasConversions()) { - return -1; - } - else { - // both params have no conversions - var ai, bi; - - for (i = 0; i < typed.types.length; i++) { - if (typed.types[i].name === a.types[0]) { - ai = i; - break; - } - } - - for (i = 0; i < typed.types.length; i++) { - if (typed.types[i].name === b.types[0]) { - bi = i; - break; - } - } - - return ai - bi; - } - } - }; - - /** - * Test whether this parameters types overlap an other parameters types. - * @param {Param} other - * @return {boolean} Returns true when there are conflicting types - */ - Param.prototype.overlapping = function (other) { - for (var i = 0; i < this.types.length; i++) { - if (contains(other.types, this.types[i])) { - return true; - } - } - return false; - }; - - /** - * Create a clone of this param - * @returns {Param} Returns a cloned version of this param - */ - Param.prototype.clone = function () { - var param = new Param(this.types.slice(), this.varArgs); - param.conversions = this.conversions.slice(); - return param; - }; - - /** - * Test whether this parameter contains conversions - * @returns {boolean} Returns true if the parameter contains one or - * multiple conversions. - */ - Param.prototype.hasConversions = function () { - return this.conversions.length > 0; - }; - - /** - * Tests whether this parameters contains any of the provided types - * @param {Object} types A Map with types, like {'number': true} - * @returns {boolean} Returns true when the parameter contains any - * of the provided types - */ - Param.prototype.contains = function (types) { - for (var i = 0; i < this.types.length; i++) { - if (types[this.types[i]]) { - return true; - } - } - return false; - }; - - /** - * Return a string representation of this params types, like 'string' or - * 'number | boolean' or '...number' - * @param {boolean} [toConversion] If true, the returned types string - * contains the types where the parameter - * will convert to. If false (default) - * the "from" types are returned - * @returns {string} - */ - Param.prototype.toString = function (toConversion) { - var types = []; - var keys = {}; - - for (var i = 0; i < this.types.length; i++) { - var conversion = this.conversions[i]; - var type = toConversion && conversion ? conversion.to : this.types[i]; - if (!(type in keys)) { - keys[type] = true; - types.push(type); - } - } - - return (this.varArgs ? '...' : '') + types.join('|'); - }; - - /** - * A function signature - * @param {string | string[] | Param[]} params - * Array with the type(s) of each parameter, - * or a comma separated string with types - * @param {Function} fn The actual function - * @constructor - */ - function Signature(params, fn) { - var _params; - if (typeof params === 'string') { - _params = (params !== '') ? params.split(',') : []; - } - else if (Array.isArray(params)) { - _params = params; - } - else { - throw new Error('string or Array expected'); - } - - this.params = new Array(_params.length); - for (var i = 0; i < _params.length; i++) { - var param = new Param(_params[i]); - this.params[i] = param; - if (i === _params.length - 1) { - // the last argument - this.varArgs = param.varArgs; - } - else { - // non-last argument - if (param.varArgs) { - throw new SyntaxError('Unexpected variable arguments operator "..."'); - } - } - } - - this.fn = fn; - } - - /** - * Create a clone of this signature - * @returns {Signature} Returns a cloned version of this signature - */ - Signature.prototype.clone = function () { - return new Signature(this.params.slice(), this.fn); - }; - - /** - * Expand a signature: split params with union types in separate signatures - * For example split a Signature "string | number" into two signatures. - * @return {Signature[]} Returns an array with signatures (at least one) - */ - Signature.prototype.expand = function () { - var signatures = []; - - function recurse(signature, path) { - if (path.length < signature.params.length) { - var i, newParam, conversion; - - var param = signature.params[path.length]; - if (param.varArgs) { - // a variable argument. do not split the types in the parameter - newParam = param.clone(); - - // add conversions to the parameter - // recurse for all conversions - for (i = 0; i < typed.conversions.length; i++) { - conversion = typed.conversions[i]; - if (!contains(param.types, conversion.from) && contains(param.types, conversion.to)) { - var j = newParam.types.length; - newParam.types[j] = conversion.from; - newParam.conversions[j] = conversion; - } - } - - recurse(signature, path.concat(newParam)); - } - else { - // split each type in the parameter - for (i = 0; i < param.types.length; i++) { - recurse(signature, path.concat(new Param(param.types[i]))); - } - - // recurse for all conversions - for (i = 0; i < typed.conversions.length; i++) { - conversion = typed.conversions[i]; - if (!contains(param.types, conversion.from) && contains(param.types, conversion.to)) { - newParam = new Param(conversion.from); - newParam.conversions[0] = conversion; - recurse(signature, path.concat(newParam)); - } - } - } - } - else { - signatures.push(new Signature(path, signature.fn)); - } - } - - recurse(this, []); - - return signatures; - }; - - /** - * Compare two signatures. - * - * When two params are equal and contain conversions, they will be sorted - * by lowest index of the first conversions. - * - * @param {Signature} a - * @param {Signature} b - * @returns {number} Returns 1 if a > b, -1 if a < b, and else 0. - */ - Signature.compare = function (a, b) { - if (a.params.length > b.params.length) return 1; - if (a.params.length < b.params.length) return -1; - - // count the number of conversions - var i; - var len = a.params.length; // a and b have equal amount of params - var ac = 0; - var bc = 0; - for (i = 0; i < len; i++) { - if (a.params[i].hasConversions()) ac++; - if (b.params[i].hasConversions()) bc++; - } - - if (ac > bc) return 1; - if (ac < bc) return -1; - - // compare the order per parameter - for (i = 0; i < a.params.length; i++) { - var cmp = Param.compare(a.params[i], b.params[i]); - if (cmp !== 0) { - return cmp; - } - } - - return 0; - }; - - /** - * Test whether any of the signatures parameters has conversions - * @return {boolean} Returns true when any of the parameters contains - * conversions. - */ - Signature.prototype.hasConversions = function () { - for (var i = 0; i < this.params.length; i++) { - if (this.params[i].hasConversions()) { - return true; - } - } - return false; - }; - - /** - * Test whether this signature should be ignored. - * Checks whether any of the parameters contains a type listed in - * typed.ignore - * @return {boolean} Returns true when the signature should be ignored - */ - Signature.prototype.ignore = function () { - // create a map with ignored types - var types = {}; - for (var i = 0; i < typed.ignore.length; i++) { - types[typed.ignore[i]] = true; - } - - // test whether any of the parameters contains this type - for (i = 0; i < this.params.length; i++) { - if (this.params[i].contains(types)) { - return true; - } - } - - return false; - }; - - /** - * Generate the code to invoke this signature - * @param {Refs} refs - * @param {string} prefix - * @returns {string} Returns code - */ - Signature.prototype.toCode = function (refs, prefix) { - var code = []; - - var args = new Array(this.params.length); - for (var i = 0; i < this.params.length; i++) { - var param = this.params[i]; - var conversion = param.conversions[0]; - if (param.varArgs) { - args[i] = 'varArgs'; - } - else if (conversion) { - args[i] = refs.add(conversion.convert, 'convert') + '(arg' + i + ')'; - } - else { - args[i] = 'arg' + i; - } - } - - var ref = this.fn ? refs.add(this.fn, 'signature') : undefined; - if (ref) { - return prefix + 'return ' + ref + '(' + args.join(', ') + '); // signature: ' + this.params.join(', '); - } - - return code.join('\n'); - }; - - /** - * Return a string representation of the signature - * @returns {string} - */ - Signature.prototype.toString = function () { - return this.params.join(', '); - }; - - /** - * A group of signatures with the same parameter on given index - * @param {Param[]} path - * @param {Signature} [signature] - * @param {Node[]} childs - * @constructor - */ - function Node(path, signature, childs) { - this.path = path || []; - this.param = path[path.length - 1] || null; - this.signature = signature || null; - this.childs = childs || []; - } - - /** - * Generate code for this group of signatures - * @param {Refs} refs - * @param {string} prefix - * @param {Node | undefined} [anyType] Sibling of this node with any type parameter - * @returns {string} Returns the code as string - */ - Node.prototype.toCode = function (refs, prefix, anyType) { - // TODO: split this function in multiple functions, it's too large - var code = []; - - if (this.param) { - var index = this.path.length - 1; - var conversion = this.param.conversions[0]; - var comment = '// type: ' + (conversion ? - (conversion.from + ' (convert to ' + conversion.to + ')') : - this.param); - - // non-root node (path is non-empty) - if (this.param.varArgs) { - if (this.param.anyType) { - // variable arguments with any type - code.push(prefix + 'if (arguments.length > ' + index + ') {'); - code.push(prefix + ' var varArgs = [];'); - code.push(prefix + ' for (var i = ' + index + '; i < arguments.length; i++) {'); - code.push(prefix + ' varArgs.push(arguments[i]);'); - code.push(prefix + ' }'); - code.push(this.signature.toCode(refs, prefix + ' ')); - code.push(prefix + '}'); - } - else { - // variable arguments with a fixed type - var getTests = function (types, arg) { - var tests = []; - for (var i = 0; i < types.length; i++) { - tests[i] = refs.add(getTypeTest(types[i]), 'test') + '(' + arg + ')'; - } - return tests.join(' || '); - }.bind(this); - - var allTypes = this.param.types; - var exactTypes = []; - for (var i = 0; i < allTypes.length; i++) { - if (this.param.conversions[i] === undefined) { - exactTypes.push(allTypes[i]); - } - } - - code.push(prefix + 'if (' + getTests(allTypes, 'arg' + index) + ') { ' + comment); - code.push(prefix + ' var varArgs = [arg' + index + '];'); - code.push(prefix + ' for (var i = ' + (index + 1) + '; i < arguments.length; i++) {'); - code.push(prefix + ' if (' + getTests(exactTypes, 'arguments[i]') + ') {'); - code.push(prefix + ' varArgs.push(arguments[i]);'); - - for (var i = 0; i < allTypes.length; i++) { - var conversion_i = this.param.conversions[i]; - if (conversion_i) { - var test = refs.add(getTypeTest(allTypes[i]), 'test'); - var convert = refs.add(conversion_i.convert, 'convert'); - code.push(prefix + ' }'); - code.push(prefix + ' else if (' + test + '(arguments[i])) {'); - code.push(prefix + ' varArgs.push(' + convert + '(arguments[i]));'); - } - } - code.push(prefix + ' } else {'); - code.push(prefix + ' throw createError(name, arguments.length, i, arguments[i], \'' + exactTypes.join(',') + '\');'); - code.push(prefix + ' }'); - code.push(prefix + ' }'); - code.push(this.signature.toCode(refs, prefix + ' ')); - code.push(prefix + '}'); - } - } - else { - if (this.param.anyType) { - // any type - code.push(prefix + '// type: any'); - code.push(this._innerCode(refs, prefix, anyType)); - } - else { - // regular type - var type = this.param.types[0]; - var test = type !== 'any' ? refs.add(getTypeTest(type), 'test') : null; - - code.push(prefix + 'if (' + test + '(arg' + index + ')) { ' + comment); - code.push(this._innerCode(refs, prefix + ' ', anyType)); - code.push(prefix + '}'); - } - } - } - else { - // root node (path is empty) - code.push(this._innerCode(refs, prefix, anyType)); - } - - return code.join('\n'); - }; - - /** - * Generate inner code for this group of signatures. - * This is a helper function of Node.prototype.toCode - * @param {Refs} refs - * @param {string} prefix - * @param {Node | undefined} [anyType] Sibling of this node with any type parameter - * @returns {string} Returns the inner code as string - * @private - */ - Node.prototype._innerCode = function (refs, prefix, anyType) { - var code = []; - var i; - - if (this.signature) { - code.push(prefix + 'if (arguments.length === ' + this.path.length + ') {'); - code.push(this.signature.toCode(refs, prefix + ' ')); - code.push(prefix + '}'); - } - - var nextAnyType; - for (i = 0; i < this.childs.length; i++) { - if (this.childs[i].param.anyType) { - nextAnyType = this.childs[i]; - break; - } - } - - for (i = 0; i < this.childs.length; i++) { - code.push(this.childs[i].toCode(refs, prefix, nextAnyType)); - } - - if (anyType && !this.param.anyType) { - code.push(anyType.toCode(refs, prefix, nextAnyType)); - } - - var exceptions = this._exceptions(refs, prefix); - if (exceptions) { - code.push(exceptions); - } - - return code.join('\n'); - }; - - /** - * Generate code to throw exceptions - * @param {Refs} refs - * @param {string} prefix - * @returns {string} Returns the inner code as string - * @private - */ - Node.prototype._exceptions = function (refs, prefix) { - var index = this.path.length; - - if (this.childs.length === 0) { - // TODO: can this condition be simplified? (we have a fall-through here) - return [ - prefix + 'if (arguments.length > ' + index + ') {', - prefix + ' throw createError(name, arguments.length, ' + index + ', arguments[' + index + ']);', - prefix + '}' - ].join('\n'); - } - else { - var keys = {}; - var types = []; - - for (var i = 0; i < this.childs.length; i++) { - var node = this.childs[i]; - if (node.param) { - for (var j = 0; j < node.param.types.length; j++) { - var type = node.param.types[j]; - if (!(type in keys) && !node.param.conversions[j]) { - keys[type] = true; - types.push(type); - } - } - } - } - - return prefix + 'throw createError(name, arguments.length, ' + index + ', arguments[' + index + '], \'' + types.join(',') + '\');'; - } - }; - - /** - * Split all raw signatures into an array with expanded Signatures - * @param {Object.} rawSignatures - * @return {Signature[]} Returns an array with expanded signatures - */ - function parseSignatures(rawSignatures) { - // FIXME: need to have deterministic ordering of signatures, do not create via object - var signature; - var keys = {}; - var signatures = []; - var i; - - for (var types in rawSignatures) { - if (rawSignatures.hasOwnProperty(types)) { - var fn = rawSignatures[types]; - signature = new Signature(types, fn); - - if (signature.ignore()) { - continue; - } - - var expanded = signature.expand(); - - for (i = 0; i < expanded.length; i++) { - var signature_i = expanded[i]; - var key = signature_i.toString(); - var existing = keys[key]; - if (!existing) { - keys[key] = signature_i; - } - else { - var cmp = Signature.compare(signature_i, existing); - if (cmp < 0) { - // override if sorted first - keys[key] = signature_i; - } - else if (cmp === 0) { - throw new Error('Signature "' + key + '" is defined twice'); - } - // else: just ignore - } - } - } - } - - // convert from map to array - for (key in keys) { - if (keys.hasOwnProperty(key)) { - signatures.push(keys[key]); - } - } - - // order the signatures - signatures.sort(function (a, b) { - return Signature.compare(a, b); - }); - - // filter redundant conversions from signatures with varArgs - // TODO: simplify this loop or move it to a separate function - for (i = 0; i < signatures.length; i++) { - signature = signatures[i]; - - if (signature.varArgs) { - var index = signature.params.length - 1; - var param = signature.params[index]; - - var t = 0; - while (t < param.types.length) { - if (param.conversions[t]) { - var type = param.types[t]; - - for (var j = 0; j < signatures.length; j++) { - var other = signatures[j]; - var p = other.params[index]; - - if (other !== signature && - p && - contains(p.types, type) && !p.conversions[index]) { - // this (conversion) type already exists, remove it - param.types.splice(t, 1); - param.conversions.splice(t, 1); - t--; - break; - } - } - } - t++; - } - } - } - - return signatures; - } - - /** - * create a map with normalized signatures as key and the function as value - * @param {Signature[]} signatures An array with split signatures - * @return {Object.} Returns a map with normalized - * signatures as key, and the function - * as value. - */ - function mapSignatures(signatures) { - var normalized = {}; - - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signature.fn && !signature.hasConversions()) { - var params = signature.params.join(','); - normalized[params] = signature.fn; - } - } - - return normalized; - } - - /** - * Parse signatures recursively in a node tree. - * @param {Signature[]} signatures Array with expanded signatures - * @param {Param[]} path Traversed path of parameter types - * @return {Node} Returns a node tree - */ - function parseTree(signatures, path) { - var i, signature; - var index = path.length; - var nodeSignature; - - var filtered = []; - for (i = 0; i < signatures.length; i++) { - signature = signatures[i]; - - // filter the first signature with the correct number of params - if (signature.params.length === index && !nodeSignature) { - nodeSignature = signature; - } - - if (signature.params[index] != undefined) { - filtered.push(signature); - } - } - - // sort the filtered signatures by param - filtered.sort(function (a, b) { - return Param.compare(a.params[index], b.params[index]); - }); - - // recurse over the signatures - var entries = []; - for (i = 0; i < filtered.length; i++) { - signature = filtered[i]; - // group signatures with the same param at current index - var param = signature.params[index]; - - // TODO: replace the next filter loop - var existing = entries.filter(function (entry) { - return entry.param.overlapping(param); - })[0]; - - //var existing; - //for (var j = 0; j < entries.length; j++) { - // if (entries[j].param.overlapping(param)) { - // existing = entries[j]; - // break; - // } - //} - - if (existing) { - if (existing.param.varArgs) { - throw new Error('Conflicting types "' + existing.param + '" and "' + param + '"'); - } - existing.signatures.push(signature); - } - else { - entries.push({ - param: param, - signatures: [signature] - }); - } - } - - // parse the childs - var childs = new Array(entries.length); - for (i = 0; i < entries.length; i++) { - var entry = entries[i]; - childs[i] = parseTree(entry.signatures, path.concat(entry.param)) - } - - return new Node(path, nodeSignature, childs); - } - - /** - * Generate an array like ['arg0', 'arg1', 'arg2'] - * @param {number} count Number of arguments to generate - * @returns {Array} Returns an array with argument names - */ - function getArgs(count) { - // create an array with all argument names - var args = []; - for (var i = 0; i < count; i++) { - args[i] = 'arg' + i; - } - - return args; - } - - /** - * Compose a function from sub-functions each handling a single type signature. - * Signatures: - * typed(signature: string, fn: function) - * typed(name: string, signature: string, fn: function) - * typed(signatures: Object.) - * typed(name: string, signatures: Object.) - * - * @param {string | null} name - * @param {Object.} signatures - * @return {Function} Returns the typed function - * @private - */ - function _typed(name, signatures) { - var refs = new Refs(); - - // parse signatures, expand them - var _signatures = parseSignatures(signatures); - if (_signatures.length == 0) { - throw new Error('No signatures provided'); - } - - // parse signatures into a node tree - var node = parseTree(_signatures, []); - - //var util = require('util'); - //console.log('ROOT'); - //console.log(util.inspect(node, { depth: null })); - - // generate code for the typed function - var code = []; - var _name = name || ''; - var _args = getArgs(maxParams(_signatures)); - code.push('function ' + _name + '(' + _args.join(', ') + ') {'); - code.push(' "use strict";'); - code.push(' var name = \'' + _name + '\';'); - code.push(node.toCode(refs, ' ')); - code.push('}'); - - // generate body for the factory function - var body = [ - refs.toCode(), - 'return ' + code.join('\n') - ].join('\n'); - - // evaluate the JavaScript code and attach function references - var factory = (new Function(refs.name, 'createError', body)); - var fn = factory(refs, createError); - - //console.log('FN\n' + fn.toString()); // TODO: cleanup - - // attach the signatures with sub-functions to the constructed function - fn.signatures = mapSignatures(_signatures); - - return fn; - } - - /** - * Calculate the maximum number of parameters in givens signatures - * @param {Signature[]} signatures - * @returns {number} The maximum number of parameters - */ - function maxParams(signatures) { - var max = 0; - - for (var i = 0; i < signatures.length; i++) { - var len = signatures[i].params.length; - if (len > max) { - max = len; - } - } - - return max; - } - - /** - * Get the type of a value - * @param {*} x - * @returns {string} Returns a string with the type of value - */ - function getTypeOf(x) { - var obj; - - for (var i = 0; i < typed.types.length; i++) { - var entry = typed.types[i]; - - if (entry.name === 'Object') { - // Array and Date are also Object, so test for Object afterwards - obj = entry; - } - else { - if (entry.test(x)) return entry.name; - } - } - - // at last, test whether an object - if (obj && obj.test(x)) return obj.name; - - return 'unknown'; - } - - /** - * Test whether an array contains some entry - * @param {Array} array - * @param {*} entry - * @return {boolean} Returns true if array contains entry, false if not. - */ - function contains(array, entry) { - return array.indexOf(entry) !== -1; - } - - // data type tests - var types = [ - { name: 'number', test: function (x) { return typeof x === 'number' } }, - { name: 'string', test: function (x) { return typeof x === 'string' } }, - { name: 'boolean', test: function (x) { return typeof x === 'boolean' } }, - { name: 'Function', test: function (x) { return typeof x === 'function'} }, - { name: 'Array', test: Array.isArray }, - { name: 'Date', test: function (x) { return x instanceof Date } }, - { name: 'RegExp', test: function (x) { return x instanceof RegExp } }, - { name: 'Object', test: function (x) { return typeof x === 'object' } }, - { name: 'null', test: function (x) { return x === null } }, - { name: 'undefined', test: function (x) { return x === undefined } } - ]; - - // configuration - var config = {}; - - // type conversions. Order is important - var conversions = []; - - // types to be ignored - var ignore = []; - - // temporary object for holding types and conversions, for constructing - // the `typed` function itself - // TODO: find a more elegant solution for this - var typed = { - config: config, - types: types, - conversions: conversions, - ignore: ignore - }; - - /** - * Construct the typed function itself with various signatures - * - * Signatures: - * - * typed(signatures: Object.) - * typed(name: string, signatures: Object.) - */ - typed = _typed('typed', { - 'Object': function (signatures) { - var fns = []; - for (var signature in signatures) { - if (signatures.hasOwnProperty(signature)) { - fns.push(signatures[signature]); - } - } - var name = getName(fns); - - return _typed(name, signatures); - }, - 'string, Object': _typed, - // TODO: add a signature 'Array.' - '...Function': function (fns) { - var err; - var name = getName(fns); - var signatures = {}; - - for (var i = 0; i < fns.length; i++) { - var fn = fns[i]; - - // test whether this is a typed-function - if (!(typeof fn.signatures === 'object')) { - err = new TypeError('Function is no typed-function (index: ' + i + ')'); - err.data = {index: i}; - throw err; - } - - // merge the signatures - for (var signature in fn.signatures) { - if (fn.signatures.hasOwnProperty(signature)) { - if (signatures.hasOwnProperty(signature)) { - if (fn.signatures[signature] !== signatures[signature]) { - err = new Error('Signature "' + signature + '" is defined twice'); - err.data = {signature: signature}; - throw err; - } - // else: both signatures point to the same function, that's fine - } - else { - signatures[signature] = fn.signatures[signature]; - } - } - } - } - - return _typed(name, signatures); - } - }); - - /** - * Find a specific signature from a (composed) typed function, for - * example: - * - * typed.find(fn, ['number', 'string']) - * typed.find(fn, 'number, string') - * - * Function find only only works for exact matches. - * - * @param {Function} fn A typed-function - * @param {string | string[]} signature Signature to be found, can be - * an array or a comma separated string. - * @return {Function} Returns the matching signature, or - * throws an errror when no signature - * is found. - */ - function find (fn, signature) { - if (!fn.signatures) { - throw new TypeError('Function is no typed-function'); - } - - // normalize input - var arr; - if (typeof signature === 'string') { - arr = signature.split(','); - for (var i = 0; i < arr.length; i++) { - arr[i] = arr[i].trim(); - } - } - else if (Array.isArray(signature)) { - arr = signature; - } - else { - throw new TypeError('String array or a comma separated string expected'); - } - - var str = arr.join(','); - - // find an exact match - var match = fn.signatures[str]; - if (match) { - return match; - } - - // TODO: extend find to match non-exact signatures - - throw new TypeError('Signature not found (signature: ' + (fn.name || 'unnamed') + '(' + arr.join(', ') + '))'); - } - - /** - * Convert a given value to another data type. - * @param {*} value - * @param {string} type - */ - function convert (value, type) { - var from = getTypeOf(value); - - // check conversion is needed - if (type === from) { - return value; - } - - for (var i = 0; i < typed.conversions.length; i++) { - var conversion = typed.conversions[i]; - if (conversion.from === from && conversion.to === type) { - return conversion.convert(value); - } - } - - throw new Error('Cannot convert from ' + from + ' to ' + type); - } - - // attach types and conversions to the final `typed` function - typed.config = config; - typed.types = types; - typed.conversions = conversions; - typed.ignore = ignore; - typed.create = create; - typed.find = find; - typed.convert = convert; - - // add a type - typed.addType = function (type) { - if (!type || typeof type.name !== 'string' || typeof type.test !== 'function') { - throw new TypeError('Object with properties {name: string, test: function} expected'); - } - - typed.types.push(type); - }; - - // add a conversion - typed.addConversion = function (conversion) { - if (!conversion - || typeof conversion.from !== 'string' - || typeof conversion.to !== 'string' - || typeof conversion.convert !== 'function') { - throw new TypeError('Object with properties {from: string, to: string, convert: function} expected'); - } - - typed.conversions.push(conversion); - }; - - return typed; - } - - return create(); - })); - - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var NumberFormatter = __webpack_require__(7); - - /** - * Test whether value is a number - * @param {*} value - * @return {boolean} isNumber - */ - exports.isNumber = function(value) { - return typeof value === 'number'; - }; - - /** - * Check if a number is integer - * @param {number | boolean} value - * @return {boolean} isInteger - */ - exports.isInteger = function(value) { - return isFinite(value) - ? (value == Math.round(value)) - : false; - // Note: we use ==, not ===, as we can have Booleans as well - }; - - /** - * Calculate the sign of a number - * @param {number} x - * @returns {*} - */ - exports.sign = Math.sign || function(x) { - if (x > 0) { - return 1; - } - else if (x < 0) { - return -1; - } - else { - return 0; - } - }; - - /** - * Convert a number to a formatted string representation. - * - * Syntax: - * - * format(value) - * format(value, options) - * format(value, precision) - * format(value, fn) - * - * Where: - * - * {number} value The value to be formatted - * {Object} options An object with formatting options. Available options: - * {string} notation - * Number notation. Choose from: - * 'fixed' Always use regular number notation. - * For example '123.40' and '14000000' - * 'exponential' Always use exponential notation. - * For example '1.234e+2' and '1.4e+7' - * 'engineering' Always use engineering notation. - * For example '123.4e+0' and '14.0e+6' - * 'auto' (default) Regular number notation for numbers - * having an absolute value between - * `lower` and `upper` bounds, and uses - * exponential notation elsewhere. - * Lower bound is included, upper bound - * is excluded. - * For example '123.4' and '1.4e7'. - * {number} precision A number between 0 and 16 to round - * the digits of the number. - * In case of notations 'exponential' and - * 'auto', `precision` defines the total - * number of significant digits returned - * and is undefined by default. - * In case of notation 'fixed', - * `precision` defines the number of - * significant digits after the decimal - * point, and is 0 by default. - * {Object} exponential An object containing two parameters, - * {number} lower and {number} upper, - * used by notation 'auto' to determine - * when to return exponential notation. - * Default values are `lower=1e-3` and - * `upper=1e5`. - * Only applicable for notation `auto`. - * {Function} fn A custom formatting function. Can be used to override the - * built-in notations. Function `fn` is called with `value` as - * parameter and must return a string. Is useful for example to - * format all values inside a matrix in a particular way. - * - * Examples: - * - * format(6.4); // '6.4' - * format(1240000); // '1.24e6' - * format(1/3); // '0.3333333333333333' - * format(1/3, 3); // '0.333' - * format(21385, 2); // '21000' - * format(12.071, {notation: 'fixed'}); // '12' - * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' - * format(52.8, {notation: 'exponential'}); // '5.28e+1' - * format(12345678, {notation: 'engineering'}); // '12.345678e+6' - * - * @param {number} value - * @param {Object | Function | number} [options] - * @return {string} str The formatted value - */ - exports.format = function(value, options) { - if (typeof options === 'function') { - // handle format(value, fn) - return options(value); - } - - // handle special cases - if (value === Infinity) { - return 'Infinity'; - } - else if (value === -Infinity) { - return '-Infinity'; - } - else if (isNaN(value)) { - return 'NaN'; - } - - // default values for options - var notation = 'auto'; - var precision = undefined; - - if (options) { - // determine notation from options - if (options.notation) { - notation = options.notation; - } - - // determine precision from options - if (exports.isNumber(options)) { - precision = options; - } - else if (options.precision) { - precision = options.precision; - } - } - - // handle the various notations - switch (notation) { - case 'fixed': - return exports.toFixed(value, precision); - - case 'exponential': - return exports.toExponential(value, precision); - - case 'engineering': - return exports.toEngineering(value, precision); - - case 'auto': - return exports - .toPrecision(value, precision, options && options.exponential) - - // remove trailing zeros after the decimal point - .replace(/((\.\d*?)(0+))($|e)/, function () { - var digits = arguments[2]; - var e = arguments[4]; - return (digits !== '.') ? digits + e : e; - }); - - default: - throw new Error('Unknown notation "' + notation + '". ' + - 'Choose "auto", "exponential", or "fixed".'); - } - }; - - /** - * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' - * @param {number} value - * @param {number} [precision] Number of digits in formatted output. - * If not provided, the maximum available digits - * is used. - * @returns {string} str - */ - exports.toExponential = function(value, precision) { - return new NumberFormatter(value).toExponential(precision); - }; - - /** - * Format a number in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3' - * @param {number} value - * @param {number} [precision] Number of digits in formatted output. - * If not provided, the maximum available digits - * is used. - * @returns {string} str - */ - exports.toEngineering = function(value, precision) { - return new NumberFormatter(value).toEngineering(precision); - }; - - /** - * Format a number with fixed notation. - * @param {number} value - * @param {number} [precision=0] Optional number of decimals after the - * decimal point. Zero by default. - */ - exports.toFixed = function(value, precision) { - return new NumberFormatter(value).toFixed(precision); - }; - - /** - * Format a number with a certain precision - * @param {number} value - * @param {number} [precision=undefined] Optional number of digits. - * @param {{lower: number, upper: number}} [options] By default: - * lower = 1e-3 (excl) - * upper = 1e+5 (incl) - * @return {string} - */ - exports.toPrecision = function(value, precision, options) { - return new NumberFormatter(value).toPrecision(precision, options); - }; - - /** - * Count the number of significant digits of a number. - * - * For example: - * 2.34 returns 3 - * 0.0034 returns 2 - * 120.5e+30 returns 4 - * - * @param {number} value - * @return {number} digits Number of significant digits - */ - exports.digits = function(value) { - return value - .toExponential() - .replace(/e.*$/, '') // remove exponential notation - .replace( /^0\.?0*|\./, '') // remove decimal point and leading zeros - .length - }; - - /** - * Minimum number added to one that makes the result different than one - */ - exports.DBL_EPSILON = Number.EPSILON || 2.2204460492503130808472633361816E-16; - - /** - * Compares two floating point numbers. - * @param {number} x First value to compare - * @param {number} y Second value to compare - * @param {number} [epsilon] The maximum relative difference between x and y - * If epsilon is undefined or null, the function will - * test whether x and y are exactly equal. - * @return {boolean} whether the two numbers are nearly equal - */ - exports.nearlyEqual = function(x, y, epsilon) { - // if epsilon is null or undefined, test whether x and y are exactly equal - if (epsilon == null) { - return x == y; - } - - // use "==" operator, handles infinities - if (x == y) { - return true; - } - - // NaN - if (isNaN(x) || isNaN(y)) { - return false; - } - - // at this point x and y should be finite - if(isFinite(x) && isFinite(y)) { - // check numbers are very close, needed when comparing numbers near zero - var diff = Math.abs(x - y); - if (diff < exports.DBL_EPSILON) { - return true; - } - else { - // use relative error - return diff <= Math.max(Math.abs(x), Math.abs(y)) * epsilon; - } - } - - // Infinite and Number or negative Infinite and positive Infinite cases - return false; - }; - - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Format a number using methods toPrecision, toFixed, toExponential. - * @param {number | string} value - * @constructor - */ - function NumberFormatter (value) { - // parse the input value - var match = String(value).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/); - if (!match) { - throw new SyntaxError('Invalid number'); - } - - var sign = match[1]; - var coefficients = match[2]; - var exponent = parseFloat(match[4] || '0'); - - var dot = coefficients.indexOf('.'); - exponent += (dot !== -1) ? (dot - 1) : (coefficients.length - 1); - - this.sign = sign; - this.coefficients = coefficients - .replace('.', '') // remove the dot (must be removed before removing leading zeros) - .replace(/^0*/, function (zeros) { - // remove leading zeros, add their count to the exponent - exponent -= zeros.length; - return ''; - }) - .replace(/0*$/, '') // remove trailing zeros - .split('') - .map(function (d) { - return parseInt(d); - }); - - if (this.coefficients.length === 0) { - this.coefficients.push(0); - exponent++; - } - - this.exponent = exponent; - } - - - /** - * Format a number with engineering notation. - * @param {number} [precision=0] Optional number of decimals after the - * decimal point. Zero by default. - */ - NumberFormatter.prototype.toEngineering = function(precision) { - var rounded = this.roundDigits(precision); - - var e = rounded.exponent; - var c = rounded.coefficients; - - // find nearest lower multiple of 3 for exponent - var newExp = e % 3 === 0 ? e : (e < 0 ? (e - 3) - (e % 3) : e - (e % 3)); - - // concatenate coefficients with necessary zeros - var significandsDiff = e >= 0 ? e : Math.abs(newExp); - - // add zeros if necessary (for ex: 1e+8) - if (c.length - 1 < significandsDiff) c = c.concat(zeros(significandsDiff - (c.length - 1))); - - // find difference in exponents - var expDiff = Math.abs(e - newExp); - - var decimalIdx = 1; - var str = ''; - - // push decimal index over by expDiff times - while (--expDiff >= 0) decimalIdx++; - - // if all coefficient values are zero after the decimal point, don't add a decimal value. - // otherwise concat with the rest of the coefficients - var decimals = c.slice(decimalIdx).join(''); - var decimalVal = decimals.match(/[1-9]/) ? ('.' + decimals) : ''; - - str = c.slice(0, decimalIdx).join('') + decimalVal; - - str += 'e' + (e >= 0 ? '+' : '') + newExp.toString(); - return rounded.sign + str; - } - - /** - * Format a number with fixed notation. - * @param {number} [precision=0] Optional number of decimals after the - * decimal point. Zero by default. - */ - NumberFormatter.prototype.toFixed = function (precision) { - var rounded = this.roundDigits(this.exponent + 1 + (precision || 0)); - var c = rounded.coefficients; - var p = rounded.exponent + 1; // exponent may have changed - - // append zeros if needed - var pp = p + (precision || 0); - if (c.length < pp) { - c = c.concat(zeros(pp - c.length)); - } - - // prepend zeros if needed - if (p < 0) { - c = zeros(-p + 1).concat(c); - p = 1; - } - - // insert a dot if needed - if (precision) { - c.splice(p, 0, (p === 0) ? '0.' : '.'); - } - - return this.sign + c.join(''); - }; - - /** - * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' - * @param {number} [precision] Number of digits in formatted output. - * If not provided, the maximum available digits - * is used. - */ - NumberFormatter.prototype.toExponential = function (precision) { - // round if needed, else create a clone - var rounded = precision ? this.roundDigits(precision) : this.clone(); - var c = rounded.coefficients; - var e = rounded.exponent; - - // append zeros if needed - if (c.length < precision) { - c = c.concat(zeros(precision - c.length)); - } - - // format as `C.CCCe+EEE` or `C.CCCe-EEE` - var first = c.shift(); - return this.sign + first + (c.length > 0 ? ('.' + c.join('')) : '') + - 'e' + (e >= 0 ? '+' : '') + e; - }; - - /** - * Format a number with a certain precision - * @param {number} [precision=undefined] Optional number of digits. - * @param {{lower: number | undefined, upper: number | undefined}} [options] - * By default: - * lower = 1e-3 (excl) - * upper = 1e+5 (incl) - * @return {string} - */ - NumberFormatter.prototype.toPrecision = function(precision, options) { - // determine lower and upper bound for exponential notation. - var lower = (options && options.lower !== undefined) ? options.lower : 1e-3; - var upper = (options && options.upper !== undefined) ? options.upper : 1e+5; - - var abs = Math.abs(Math.pow(10, this.exponent)); - if (abs < lower || abs >= upper) { - // exponential notation - return this.toExponential(precision); - } - else { - var rounded = precision ? this.roundDigits(precision) : this.clone(); - var c = rounded.coefficients; - var e = rounded.exponent; - - // append trailing zeros - if (c.length < precision) { - c = c.concat(zeros(precision - c.length)); - } - - // append trailing zeros - // TODO: simplify the next statement - c = c.concat(zeros(e - c.length + 1 + - (c.length < precision ? precision - c.length : 0))); - - // prepend zeros - c = zeros(-e).concat(c); - - var dot = e > 0 ? e : 0; - if (dot < c.length - 1) { - c.splice(dot + 1, 0, '.'); - } - - return this.sign + c.join(''); - } - }; - - /** - * Crete a clone of the NumberFormatter - * @return {NumberFormatter} Returns a clone of the NumberFormatter - */ - NumberFormatter.prototype.clone = function () { - var clone = new NumberFormatter('0'); - clone.sign = this.sign; - clone.coefficients = this.coefficients.slice(0); - clone.exponent = this.exponent; - return clone; - }; - - /** - * Round the number of digits of a number * - * @param {number} precision A positive integer - * @return {NumberFormatter} Returns a new NumberFormatter with the rounded - * digits - */ - NumberFormatter.prototype.roundDigits = function (precision) { - var rounded = this.clone(); - var c = rounded.coefficients; - - // prepend zeros if needed - while (precision <= 0) { - c.unshift(0); - rounded.exponent++; - precision++; - } - - if (c.length > precision) { - var removed = c.splice(precision, c.length - precision); - - if (removed[0] >= 5) { - var i = precision - 1; - c[i]++; - while (c[i] === 10) { - c.pop(); - if (i === 0) { - c.unshift(0); - rounded.exponent++; - i++; - } - i--; - c[i]++; - } - } - } - - return rounded; - }; - - /** - * Create an array filled with zeros. - * @param {number} length - * @return {Array} - */ - function zeros(length) { - var arr = []; - for (var i = 0; i < length; i++) { - arr.push(0); - } - return arr; - } - - module.exports = NumberFormatter; - - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - var Emitter = __webpack_require__(9); - - /** - * Extend given object with emitter functions `on`, `off`, `once`, `emit` - * @param {Object} obj - * @return {Object} obj - */ - exports.mixin = function (obj) { - // create event emitter - var emitter = new Emitter(); - - // bind methods to obj (we don't want to expose the emitter.e Array...) - obj.on = emitter.on.bind(emitter); - obj.off = emitter.off.bind(emitter); - obj.once = emitter.once.bind(emitter); - obj.emit = emitter.emit.bind(emitter); - - return obj; - }; - - -/***/ }, -/* 9 */ -/***/ function(module, exports) { - - function E () { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) - } - - E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - function listener () { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); - } - } - - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 - - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; - - return this; - } - }; - - module.exports = E; - - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var lazy = __webpack_require__(3).lazy; - var isFactory = __webpack_require__(3).isFactory; - var traverse = __webpack_require__(3).traverse; - var extend = __webpack_require__(3).extend; - var ArgumentsError = __webpack_require__(11); - - function factory (type, config, load, typed, math) { - /** - * Import functions from an object or a module - * - * Syntax: - * - * math.import(object) - * math.import(object, options) - * - * Where: - * - * - `object: Object` - * An object with functions to be imported. - * - `options: Object` An object with import options. Available options: - * - `override: boolean` - * If true, existing functions will be overwritten. False by default. - * - `silent: boolean` - * If true, the function will not throw errors on duplicates or invalid - * types. False by default. - * - `wrap: boolean` - * If true, the functions will be wrapped in a wrapper function - * which converts data types like Matrix to primitive data types like Array. - * The wrapper is needed when extending math.js with libraries which do not - * support these data type. False by default. - * - * Examples: - * - * // define new functions and variables - * math.import({ - * myvalue: 42, - * hello: function (name) { - * return 'hello, ' + name + '!'; - * } - * }); - * - * // use the imported function and variable - * math.myvalue * 2; // 84 - * math.hello('user'); // 'hello, user!' - * - * // import the npm module 'numbers' - * // (must be installed first with `npm install numbers`) - * math.import(require('numbers'), {wrap: true}); - * - * math.fibonacci(7); // returns 13 - * - * @param {Object | Array} object Object with functions to be imported. - * @param {Object} [options] Import options. - */ - function math_import(object, options) { - var num = arguments.length; - if (num != 1 && num != 2) { - throw new ArgumentsError('import', num, 1, 2); - } - - if (!options) { - options = {}; - } - - if (isFactory(object)) { - _importFactory(object, options); - } - // TODO: allow a typed-function with name too - else if (Array.isArray(object)) { - object.forEach(function (entry) { - math_import(entry, options); - }); - } - else if (typeof object === 'object') { - // a map with functions - for (var name in object) { - if (object.hasOwnProperty(name)) { - var value = object[name]; - if (isSupportedType(value)) { - _import(name, value, options); - } - else if (isFactory(object)) { - _importFactory(object, options); - } - else { - math_import(value, options); - } - } - } - } - else { - if (!options.silent) { - throw new TypeError('Factory, Object, or Array expected'); - } - } - } - - /** - * Add a property to the math namespace and create a chain proxy for it. - * @param {string} name - * @param {*} value - * @param {Object} options See import for a description of the options - * @private - */ - function _import(name, value, options) { - if (options.wrap && typeof value === 'function') { - // create a wrapper around the function - value = _wrap(value); - } - - if (isTypedFunction(math[name]) && isTypedFunction(value)) { - if (options.override) { - // give the typed function the right name - value = typed(name, value.signatures); - } - else { - // merge the existing and typed function - value = typed(math[name], value); - } - - math[name] = value; - _importTransform(name, value); - math.emit('import', name, function resolver() { - return value; - }); - return; - } - - if (math[name] === undefined || options.override) { - math[name] = value; - _importTransform(name, value); - math.emit('import', name, function resolver() { - return value; - }); - return; - } - - if (!options.silent) { - throw new Error('Cannot import "' + name + '": already exists'); - } - } - - function _importTransform (name, value) { - if (value && typeof value.transform === 'function') { - math.expression.transform[name] = value.transform; - } - } - - /** - * Create a wrapper a round an function which converts the arguments - * to their primitive values (like convert a Matrix to Array) - * @param {Function} fn - * @return {Function} Returns the wrapped function - * @private - */ - function _wrap (fn) { - var wrapper = function wrapper () { - var args = []; - for (var i = 0, len = arguments.length; i < len; i++) { - var arg = arguments[i]; - args[i] = arg && arg.valueOf(); - } - return fn.apply(math, args); - }; - - if (fn.transform) { - wrapper.transform = fn.transform; - } - - return wrapper; - } - - /** - * Import an instance of a factory into math.js - * @param {{factory: Function, name: string, path: string, math: boolean}} factory - * @param {Object} options See import for a description of the options - * @private - */ - function _importFactory(factory, options) { - if (typeof factory.name === 'string') { - var name = factory.name; - var namespace = factory.path ? traverse(math, factory.path) : math; - var existing = namespace.hasOwnProperty(name) ? namespace[name] : undefined; - - var resolver = function () { - var instance = load(factory); - - if (isTypedFunction(existing) && isTypedFunction(instance)) { - if (options.override) { - // replace the existing typed function (nothing to do) - } - else { - // merge the existing and new typed function - instance = typed(existing, instance); - } - - return instance; - } - - if (existing === undefined || options.override) { - return instance; - } - - if (!options.silent) { - throw new Error('Cannot import "' + name + '": already exists'); - } - }; - - if (factory.lazy !== false) { - lazy(namespace, name, resolver); - } - else { - namespace[name] = resolver(); - } - - math.emit('import', name, resolver, factory.path); - } - else { - // unnamed factory. - // no lazy loading - load(factory); - } - } - - /** - * Check whether given object is a type which can be imported - * @param {Function | number | string | boolean | null | Unit | Complex} object - * @return {boolean} - * @private - */ - function isSupportedType(object) { - return typeof object == 'function' - || typeof object === 'number' - || typeof object === 'string' - || typeof object === 'boolean' - || object === null - || (object && object.isUnit === true) - || (object && object.isComplex === true) - || (object && object.isBigNumber === true) - || (object && object.isFraction === true) - || (object && object.isMatrix === true) - || (object && Array.isArray(object) === true) - } - - /** - * Test whether a given thing is a typed-function - * @param {*} fn - * @return {boolean} Returns true when `fn` is a typed-function - */ - function isTypedFunction (fn) { - return typeof fn === 'function' && typeof fn.signatures === 'object'; - } - - return math_import; - } - - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.name = 'import'; - exports.factory = factory; - exports.lazy = true; - - -/***/ }, -/* 11 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Create a syntax error with the message: - * 'Wrong number of arguments in function ( provided, - expected)' - * @param {string} fn Function name - * @param {number} count Actual argument count - * @param {number} min Minimum required argument count - * @param {number} [max] Maximum required argument count - * @extends Error - */ - function ArgumentsError(fn, count, min, max) { - if (!(this instanceof ArgumentsError)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.fn = fn; - this.count = count; - this.min = min; - this.max = max; - - this.message = 'Wrong number of arguments in function ' + fn + - ' (' + count + ' provided, ' + - min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; - - this.stack = (new Error()).stack; - } - - ArgumentsError.prototype = new Error(); - ArgumentsError.prototype.constructor = Error; - ArgumentsError.prototype.name = 'ArgumentsError'; - ArgumentsError.prototype.isArgumentsError = true; - - module.exports = ArgumentsError; - - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(3); - - function factory (type, config, load, typed, math) { - var MATRIX = ['Matrix', 'Array']; // valid values for option matrix - var NUMBER = ['number', 'BigNumber', 'Fraction']; // valid values for option number - - /** - * Set configuration options for math.js, and get current options. - * Will emit a 'config' event, with arguments (curr, prev). - * - * Syntax: - * - * math.config(config: Object): Object - * - * Examples: - * - * math.config().number; // outputs 'number' - * math.eval('0.4'); // outputs number 0.4 - * math.config({number: 'Fraction'}); - * math.eval('0.4'); // outputs Fraction 2/5 - * - * @param {Object} [options] Available options: - * {number} epsilon - * Minimum relative difference between two - * compared values, used by all comparison functions. - * {string} matrix - * A string 'Matrix' (default) or 'Array'. - * {string} number - * A string 'number' (default), 'BigNumber', or 'Fraction' - * {number} precision - * The number of significant digits for BigNumbers. - * Not applicable for Numbers. - * {string} parenthesis - * How to display parentheses in LaTeX and string - * output. - * @return {Object} Returns the current configuration - */ - function _config(options) { - if (options) { - var prev = object.clone(config); - - // validate some of the options - validateOption(options, 'matrix', MATRIX); - validateOption(options, 'number', NUMBER); - - // merge options - object.deepExtend(config, options); - - var curr = object.clone(config); - - // emit 'config' event - math.emit('config', curr, prev); - - return curr; - } - else { - return object.clone(config); - } - } - - // attach the valid options to the function so they can be extended - _config.MATRIX = MATRIX; - _config.NUMBER = NUMBER; - - return _config; - } - - /** - * Test whether an Array contains a specific item. - * @param {Array.} array - * @param {string} item - * @return {boolean} - */ - function contains (array, item) { - return array.indexOf(item) !== -1; - } - - /** - * Find a string in an array. Case insensitive search - * @param {Array.} array - * @param {string} item - * @return {number} Returns the index when found. Returns -1 when not found - */ - function findIndex (array, item) { - return array - .map(function (i) { - return i.toLowerCase(); - }) - .indexOf(item.toLowerCase()); - } - - /** - * Validate an option - * @param {Object} options Object with options - * @param {string} name Name of the option to validate - * @param {Array.} values Array with valid values for this option - */ - function validateOption(options, name, values) { - if (options[name] !== undefined && !contains(values, options[name])) { - var index = findIndex(values, options[name]); - if (index !== -1) { - // right value, wrong casing - // TODO: lower case values are deprecated since v3, remove this warning some day. - console.warn('Warning: Wrong casing for configuration option "' + name + '", should be "' + values[index] + '" instead of "' + options[name] + '".'); - - options[name] = values[index]; // change the option to the right casing - } - else { - // unknown value - console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". Available options: ' + values.map(JSON.stringify).join(', ') + '.'); - } - } - } - - exports.name = 'config'; - exports.math = true; // request the math namespace as fifth argument - exports.factory = factory; - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(14), // data types (Matrix, Complex, Unit, ...) - __webpack_require__(93), // constants - __webpack_require__(95), // expression parsing - __webpack_require__(326), // functions - __webpack_require__(489), // serialization utility (math.json.reviver) - __webpack_require__(491) // errors - ]; - - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(15), - __webpack_require__(20), - __webpack_require__(21), - __webpack_require__(26), - __webpack_require__(33), - __webpack_require__(37), - __webpack_require__(70), - __webpack_require__(71), - __webpack_require__(73), - __webpack_require__(74) - ]; - - -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(16), - - // construction function - __webpack_require__(18) - ]; - - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - var Decimal = __webpack_require__(17); - - function factory (type, config, load, typed, math) { - var BigNumber = Decimal.clone({precision: config.precision}); - - /** - * Attach type information - */ - BigNumber.prototype.type = 'BigNumber'; - BigNumber.prototype.isBigNumber = true; - - /** - * Get a JSON representation of a BigNumber containing - * type information - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "BigNumber", "value": "0.2"}` - */ - BigNumber.prototype.toJSON = function () { - return { - mathjs: 'BigNumber', - value: this.toString() - }; - }; - - /** - * Instantiate a BigNumber from a JSON object - * @param {Object} json a JSON object structured as: - * `{"mathjs": "BigNumber", "value": "0.2"}` - * @return {BigNumber} - */ - BigNumber.fromJSON = function (json) { - return new BigNumber(json.value); - }; - - // listen for changed in the configuration, automatically apply changed precision - math.on('config', function (curr, prev) { - if (curr.precision !== prev.precision) { - BigNumber.config({ precision: curr.precision }); - } - }); - - return BigNumber; - } - - exports.name = 'BigNumber'; - exports.path = 'type'; - exports.factory = factory; - exports.math = true; // request access to the math namespace - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v5.0.8 https://github.com/MikeMcl/decimal.js/LICENCE */ - ;(function (globalScope) { - 'use strict'; - - - /* - * decimal.js v5.0.8 - * An arbitrary-precision Decimal type for JavaScript. - * https://github.com/MikeMcl/decimal.js - * Copyright (c) 2016 Michael Mclaughlin - * MIT Expat Licence - */ - - - // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ // - - - // The maximum exponent magnitude. - // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`. - var EXP_LIMIT = 9e15, // 0 to 9e15 - - // The limit on the value of `precision`, and on the value of the first argument to - // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`. - MAX_DIGITS = 1e9, // 0 to 1e9 - - // The base 88 alphabet used by `toJSON` and `fromJSON`. - // 7 printable ASCII characters omitted (space) \ " & ' < > - NUMERALS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~', - - // The natural logarithm of 10 (1025 digits). - LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058', - - // Pi (1025 digits). - PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789', - - - // The initial configuration properties of the Decimal constructor. - Decimal = { - - // These values must be integers within the stated ranges (inclusive). - // Most of these values can be changed during run-time using `Decimal.config`. - - // The maximum number of significant digits of the result of a calculation or base conversion. - // E.g. `Decimal.config({ precision: 20 });` - precision: 20, // 1 to MAX_DIGITS - - // The rounding mode used when rounding to `precision`. - // - // ROUND_UP 0 Away from zero. - // ROUND_DOWN 1 Towards zero. - // ROUND_CEIL 2 Towards +Infinity. - // ROUND_FLOOR 3 Towards -Infinity. - // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up. - // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. - // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. - // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. - // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. - // - // E.g. - // `Decimal.rounding = 4;` - // `Decimal.rounding = Decimal.ROUND_HALF_UP;` - rounding: 4, // 0 to 8 - - // The modulo mode used when calculating the modulus: a mod n. - // The quotient (q = a / n) is calculated according to the corresponding rounding mode. - // The remainder (r) is calculated as: r = a - n * q. - // - // UP 0 The remainder is positive if the dividend is negative, else is negative. - // DOWN 1 The remainder has the same sign as the dividend (JavaScript %). - // FLOOR 3 The remainder has the same sign as the divisor (Python %). - // HALF_EVEN 6 The IEEE 754 remainder function. - // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive. - // - // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian - // division (9) are commonly used for the modulus operation. The other rounding modes can also - // be used, but they may not give useful results. - modulo: 1, // 0 to 9 - - // The exponent value at and beneath which `toString` returns exponential notation. - // JavaScript numbers: -7 - toExpNeg: -7, // 0 to -EXP_LIMIT - - // The exponent value at and above which `toString` returns exponential notation. - // JavaScript numbers: 21 - toExpPos: 21, // 0 to EXP_LIMIT - - // The minimum exponent value, beneath which underflow to zero occurs. - // JavaScript numbers: -324 (5e-324) - minE: -EXP_LIMIT, // -1 to -EXP_LIMIT - - // The maximum exponent value, above which overflow to Infinity occurs. - // JavaScript numbers: 308 (1.7976931348623157e+308) - maxE: EXP_LIMIT, // 1 to EXP_LIMIT - - // Whether to use cryptographically-secure random number generation, if available. - crypto: void 0 // true/false/undefined - }, - - - // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- // - - - inexact, noConflict, quadrant, - cryptoObject = typeof crypto != 'undefined' ? crypto : null, - external = true, - - decimalError = '[DecimalError] ', - invalidArgument = decimalError + 'Invalid argument: ', - precisionLimitExceeded = decimalError + 'Precision limit exceeded', - - mathfloor = Math.floor, - mathpow = Math.pow, - - isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, - isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, - isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, - isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, - - BASE = 1e7, - LOG_BASE = 7, - MAX_SAFE_INTEGER = 9007199254740991, - - LN10_PRECISION = LN10.length - 1, - PI_PRECISION = PI.length - 1, - - // Decimal.prototype object - P = {}; - - - // Decimal prototype methods - - - /* - * absoluteValue abs - * ceil - * comparedTo cmp - * cosine cos - * cubeRoot cbrt - * decimalPlaces dp - * dividedBy div - * dividedToIntegerBy divToInt - * equals eq - * floor - * greaterThan gt - * greaterThanOrEqualTo gte - * hyperbolicCosine cosh - * hyperbolicSine sinh - * hyperbolicTangent tanh - * inverseCosine acos - * inverseHyperbolicCosine acosh - * inverseHyperbolicSine asinh - * inverseHyperbolicTangent atanh - * inverseSine asin - * inverseTangent atan - * isFinite - * isInteger isInt - * isNaN - * isNegative isNeg - * isPositive isPos - * isZero - * lessThan lt - * lessThanOrEqualTo lte - * logarithm log - * [maximum] [max] - * [minimum] [min] - * minus sub - * modulo mod - * naturalExponential exp - * naturalLogarithm ln - * negated neg - * plus add - * precision sd - * round - * sine sin - * squareRoot sqrt - * tangent tan - * times mul - * toBinary - * toDecimalPlaces toDP - * toExponential - * toFixed - * toFraction - * toHexadecimal toHex - * toJSON - * toNearest - * toNumber - * toOctal - * toPower pow - * toPrecision - * toSignificantDigits toSD - * toString - * truncated trunc - * valueOf - */ - - - /* - * Return a new Decimal whose value is the absolute value of this Decimal. - * - */ - P.absoluteValue = P.abs = function () { - var x = new this.constructor(this); - if (x.s < 0) x.s = 1; - return finalise(x); - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the - * direction of positive Infinity. - * - */ - P.ceil = function () { - return finalise(new this.constructor(this), this.e + 1, 2); - }; - - - /* - * Return - * 1 if the value of this Decimal is greater than the value of `y`, - * -1 if the value of this Decimal is less than the value of `y`, - * 0 if they have the same value, - * NaN if the value of either Decimal is NaN. - * - */ - P.comparedTo = P.cmp = function (y) { - var i, j, xdL, ydL, - x = this, - xd = x.d, - yd = (y = new x.constructor(y)).d, - xs = x.s, - ys = y.s; - - // Either NaN or ±Infinity? - if (!xd || !yd) { - return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1; - } - - // Either zero? - if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0; - - // Signs differ? - if (xs !== ys) return xs; - - // Compare exponents. - if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1; - - xdL = xd.length; - ydL = yd.length; - - // Compare digit by digit. - for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) { - if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1; - } - - // Compare lengths. - return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1; - }; - - - /* - * Return a new Decimal whose value is the cosine of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * cos(0) = 1 - * cos(-0) = 1 - * cos(Infinity) = NaN - * cos(-Infinity) = NaN - * cos(NaN) = NaN - * - */ - P.cosine = P.cos = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (!x.d) return new Ctor(NaN); - - // cos(0) = cos(-0) = 1 - if (!x.d[0]) return new Ctor(1); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE; - Ctor.rounding = 1; - - x = cosine(Ctor, toLessThanHalfPi(Ctor, x)); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true); - }; - - - /* - * - * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * cbrt(0) = 0 - * cbrt(-0) = -0 - * cbrt(1) = 1 - * cbrt(-1) = -1 - * cbrt(N) = N - * cbrt(-I) = -I - * cbrt(I) = I - * - * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3)) - * - */ - P.cubeRoot = P.cbrt = function () { - var e, m, n, r, rep, s, sd, t, t3, t3plusx, - x = this, - Ctor = x.constructor; - - if (!x.isFinite() || x.isZero()) return new Ctor(x); - external = false; - - // Initial estimate. - s = x.s * Math.pow(x.s * x, 1 / 3); - - // Math.cbrt underflow/overflow? - // Pass x to Math.pow as integer, then adjust the exponent of the result. - if (!s || Math.abs(s) == 1 / 0) { - n = digitsToString(x.d); - e = x.e; - - // Adjust n exponent so it is a multiple of 3 away from x exponent. - if (s = (e - n.length + 1) % 3) n += (s == 1 || s == -2 ? '0' : '00'); - s = Math.pow(n, 1 / 3); - - // Rarely, e may be one less than the result exponent value. - e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)); - - if (s == 1 / 0) { - n = '5e' + e; - } else { - n = s.toExponential(); - n = n.slice(0, n.indexOf('e') + 1) + e; - } - - r = new Ctor(n); - r.s = x.s; - } else { - r = new Ctor(s.toString()); - } - - sd = (e = Ctor.precision) + 3; - - // Halley's method. - // TODO? Compare Newton's method. - for (;;) { - t = r; - t3 = t.times(t).times(t); - t3plusx = t3.plus(x); - r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1); - - // TODO? Replace with for-loop and checkRoundingDigits. - if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) { - n = n.slice(sd - 3, sd + 1); - - // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999 - // , i.e. approaching a rounding boundary, continue the iteration. - if (n == '9999' || !rep && n == '4999') { - - // On the first iteration only, check to see if rounding up gives the exact result as the - // nines may infinitely repeat. - if (!rep) { - finalise(t, e + 1, 0); - - if (t.times(t).times(t).eq(x)) { - r = t; - break; - } - } - - sd += 4; - rep = 1; - } else { - - // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result. - // If not, then there are further digits and m will be truthy. - if (!+n || !+n.slice(1) && n.charAt(0) == '5') { - - // Truncate to the first rounding digit. - finalise(r, e + 1, 1); - m = !r.times(r).times(r).eq(x); - } - - break; - } - } - } - - external = true; - - return finalise(r, e, Ctor.rounding, m); - }; - - - /* - * Return the number of decimal places of the value of this Decimal. - * - */ - P.decimalPlaces = P.dp = function () { - var w, - d = this.d, - n = NaN; - - if (d) { - w = d.length - 1; - n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE; - - // Subtract the number of trailing zeros of the last word. - w = d[w]; - if (w) for (; w % 10 == 0; w /= 10) n--; - if (n < 0) n = 0; - } - - return n; - }; - - - /* - * n / 0 = I - * n / N = N - * n / I = 0 - * 0 / n = 0 - * 0 / 0 = N - * 0 / N = N - * 0 / I = 0 - * N / n = N - * N / 0 = N - * N / N = N - * N / I = N - * I / n = I - * I / 0 = I - * I / N = N - * I / I = N - * - * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - */ - P.dividedBy = P.div = function (y) { - return divide(this, new this.constructor(y)); - }; - - - /* - * Return a new Decimal whose value is the integer part of dividing the value of this Decimal - * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`. - * - */ - P.dividedToIntegerBy = P.divToInt = function (y) { - var x = this, - Ctor = x.constructor; - return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding); - }; - - - /* - * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false. - * - */ - P.equals = P.eq = function (y) { - return this.cmp(y) === 0; - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the - * direction of negative Infinity. - * - */ - P.floor = function () { - return finalise(new this.constructor(this), this.e + 1, 3); - }; - - - /* - * Return true if the value of this Decimal is greater than the value of `y`, otherwise return - * false. - * - */ - P.greaterThan = P.gt = function (y) { - return this.cmp(y) > 0; - }; - - - /* - * Return true if the value of this Decimal is greater than or equal to the value of `y`, - * otherwise return false. - * - */ - P.greaterThanOrEqualTo = P.gte = function (y) { - var k = this.cmp(y); - return k == 1 || k === 0; - }; - - - /* - * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [1, Infinity] - * - * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ... - * - * cosh(0) = 1 - * cosh(-0) = 1 - * cosh(Infinity) = Infinity - * cosh(-Infinity) = Infinity - * cosh(NaN) = NaN - * - * x time taken (ms) result - * 1000 9 9.8503555700852349694e+433 - * 10000 25 4.4034091128314607936e+4342 - * 100000 171 1.4033316802130615897e+43429 - * 1000000 3817 1.5166076984010437725e+434294 - * 10000000 abandoned after 2 minute wait - * - * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x)) - * - */ - P.hyperbolicCosine = P.cosh = function () { - var k, n, pr, rm, len, - x = this, - Ctor = x.constructor, - one = new Ctor(1); - - if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN); - if (x.isZero()) return one; - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + Math.max(x.e, x.sd()) + 4; - Ctor.rounding = 1; - len = x.d.length; - - // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1 - // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4)) - - // Estimate the optimum number of times to use the argument reduction. - // TODO? Estimation reused from cosine() and may not be optimal here. - if (len < 32) { - k = Math.ceil(len / 3); - n = Math.pow(4, -k).toString(); - } else { - k = 16; - n = '2.3283064365386962890625e-10'; - } - - x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true); - - // Reverse argument reduction - var cosh2_x, - i = k, - d8 = new Ctor(8); - for (; i--;) { - cosh2_x = x.times(x); - x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8)))); - } - - return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true); - }; - - - /* - * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ... - * - * sinh(0) = 0 - * sinh(-0) = -0 - * sinh(Infinity) = Infinity - * sinh(-Infinity) = -Infinity - * sinh(NaN) = NaN - * - * x time taken (ms) - * 10 2 ms - * 100 5 ms - * 1000 14 ms - * 10000 82 ms - * 100000 886 ms 1.4033316802130615897e+43429 - * 200000 2613 ms - * 300000 5407 ms - * 400000 8824 ms - * 500000 13026 ms 8.7080643612718084129e+217146 - * 1000000 48543 ms - * - * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x)) - * - */ - P.hyperbolicSine = P.sinh = function () { - var k, pr, rm, len, - x = this, - Ctor = x.constructor; - - if (!x.isFinite() || x.isZero()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + Math.max(x.e, x.sd()) + 4; - Ctor.rounding = 1; - len = x.d.length; - - if (len < 3) { - x = taylorSeries(Ctor, 2, x, x, true); - } else { - - // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x)) - // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3)) - // 3 multiplications and 1 addition - - // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x))) - // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5))) - // 4 multiplications and 2 additions - - // Estimate the optimum number of times to use the argument reduction. - k = 1.4 * Math.sqrt(len); - k = k > 16 ? 16 : k | 0; - - x = x.times(Math.pow(5, -k)); - - x = taylorSeries(Ctor, 2, x, x, true); - - // Reverse argument reduction - var sinh2_x, - d5 = new Ctor(5), - d16 = new Ctor(16), - d20 = new Ctor(20); - for (; k--;) { - sinh2_x = x.times(x); - x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20)))); - } - } - - Ctor.precision = pr; - Ctor.rounding = rm; - - return finalise(x, pr, rm, true); - }; - - - /* - * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * tanh(x) = sinh(x) / cosh(x) - * - * tanh(0) = 0 - * tanh(-0) = -0 - * tanh(Infinity) = 1 - * tanh(-Infinity) = -1 - * tanh(NaN) = NaN - * - */ - P.hyperbolicTangent = P.tanh = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (!x.isFinite()) return new Ctor(x.s); - if (x.isZero()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + 7; - Ctor.rounding = 1; - - return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm); - }; - - - /* - * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of - * this Decimal. - * - * Domain: [-1, 1] - * Range: [0, pi] - * - * acos(x) = pi/2 - asin(x) - * - * acos(0) = pi/2 - * acos(-0) = pi/2 - * acos(1) = 0 - * acos(-1) = pi - * acos(1/2) = pi/3 - * acos(-1/2) = 2*pi/3 - * acos(|x| > 1) = NaN - * acos(NaN) = NaN - * - */ - P.inverseCosine = P.acos = function () { - var halfPi, - x = this, - Ctor = x.constructor, - k = x.abs().cmp(1), - pr = Ctor.precision, - rm = Ctor.rounding; - - if (k !== -1) { - return k === 0 - // |x| is 1 - ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) - // |x| > 1 or x is NaN - : new Ctor(NaN); - } - - if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5); - - // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3 - - Ctor.precision = pr + 6; - Ctor.rounding = 1; - - x = x.asin(); - halfPi = getPi(Ctor, pr + 4, rm).times(0.5); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return halfPi.minus(x); - }; - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the - * value of this Decimal. - * - * Domain: [1, Infinity] - * Range: [0, Infinity] - * - * acosh(x) = ln(x + sqrt(x^2 - 1)) - * - * acosh(x < 1) = NaN - * acosh(NaN) = NaN - * acosh(Infinity) = Infinity - * acosh(-Infinity) = NaN - * acosh(0) = NaN - * acosh(-0) = NaN - * acosh(1) = 0 - * acosh(-1) = NaN - * - */ - P.inverseHyperbolicCosine = P.acosh = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN); - if (!x.isFinite()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4; - Ctor.rounding = 1; - external = false; - - x = x.times(x).minus(1).sqrt().plus(x); - - external = true; - Ctor.precision = pr; - Ctor.rounding = rm; - - return x.ln(); - }; - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value - * of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * asinh(x) = ln(x + sqrt(x^2 + 1)) - * - * asinh(NaN) = NaN - * asinh(Infinity) = Infinity - * asinh(-Infinity) = -Infinity - * asinh(0) = 0 - * asinh(-0) = -0 - * - */ - P.inverseHyperbolicSine = P.asinh = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (!x.isFinite() || x.isZero()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6; - Ctor.rounding = 1; - external = false; - - x = x.times(x).plus(1).sqrt().plus(x); - - external = true; - Ctor.precision = pr; - Ctor.rounding = rm; - - return x.ln(); - }; - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the - * value of this Decimal. - * - * Domain: [-1, 1] - * Range: [-Infinity, Infinity] - * - * atanh(x) = 0.5 * ln((1 + x) / (1 - x)) - * - * atanh(|x| > 1) = NaN - * atanh(NaN) = NaN - * atanh(Infinity) = NaN - * atanh(-Infinity) = NaN - * atanh(0) = 0 - * atanh(-0) = -0 - * atanh(1) = Infinity - * atanh(-1) = -Infinity - * - */ - P.inverseHyperbolicTangent = P.atanh = function () { - var pr, rm, wpr, xsd, - x = this, - Ctor = x.constructor; - - if (!x.isFinite()) return new Ctor(NaN); - if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN); - - pr = Ctor.precision; - rm = Ctor.rounding; - xsd = x.sd(); - - if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true); - - Ctor.precision = wpr = xsd - x.e; - - x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1); - - Ctor.precision = pr + 4; - Ctor.rounding = 1; - - x = x.ln(); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return x.times(0.5); - }; - - - /* - * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this - * Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi/2, pi/2] - * - * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2))) - * - * asin(0) = 0 - * asin(-0) = -0 - * asin(1/2) = pi/6 - * asin(-1/2) = -pi/6 - * asin(1) = pi/2 - * asin(-1) = -pi/2 - * asin(|x| > 1) = NaN - * asin(NaN) = NaN - * - * TODO? Compare performance of Taylor series. - * - */ - P.inverseSine = P.asin = function () { - var halfPi, k, - pr, rm, - x = this, - Ctor = x.constructor; - - if (x.isZero()) return new Ctor(x); - - k = x.abs().cmp(1); - pr = Ctor.precision; - rm = Ctor.rounding; - - if (k !== -1) { - - // |x| is 1 - if (k === 0) { - halfPi = getPi(Ctor, pr + 4, rm).times(0.5); - halfPi.s = x.s; - return halfPi; - } - - // |x| > 1 or x is NaN - return new Ctor(NaN); - } - - // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6 - - Ctor.precision = pr + 6; - Ctor.rounding = 1; - - x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan(); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return x.times(2); - }; - - - /* - * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value - * of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi/2, pi/2] - * - * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... - * - * atan(0) = 0 - * atan(-0) = -0 - * atan(1) = pi/4 - * atan(-1) = -pi/4 - * atan(Infinity) = pi/2 - * atan(-Infinity) = -pi/2 - * atan(NaN) = NaN - * - */ - P.inverseTangent = P.atan = function () { - var i, j, k, n, px, t, r, wpr, x2, - x = this, - Ctor = x.constructor, - pr = Ctor.precision, - rm = Ctor.rounding; - - if (!x.isFinite()) { - if (!x.s) return new Ctor(NaN); - if (pr + 4 <= PI_PRECISION) { - r = getPi(Ctor, pr + 4, rm).times(0.5); - r.s = x.s; - return r; - } - } else if (x.isZero()) { - return new Ctor(x); - } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) { - r = getPi(Ctor, pr + 4, rm).times(0.25); - r.s = x.s; - return r; - } - - Ctor.precision = wpr = pr + 10; - Ctor.rounding = 1; - - // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x); - - // Argument reduction - // Ensure |x| < 0.42 - // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2))) - - k = Math.min(28, wpr / LOG_BASE + 2 | 0); - - for (i = k; i; --i) x = x.div(x.times(x).plus(1).sqrt().plus(1)); - - external = false; - - j = Math.ceil(wpr / LOG_BASE); - n = 1; - x2 = x.times(x); - r = new Ctor(x); - px = x; - - // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... - for (; i !== -1;) { - px = px.times(x2); - t = r.minus(px.div(n += 2)); - - px = px.times(x2); - r = t.plus(px.div(n += 2)); - - if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;); - } - - if (k) r = r.times(2 << (k - 1)); - - external = true; - - return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true); - }; - - - /* - * Return true if the value of this Decimal is a finite number, otherwise return false. - * - */ - P.isFinite = function () { - return !!this.d; - }; - - - /* - * Return true if the value of this Decimal is an integer, otherwise return false. - * - */ - P.isInteger = P.isInt = function () { - return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2; - }; - - - /* - * Return true if the value of this Decimal is NaN, otherwise return false. - * - */ - P.isNaN = function () { - return !this.s; - }; - - - /* - * Return true if the value of this Decimal is negative, otherwise return false. - * - */ - P.isNegative = P.isNeg = function () { - return this.s < 0; - }; - - - /* - * Return true if the value of this Decimal is positive, otherwise return false. - * - */ - P.isPositive = P.isPos = function () { - return this.s > 0; - }; - - - /* - * Return true if the value of this Decimal is 0 or -0, otherwise return false. - * - */ - P.isZero = function () { - return !!this.d && this.d[0] === 0; - }; - - - /* - * Return true if the value of this Decimal is less than `y`, otherwise return false. - * - */ - P.lessThan = P.lt = function (y) { - return this.cmp(y) < 0; - }; - - - /* - * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false. - * - */ - P.lessThanOrEqualTo = P.lte = function (y) { - return this.cmp(y) < 1; - }; - - - /* - * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * If no base is specified, return log[10](arg). - * - * log[base](arg) = ln(arg) / ln(base) - * - * The result will always be correctly rounded if the base of the log is 10, and 'almost always' - * otherwise: - * - * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen - * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error - * between the result and the correctly rounded result will be one ulp (unit in the last place). - * - * log[-b](a) = NaN - * log[0](a) = NaN - * log[1](a) = NaN - * log[NaN](a) = NaN - * log[Infinity](a) = NaN - * log[b](0) = -Infinity - * log[b](-0) = -Infinity - * log[b](-a) = NaN - * log[b](1) = 0 - * log[b](Infinity) = Infinity - * log[b](NaN) = NaN - * - * [base] {number|string|Decimal} The base of the logarithm. - * - */ - P.logarithm = P.log = function (base) { - var isBase10, d, denominator, k, inf, num, sd, r, - arg = this, - Ctor = arg.constructor, - pr = Ctor.precision, - rm = Ctor.rounding, - guard = 5; - - // Default base is 10. - if (base == null) { - base = new Ctor(10); - isBase10 = true; - } else { - base = new Ctor(base); - d = base.d; - - // Return NaN if base is negative, or non-finite, or is 0 or 1. - if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN); - - isBase10 = base.eq(10); - } - - d = arg.d; - - // Is arg negative, non-finite, 0 or 1? - if (arg.s < 0 || !d || !d[0] || arg.eq(1)) { - return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0); - } - - // The result will have a non-terminating decimal expansion if base is 10 and arg is not an - // integer power of 10. - if (isBase10) { - if (d.length > 1) { - inf = true; - } else { - for (k = d[0]; k % 10 === 0;) k /= 10; - inf = k !== 1; - } - } - - external = false; - sd = pr + guard; - num = naturalLogarithm(arg, sd); - denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd); - - // The result will have 5 rounding digits. - r = divide(num, denominator, sd, 1); - - // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000, - // calculate 10 further digits. - // - // If the result is known to have an infinite decimal expansion, repeat this until it is clear - // that the result is above or below the boundary. Otherwise, if after calculating the 10 - // further digits, the last 14 are nines, round up and assume the result is exact. - // Also assume the result is exact if the last 14 are zero. - // - // Example of a result that will be incorrectly rounded: - // log[1048576](4503599627370502) = 2.60000000000000009610279511444746... - // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it - // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so - // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal - // place is still 2.6. - if (checkRoundingDigits(r.d, k = pr, rm)) { - - do { - sd += 10; - num = naturalLogarithm(arg, sd); - denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd); - r = divide(num, denominator, sd, 1); - - if (!inf) { - - // Check for 14 nines from the 2nd rounding digit, as the first may be 4. - if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) { - r = finalise(r, pr + 1, 0); - } - - break; - } - } while (checkRoundingDigits(r.d, k += 10, rm)); - } - - external = true; - - return finalise(r, pr, rm); - }; - - - /* - * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal. - * - * arguments {number|string|Decimal} - * - P.max = function () { - Array.prototype.push.call(arguments, this); - return maxOrMin(this.constructor, arguments, 'lt'); - }; - */ - - - /* - * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal. - * - * arguments {number|string|Decimal} - * - P.min = function () { - Array.prototype.push.call(arguments, this); - return maxOrMin(this.constructor, arguments, 'gt'); - }; - */ - - - /* - * n - 0 = n - * n - N = N - * n - I = -I - * 0 - n = -n - * 0 - 0 = 0 - * 0 - N = N - * 0 - I = -I - * N - n = N - * N - 0 = N - * N - N = N - * N - I = N - * I - n = I - * I - 0 = I - * I - N = N - * I - I = N - * - * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - */ - P.minus = P.sub = function (y) { - var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, - x = this, - Ctor = x.constructor; - - y = new Ctor(y); - - // If either is not finite... - if (!x.d || !y.d) { - - // Return NaN if either is NaN. - if (!x.s || !y.s) y = new Ctor(NaN); - - // Return y negated if x is finite and y is ±Infinity. - else if (x.d) y.s = -y.s; - - // Return x if y is finite and x is ±Infinity. - // Return x if both are ±Infinity with different signs. - // Return NaN if both are ±Infinity with the same sign. - else y = new Ctor(y.d || x.s !== y.s ? x : NaN); - - return y; - } - - // If signs differ... - if (x.s != y.s) { - y.s = -y.s; - return x.plus(y); - } - - xd = x.d; - yd = y.d; - pr = Ctor.precision; - rm = Ctor.rounding; - - // If either is zero... - if (!xd[0] || !yd[0]) { - - // Return y negated if x is zero and y is non-zero. - if (yd[0]) y.s = -y.s; - - // Return x if y is zero and x is non-zero. - else if (xd[0]) y = new Ctor(x); - - // Return zero if both are zero. - // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity. - else return new Ctor(rm === 3 ? -0 : 0); - - return external ? finalise(y, pr, rm) : y; - } - - // x and y are finite, non-zero numbers with the same sign. - - // Calculate base 1e7 exponents. - e = mathfloor(y.e / LOG_BASE); - xe = mathfloor(x.e / LOG_BASE); - - xd = xd.slice(); - k = xe - e; - - // If base 1e7 exponents differ... - if (k) { - xLTy = k < 0; - - if (xLTy) { - d = xd; - k = -k; - len = yd.length; - } else { - d = yd; - e = xe; - len = xd.length; - } - - // Numbers with massively different exponents would result in a very high number of - // zeros needing to be prepended, but this can be avoided while still ensuring correct - // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`. - i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2; - - if (k > i) { - k = i; - d.length = 1; - } - - // Prepend zeros to equalise exponents. - d.reverse(); - for (i = k; i--;) d.push(0); - d.reverse(); - - // Base 1e7 exponents equal. - } else { - - // Check digits to determine which is the bigger number. - - i = xd.length; - len = yd.length; - xLTy = i < len; - if (xLTy) len = i; - - for (i = 0; i < len; i++) { - if (xd[i] != yd[i]) { - xLTy = xd[i] < yd[i]; - break; - } - } - - k = 0; - } - - if (xLTy) { - d = xd; - xd = yd; - yd = d; - y.s = -y.s; - } - - len = xd.length; - - // Append zeros to `xd` if shorter. - // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length. - for (i = yd.length - len; i > 0; --i) xd[len++] = 0; - - // Subtract yd from xd. - for (i = yd.length; i > k;) { - - if (xd[--i] < yd[i]) { - for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1; - --xd[j]; - xd[i] += BASE; - } - - xd[i] -= yd[i]; - } - - // Remove trailing zeros. - for (; xd[--len] === 0;) xd.pop(); - - // Remove leading zeros and adjust exponent accordingly. - for (; xd[0] === 0; xd.shift()) --e; - - // Zero? - if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0); - - y.d = xd; - y.e = getBase10Exponent(xd, e); - - return external ? finalise(y, pr, rm) : y; - }; - - - /* - * n % 0 = N - * n % N = N - * n % I = n - * 0 % n = 0 - * -0 % n = -0 - * 0 % 0 = N - * 0 % N = N - * 0 % I = 0 - * N % n = N - * N % 0 = N - * N % N = N - * N % I = N - * I % n = N - * I % 0 = N - * I % N = N - * I % I = N - * - * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * The result depends on the modulo mode. - * - */ - P.modulo = P.mod = function (y) { - var q, - x = this, - Ctor = x.constructor; - - y = new Ctor(y); - - // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0. - if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN); - - // Return x if y is ±Infinity or x is ±0. - if (!y.d || x.d && !x.d[0]) { - return finalise(new Ctor(x), Ctor.precision, Ctor.rounding); - } - - // Prevent rounding of intermediate calculations. - external = false; - - if (Ctor.modulo == 9) { - - // Euclidian division: q = sign(y) * floor(x / abs(y)) - // result = x - q * y where 0 <= result < abs(y) - q = divide(x, y.abs(), 0, 3, 1); - q.s *= y.s; - } else { - q = divide(x, y, 0, Ctor.modulo, 1); - } - - q = q.times(y); - - external = true; - - return x.minus(q); - }; - - - /* - * Return a new Decimal whose value is the natural exponential of the value of this Decimal, - * i.e. the base e raised to the power the value of this Decimal, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - */ - P.naturalExponential = P.exp = function () { - return naturalExponential(this); - }; - - - /* - * Return a new Decimal whose value is the natural logarithm of the value of this Decimal, - * rounded to `precision` significant digits using rounding mode `rounding`. - * - */ - P.naturalLogarithm = P.ln = function () { - return naturalLogarithm(this); - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by - * -1. - * - */ - P.negated = P.neg = function () { - var x = new this.constructor(this); - x.s = -x.s; - return finalise(x); - }; - - - /* - * n + 0 = n - * n + N = N - * n + I = I - * 0 + n = n - * 0 + 0 = 0 - * 0 + N = N - * 0 + I = I - * N + n = N - * N + 0 = N - * N + N = N - * N + I = N - * I + n = I - * I + 0 = I - * I + N = N - * I + I = I - * - * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - */ - P.plus = P.add = function (y) { - var carry, d, e, i, k, len, pr, rm, xd, yd, - x = this, - Ctor = x.constructor; - - y = new Ctor(y); - - // If either is not finite... - if (!x.d || !y.d) { - - // Return NaN if either is NaN. - if (!x.s || !y.s) y = new Ctor(NaN); - - // Return x if y is finite and x is ±Infinity. - // Return x if both are ±Infinity with the same sign. - // Return NaN if both are ±Infinity with different signs. - // Return y if x is finite and y is ±Infinity. - else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN); - - return y; - } - - // If signs differ... - if (x.s != y.s) { - y.s = -y.s; - return x.minus(y); - } - - xd = x.d; - yd = y.d; - pr = Ctor.precision; - rm = Ctor.rounding; - - // If either is zero... - if (!xd[0] || !yd[0]) { - - // Return x if y is zero. - // Return y if y is non-zero. - if (!yd[0]) y = new Ctor(x); - - return external ? finalise(y, pr, rm) : y; - } - - // x and y are finite, non-zero numbers with the same sign. - - // Calculate base 1e7 exponents. - k = mathfloor(x.e / LOG_BASE); - e = mathfloor(y.e / LOG_BASE); - - xd = xd.slice(); - i = k - e; - - // If base 1e7 exponents differ... - if (i) { - - if (i < 0) { - d = xd; - i = -i; - len = yd.length; - } else { - d = yd; - e = k; - len = xd.length; - } - - // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1. - k = Math.ceil(pr / LOG_BASE); - len = k > len ? k + 1 : len + 1; - - if (i > len) { - i = len; - d.length = 1; - } - - // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts. - d.reverse(); - for (; i--;) d.push(0); - d.reverse(); - } - - len = xd.length; - i = yd.length; - - // If yd is longer than xd, swap xd and yd so xd points to the longer array. - if (len - i < 0) { - i = len; - d = yd; - yd = xd; - xd = d; - } - - // Only start adding at yd.length - 1 as the further digits of xd can be left as they are. - for (carry = 0; i;) { - carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0; - xd[i] %= BASE; - } - - if (carry) { - xd.unshift(carry); - ++e; - } - - // Remove trailing zeros. - // No need to check for zero, as +x + +y != 0 && -x + -y != 0 - for (len = xd.length; xd[--len] == 0;) xd.pop(); - - y.d = xd; - y.e = getBase10Exponent(xd, e); - - return external ? finalise(y, pr, rm) : y; - }; - - - /* - * Return the number of significant digits of the value of this Decimal. - * - * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0. - * - */ - P.precision = P.sd = function (z) { - var k, - x = this; - - if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z); - - if (x.d) { - k = getPrecision(x.d); - if (z && x.e + 1 > k) k = x.e + 1; - } else { - k = NaN; - } - - return k; - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using - * rounding mode `rounding`. - * - */ - P.round = function () { - var x = this, - Ctor = x.constructor; - - return finalise(new Ctor(x), x.e + 1, Ctor.rounding); - }; - - - /* - * Return a new Decimal whose value is the sine of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-1, 1] - * - * sin(x) = x - x^3/3! + x^5/5! - ... - * - * sin(0) = 0 - * sin(-0) = -0 - * sin(Infinity) = NaN - * sin(-Infinity) = NaN - * sin(NaN) = NaN - * - */ - P.sine = P.sin = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (!x.isFinite()) return new Ctor(NaN); - if (x.isZero()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE; - Ctor.rounding = 1; - - x = sine(Ctor, toLessThanHalfPi(Ctor, x)); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true); - }; - - - /* - * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * sqrt(-n) = N - * sqrt(N) = N - * sqrt(-I) = N - * sqrt(I) = I - * sqrt(0) = 0 - * sqrt(-0) = -0 - * - */ - P.squareRoot = P.sqrt = function () { - var m, n, sd, r, rep, t, - x = this, - d = x.d, - e = x.e, - s = x.s, - Ctor = x.constructor; - - // Negative/NaN/Infinity/zero? - if (s !== 1 || !d || !d[0]) { - return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0); - } - - external = false; - - // Initial estimate. - s = Math.sqrt(+x); - - // Math.sqrt underflow/overflow? - // Pass x to Math.sqrt as integer, then adjust the exponent of the result. - if (s == 0 || s == 1 / 0) { - n = digitsToString(d); - - if ((n.length + e) % 2 == 0) n += '0'; - s = Math.sqrt(n); - e = mathfloor((e + 1) / 2) - (e < 0 || e % 2); - - if (s == 1 / 0) { - n = '1e' + e; - } else { - n = s.toExponential(); - n = n.slice(0, n.indexOf('e') + 1) + e; - } - - r = new Ctor(n); - } else { - r = new Ctor(s.toString()); - } - - sd = (e = Ctor.precision) + 3; - - // Newton-Raphson iteration. - for (;;) { - t = r; - r = t.plus(divide(x, t, sd + 2, 1)).times(0.5); - - // TODO? Replace with for-loop and checkRoundingDigits. - if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) { - n = n.slice(sd - 3, sd + 1); - - // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or - // 4999, i.e. approaching a rounding boundary, continue the iteration. - if (n == '9999' || !rep && n == '4999') { - - // On the first iteration only, check to see if rounding up gives the exact result as the - // nines may infinitely repeat. - if (!rep) { - finalise(t, e + 1, 0); - - if (t.times(t).eq(x)) { - r = t; - break; - } - } - - sd += 4; - rep = 1; - } else { - - // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result. - // If not, then there are further digits and m will be truthy. - if (!+n || !+n.slice(1) && n.charAt(0) == '5') { - - // Truncate to the first rounding digit. - finalise(r, e + 1, 1); - m = !r.times(r).eq(x); - } - - break; - } - } - } - - external = true; - - return finalise(r, e, Ctor.rounding, m); - }; - - - /* - * Return a new Decimal whose value is the tangent of the value in radians of this Decimal. - * - * Domain: [-Infinity, Infinity] - * Range: [-Infinity, Infinity] - * - * tan(0) = 0 - * tan(-0) = -0 - * tan(Infinity) = NaN - * tan(-Infinity) = NaN - * tan(NaN) = NaN - * - */ - P.tangent = P.tan = function () { - var pr, rm, - x = this, - Ctor = x.constructor; - - if (!x.isFinite()) return new Ctor(NaN); - if (x.isZero()) return new Ctor(x); - - pr = Ctor.precision; - rm = Ctor.rounding; - Ctor.precision = pr + 10; - Ctor.rounding = 1; - - x = x.sin(); - x.s = 1; - x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0); - - Ctor.precision = pr; - Ctor.rounding = rm; - - return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true); - }; - - - /* - * n * 0 = 0 - * n * N = N - * n * I = I - * 0 * n = 0 - * 0 * 0 = 0 - * 0 * N = N - * 0 * I = N - * N * n = N - * N * 0 = N - * N * N = N - * N * I = N - * I * n = I - * I * 0 = N - * I * N = N - * I * I = I - * - * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - */ - P.times = P.mul = function (y) { - var carry, e, i, k, r, rL, t, xdL, ydL, - x = this, - Ctor = x.constructor, - xd = x.d, - yd = (y = new Ctor(y)).d; - - y.s *= x.s; - - // If either is NaN, ±Infinity or ±0... - if (!xd || !xd[0] || !yd || !yd[0]) { - - return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd - - // Return NaN if either is NaN. - // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity. - ? NaN - - // Return ±Infinity if either is ±Infinity. - // Return ±0 if either is ±0. - : !xd || !yd ? y.s / 0 : y.s * 0); - } - - e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE); - xdL = xd.length; - ydL = yd.length; - - // Ensure xd points to the longer array. - if (xdL < ydL) { - r = xd; - xd = yd; - yd = r; - rL = xdL; - xdL = ydL; - ydL = rL; - } - - // Initialise the result array with zeros. - r = []; - rL = xdL + ydL; - for (i = rL; i--;) r.push(0); - - // Multiply! - for (i = ydL; --i >= 0;) { - carry = 0; - for (k = xdL + i; k > i;) { - t = r[k] + yd[i] * xd[k - i - 1] + carry; - r[k--] = t % BASE | 0; - carry = t / BASE | 0; - } - - r[k] = (r[k] + carry) % BASE | 0; - } - - // Remove trailing zeros. - for (; !r[--rL];) r.pop(); - - if (carry) ++e; - else r.shift(); - - // Remove trailing zeros. - for (i = r.length; !r[--i];) r.pop(); - - y.d = r; - y.e = getBase10Exponent(r, e); - - return external ? finalise(y, Ctor.precision, Ctor.rounding) : y; - }; - - - /* - * Return a string representing the value of this Decimal in base 2, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toBinary = function (sd, rm) { - return toStringBinary(this, 2, sd, rm); - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp` - * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted. - * - * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toDecimalPlaces = P.toDP = function (dp, rm) { - var x = this, - Ctor = x.constructor; - - x = new Ctor(x); - if (dp === void 0) return x; - - checkInt32(dp, 0, MAX_DIGITS); - - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - - return finalise(x, dp + x.e + 1, rm); - }; - - - /* - * Return a string representing the value of this Decimal in exponential notation rounded to - * `dp` fixed decimal places using rounding mode `rounding`. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toExponential = function (dp, rm) { - var str, - x = this, - Ctor = x.constructor; - - if (dp === void 0) { - str = finiteToString(x, true); - } else { - checkInt32(dp, 0, MAX_DIGITS); - - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - - x = finalise(new Ctor(x), dp + 1, rm); - str = finiteToString(x, true, dp + 1); - } - - return x.isNeg() && !x.isZero() ? '-' + str : str; - }; - - - /* - * Return a string representing the value of this Decimal in normal (fixed-point) notation to - * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is - * omitted. - * - * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'. - * - * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. - * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. - * (-0).toFixed(3) is '0.000'. - * (-0.5).toFixed(0) is '-0'. - * - */ - P.toFixed = function (dp, rm) { - var str, y, - x = this, - Ctor = x.constructor; - - if (dp === void 0) { - str = finiteToString(x); - } else { - checkInt32(dp, 0, MAX_DIGITS); - - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - - y = finalise(new Ctor(x), dp + x.e + 1, rm); - str = finiteToString(y, false, dp + y.e + 1); - } - - // To determine whether to add the minus sign look at the value before it was rounded, - // i.e. look at `x` rather than `y`. - return x.isNeg() && !x.isZero() ? '-' + str : str; - }; - - - /* - * Return an array representing the value of this Decimal as a simple fraction with an integer - * numerator and an integer denominator. - * - * The denominator will be a positive non-zero value less than or equal to the specified maximum - * denominator. If a maximum denominator is not specified, the denominator will be the lowest - * value necessary to represent the number exactly. - * - * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity. - * - */ - P.toFraction = function (maxD) { - var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, - x = this, - xd = x.d, - Ctor = x.constructor; - - if (!xd) return new Ctor(x); - - n1 = d0 = new Ctor(1); - d1 = n0 = new Ctor(0); - - d = new Ctor(d1); - e = d.e = getPrecision(xd) - x.e - 1; - k = e % LOG_BASE; - d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k); - - if (maxD == null) { - - // d is 10**e, the minimum max-denominator needed. - maxD = e > 0 ? d : n1; - } else { - n = new Ctor(maxD); - if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n); - maxD = n.gt(d) ? (e > 0 ? d : n1) : n; - } - - external = false; - n = new Ctor(digitsToString(xd)); - pr = Ctor.precision; - Ctor.precision = e = xd.length * LOG_BASE * 2; - - for (;;) { - q = divide(n, d, 0, 1, 1); - d2 = d0.plus(q.times(d1)); - if (d2.cmp(maxD) == 1) break; - d0 = d1; - d1 = d2; - d2 = n1; - n1 = n0.plus(q.times(d2)); - n0 = d2; - d2 = d; - d = n.minus(q.times(d2)); - n = d2; - } - - d2 = divide(maxD.minus(d0), d1, 0, 1, 1); - n0 = n0.plus(d2.times(n1)); - d0 = d0.plus(d2.times(d1)); - n0.s = n1.s = x.s; - - // Determine which fraction is closer to x, n0/d0 or n1/d1? - r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 - ? [n1, d1] : [n0, d0]; - - Ctor.precision = pr; - external = true; - - return r; - }; - - - /* - * Return a string representing the value of this Decimal in base 16, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toHexadecimal = P.toHex = function (sd, rm) { - return toStringBinary(this, 16, sd, rm); - }; - - - /* - * Return a string representing the exact value of this Decimal in a compact base-88 based format. - * - * The number of characters of the string will always be equal to or less than the number of - * characters returned by `toString` or `toExponential` - usually just over half as many. - * - * The original Decimal value can be recreated by passing the string to `Decimal.fromJSON`. - * - * Base 88 alphabet: - * 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~ - * - * The following 7 printable ASCII characters are not used - * (space) \ " & ' < > - * so the return value is safe for strings, HTML, JSON, and XML. - * - * 0 0 g 16 w 32 M 48 $ 64 ] 80 - * 1 1 h 17 x 33 N 49 % 65 ^ 81 - * 2 2 i 18 y 34 O 50 ( 66 _ 82 - * 3 3 j 19 z 35 P 51 ) 67 ` 83 - * 4 4 k 20 A 36 Q 52 * 68 { 84 - * 5 5 l 21 B 37 R 53 + 69 | 85 - * 6 6 m 22 C 38 S 54 , 70 } 86 - * 7 7 n 23 D 39 T 55 - 71 ~ 87 - * 8 8 o 24 E 40 U 56 . 72 - * 9 9 p 25 F 41 V 57 / 73 - * a 10 q 26 G 42 W 58 : 74 - * b 11 r 27 H 43 X 59 ; 75 - * c 12 s 28 I 44 Y 60 = 76 - * d 13 t 29 J 45 Z 61 ? 77 - * e 14 u 30 K 46 ! 62 @ 78 - * f 15 v 31 L 47 # 63 [ 79 - * - * If the return value is just one character, it represents: - * 0-81 [[0, 40][-0, -40]] - * 82 -Infinity - * 83 +Infinity - * 84 NaN - * 85-87 free - * - * 64 32 16 8 4 2 1 - * 1 0 1 0 1 1 1 = 87 - * - */ - P.toJSON = function () { - var arr, e, i, k, len, n, r, str, - x = this, - isNeg = x.s < 0; - - // -Infinity/Infinity/NaN. - if (!x.d) return NUMERALS.charAt(x.s ? isNeg ? 82 : 83 : 84); - e = x.e; - - // Small integer. - if (x.d.length === 1 && e < 4 && e >= 0) { - n = x.d[0]; - - if (n < 2857) { - - // One character. - // [[0, 40][-0, -40]] - if (n < 41) return NUMERALS.charAt(isNeg ? n + 41 : n); - - // Two characters. High bit of first character unset. - // 0XXXXXX - // 63*88 + 87 = 5631 = 5632 values, 5632/2 = 2816 - // [[0, 2815][2816, 5631]] (2816 * 2 = 5632 values) - // [[0, 2815][-0, -2815]] - // [[41, 2856][-41, -2856]] - n -= 41; - if (isNeg) n += 2816; - k = n / 88 | 0; - - return NUMERALS.charAt(k) + NUMERALS.charAt(n - k * 88); - } - } - - str = digitsToString(x.d); - r = ''; - - // Values with a small exponent. Set high bit. - // Positive value: 100XXXX - // 1 0 0 {exponent [0, 15] -> [-7, 8]} - if (!isNeg && e <= 8 && e >= -7) { - k = 64 + e + 7; - - // Negative value: 1010XXX - // 1 0 1 0 {exponent [0, 7] -> [-3, 4]} - } else if (isNeg && e <= 4 && e >= -3) { - k = 64 + 16 + e + 3; - - // Integer without trailing zeros: 0X00000 - // 0 {is negative} 0 0 0 0 0 - } else if (str.length === e + 1) { - k = 32 * isNeg; - - // All remaining values: 0XXXXXX - // Result will have at least 3 characters. - // 0 {is negative} {is exponent negative} {exponent character count [1, 15]} - } else { - k = 32 * isNeg + 16 * (e < 0); - e = Math.abs(e); - - // One character to represent the exponent. - if (e < 88) { - k += 1; - r = NUMERALS.charAt(e); - - // Two characters to represent the exponent. - // 87*88 + 87 = 7743 - } else if (e < 7744) { - k += 2; - n = e / 88 | 0; - r = NUMERALS.charAt(n) + NUMERALS.charAt(e - n * 88); - - // More than two characters to represent the exponent. - } else { - arr = convertBase(String(e), 10, 88); - len = arr.length; - k += len; - for (i = 0; i < len; i++) r += NUMERALS.charAt(arr[i]); - } - } - - // At this point r contains the characters in base 88 representing the exponent value. - // Prepend the first character, which describes the sign, the exponent sign, and the number of - // characters that follow which represent the exponent value. - r = NUMERALS.charAt(k) + r; - arr = convertBase(str, 10, 88); - len = arr.length; - - // Add the base 88 characters that represent the significand. - for (i = 0; i < len; i++) r += NUMERALS.charAt(arr[i]); - - return r; - }; - - - /* - * Returns a new Decimal whose value is the nearest multiple of the magnitude of `y` to the value - * of this Decimal. - * - * If the value of this Decimal is equidistant from two multiples of `y`, the rounding mode `rm`, - * or `Decimal.rounding` if `rm` is omitted, determines the direction of the nearest multiple. - * - * In the context of this method, rounding mode 4 (ROUND_HALF_UP) is the same as rounding mode 0 - * (ROUND_UP), and so on. - * - * The return value will always have the same sign as this Decimal, unless either this Decimal - * or `y` is NaN, in which case the return value will be also be NaN. - * - * The return value is not affected by the value of `precision`. - * - * y {number|string|Decimal} The magnitude to round to a multiple of. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * 'toNearest() rounding mode not an integer: {rm}' - * 'toNearest() rounding mode out of range: {rm}' - * - */ - P.toNearest = function (y, rm) { - var x = this, - Ctor = x.constructor; - - x = new Ctor(x); - - if (y == null) { - - // If x is not finite, return x. - if (!x.d) return x; - - y = new Ctor(1); - rm = Ctor.rounding; - } else { - y = new Ctor(y); - if (rm !== void 0) checkInt32(rm, 0, 8); - - // If x is not finite, return x if y is not NaN, else NaN. - if (!x.d) return y.s ? x : y; - - // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN. - if (!y.d) { - if (y.s) y.s = x.s; - return y; - } - } - - // If y is not zero, calculate the nearest multiple of y to x. - if (y.d[0]) { - external = false; - if (rm < 4) rm = [4, 5, 7, 8][rm]; - x = divide(x, y, 0, rm, 1).times(y); - external = true; - finalise(x); - - // If y is zero, return zero with the sign of x. - } else { - y.s = x.s; - x = y; - } - - return x; - }; - - - /* - * Return the value of this Decimal converted to a number primitive. - * Zero keeps its sign. - * - */ - P.toNumber = function () { - return +this; - }; - - - /* - * Return a string representing the value of this Decimal in base 8, round to `sd` significant - * digits using rounding mode `rm`. - * - * If the optional `sd` argument is present then return binary exponential notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toOctal = function (sd, rm) { - return toStringBinary(this, 8, sd, rm); - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded - * to `precision` significant digits using rounding mode `rounding`. - * - * ECMAScript compliant. - * - * pow(x, NaN) = NaN - * pow(x, ±0) = 1 - - * pow(NaN, non-zero) = NaN - * pow(abs(x) > 1, +Infinity) = +Infinity - * pow(abs(x) > 1, -Infinity) = +0 - * pow(abs(x) == 1, ±Infinity) = NaN - * pow(abs(x) < 1, +Infinity) = +0 - * pow(abs(x) < 1, -Infinity) = +Infinity - * pow(+Infinity, y > 0) = +Infinity - * pow(+Infinity, y < 0) = +0 - * pow(-Infinity, odd integer > 0) = -Infinity - * pow(-Infinity, even integer > 0) = +Infinity - * pow(-Infinity, odd integer < 0) = -0 - * pow(-Infinity, even integer < 0) = +0 - * pow(+0, y > 0) = +0 - * pow(+0, y < 0) = +Infinity - * pow(-0, odd integer > 0) = -0 - * pow(-0, even integer > 0) = +0 - * pow(-0, odd integer < 0) = -Infinity - * pow(-0, even integer < 0) = +Infinity - * pow(finite x < 0, finite non-integer) = NaN - * - * For non-integer or very large exponents pow(x, y) is calculated using - * - * x^y = exp(y*ln(x)) - * - * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the - * probability of an incorrectly rounded result - * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14 - * i.e. 1 in 250,000,000,000,000 - * - * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place). - * - * y {number|string|Decimal} The power to which to raise this Decimal. - * - */ - P.toPower = P.pow = function (y) { - var e, k, pr, r, rm, sign, yIsInt, - x = this, - Ctor = x.constructor, - yn = +(y = new Ctor(y)); - - // Either ±Infinity, NaN or ±0? - if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn)); - - x = new Ctor(x); - - if (x.eq(1)) return x; - - pr = Ctor.precision; - rm = Ctor.rounding; - - if (y.eq(1)) return finalise(x, pr, rm); - - e = mathfloor(y.e / LOG_BASE); - k = y.d.length - 1; - yIsInt = e >= k; - sign = x.s; - - if (!yIsInt) { - if (sign < 0) return new Ctor(NaN); - - // If y is a small integer use the 'exponentiation by squaring' algorithm. - } else if ((k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) { - r = intPow(Ctor, x, k, pr); - return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm); - } - - // Result is negative if x is negative and the last digit of integer y is odd. - sign = sign < 0 && y.d[Math.max(e, k)] & 1 ? -1 : 1; - - // Estimate result exponent. - // x^y = 10^e, where e = y * log10(x) - // log10(x) = log10(x_significand) + x_exponent - // log10(x_significand) = ln(x_significand) / ln(10) - k = mathpow(+x, yn); - e = k == 0 || !isFinite(k) - ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1)) - : new Ctor(k + '').e; - - // Estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1. - - // Overflow/underflow? - if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? sign / 0 : 0); - - external = false; - Ctor.rounding = x.s = 1; - - // Estimate the extra guard digits needed to ensure five correct rounding digits from - // naturalLogarithm(x). Example of failure without these extra digits (precision: 10): - // new Decimal(2.32456).pow('2087987436534566.46411') - // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815 - k = Math.min(12, (e + '').length); - - // r = x^y = exp(y*ln(x)) - r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr); - - // Truncate to the required precision plus five rounding digits. - r = finalise(r, pr + 5, 1); - - // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate - // the result. - if (checkRoundingDigits(r.d, pr, rm)) { - e = pr + 10; - - // Truncate to the increased precision plus five rounding digits. - r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1); - - // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9). - if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) { - r = finalise(r, pr + 1, 0); - } - } - - r.s = sign; - external = true; - Ctor.rounding = rm; - - return finalise(r, pr, rm); - }; - - - /* - * Return a string representing the value of this Decimal rounded to `sd` significant digits - * using rounding mode `rounding`. - * - * Return exponential notation if `sd` is less than the number of digits necessary to represent - * the integer part of the value in normal notation. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - */ - P.toPrecision = function (sd, rm) { - var str, - x = this, - Ctor = x.constructor; - - if (sd === void 0) { - str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); - } else { - checkInt32(sd, 1, MAX_DIGITS); - - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - - x = finalise(new Ctor(x), sd, rm); - str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd); - } - - return x.isNeg() && !x.isZero() ? '-' + str : str; - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd` - * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if - * omitted. - * - * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. - * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. - * - * 'toSD() digits out of range: {sd}' - * 'toSD() digits not an integer: {sd}' - * 'toSD() rounding mode not an integer: {rm}' - * 'toSD() rounding mode out of range: {rm}' - * - */ - P.toSignificantDigits = P.toSD = function (sd, rm) { - var x = this, - Ctor = x.constructor; - - if (sd === void 0) { - sd = Ctor.precision; - rm = Ctor.rounding; - } else { - checkInt32(sd, 1, MAX_DIGITS); - - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - } - - return finalise(new Ctor(x), sd, rm); - }; - - - /* - * Return a string representing the value of this Decimal. - * - * Return exponential notation if this Decimal has a positive exponent equal to or greater than - * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`. - * - */ - P.toString = function () { - var x = this, - Ctor = x.constructor, - str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); - - return x.isNeg() && !x.isZero() ? '-' + str : str; - }; - - - /* - * Return a new Decimal whose value is the value of this Decimal truncated to a whole number. - * - */ - P.truncated = P.trunc = function () { - return finalise(new this.constructor(this), this.e + 1, 1); - }; - - - /* - * Return a string representing the value of this Decimal. - * Unlike `toString`, negative zero will include the minus sign. - * - */ - P.valueOf = function () { - var x = this, - Ctor = x.constructor, - str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); - - return x.isNeg() ? '-' + str : str; - }; - - - /* - // Add aliases to match BigDecimal method names. - // P.add = P.plus; - P.subtract = P.minus; - P.multiply = P.times; - P.divide = P.div; - P.remainder = P.mod; - P.compareTo = P.cmp; - P.negate = P.neg; - */ - - - // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers. - - - /* - * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toJSON, - * P.toPower, finiteToString, naturalExponential, naturalLogarithm - * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest, - * P.toPrecision, P.toSignificantDigits, toStringBinary, random - * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm - * convertBase P.toJSON, toStringBinary, fromJSON, parseOther - * cos P.cos - * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy, - * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction, - * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm, - * taylorSeries, atan2, parseOther - * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh, - * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus, - * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot, - * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed, - * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits, - * P.truncated, divide, getLn10, getPi, naturalExponential, - * naturalLogarithm, ceil, floor, round, trunc - * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf, - * toStringBinary - * getBase10Exponent P.minus, P.plus, P.times, parseOther - * getLn10 P.logarithm, naturalLogarithm - * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2 - * getPrecision P.precision, P.toFraction - * getZeroString digitsToString, finiteToString - * intPow P.toPower, parseOther - * isOdd toLessThanHalfPi - * maxOrMin max, min - * naturalExponential P.naturalExponential, P.toPower - * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm, - * P.toPower, naturalExponential - * nonFiniteToString finiteToString, toStringBinary - * parseDecimal Decimal - * parseOther Decimal - * sin P.sin - * taylorSeries P.cosh, P.sinh, cos, sin - * toLessThanHalfPi P.cos, P.sin - * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal - * truncate intPow - * - * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi, - * naturalLogarithm, config, fromJSON, parseOther, random, Decimal * - */ - - - function digitsToString(d) { - var i, k, ws, - indexOfLastWord = d.length - 1, - str = '', - w = d[0]; - - if (indexOfLastWord > 0) { - str += w; - for (i = 1; i < indexOfLastWord; i++) { - ws = d[i] + ''; - k = LOG_BASE - ws.length; - if (k) str += getZeroString(k); - str += ws; - } - - w = d[i]; - ws = w + ''; - k = LOG_BASE - ws.length; - if (k) str += getZeroString(k); - } else if (w === 0) { - return '0'; - } - - // Remove trailing zeros of last w. - for (; w % 10 === 0;) w /= 10; - - return str + w; - } - - - function checkInt32(i, min, max) { - if (i !== ~~i || i < min || i > max) { - throw Error(invalidArgument + i); - } - } - - - /* - * Check 5 rounding digits if `repeating` is null, 4 otherwise. - * `repeating == null` if caller is `log` or `pow`, - * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`. - */ - function checkRoundingDigits(d, i, rm, repeating) { - var di, k, r, rd; - - // Get the length of the first word of the array d. - for (k = d[0]; k >= 10; k /= 10) --i; - - // Is the rounding digit in the first word of d? - if (--i < 0) { - i += LOG_BASE; - di = 0; - } else { - di = Math.ceil((i + 1) / LOG_BASE); - i %= LOG_BASE; - } - - // i is the index (0 - 6) of the rounding digit. - // E.g. if within the word 3487563 the first rounding digit is 5, - // then i = 4, k = 1000, rd = 3487563 % 1000 = 563 - k = mathpow(10, LOG_BASE - i); - rd = d[di] % k | 0; - - if (repeating == null) { - if (i < 3) { - if (i == 0) rd = rd / 100 | 0; - else if (i == 1) rd = rd / 10 | 0; - r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0; - } else { - r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && - (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || - (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0; - } - } else { - if (i < 4) { - if (i == 0) rd = rd / 1000 | 0; - else if (i == 1) rd = rd / 100 | 0; - else if (i == 2) rd = rd / 10 | 0; - r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999; - } else { - r = ((repeating || rm < 4) && rd + 1 == k || - (!repeating && rm > 3) && rd + 1 == k / 2) && - (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1; - } - } - - return r; - } - - - // Convert string of `baseIn` to an array of numbers of `baseOut`. - // Eg. convertBase('255', 10, 16) returns [15, 15]. - // Eg. convertBase('ff', 16, 10) returns [2, 5, 5]. - function convertBase(str, baseIn, baseOut) { - var j, - arr = [0], - arrL, - i = 0, - strL = str.length; - - for (; i < strL;) { - for (arrL = arr.length; arrL--;) arr[arrL] *= baseIn; - arr[0] += NUMERALS.indexOf(str.charAt(i++)); - for (j = 0; j < arr.length; j++) { - if (arr[j] > baseOut - 1) { - if (arr[j + 1] === void 0) arr[j + 1] = 0; - arr[j + 1] += arr[j] / baseOut | 0; - arr[j] %= baseOut; - } - } - } - - return arr.reverse(); - } - - - /* - * cos(x) = 1 - x^2/2! + x^4/4! - ... - * |x| < pi/2 - * - */ - function cosine(Ctor, x) { - var k, y, - len = x.d.length; - - // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1 - // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1 - - // Estimate the optimum number of times to use the argument reduction. - if (len < 32) { - k = Math.ceil(len / 3); - y = Math.pow(4, -k).toString(); - } else { - k = 16; - y = '2.3283064365386962890625e-10'; - } - - Ctor.precision += k; - - x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1)); - - // Reverse argument reduction - for (var i = k; i--;) { - var cos2x = x.times(x); - x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1); - } - - Ctor.precision -= k; - - return x; - } - - - /* - * Perform division in the specified base. - */ - var divide = (function () { - - // Assumes non-zero x and k, and hence non-zero result. - function multiplyInteger(x, k, base) { - var temp, - carry = 0, - i = x.length; - - for (x = x.slice(); i--;) { - temp = x[i] * k + carry; - x[i] = temp % base | 0; - carry = temp / base | 0; - } - - if (carry) x.unshift(carry); - - return x; - } - - function compare(a, b, aL, bL) { - var i, r; - - if (aL != bL) { - r = aL > bL ? 1 : -1; - } else { - for (i = r = 0; i < aL; i++) { - if (a[i] != b[i]) { - r = a[i] > b[i] ? 1 : -1; - break; - } - } - } - - return r; - } - - function subtract(a, b, aL, base) { - var i = 0; - - // Subtract b from a. - for (; aL--;) { - a[aL] -= i; - i = a[aL] < b[aL] ? 1 : 0; - a[aL] = i * base + a[aL] - b[aL]; - } - - // Remove leading zeros. - for (; !a[0] && a.length > 1;) a.shift(); - } - - return function (x, y, pr, rm, dp, base) { - var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, - yL, yz, - Ctor = x.constructor, - sign = x.s == y.s ? 1 : -1, - xd = x.d, - yd = y.d; - - // Either NaN, Infinity or 0? - if (!xd || !xd[0] || !yd || !yd[0]) { - - return new Ctor(// Return NaN if either NaN, or both Infinity or 0. - !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : - - // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0. - xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0); - } - - if (base) { - logBase = 1; - e = x.e - y.e; - } else { - base = BASE; - logBase = LOG_BASE; - e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase); - } - - yL = yd.length; - xL = xd.length; - q = new Ctor(sign); - qd = q.d = []; - - // Result exponent may be one less than e. - // The digit array of a Decimal from toStringBinary may have trailing zeros. - for (i = 0; yd[i] == (xd[i] || 0); i++); - - if (yd[i] > (xd[i] || 0)) e--; - - if (pr == null) { - sd = pr = Ctor.precision; - rm = Ctor.rounding; - } else if (dp) { - sd = pr + (x.e - y.e) + 1; - } else { - sd = pr; - } - - if (sd < 0) { - qd.push(1); - more = true; - } else { - - // Convert precision in number of base 10 digits to base 1e7 digits. - sd = sd / logBase + 2 | 0; - i = 0; - - // divisor < 1e7 - if (yL == 1) { - k = 0; - yd = yd[0]; - sd++; - - // k is the carry. - for (; (i < xL || k) && sd--; i++) { - t = k * base + (xd[i] || 0); - qd[i] = t / yd | 0; - k = t % yd | 0; - } - - more = k || i < xL; - - // divisor >= 1e7 - } else { - - // Normalise xd and yd so highest order digit of yd is >= base/2 - k = base / (yd[0] + 1) | 0; - - if (k > 1) { - yd = multiplyInteger(yd, k, base); - xd = multiplyInteger(xd, k, base); - yL = yd.length; - xL = xd.length; - } - - xi = yL; - rem = xd.slice(0, yL); - remL = rem.length; - - // Add zeros to make remainder as long as divisor. - for (; remL < yL;) rem[remL++] = 0; - - yz = yd.slice(); - yz.unshift(0); - yd0 = yd[0]; - - if (yd[1] >= base / 2) ++yd0; - - do { - k = 0; - - // Compare divisor and remainder. - cmp = compare(yd, rem, yL, remL); - - // If divisor < remainder. - if (cmp < 0) { - - // Calculate trial digit, k. - rem0 = rem[0]; - if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); - - // k will be how many times the divisor goes into the current remainder. - k = rem0 / yd0 | 0; - - // Algorithm: - // 1. product = divisor * trial digit (k) - // 2. if product > remainder: product -= divisor, k-- - // 3. remainder -= product - // 4. if product was < remainder at 2: - // 5. compare new remainder and divisor - // 6. If remainder > divisor: remainder -= divisor, k++ - - if (k > 1) { - if (k >= base) k = base - 1; - - // product = divisor * trial digit. - prod = multiplyInteger(yd, k, base); - prodL = prod.length; - remL = rem.length; - - // Compare product and remainder. - cmp = compare(prod, rem, prodL, remL); - - // product > remainder. - if (cmp == 1) { - k--; - - // Subtract divisor from product. - subtract(prod, yL < prodL ? yz : yd, prodL, base); - } - } else { - - // cmp is -1. - // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1 - // to avoid it. If k is 1 there is a need to compare yd and rem again below. - if (k == 0) cmp = k = 1; - prod = yd.slice(); - } - - prodL = prod.length; - if (prodL < remL) prod.unshift(0); - - // Subtract product from remainder. - subtract(rem, prod, remL, base); - - // If product was < previous remainder. - if (cmp == -1) { - remL = rem.length; - - // Compare divisor and new remainder. - cmp = compare(yd, rem, yL, remL); - - // If divisor < new remainder, subtract divisor from remainder. - if (cmp < 1) { - k++; - - // Subtract divisor from remainder. - subtract(rem, yL < remL ? yz : yd, remL, base); - } - } - - remL = rem.length; - } else if (cmp === 0) { - k++; - rem = [0]; - } // if cmp === 1, k will be 0 - - // Add the next digit, k, to the result array. - qd[i++] = k; - - // Update the remainder. - if (cmp && rem[0]) { - rem[remL++] = xd[xi] || 0; - } else { - rem = [xd[xi]]; - remL = 1; - } - - } while ((xi++ < xL || rem[0] !== void 0) && sd--); - - more = rem[0] !== void 0; - } - - // Leading zero? - if (!qd[0]) qd.shift(); - } - - // logBase is 1 when divide is being used for base conversion. - if (logBase == 1) { - q.e = e; - inexact = more; - } else { - - // To calculate q.e, first get the number of digits of qd[0]. - for (i = 1, k = qd[0]; k >= 10; k /= 10) i++; - q.e = i + e * logBase - 1; - - finalise(q, dp ? pr + q.e + 1 : pr, rm, more); - } - - return q; - }; - })(); - - - /* - * Round `x` to `sd` significant digits using rounding mode `rm`. - * Check for over/under-flow. - */ - function finalise(x, sd, rm, isTruncated) { - var digits, i, j, k, rd, roundUp, w, xd, xdi, - Ctor = x.constructor; - - // Don't round if sd is null or undefined. - out: if (sd != null) { - xd = x.d; - - // Infinity/NaN. - if (!xd) return x; - - // rd: the rounding digit, i.e. the digit after the digit that may be rounded up. - // w: the word of xd containing rd, a base 1e7 number. - // xdi: the index of w within xd. - // digits: the number of digits of w. - // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if - // they had leading zeros) - // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero). - - // Get the length of the first word of the digits array xd. - for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++; - i = sd - digits; - - // Is the rounding digit in the first word of xd? - if (i < 0) { - i += LOG_BASE; - j = sd; - w = xd[xdi = 0]; - - // Get the rounding digit at index j of w. - rd = w / mathpow(10, digits - j - 1) % 10 | 0; - } else { - xdi = Math.ceil((i + 1) / LOG_BASE); - k = xd.length; - if (xdi >= k) { - if (isTruncated) { - - // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`. - for (; k++ <= xdi;) xd.push(0); - w = rd = 0; - digits = 1; - i %= LOG_BASE; - j = i - LOG_BASE + 1; - } else { - break out; - } - } else { - w = k = xd[xdi]; - - // Get the number of digits of w. - for (digits = 1; k >= 10; k /= 10) digits++; - - // Get the index of rd within w. - i %= LOG_BASE; - - // Get the index of rd within w, adjusted for leading zeros. - // The number of leading zeros of w is given by LOG_BASE - digits. - j = i - LOG_BASE + digits; - - // Get the rounding digit at index j of w. - rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0; - } - } - - // Are there any non-zero digits after the rounding digit? - isTruncated = isTruncated || sd < 0 || - xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1)); - - // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right - // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression - // will give 714. - - roundUp = rm < 4 - ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) - : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && - - // Check whether the digit to the left of the rounding digit is odd. - ((i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10) & 1 || - rm == (x.s < 0 ? 8 : 7)); - - if (sd < 1 || !xd[0]) { - xd.length = 0; - if (roundUp) { - - // Convert sd to decimal places. - sd -= x.e + 1; - - // 1, 0.1, 0.01, 0.001, 0.0001 etc. - xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE); - x.e = -sd || 0; - } else { - - // Zero. - xd[0] = x.e = 0; - } - - return x; - } - - // Remove excess digits. - if (i == 0) { - xd.length = xdi; - k = 1; - xdi--; - } else { - xd.length = xdi + 1; - k = mathpow(10, LOG_BASE - i); - - // E.g. 56700 becomes 56000 if 7 is the rounding digit. - // j > 0 means i > number of leading zeros of w. - xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0; - } - - if (roundUp) { - for (;;) { - - // Is the digit to be rounded up in the first word of xd? - if (xdi == 0) { - - // i will be the length of xd[0] before k is added. - for (i = 1, j = xd[0]; j >= 10; j /= 10) i++; - j = xd[0] += k; - for (k = 1; j >= 10; j /= 10) k++; - - // if i != k the length has increased. - if (i != k) { - x.e++; - if (xd[0] == BASE) xd[0] = 1; - } - - break; - } else { - xd[xdi] += k; - if (xd[xdi] != BASE) break; - xd[xdi--] = 0; - k = 1; - } - } - } - - // Remove trailing zeros. - for (i = xd.length; xd[--i] === 0;) xd.pop(); - } - - if (external) { - - // Overflow? - if (x.e > Ctor.maxE) { - - // Infinity. - x.d = null; - x.e = NaN; - - // Underflow? - } else if (x.e < Ctor.minE) { - - // Zero. - x.e = 0; - x.d = [0]; - // Ctor.underflow = true; - } // else Ctor.underflow = false; - } - - return x; - } - - - function finiteToString(x, isExp, sd) { - if (!x.isFinite()) return nonFiniteToString(x); - var k, - e = x.e, - str = digitsToString(x.d), - len = str.length; - - if (isExp) { - if (sd && (k = sd - len) > 0) { - str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k); - } else if (len > 1) { - str = str.charAt(0) + '.' + str.slice(1); - } - - str = str + (x.e < 0 ? 'e' : 'e+') + x.e; - } else if (e < 0) { - str = '0.' + getZeroString(-e - 1) + str; - if (sd && (k = sd - len) > 0) str += getZeroString(k); - } else if (e >= len) { - str += getZeroString(e + 1 - len); - if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k); - } else { - if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k); - if (sd && (k = sd - len) > 0) { - if (e + 1 === len) str += '.'; - str += getZeroString(k); - } - } - - return str; - } - - - // Calculate the base 10 exponent from the base 1e7 exponent. - function getBase10Exponent(digits, e) { - - // First get the number of digits of the first word of the digits array. - for (var i = 1, w = digits[0]; w >= 10; w /= 10) i++; - return i + e * LOG_BASE - 1; - } - - - function getLn10(Ctor, sd, pr) { - if (sd > LN10_PRECISION) { - - // Reset global state in case the exception is caught. - external = true; - if (pr) Ctor.precision = pr; - throw Error(precisionLimitExceeded); - } - return finalise(new Ctor(LN10), sd, 1, true); - } - - - function getPi(Ctor, sd, rm) { - if (sd > PI_PRECISION) throw Error(precisionLimitExceeded); - return finalise(new Ctor(PI), sd, rm, true); - } - - - function getPrecision(digits) { - var w = digits.length - 1, - len = w * LOG_BASE + 1; - - w = digits[w]; - - // If non-zero... - if (w) { - - // Subtract the number of trailing zeros of the last word. - for (; w % 10 == 0; w /= 10) len--; - - // Add the number of digits of the first word. - for (w = digits[0]; w >= 10; w /= 10) len++; - } - - return len; - } - - - function getZeroString(k) { - var zs = ''; - for (; k--;) zs += '0'; - return zs; - } - - - /* - * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an - * integer of type number. - * - * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`. - * - */ - function intPow(Ctor, x, n, pr) { - var isTruncated, - r = new Ctor(1), - - // Max n of 9007199254740991 takes 53 loop iterations. - // Maximum digits array length; leaves [28, 34] guard digits. - k = Math.ceil(pr / LOG_BASE + 4); - - external = false; - - for (;;) { - if (n % 2) { - r = r.times(x); - if (truncate(r.d, k)) isTruncated = true; - } - - n = mathfloor(n / 2); - if (n === 0) { - - // To ensure correct rounding when r.d is truncated, increment the last word if it is zero. - n = r.d.length - 1; - if (isTruncated && r.d[n] === 0) ++r.d[n]; - break; - } - - x = x.times(x); - truncate(x.d, k); - } - - external = true; - - return r; - } - - - function isOdd(n) { - return n.d[n.d.length - 1] & 1; - } - - - /* - * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'. - */ - function maxOrMin(Ctor, args, ltgt) { - var y, - x = new Ctor(args[0]), - i = 0; - - for (; ++i < args.length;) { - y = new Ctor(args[i]); - if (!y.s) { - x = y; - break; - } else if (x[ltgt](y)) { - x = y; - } - } - - return x; - } - - - /* - * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant - * digits. - * - * Taylor/Maclaurin series. - * - * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ... - * - * Argument reduction: - * Repeat x = x / 32, k += 5, until |x| < 0.1 - * exp(x) = exp(x / 2^k)^(2^k) - * - * Previously, the argument was initially reduced by - * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10) - * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was - * found to be slower than just dividing repeatedly by 32 as above. - * - * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000 - * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000 - * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324) - * - * exp(Infinity) = Infinity - * exp(-Infinity) = 0 - * exp(NaN) = NaN - * exp(±0) = 1 - * - * exp(x) is non-terminating for any finite, non-zero x. - * - * The result will always be correctly rounded. - * - */ - function naturalExponential(x, sd) { - var denominator, guard, j, pow, sum, t, wpr, - rep = 0, - i = 0, - k = 0, - Ctor = x.constructor, - rm = Ctor.rounding, - pr = Ctor.precision; - - // 0/NaN/Infinity? - if (!x.d || !x.d[0] || x.e > 17) { - - return new Ctor(x.d - ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 - : x.s ? x.s < 0 ? 0 : x : 0 / 0); - } - - if (sd == null) { - external = false; - wpr = pr; - } else { - wpr = sd; - } - - t = new Ctor(0.03125); - - // while abs(x) >= 0.1 - while (x.e > -2) { - - // x = x / 2^5 - x = x.times(t); - k += 5; - } - - // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision - // necessary to ensure the first 4 rounding digits are correct. - guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0; - wpr += guard; - denominator = pow = sum = new Ctor(1); - Ctor.precision = wpr; - - for (;;) { - pow = finalise(pow.times(x), wpr, 1); - denominator = denominator.times(++i); - t = sum.plus(divide(pow, denominator, wpr, 1)); - - if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) { - j = k; - while (j--) sum = finalise(sum.times(sum), wpr, 1); - - // Check to see if the first 4 rounding digits are [49]999. - // If so, repeat the summation with a higher precision, otherwise - // e.g. with precision: 18, rounding: 1 - // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123) - // `wpr - guard` is the index of first rounding digit. - if (sd == null) { - - if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) { - Ctor.precision = wpr += 10; - denominator = pow = t = new Ctor(1); - i = 0; - rep++; - } else { - return finalise(sum, Ctor.precision = pr, rm, external = true); - } - } else { - Ctor.precision = pr; - return sum; - } - } - - sum = t; - } - } - - - /* - * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant - * digits. - * - * ln(-n) = NaN - * ln(0) = -Infinity - * ln(-0) = -Infinity - * ln(1) = 0 - * ln(Infinity) = Infinity - * ln(-Infinity) = NaN - * ln(NaN) = NaN - * - * ln(n) (n != 1) is non-terminating. - * - */ - function naturalLogarithm(y, sd) { - var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2, - n = 1, - guard = 10, - x = y, - xd = x.d, - Ctor = x.constructor, - rm = Ctor.rounding, - pr = Ctor.precision; - - // Is x negative or Infinity, NaN, 0 or 1? - if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) { - return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x); - } - - if (sd == null) { - external = false; - wpr = pr; - } else { - wpr = sd; - } - - Ctor.precision = wpr += guard; - c = digitsToString(xd); - c0 = c.charAt(0); - - if (Math.abs(e = x.e) < 1.5e15) { - - // Argument reduction. - // The series converges faster the closer the argument is to 1, so using - // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b - // multiply the argument by itself until the leading digits of the significand are 7, 8, 9, - // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can - // later be divided by this number, then separate out the power of 10 using - // ln(a*10^b) = ln(a) + b*ln(10). - - // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14). - //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) { - // max n is 6 (gives 0.7 - 1.3) - while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) { - x = x.times(y); - c = digitsToString(x.d); - c0 = c.charAt(0); - n++; - } - - e = x.e; - - if (c0 > 1) { - x = new Ctor('0.' + c); - e++; - } else { - x = new Ctor(c0 + '.' + c.slice(1)); - } - } else { - - // The argument reduction method above may result in overflow if the argument y is a massive - // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this - // function using ln(x*10^e) = ln(x) + e*ln(10). - t = getLn10(Ctor, wpr + 2, pr).times(e + ''); - x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t); - Ctor.precision = pr; - - return sd == null ? finalise(x, pr, rm, external = true) : x; - } - - // x1 is x reduced to a value near 1. - x1 = x; - - // Taylor series. - // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...) - // where x = (y - 1)/(y + 1) (|x| < 1) - sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1); - x2 = finalise(x.times(x), wpr, 1); - denominator = 3; - - for (;;) { - numerator = finalise(numerator.times(x2), wpr, 1); - t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1)); - - if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) { - sum = sum.times(2); - - // Reverse the argument reduction. Check that e is not 0 because, besides preventing an - // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0. - if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + '')); - sum = divide(sum, new Ctor(n), wpr, 1); - - // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has - // been repeated previously) and the first 4 rounding digits 9999? - // If so, restart the summation with a higher precision, otherwise - // e.g. with precision: 12, rounding: 1 - // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463. - // `wpr - guard` is the index of first rounding digit. - if (sd == null) { - if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) { - Ctor.precision = wpr += guard; - t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1); - x2 = finalise(x.times(x), wpr, 1); - denominator = rep = 1; - } else { - return finalise(sum, Ctor.precision = pr, rm, external = true); - } - } else { - Ctor.precision = pr; - return sum; - } - } - - sum = t; - denominator += 2; - } - } - - - // ±Infinity, NaN. - function nonFiniteToString(x) { - // Unsigned. - return String(x.s * x.s / 0); - } - - - /* - * Parse the value of a new Decimal `x` from string `str`. - */ - function parseDecimal(x, str) { - var e, i, len; - - // Decimal point? - if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); - - // Exponential form? - if ((i = str.search(/e/i)) > 0) { - - // Determine exponent. - if (e < 0) e = i; - e += +str.slice(i + 1); - str = str.substring(0, i); - } else if (e < 0) { - - // Integer. - e = str.length; - } - - // Determine leading zeros. - for (i = 0; str.charCodeAt(i) === 48; i++); - - // Determine trailing zeros. - for (len = str.length; str.charCodeAt(len - 1) === 48; --len); - str = str.slice(i, len); - - if (str) { - len -= i; - x.e = e = e - i - 1; - x.d = []; - - // Transform base - - // e is the base 10 exponent. - // i is where to slice str to get the first word of the digits array. - i = (e + 1) % LOG_BASE; - if (e < 0) i += LOG_BASE; - - if (i < len) { - if (i) x.d.push(+str.slice(0, i)); - for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE)); - str = str.slice(i); - i = LOG_BASE - str.length; - } else { - i -= len; - } - - for (; i--;) str += '0'; - x.d.push(+str); - - if (external) { - - // Overflow? - if (x.e > x.constructor.maxE) { - - // Infinity. - x.d = null; - x.e = NaN; - - // Underflow? - } else if (x.e < x.constructor.minE) { - - // Zero. - x.e = 0; - x.d = [0]; - // x.constructor.underflow = true; - } // else x.constructor.underflow = false; - } - } else { - - // Zero. - x.e = 0; - x.d = [0]; - } - - return x; - } - - - /* - * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value. - */ - function parseOther(x, str) { - var base, Ctor, divisor, i, isFloat, len, p, xd, xe; - - if (str === 'Infinity' || str === 'NaN') { - if (!+str) x.s = NaN; - x.e = NaN; - x.d = null; - return x; - } - - if (isHex.test(str)) { - base = 16; - str = str.toLowerCase(); - } else if (isBinary.test(str)) { - base = 2; - } else if (isOctal.test(str)) { - base = 8; - } else { - throw Error(invalidArgument + str); - } - - // Is there a binary exponent part? - i = str.search(/p/i); - - if (i > 0) { - p = +str.slice(i + 1); - str = str.substring(2, i); - } else { - str = str.slice(2); - } - - // Convert `str` as an integer then divide the result by `base` raised to a power such that the - // fraction part will be restored. - i = str.indexOf('.'); - isFloat = i >= 0; - Ctor = x.constructor; - - if (isFloat) { - str = str.replace('.', ''); - len = str.length; - i = len - i; - - // log[10](16) = 1.2041... , log[10](88) = 1.9444.... - divisor = intPow(Ctor, new Ctor(base), i, i * 2); - } - - xd = convertBase(str, base, BASE); - xe = xd.length - 1; - - // Remove trailing zeros. - for (i = xe; xd[i] === 0; --i) xd.pop(); - if (i < 0) return new Ctor(x.s * 0); - x.e = getBase10Exponent(xd, xe); - x.d = xd; - external = false; - - // At what precision to perform the division to ensure exact conversion? - // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount) - // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412 - // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits. - // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount - // Therefore using 4 * the number of digits of str will always be enough. - if (isFloat) x = divide(x, divisor, len * 4); - - // Multiply by the binary exponent part if present. - if (p) x = x.times(Math.abs(p) < 54 ? Math.pow(2, p) : Decimal.pow(2, p)); - external = true; - - return x; - } - - - /* - * sin(x) = x - x^3/3! + x^5/5! - ... - * |x| < pi/2 - * - */ - function sine(Ctor, x) { - var k, - len = x.d.length; - - if (len < 3) return taylorSeries(Ctor, 2, x, x); - - // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x) - // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5) - // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20)) - - // Estimate the optimum number of times to use the argument reduction. - k = 1.4 * Math.sqrt(len); - k = k > 16 ? 16 : k | 0; - - // Max k before Math.pow precision loss is 22 - x = x.times(Math.pow(5, -k)); - x = taylorSeries(Ctor, 2, x, x); - - // Reverse argument reduction - var sin2_x, - d5 = new Ctor(5), - d16 = new Ctor(16), - d20 = new Ctor(20); - for (; k--;) { - sin2_x = x.times(x); - x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20)))); - } - - return x; - } - - - // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`. - function taylorSeries(Ctor, n, x, y, isHyperbolic) { - var j, t, u, x2, - i = 1, - pr = Ctor.precision, - k = Math.ceil(pr / LOG_BASE); - - external = false; - x2 = x.times(x); - u = new Ctor(y); - - for (;;) { - t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1); - u = isHyperbolic ? y.plus(t) : y.minus(t); - y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1); - t = u.plus(y); - - if (t.d[k] !== void 0) { - for (j = k; t.d[j] === u.d[j] && j--;); - if (j == -1) break; - } - - j = u; - u = y; - y = t; - t = j; - i++; - } - - external = true; - t.d.length = k + 1; - - return t; - } - - - // Return the absolute value of `x` reduced to less than or equal to half pi. - function toLessThanHalfPi(Ctor, x) { - var t, - isNeg = x.s < 0, - pi = getPi(Ctor, Ctor.precision, 1), - halfPi = pi.times(0.5); - - x = x.abs(); - - if (x.lte(halfPi)) { - quadrant = isNeg ? 4 : 1; - return x; - } - - t = x.divToInt(pi); - - if (t.isZero()) { - quadrant = isNeg ? 3 : 2; - } else { - x = x.minus(t.times(pi)); - - // 0 <= x < pi - if (x.lte(halfPi)) { - quadrant = isOdd(t) ? (isNeg ? 2 : 3) : (isNeg ? 4 : 1); - return x; - } - - quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2); - } - - return x.minus(pi).abs(); - } - - - /* - * Return the value of Decimal `x` as a string in base `baseOut`. - * - * If the optional `sd` argument is present include a binary exponent suffix. - */ - function toStringBinary(x, baseOut, sd, rm) { - var base, e, i, k, len, roundUp, str, xd, y, - Ctor = x.constructor, - isExp = sd !== void 0; - - if (isExp) { - checkInt32(sd, 1, MAX_DIGITS); - if (rm === void 0) rm = Ctor.rounding; - else checkInt32(rm, 0, 8); - } else { - sd = Ctor.precision; - rm = Ctor.rounding; - } - - if (!x.isFinite()) { - str = nonFiniteToString(x); - } else { - str = finiteToString(x); - i = str.indexOf('.'); - - // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required: - // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10)) - // minBinaryExponent = floor(decimalExponent * log[2](10)) - // log[2](10) = 3.321928094887362347870319429489390175864 - - if (isExp) { - base = 2; - if (baseOut == 16) { - sd = sd * 4 - 3; - } else if (baseOut == 8) { - sd = sd * 3 - 2; - } - } else { - base = baseOut; - } - - // Convert the number as an integer then divide the result by its base raised to a power such - // that the fraction part will be restored. - - // Non-integer. - if (i >= 0) { - str = str.replace('.', ''); - y = new Ctor(1); - y.e = str.length - i; - y.d = convertBase(finiteToString(y), 10, base); - y.e = y.d.length; - } - - xd = convertBase(str, 10, base); - e = len = xd.length; - - // Remove trailing zeros. - for (; xd[--len] == 0;) xd.pop(); - - if (!xd[0]) { - str = isExp ? '0p+0' : '0'; - } else { - if (i < 0) { - e--; - } else { - x = new Ctor(x); - x.d = xd; - x.e = e; - x = divide(x, y, sd, rm, 0, base); - xd = x.d; - e = x.e; - roundUp = inexact; - } - - // The rounding digit, i.e. the digit after the digit that may be rounded up. - i = xd[sd]; - k = base / 2; - roundUp = roundUp || xd[sd + 1] !== void 0; - - roundUp = rm < 4 - ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) - : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || - rm === (x.s < 0 ? 8 : 7)); - - xd.length = sd; - - if (roundUp) { - - // Rounding up may mean the previous digit has to be rounded up and so on. - for (; ++xd[--sd] > base - 1;) { - xd[sd] = 0; - if (!sd) { - ++e; - xd.unshift(1); - } - } - } - - // Determine trailing zeros. - for (len = xd.length; !xd[len - 1]; --len); - - // E.g. [4, 11, 15] becomes 4bf. - for (i = 0, str = ''; i < len; i++) str += NUMERALS.charAt(xd[i]); - - // Add binary exponent suffix? - if (isExp) { - if (len > 1) { - if (baseOut == 16 || baseOut == 8) { - i = baseOut == 16 ? 4 : 3; - for (--len; len % i; len++) str += '0'; - xd = convertBase(str, base, baseOut); - for (len = xd.length; !xd[len - 1]; --len); - - // xd[0] will always be be 1 - for (i = 1, str = '1.'; i < len; i++) str += NUMERALS.charAt(xd[i]); - } else { - str = str.charAt(0) + '.' + str.slice(1); - } - } - - str = str + (e < 0 ? 'p' : 'p+') + e; - } else if (e < 0) { - for (; ++e;) str = '0' + str; - str = '0.' + str; - } else { - if (++e > len) for (e -= len; e-- ;) str += '0'; - else if (e < len) str = str.slice(0, e) + '.' + str.slice(e); - } - } - - str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str; - } - - return x.s < 0 ? '-' + str : str; - } - - - // Does not strip trailing zeros. - function truncate(arr, len) { - if (arr.length > len) { - arr.length = len; - return true; - } - } - - - // Decimal methods - - - /* - * abs - * acos - * acosh - * add - * asin - * asinh - * atan - * atanh - * atan2 - * cbrt - * ceil - * clone - * config - * cos - * cosh - * div - * exp - * floor - * fromJSON - * hypot - * ln - * log - * log2 - * log10 - * max - * min - * mod - * mul - * pow - * random - * round - * sign - * sin - * sinh - * sqrt - * sub - * tan - * tanh - * trunc - */ - - - /* - * Return a new Decimal whose value is the absolute value of `x`. - * - * x {number|string|Decimal} - * - */ - function abs(x) { - return new this(x).abs(); - } - - - /* - * Return a new Decimal whose value is the arccosine in radians of `x`. - * - * x {number|string|Decimal} - * - */ - function acos(x) { - return new this(x).acos(); - } - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function acosh(x) { - return new this(x).acosh(); - } - - - /* - * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * y {number|string|Decimal} - * - */ - function add(x, y) { - return new this(x).plus(y); - } - - - /* - * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function asin(x) { - return new this(x).asin(); - } - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function asinh(x) { - return new this(x).asinh(); - } - - - /* - * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function atan(x) { - return new this(x).atan(); - } - - - /* - * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to - * `precision` significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function atanh(x) { - return new this(x).atanh(); - } - - - /* - * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi - * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`. - * - * Domain: [-Infinity, Infinity] - * Range: [-pi, pi] - * - * y {number|string|Decimal} The y-coordinate. - * x {number|string|Decimal} The x-coordinate. - * - * atan2(±0, -0) = ±pi - * atan2(±0, +0) = ±0 - * atan2(±0, -x) = ±pi for x > 0 - * atan2(±0, x) = ±0 for x > 0 - * atan2(-y, ±0) = -pi/2 for y > 0 - * atan2(y, ±0) = pi/2 for y > 0 - * atan2(±y, -Infinity) = ±pi for finite y > 0 - * atan2(±y, +Infinity) = ±0 for finite y > 0 - * atan2(±Infinity, x) = ±pi/2 for finite x - * atan2(±Infinity, -Infinity) = ±3*pi/4 - * atan2(±Infinity, +Infinity) = ±pi/4 - * atan2(NaN, x) = NaN - * atan2(y, NaN) = NaN - * - */ - function atan2(y, x) { - y = new this(y); - x = new this(x); - var r, - pr = this.precision, - rm = this.rounding, - wpr = pr + 4; - - // Either NaN - if (!y.s || !x.s) { - r = new this(NaN); - - // Both ±Infinity - } else if (!y.d && !x.d) { - r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75); - r.s = y.s; - - // x is ±Infinity or y is ±0 - } else if (!x.d || y.isZero()) { - r = x.s < 0 ? getPi(this, pr, rm) : new this(0); - r.s = y.s; - - // y is ±Infinity or x is ±0 - } else if (!y.d || x.isZero()) { - r = getPi(this, wpr, 1).times(0.5); - r.s = y.s; - - // Both non-zero and finite - } else if (x.s < 0) { - this.precision = wpr; - this.rounding = 1; - r = this.atan(divide(y, x, wpr, 1)); - x = getPi(this, wpr, 1); - this.precision = pr; - this.rounding = rm; - r = y.s < 0 ? r.minus(x) : r.plus(x); - } else { - r = this.atan(divide(y, x, wpr, 1)); - } - - return r; - } - - - /* - * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function cbrt(x) { - return new this(x).cbrt(); - } - - - /* - * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`. - * - * x {number|string|Decimal} - * - */ - function ceil(x) { - return finalise(x = new this(x), x.e + 1, 2); - } - - - /* - * Configure global settings for a Decimal constructor. - * - * `obj` is an object with one or more of the following properties, - * - * precision {number} - * rounding {number} - * toExpNeg {number} - * toExpPos {number} - * maxE {number} - * minE {number} - * modulo {number} - * crypto {boolean|number|undefined} - * - * E.g. Decimal.config({ precision: 20, rounding: 4 }) - * - */ - function config(obj) { - if (!obj || typeof obj !== 'object') throw Error(decimalError + 'Object expected'); - var i, p, v, - ps = [ - 'precision', 1, MAX_DIGITS, - 'rounding', 0, 8, - 'toExpNeg', -EXP_LIMIT, 0, - 'toExpPos', 0, EXP_LIMIT, - 'maxE', 0, EXP_LIMIT, - 'minE', -EXP_LIMIT, 0, - 'modulo', 0, 9 - ]; - - for (i = 0; i < ps.length; i += 3) { - if ((v = obj[p = ps[i]]) !== void 0) { - if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v; - else throw Error(invalidArgument + p + ': ' + v); - } - } - - if (obj.hasOwnProperty(p = 'crypto')) { - if ((v = obj[p]) === void 0) { - this[p] = v; - } else if (v === true || v === false || v === 0 || v === 1) { - this[p] = !!(v && cryptoObject && - (cryptoObject.getRandomValues || cryptoObject.randomBytes)); - } else { - throw Error(invalidArgument + p + ': ' + v); - } - } - - return this; - } - - - /* - * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function cos(x) { - return new this(x).cos(); - } - - - /* - * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function cosh(x) { - return new this(x).cosh(); - } - - - /* - * Create and return a Decimal constructor with the same configuration properties as this Decimal - * constructor. - * - */ - function clone(obj) { - var i, p, ps; - - /* - * The Decimal constructor and exported function. - * Return a new Decimal instance. - * - * v {number|string|Decimal} A numeric value. - * - */ - function Decimal(v) { - var e, i, t, - x = this; - - // Decimal called without new. - if (!(x instanceof Decimal)) return new Decimal(v); - - // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor - // which points to Object. - x.constructor = Decimal; - - // Duplicate. - if (v instanceof Decimal) { - x.s = v.s; - x.e = v.e; - x.d = (v = v.d) ? v.slice() : v; - return; - } - - t = typeof v; - - if (t === 'number') { - if (v === 0) { - x.s = 1 / v < 0 ? -1 : 1; - x.e = 0; - x.d = [0]; - return; - } - - if (v < 0) { - v = -v; - x.s = -1; - } else { - x.s = 1; - } - - // Fast path for small integers. - if (v === ~~v && v < 1e7) { - for (e = 0, i = v; i >= 10; i /= 10) e++; - x.e = e; - x.d = [v]; - return; - - // Infinity, NaN. - } else if (v * 0 !== 0) { - if (!v) x.s = NaN; - x.e = NaN; - x.d = null; - return; - } - - return parseDecimal(x, v.toString()); - - } else if (t !== 'string') { - throw Error(invalidArgument + v); - } - - // Minus sign? - if (v.charCodeAt(0) === 45) { - v = v.slice(1); - x.s = -1; - } else { - x.s = 1; - } - - return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v); - } - - Decimal.prototype = P; - - Decimal.ROUND_UP = 0; - Decimal.ROUND_DOWN = 1; - Decimal.ROUND_CEIL = 2; - Decimal.ROUND_FLOOR = 3; - Decimal.ROUND_HALF_UP = 4; - Decimal.ROUND_HALF_DOWN = 5; - Decimal.ROUND_HALF_EVEN = 6; - Decimal.ROUND_HALF_CEIL = 7; - Decimal.ROUND_HALF_FLOOR = 8; - Decimal.EUCLID = 9; - - Decimal.config = config; - Decimal.clone = clone; - - Decimal.abs = abs; - Decimal.acos = acos; - Decimal.acosh = acosh; // ES6 - Decimal.add = add; - Decimal.asin = asin; - Decimal.asinh = asinh; // ES6 - Decimal.atan = atan; - Decimal.atanh = atanh; // ES6 - Decimal.atan2 = atan2; - Decimal.cbrt = cbrt; // ES6 - Decimal.ceil = ceil; - Decimal.cos = cos; - Decimal.cosh = cosh; // ES6 - Decimal.div = div; - Decimal.exp = exp; - Decimal.floor = floor; - Decimal.fromJSON = fromJSON; - Decimal.hypot = hypot; // ES6 - Decimal.ln = ln; - Decimal.log = log; - Decimal.log10 = log10; // ES6 - Decimal.log2 = log2; // ES6 - Decimal.max = max; - Decimal.min = min; - Decimal.mod = mod; - Decimal.mul = mul; - Decimal.pow = pow; - Decimal.random = random; - Decimal.round = round; - Decimal.sign = sign; // ES6 - Decimal.sin = sin; - Decimal.sinh = sinh; // ES6 - Decimal.sqrt = sqrt; - Decimal.sub = sub; - Decimal.tan = tan; - Decimal.tanh = tanh; // ES6 - Decimal.trunc = trunc; // ES6 - - if (obj === void 0) obj = {}; - if (obj) { - ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto']; - for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p]; - } - - Decimal.config(obj); - - return Decimal; - } - - - /* - * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * y {number|string|Decimal} - * - */ - function div(x, y) { - return new this(x).div(y); - } - - - /* - * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} The power to which to raise the base of the natural log. - * - */ - function exp(x) { - return new this(x).exp(); - } - - - /* - * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`. - * - * x {number|string|Decimal} - * - */ - function floor(x) { - return finalise(x = new this(x), x.e + 1, 3); - } - - - /* - * Return a new Decimal from `str`, a string value created by `toJSON`. - * - * Base 88 alphabet: - * 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~ - * - * If `str` is just one character: - * 0-81 [[0, 40][-0, -40]] - * 82 -Infinity - * 83 +Infinity - * 84 NaN - * - * 64 32 16 8 4 2 1 - * 1 0 1 0 1 1 1 = 87 - * - */ - function fromJSON(str) { - var e, isNeg, k, n; - - if (typeof str !== 'string' || !str) throw Error(invalidArgument + str); - k = str.length; - n = NUMERALS.indexOf(str.charAt(0)); - - // [0, 81] -> [[0, 40][-0, -40]] - if (k === 1) { - return new this(n > 81 ? [-1 / 0, 1 / 0, 0 / 0][n - 82] : n > 40 ? -(n - 41) : n); - } else if (n & 64) { - isNeg = n & 16; - - // e = isNeg ? [-3, 4] : [-7, 8] - e = isNeg ? (n & 7) - 3 : (n & 15) - 7; - k = 1; - } else if (k === 2) { - n = n * 88 + NUMERALS.indexOf(str.charAt(1)); - - // [0, 5631] -> [[0, 2815][-0, -2815]] -> [[41, 2856][-41, -2856]] - return new this(n >= 2816 ? -(n - 2816) - 41 : n + 41); - } else { - - // 0XXXXXX - // 0 {is negative} {is exponent negative} {exponent digit count [0, 15]} - isNeg = n & 32; - - // Has an exponent been specified? - if (n & 31) { - e = n & 15; // Exponent character count [1, 15] - k = e + 1; // Index of first character of the significand. - - if (e === 1) { - e = NUMERALS.indexOf(str.charAt(1)); - } else if (e === 2) { - e = NUMERALS.indexOf(str.charAt(1)) * 88 + - NUMERALS.indexOf(str.charAt(2)); - } else { - e = +convertBase(str.slice(1, k), 88, 10).join(''); - } - - // Negative exponent? - if (n & 16) e = -e; - } else { - - // Integer without trailing zeros. - // 0X00000 - // 0 {is negative} 0 0 0 0 0 - str = convertBase(str.slice(1), 88, 10).join(''); - return new this(isNeg ? '-' + str : str); - } - } - - str = convertBase(str.slice(k), 88, 10).join(''); - e = e - str.length + 1; - str = str + 'e' + e; - - return new this(isNeg ? '-' + str : str); - } - - - /* - * Return a new Decimal whose value is the square root of the sum of the squares of the arguments, - * rounded to `precision` significant digits using rounding mode `rounding`. - * - * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...) - * - */ - function hypot() { - var i, n, - t = new this(0); - - external = false; - - for (i = 0; i < arguments.length;) { - n = new this(arguments[i++]); - if (!n.d) { - if (n.s) { - external = true; - return new this(1 / 0); - } - t = n; - } else if (t.d) { - t = t.plus(n.times(n)); - } - } - - external = true; - - return t.sqrt(); - } - - - /* - * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function ln(x) { - return new this(x).ln(); - } - - - /* - * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base - * is specified, rounded to `precision` significant digits using rounding mode `rounding`. - * - * log[y](x) - * - * x {number|string|Decimal} The argument of the logarithm. - * y {number|string|Decimal} The base of the logarithm. - * - */ - function log(x, y) { - return new this(x).log(y); - } - - - /* - * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function log2(x) { - return new this(x).log(2); - } - - - /* - * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function log10(x) { - return new this(x).log(10); - } - - - /* - * Return a new Decimal whose value is the maximum of the arguments. - * - * arguments {number|string|Decimal} - * - */ - function max() { - return maxOrMin(this, arguments, 'lt'); - } - - - /* - * Return a new Decimal whose value is the minimum of the arguments. - * - * arguments {number|string|Decimal} - * - */ - function min() { - return maxOrMin(this, arguments, 'gt'); - } - - - /* - * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|Decimal} - * y {number|string|Decimal} - * - */ - function mod(x, y) { - return new this(x).mod(y); - } - - - /* - * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * y {number|string|Decimal} - * - */ - function mul(x, y) { - return new this(x).mul(y); - } - - - /* - * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} The base. - * y {number|string|Decimal} The exponent. - * - */ - function pow(x, y) { - return new this(x).pow(y); - } - - - /* - * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with - * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros - * are produced). - * - * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive. - * - */ - function random(sd) { - var d, e, k, n, - i = 0, - r = new this(1), - rd = []; - - if (sd === void 0) sd = this.precision; - else checkInt32(sd, 1, MAX_DIGITS); - - k = Math.ceil(sd / LOG_BASE); - - if (this.crypto === false) { - for (; i < k;) rd[i++] = Math.random() * 1e7 | 0; - - // Browsers supporting crypto.getRandomValues. - } else if (cryptoObject && cryptoObject.getRandomValues) { - d = cryptoObject.getRandomValues(new Uint32Array(k)); - - for (; i < k;) { - n = d[i]; - - // 0 <= n < 4294967296 - // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865). - if (n >= 4.29e9) { - d[i] = cryptoObject.getRandomValues(new Uint32Array(1))[0]; - } else { - - // 0 <= n <= 4289999999 - // 0 <= (n % 1e7) <= 9999999 - rd[i++] = n % 1e7; - } - } - - // Node.js supporting crypto.randomBytes. - } else if (cryptoObject && cryptoObject.randomBytes) { - - // buffer - d = cryptoObject.randomBytes(k *= 4); - - for (; i < k;) { - - // 0 <= n < 2147483648 - n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24); - - // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286). - if (n >= 2.14e9) { - cryptoObject.randomBytes(4).copy(d, i); - } else { - - // 0 <= n <= 2139999999 - // 0 <= (n % 1e7) <= 9999999 - rd.push(n % 1e7); - i += 4; - } - } - - i = k / 4; - } else if (this.crypto) { - throw Error(decimalError + 'crypto unavailable'); - } else { - for (; i < k;) rd[i++] = Math.random() * 1e7 | 0; - } - - k = rd[--i]; - sd %= LOG_BASE; - - // Convert trailing digits to zeros according to sd. - if (k && sd) { - n = mathpow(10, LOG_BASE - sd); - rd[i] = (k / n | 0) * n; - } - - // Remove trailing words which are zero. - for (; rd[i] === 0; i--) rd.pop(); - - // Zero? - if (i < 0) { - e = 0; - rd = [0]; - } else { - e = -1; - - // Remove leading words which are zero and adjust exponent accordingly. - for (; rd[0] === 0; e -= LOG_BASE) rd.shift(); - - // Count the digits of the first word of rd to determine leading zeros. - for (k = 1, n = rd[0]; n >= 10; n /= 10) k++; - - // Adjust the exponent for leading zeros of the first word of rd. - if (k < LOG_BASE) e -= LOG_BASE - k; - } - - r.e = e; - r.d = rd; - - return r; - } - - - /* - * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`. - * - * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL). - * - * x {number|string|Decimal} - * - */ - function round(x) { - return finalise(x = new this(x), x.e + 1, this.rounding); - } - - - /* - * Return - * 1 if x > 0, - * -1 if x < 0, - * 0 if x is 0, - * -0 if x is -0, - * NaN otherwise - * - */ - function sign(x) { - x = new this(x); - return x.d ? (x.d[0] ? x.s : 0 * x.s) : x.s || NaN; - } - - - /* - * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function sin(x) { - return new this(x).sin(); - } - - - /* - * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function sinh(x) { - return new this(x).sinh(); - } - - - /* - * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} - * - */ - function sqrt(x) { - return new this(x).sqrt(); - } - - - /* - * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits - * using rounding mode `rounding`. - * - * x {number|string|Decimal} - * y {number|string|Decimal} - * - */ - function sub(x, y) { - return new this(x).sub(y); - } - - - /* - * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant - * digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function tan(x) { - return new this(x).tan(); - } - - - /* - * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision` - * significant digits using rounding mode `rounding`. - * - * x {number|string|Decimal} A value in radians. - * - */ - function tanh(x) { - return new this(x).tanh(); - } - - - /* - * Return a new Decimal whose value is `x` truncated to an integer. - * - * x {number|string|Decimal} - * - */ - function trunc(x) { - return finalise(x = new this(x), x.e + 1, 1); - } - - - // Create and configure initial Decimal constructor. - Decimal = clone(Decimal); - - // Create the internal constants from their string values. - LN10 = new Decimal(LN10); - PI = new Decimal(PI); - - - // Export. - - - // AMD. - if (true) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { - return Decimal; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - - // Node and other environments that support module.exports. - } else if (typeof module != 'undefined' && module.exports) { - module.exports = Decimal; - - if (!cryptoObject) { - try { - cryptoObject = require('cry' + 'pto'); - } catch (e) { - // Ignore. - } - } - - // Browser. - } else { - if (!globalScope) { - globalScope = typeof self != 'undefined' && self && self.self == self - ? self : Function('return this')(); - } - - noConflict = globalScope.Decimal; - Decimal.noConflict = function () { - globalScope.Decimal = noConflict; - return Decimal; - }; - - globalScope.Decimal = Decimal; - } - })(this); - - -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Create a BigNumber, which can store numbers with arbitrary precision. - * When a matrix is provided, all elements will be converted to BigNumber. - * - * Syntax: - * - * math.bignumber(x) - * - * Examples: - * - * 0.1 + 0.2; // returns number 0.30000000000000004 - * math.bignumber(0.1) + math.bignumber(0.2); // returns BigNumber 0.3 - * - * - * 7.2e500; // returns number Infinity - * math.bignumber('7.2e500'); // returns BigNumber 7.2e500 - * - * See also: - * - * boolean, complex, index, matrix, string, unit - * - * @param {number | string | Fraction | BigNumber | Array | Matrix | boolean | null} [value] Value for the big number, - * 0 by default. - * @returns {BigNumber} The created bignumber - */ - var bignumber = typed('bignumber', { - '': function () { - return new type.BigNumber(0); - }, - - 'number': function (x) { - // convert to string to prevent errors in case of >15 digits - return new type.BigNumber(x + ''); - }, - - 'string': function (x) { - return new type.BigNumber(x); - }, - - 'BigNumber': function (x) { - // we assume a BigNumber is immutable - return x; - }, - - 'Fraction': function (x) { - return new type.BigNumber(x.n).div(x.d); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, bignumber); - } - }); - - bignumber.toTex = { - 0: '0', - 1: '\\left(${args[0]}\\right)' - }; - - return bignumber; - } - - exports.name = 'bignumber'; - exports.factory = factory; - - -/***/ }, -/* 19 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Execute the callback function element wise for each element in array and any - * nested array - * Returns an array with the results - * @param {Array | Matrix} array - * @param {Function} callback The callback is called with two parameters: - * value1 and value2, which contain the current - * element of both arrays. - * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. - * - * @return {Array | Matrix} res - */ - module.exports = function deepMap(array, callback, skipZeros) { - if (array && (typeof array.map === 'function')) { - // TODO: replace array.map with a for loop to improve performance - return array.map(function (x) { - return deepMap(x, callback, skipZeros); - }); - } - else { - return callback(array); - } - }; - - -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Create a boolean or convert a string or number to a boolean. - * In case of a number, `true` is returned for non-zero numbers, and `false` in - * case of zero. - * Strings can be `'true'` or `'false'`, or can contain a number. - * When value is a matrix, all elements will be converted to boolean. - * - * Syntax: - * - * math.boolean(x) - * - * Examples: - * - * math.boolean(0); // returns false - * math.boolean(1); // returns true - * math.boolean(-3); // returns true - * math.boolean('true'); // returns true - * math.boolean('false'); // returns false - * math.boolean([1, 0, 1, 1]); // returns [true, false, true, true] - * - * See also: - * - * bignumber, complex, index, matrix, string, unit - * - * @param {string | number | boolean | Array | Matrix | null} value A value of any type - * @return {boolean | Array | Matrix} The boolean value - */ - var bool = typed('bool', { - '': function () { - return false; - }, - - 'boolean': function (x) { - return x; - }, - - 'number': function (x) { - return !!x; - }, - - 'BigNumber': function (x) { - return !x.isZero(); - }, - - 'string': function (x) { - // try case insensitive - var lcase = x.toLowerCase(); - if (lcase === 'true') { - return true; - } - else if (lcase === 'false') { - return false; - } - - // test whether value is a valid number - var num = Number(x); - if (x != '' && !isNaN(num)) { - return !!num; - } - - throw new Error('Cannot convert "' + x + '" to a boolean'); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, bool); - } - }); - - return bool; - } - - exports.name = 'boolean'; - exports.factory = factory; - - -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(22), - - // construction function - __webpack_require__(25) - ]; - - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var format = __webpack_require__(23).format; - var lazy = __webpack_require__(3).lazy; - - function factory (type, config, load, typed, math) { - /** - * @constructor Chain - * Wrap any value in a chain, allowing to perform chained operations on - * the value. - * - * All methods available in the math.js library can be called upon the chain, - * and then will be evaluated with the value itself as first argument. - * The chain can be closed by executing chain.done(), which will return - * the final value. - * - * The Chain has a number of special functions: - * - done() Finalize the chained operation and return the - * chain's value. - * - valueOf() The same as done() - * - toString() Returns a string representation of the chain's value. - * - * @param {*} [value] - */ - function Chain (value) { - if (!(this instanceof Chain)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (value && value.isChain) { - this.value = value.value; - } - else { - this.value = value; - } - } - - /** - * Attach type information - */ - Chain.prototype.type = 'Chain'; - Chain.prototype.isChain = true; - - /** - * Close the chain. Returns the final value. - * Does the same as method valueOf() - * @returns {*} value - */ - Chain.prototype.done = function () { - return this.value; - }; - - /** - * Close the chain. Returns the final value. - * Does the same as method done() - * @returns {*} value - */ - Chain.prototype.valueOf = function () { - return this.value; - }; - - /** - * Get a string representation of the value in the chain - * @returns {string} - */ - Chain.prototype.toString = function () { - return format(this.value); - }; - - /** - * Create a proxy method for the chain - * @param {string} name - * @param {Function} fn The function to be proxied - * If fn is no function, it is silently ignored. - * @private - */ - function createProxy(name, fn) { - if (typeof fn === 'function') { - Chain.prototype[name] = chainify(fn); - } - } - - /** - * Create a proxy method for the chain - * @param {string} name - * @param {function} resolver The function resolving with the - * function to be proxied - * @private - */ - function createLazyProxy(name, resolver) { - lazy(Chain.prototype, name, function outerResolver() { - var fn = resolver(); - if (typeof fn === 'function') { - return chainify(fn); - } - - return undefined; // if not a function, ignore - }); - } - - /** - * Make a function chainable - * @param {function} fn - * @return {Function} chain function - * @private - */ - function chainify (fn) { - return function () { - var args = [this.value]; // `this` will be the context of a Chain instance - for (var i = 0; i < arguments.length; i++) { - args[i + 1] = arguments[i]; - } - - return new Chain(fn.apply(fn, args)); - } - } - - /** - * Create a proxy for a single method, or an object with multiple methods. - * Example usage: - * - * Chain.createProxy('add', function add (x, y) {...}); - * Chain.createProxy({ - * add: function add (x, y) {...}, - * subtract: function subtract (x, y) {...} - * } - * - * @param {string | Object} arg0 A name (string), or an object with - * functions - * @param {*} [arg1] A function, when arg0 is a name - */ - Chain.createProxy = function (arg0, arg1) { - if (typeof arg0 === 'string') { - // createProxy(name, value) - createProxy(arg0, arg1); - } - else { - // createProxy(values) - for (var prop in arg0) { - if (arg0.hasOwnProperty(prop)) { - createProxy(prop, arg0[prop]); - } - } - } - }; - - // create proxy for everything that is in math.js - Chain.createProxy(math); - - // register on the import event, automatically add a proxy for every imported function. - math.on('import', function (name, resolver, path) { - if (path === undefined) { - // an imported function (not a data type or something special) - createLazyProxy(name, resolver); - } - }); - - return Chain; - } - - exports.name = 'Chain'; - exports.path = 'type'; - exports.factory = factory; - exports.math = true; // require providing the math namespace as 5th argument - exports.lazy = false; // we need to register a listener on the import events, so no lazy loading - - -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var formatNumber = __webpack_require__(6).format; - var formatBigNumber = __webpack_require__(24).format; - - /** - * Test whether value is a string - * @param {*} value - * @return {boolean} isString - */ - exports.isString = function(value) { - return typeof value === 'string'; - }; - - /** - * Check if a text ends with a certain string. - * @param {string} text - * @param {string} search - */ - exports.endsWith = function(text, search) { - var start = text.length - search.length; - var end = text.length; - return (text.substring(start, end) === search); - }; - - /** - * Format a value of any type into a string. - * - * Usage: - * math.format(value) - * math.format(value, precision) - * - * When value is a function: - * - * - When the function has a property `syntax`, it returns this - * syntax description. - * - In other cases, a string `'function'` is returned. - * - * When `value` is an Object: - * - * - When the object contains a property `format` being a function, this - * function is invoked as `value.format(options)` and the result is returned. - * - When the object has its own `toString` method, this method is invoked - * and the result is returned. - * - In other cases the function will loop over all object properties and - * return JSON object notation like '{"a": 2, "b": 3}'. - * - * Example usage: - * math.format(2/7); // '0.2857142857142857' - * math.format(math.pi, 3); // '3.14' - * math.format(new Complex(2, 3)); // '2 + 3i' - * math.format('hello'); // '"hello"' - * - * @param {*} value Value to be stringified - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @return {string} str - */ - exports.format = function(value, options) { - if (typeof value === 'number') { - return formatNumber(value, options); - } - - if (value && value.isBigNumber === true) { - return formatBigNumber(value, options); - } - - if (value && value.isFraction === true) { - if (!options || options.fraction !== 'decimal') { - // output as ratio, like '1/3' - return (value.s * value.n) + '/' + value.d; - } - else { - // output as decimal, like '0.(3)' - return value.toString(); - } - } - - if (Array.isArray(value)) { - return formatArray(value, options); - } - - if (exports.isString(value)) { - return '"' + value + '"'; - } - - if (typeof value === 'function') { - return value.syntax ? String(value.syntax) : 'function'; - } - - if (value && typeof value === 'object') { - if (typeof value.format === 'function') { - return value.format(options); - } - else if (value && value.toString() !== {}.toString()) { - // this object has a non-native toString method, use that one - return value.toString(); - } - else { - var entries = []; - - for (var key in value) { - if (value.hasOwnProperty(key)) { - entries.push('"' + key + '": ' + exports.format(value[key], options)); - } - } - - return '{' + entries.join(', ') + '}'; - } - } - - return String(value); - }; - - /** - * Recursively format an n-dimensional matrix - * Example output: "[[1, 2], [3, 4]]" - * @param {Array} array - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @returns {string} str - */ - function formatArray (array, options) { - if (Array.isArray(array)) { - var str = '['; - var len = array.length; - for (var i = 0; i < len; i++) { - if (i != 0) { - str += ', '; - } - str += formatArray(array[i], options); - } - str += ']'; - return str; - } - else { - return exports.format(array, options); - } - } - - -/***/ }, -/* 24 */ -/***/ function(module, exports) { - - /** - * Convert a BigNumber to a formatted string representation. - * - * Syntax: - * - * format(value) - * format(value, options) - * format(value, precision) - * format(value, fn) - * - * Where: - * - * {number} value The value to be formatted - * {Object} options An object with formatting options. Available options: - * {string} notation - * Number notation. Choose from: - * 'fixed' Always use regular number notation. - * For example '123.40' and '14000000' - * 'exponential' Always use exponential notation. - * For example '1.234e+2' and '1.4e+7' - * 'auto' (default) Regular number notation for numbers - * having an absolute value between - * `lower` and `upper` bounds, and uses - * exponential notation elsewhere. - * Lower bound is included, upper bound - * is excluded. - * For example '123.4' and '1.4e7'. - * {number} precision A number between 0 and 16 to round - * the digits of the number. - * In case of notations 'exponential' and - * 'auto', `precision` defines the total - * number of significant digits returned - * and is undefined by default. - * In case of notation 'fixed', - * `precision` defines the number of - * significant digits after the decimal - * point, and is 0 by default. - * {Object} exponential An object containing two parameters, - * {number} lower and {number} upper, - * used by notation 'auto' to determine - * when to return exponential notation. - * Default values are `lower=1e-3` and - * `upper=1e5`. - * Only applicable for notation `auto`. - * {Function} fn A custom formatting function. Can be used to override the - * built-in notations. Function `fn` is called with `value` as - * parameter and must return a string. Is useful for example to - * format all values inside a matrix in a particular way. - * - * Examples: - * - * format(6.4); // '6.4' - * format(1240000); // '1.24e6' - * format(1/3); // '0.3333333333333333' - * format(1/3, 3); // '0.333' - * format(21385, 2); // '21000' - * format(12.071, {notation: 'fixed'}); // '12' - * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' - * format(52.8, {notation: 'exponential'}); // '5.28e+1' - * - * @param {BigNumber} value - * @param {Object | Function | number} [options] - * @return {string} str The formatted value - */ - exports.format = function (value, options) { - if (typeof options === 'function') { - // handle format(value, fn) - return options(value); - } - - // handle special cases - if (!value.isFinite()) { - return value.isNaN() ? 'NaN' : (value.gt(0) ? 'Infinity' : '-Infinity'); - } - - // default values for options - var notation = 'auto'; - var precision = undefined; - - if (options !== undefined) { - // determine notation from options - if (options.notation) { - notation = options.notation; - } - - // determine precision from options - if (typeof options === 'number') { - precision = options; - } - else if (options.precision) { - precision = options.precision; - } - } - - // handle the various notations - switch (notation) { - case 'fixed': - return exports.toFixed(value, precision); - - case 'exponential': - return exports.toExponential(value, precision); - - case 'auto': - // determine lower and upper bound for exponential notation. - // TODO: implement support for upper and lower to be BigNumbers themselves - var lower = 1e-3; - var upper = 1e5; - if (options && options.exponential) { - if (options.exponential.lower !== undefined) { - lower = options.exponential.lower; - } - if (options.exponential.upper !== undefined) { - upper = options.exponential.upper; - } - } - - // adjust the configuration of the BigNumber constructor (yeah, this is quite tricky...) - var oldConfig = { - toExpNeg: value.constructor.toExpNeg, - toExpPos: value.constructor.toExpPos - }; - - value.constructor.config({ - toExpNeg: Math.round(Math.log(lower) / Math.LN10), - toExpPos: Math.round(Math.log(upper) / Math.LN10) - }); - - // handle special case zero - if (value.isZero()) return '0'; - - // determine whether or not to output exponential notation - var str; - var abs = value.abs(); - if (abs.gte(lower) && abs.lt(upper)) { - // normal number notation - str = value.toSignificantDigits(precision).toFixed(); - } - else { - // exponential notation - str = exports.toExponential(value, precision); - } - - // remove trailing zeros after the decimal point - return str.replace(/((\.\d*?)(0+))($|e)/, function () { - var digits = arguments[2]; - var e = arguments[4]; - return (digits !== '.') ? digits + e : e; - }); - - default: - throw new Error('Unknown notation "' + notation + '". ' + - 'Choose "auto", "exponential", or "fixed".'); - } - }; - - /** - * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' - * @param {BigNumber} value - * @param {number} [precision] Number of digits in formatted output. - * If not provided, the maximum available digits - * is used. - * @returns {string} str - */ - exports.toExponential = function (value, precision) { - if (precision !== undefined) { - return value.toExponential(precision - 1); // Note the offset of one - } - else { - return value.toExponential(); - } - }; - - /** - * Format a number with fixed notation. - * @param {BigNumber} value - * @param {number} [precision=0] Optional number of decimals after the - * decimal point. Zero by default. - */ - exports.toFixed = function (value, precision) { - return value.toFixed(precision || 0); - // Note: the (precision || 0) is needed as the toFixed of BigNumber has an - // undefined default precision instead of 0. - }; - - -/***/ }, -/* 25 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Wrap any value in a chain, allowing to perform chained operations on - * the value. - * - * All methods available in the math.js library can be called upon the chain, - * and then will be evaluated with the value itself as first argument. - * The chain can be closed by executing `chain.done()`, which returns - * the final value. - * - * The chain has a number of special functions: - * - * - `done()` Finalize the chain and return the chain's value. - * - `valueOf()` The same as `done()` - * - `toString()` Executes `math.format()` onto the chain's value, returning - * a string representation of the value. - * - * Syntax: - * - * math.chain(value) - * - * Examples: - * - * math.chain(3) - * .add(4) - * .subtract(2) - * .done(); // 5 - * - * math.chain( [[1, 2], [3, 4]] ) - * .subset(math.index(0, 0), 8) - * .multiply(3) - * .done(); // [[24, 6], [9, 12]] - * - * @param {*} [value] A value of any type on which to start a chained operation. - * @return {math.type.Chain} The created chain - */ - return typed('chain', { - '': function() { - return new type.Chain(); - }, - - 'any': function(value) { - return new type.Chain(value); - } - }); - } - - exports.name = 'chain'; - exports.factory = factory; - - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(27), - - // construction function - __webpack_require__(31) - ]; - - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - - var Complex = __webpack_require__(28); - var format = __webpack_require__(6).format; - var isNumber = __webpack_require__(6).isNumber; - - function factory (type, config, load, typed, math) { - - /** - * Attach type information - */ - Complex.prototype.type = 'Complex'; - Complex.prototype.isComplex = true; - - - /** - * Get a JSON representation of the complex number - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Complex", "re": 2, "im": 3}` - */ - Complex.prototype.toJSON = function () { - return { - mathjs: 'Complex', - re: this.re, - im: this.im - }; - }; - - /* - * Return the value of the complex number in polar notation - * The angle phi will be set in the interval of [-pi, pi]. - * @return {{r: number, phi: number}} Returns and object with properties r and phi. - */ - Complex.prototype.toPolar = function () { - return { - r: this.abs(), - phi: this.arg() - }; - }; - - /** - * Get a string representation of the complex number, - * with optional formatting options. - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @return {string} str - */ - Complex.prototype.format = function (options) { - var str = ''; - var im = this.im; - var re = this.re; - var strRe = format(this.re, options); - var strIm = format(this.im, options); - - // round either re or im when smaller than the configured precision - var precision = isNumber(options) ? options : options ? options.precision : null; - if (precision !== null) { - var epsilon = Math.pow(10, -precision); - if (Math.abs(re / im) < epsilon) { - re = 0; - } - if (Math.abs(im / re) < epsilon) { - im = 0; - } - } - - if (im == 0) { - // real value - str = strRe; - } else if (re == 0) { - // purely complex value - if (im == 1) { - str = 'i'; - } else if (im == -1) { - str = '-i'; - } else { - str = strIm + 'i'; - } - } else { - // complex value - if (im > 0) { - if (im == 1) { - str = strRe + ' + i'; - } else { - str = strRe + ' + ' + strIm + 'i'; - } - } else { - if (im == -1) { - str = strRe + ' - i'; - } else { - str = strRe + ' - ' + strIm.substring(1) + 'i'; - } - } - } - return str; - }; - - /** - * Create a complex number from polar coordinates - * - * Usage: - * - * Complex.fromPolar(r: number, phi: number) : Complex - * Complex.fromPolar({r: number, phi: number}) : Complex - * - * @param {*} args... - * @return {Complex} - */ - Complex.fromPolar = function (args) { - switch (arguments.length) { - case 1: - var arg = arguments[0]; - if (typeof arg === 'object') { - return Complex(arg); - } - throw new TypeError('Input has to be an object with r and phi keys.'); - - case 2: - var r = arguments[0], - phi = arguments[1]; - if (isNumber(r)) { - if (phi && phi.isUnit && phi.hasBase('ANGLE')) { - // convert unit to a number in radians - phi = phi.toNumber('rad'); - } - - if (isNumber(phi)) { - return new Complex({r: r, phi: phi}); - } - - throw new TypeError('Phi is not a number nor an angle unit.'); - } else { - throw new TypeError('Radius r is not a number.'); - } - - default: - throw new SyntaxError('Wrong number of arguments in function fromPolar'); - } - }; - - - Complex.prototype.valueOf = Complex.prototype.toString; - - /** - * Create a Complex number from a JSON object - * @param {Object} json A JSON Object structured as - * {"mathjs": "Complex", "re": 2, "im": 3} - * All properties are optional, default values - * for `re` and `im` are 0. - * @return {Complex} Returns a new Complex number - */ - Complex.fromJSON = function (json) { - return new Complex(json); - }; - - // apply the current epsilon - Complex.EPSILON = config.epsilon; - - // listen for changed in the configuration, automatically apply changed epsilon - math.on('config', function (curr, prev) { - if (curr.epsilon !== prev.epsilon) { - Complex.EPSILON = curr.epsilon; - } - }); - - return Complex; - } - - exports.name = 'Complex'; - exports.path = 'type'; - exports.factory = factory; - exports.math = true; // request access to the math namespace - - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** - * @license Complex.js v2.0.1 11/02/2016 - * - * Copyright (c) 2016, Robert Eisele (robert@xarg.org) - * Dual licensed under the MIT or GPL Version 2 licenses. - **/ - - /** - * - * This class allows the manipilation of complex numbers. - * You can pass a complex number in different formats. Either as object, double, string or two integer parameters. - * - * Object form - * { re: , im: } - * { arg: , abs: } - * { phi: , r: } - * - * Double form - * 99.3 - Single double value - * - * String form - * "23.1337" - Simple real number - * "15+3i" - a simple complex number - * "3-i" - a simple complex number - * - * Example: - * - * var c = new Complex("99.3+8i"); - * c.mul({r: 3, i: 9}).div(4.9).sub(3, 2); - * - */ - - (function(root) { - - "use strict"; - - var P = {'re': 0, 'im': 0}; - - Math.cosh = Math.cosh || function(x) { - return (Math.exp(x) + Math.exp(-x)) * 0.5; - }; - - Math.sinh = Math.sinh || function(x) { - return (Math.exp(x) - Math.exp(-x)) * 0.5; - }; - - var parser_exit = function() { - throw SyntaxError("Invalid Param"); - }; - - /** - * Calculates log(sqrt(a^2+b^2)) in a way to avoid overflows - * - * @param {number} a - * @param {number} b - * @returns {number} - */ - function logHypot(a, b) { - - var _a = Math.abs(a); - var _b = Math.abs(b); - - if (a === 0) { - return Math.log(_b); - } - - if (b === 0) { - return Math.log(_a); - } - - if (_a < 3000 && _b < 3000) { - return Math.log(a * a + b * b) * 0.5; - } - - /* I got 4 ideas to compute this property without overflow: - * - * Testing 1000000 times with random samples for a,b ∈ [1, 1000000000] against a big decimal library to get an error estimate - * - * 1. Only eliminate the square root: (OVERALL ERROR: 3.9122483030951116e-11) - - Math.log(a * a + b * b) / 2 - - * - * - * 2. Try to use the non-overflowing pythagoras: (OVERALL ERROR: 8.889760039210159e-10) - - var fn = function(a, b) { - a = Math.abs(a); - b = Math.abs(b); - var t = Math.min(a, b); - a = Math.max(a, b); - t = t / a; - - return Math.log(a) + Math.log(1 + t * t) / 2; - }; - - * 3. Abuse the identity cos(atan(y/x) = x / sqrt(x^2+y^2): (OVERALL ERROR: 3.4780178737037204e-10) - - Math.log(a / Math.cos(Math.atan2(b, a))) - - * 4. Use 3. and apply log rules: (OVERALL ERROR: 1.2014087502620896e-9) - - Math.log(a) - Math.log(Math.cos(Math.atan2(b, a))) - - */ - - return Math.log(a / Math.cos(Math.atan2(b, a))); - } - - var parse = function(a, b) { - - if (a === undefined || a === null) { - P["re"] = - P["im"] = 0; - } else if (b !== undefined) { - P["re"] = a; - P["im"] = b; - } else switch (typeof a) { - - case "object": - - if ("im" in a && "re" in a) { - P["re"] = a["re"]; - P["im"] = a["im"]; - } else if ("abs" in a && "arg" in a) { - P["re"] = a["abs"] * Math.cos(a["arg"]); - P["im"] = a["abs"] * Math.sin(a["arg"]); - } else if ("r" in a && "phi" in a) { - P["re"] = a["r"] * Math.cos(a["phi"]); - P["im"] = a["r"] * Math.sin(a["phi"]); - } else { - parser_exit(); - } - break; - - case "string": - - P["im"] = /* void */ - P["re"] = 0; - - var tokens = a.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g); - var plus = 1; - var minus = 0; - - if (tokens === null) { - parser_exit(); - } - - for (var i = 0; i < tokens.length; i++) { - - var c = tokens[i]; - - if (c === ' ' || c === '\t' || c === '\n') { - /* void */ - } else if (c === '+') { - plus++; - } else if (c === '-') { - minus++; - } else if (c === 'i' || c === 'I') { - - if (plus + minus === 0) { - parser_exit(); - } - - if (tokens[i + 1] !== ' ' && !isNaN(tokens[i + 1])) { - P["im"]+= parseFloat((minus % 2 ? "-" : "") + tokens[i + 1]); - i++; - } else { - P["im"]+= parseFloat((minus % 2 ? "-" : "") + "1"); - } - plus = minus = 0; - - } else { - - if (plus + minus === 0 || isNaN(c)) { - parser_exit(); - } - - if (tokens[i + 1] === 'i' || tokens[i + 1] === 'I') { - P["im"]+= parseFloat((minus % 2 ? "-" : "") + c); - i++; - } else { - P["re"]+= parseFloat((minus % 2 ? "-" : "") + c); - } - plus = minus = 0; - } - } - - // Still something on the stack - if (plus + minus > 0) { - parser_exit(); - } - break; - - case "number": - P["im"] = 0; - P["re"] = a; - break; - - default: - parser_exit(); - } - - if (isNaN(P["re"]) || isNaN(P["im"])) { - // If a calculation is NaN, we treat it as NaN and don't throw - //parser_exit(); - } - }; - - /** - * @constructor - * @returns {Complex} - */ - function Complex(a, b) { - - if (!(this instanceof Complex)) { - return new Complex(a, b); - } - - parse(a, b); // mutates P - - this["re"] = P["re"]; - this["im"] = P["im"]; - } - - Complex.prototype = { - - "re": 0, - "im": 0, - - /** - * Calculates the sign of a complex number - * - * @returns {Complex} - */ - "sign": function() { - - var abs = this["abs"](); - - return new Complex( - this["re"] / abs, - this["im"] / abs); - }, - - /** - * Adds two complex numbers - * - * @returns {Complex} - */ - "add": function(a, b) { - - parse(a, b); // mutates P - - return new Complex( - this["re"] + P["re"], - this["im"] + P["im"]); - }, - - /** - * Subtracts two complex numbers - * - * @returns {Complex} - */ - "sub": function(a, b) { - - parse(a, b); // mutates P - - return new Complex( - this["re"] - P["re"], - this["im"] - P["im"]); - }, - - /** - * Multiplies two complex numbers - * - * @returns {Complex} - */ - "mul": function(a, b) { - - parse(a, b); // mutates P - - // Besides the addition/subtraction, this helps having a solution for rational Infinity - if (P['im'] === 0 && this['im'] === 0) { - return new Complex(this['re'] * P['re'], 0); - } - - return new Complex( - this["re"] * P["re"] - this["im"] * P["im"], - this["re"] * P["im"] + this["im"] * P["re"]); - }, - - /** - * Divides two complex numbers - * - * @returns {Complex} - */ - "div": function(a, b) { - - parse(a, b); // mutates P - - a = this["re"]; - b = this["im"]; - - var c = P["re"]; - var d = P["im"]; - var t, x; - - // Divisor is zero - if (0 === c && 0 === d) { - return new Complex( - (a !== 0) ? (a / 0) : 0, - (b !== 0) ? (b / 0) : 0); - } - - // Divisor is rational - if (0 === d) { - return new Complex(a / c, b / c); - } - - if (Math.abs(c) < Math.abs(d)) { - - x = c / d; - t = c * x + d; - - return new Complex( - (a * x + b) / t, - (b * x - a) / t); - - } else { - - x = d / c; - t = d * x + c; - - return new Complex( - (a + b * x) / t, - (b - a * x) / t); - } - }, - - /** - * Calculate the power of two complex numbers - * - * @returns {Complex} - */ - "pow": function(a, b) { - - parse(a, b); // mutates P - - a = this["re"]; - b = this["im"]; - - if (a === 0 && b === 0) { - return new Complex(0, 0); - } - - var arg = Math.atan2(b, a); - var loh = logHypot(a, b); - - if (P["im"] === 0) { - - if (b === 0 && a >= 0) { - - return new Complex(Math.pow(a, P["re"]), 0); - - } else if (a === 0) { - - switch (P["re"] % 4) { - case 0: - return new Complex(Math.pow(b, P["re"]), 0); - case 1: - return new Complex(0, Math.pow(b, P["re"])); - case 2: - return new Complex(-Math.pow(b, P["re"]), 0); - case 3: - return new Complex(0, -Math.pow(b, P["re"])); - } - } - } - - /* I couldn"t find a good formula, so here is a derivation and optimization - * - * z_1^z_2 = (a + bi)^(c + di) - * = exp((c + di) * log(a + bi) - * = pow(a^2 + b^2, (c + di) / 2) * exp(i(c + di)atan2(b, a)) - * =>... - * Re = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * cos(d * log(a^2 + b^2) / 2 + c * atan2(b, a)) - * Im = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * sin(d * log(a^2 + b^2) / 2 + c * atan2(b, a)) - * - * =>... - * Re = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * cos(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a)) - * Im = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * sin(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a)) - * - * => - * Re = exp(c * logsq2 - d * arg(z_1)) * cos(d * logsq2 + c * arg(z_1)) - * Im = exp(c * logsq2 - d * arg(z_1)) * sin(d * logsq2 + c * arg(z_1)) - * - */ - - a = Math.exp(P["re"] * loh - P["im"] * arg); - b = P["im"] * loh + P["re"] * arg; - return new Complex( - a * Math.cos(b), - a * Math.sin(b)); - }, - - /** - * Calculate the complex square root - * - * @returns {Complex} - */ - "sqrt": function() { - - var a = this["re"]; - var b = this["im"]; - var r = this["abs"](); - - var re, im; - - if (a >= 0 && b === 0) { - return new Complex(Math.sqrt(a), 0); - } - - if (a >= 0) { - re = 0.5 * Math.sqrt(2.0 * (r + a)); - } else { - re = Math.abs(b) / Math.sqrt(2 * (r - a)); - } - - if (a <= 0) { - im = 0.5 * Math.sqrt(2.0 * (r - a)); - } else { - im = Math.abs(b) / Math.sqrt(2 * (r + a)); - } - - return new Complex(re, b >= 0 ? im : -im); - }, - - /** - * Calculate the complex exponent - * - * @returns {Complex} - */ - "exp": function() { - - var tmp = Math.exp(this["re"]); - - if (this["im"] === 0) { - //return new Complex(tmp, 0); - } - return new Complex( - tmp * Math.cos(this["im"]), - tmp * Math.sin(this["im"])); - }, - - /** - * Calculate the natural log - * - * @returns {Complex} - */ - "log": function() { - - var a = this["re"]; - var b = this["im"]; - - if (b === 0 && a > 0) { - //return new Complex(Math.log(a), 0); - } - - return new Complex( - logHypot(a, b), - Math.atan2(b, a)); - }, - - /** - * Calculate the magniture of the complex number - * - * @returns {number} - */ - "abs": function() { - - var a = Math.abs(this["re"]); - var b = Math.abs(this["im"]); - - if (a < 3000 && b < 3000) { - return Math.sqrt(a * a + b * b); - } - - if (a < b) { - a = b; - b = this["re"] / this["im"]; - } else { - b = this["im"] / this["re"]; - } - return a * Math.sqrt(1 + b * b); - }, - - /** - * Calculate the angle of the complex number - * - * @returns {number} - */ - "arg": function() { - - return Math.atan2(this["im"], this["re"]); - }, - - /** - * Calculate the sine of the complex number - * - * @returns {Complex} - */ - "sin": function() { - - var a = this["re"]; - var b = this["im"]; - - return new Complex( - Math.sin(a) * Math.cosh(b), - Math.cos(a) * Math.sinh(b)); - }, - - /** - * Calculate the cosine - * - * @returns {Complex} - */ - "cos": function() { - - var a = this["re"]; - var b = this["im"]; - - return new Complex( - Math.cos(a) * Math.cosh(b), - -Math.sin(a) * Math.sinh(b)); - }, - - /** - * Calculate the tangent - * - * @returns {Complex} - */ - "tan": function() { - - var a = 2 * this["re"]; - var b = 2 * this["im"]; - var d = Math.cos(a) + Math.cosh(b); - - return new Complex( - Math.sin(a) / d, - Math.sinh(b) / d); - }, - - /** - * Calculate the cotangent - * - * @returns {Complex} - */ - "cot": function() { - - var a = 2 * this["re"]; - var b = 2 * this["im"]; - var d = Math.cos(a) - Math.cosh(b); - - return new Complex( - -Math.sin(a) / d, - Math.sinh(b) / d); - }, - - /** - * Calculate the secant - * - * @returns {Complex} - */ - "sec": function() { - - var a = this["re"]; - var b = this["im"]; - var d = 0.5 * Math.cosh(2 * b) + 0.5 * Math.cos(2 * a); - - return new Complex( - Math.cos(a) * Math.cosh(b) / d, - Math.sin(a) * Math.sinh(b) / d); - }, - - /** - * Calculate the cosecans - * - * @returns {Complex} - */ - "csc": function() { - - var a = this["re"]; - var b = this["im"]; - var d = 0.5 * Math.cosh(2 * b) - 0.5 * Math.cos(2 * a); - - return new Complex( - Math.sin(a) * Math.cosh(b) / d, - -Math.cos(a) * Math.sinh(b) / d); - }, - - /** - * Calculate the complex arcus sinus - * - * @returns {Complex} - */ - "asin": function() { - - var a = this["re"]; - var b = this["im"]; - - var t1 = new Complex( - b * b - a * a + 1, - -2 * a * b)['sqrt'](); - - var t2 = new Complex( - t1['re'] - b, - t1['im'] + a)['log'](); - - return new Complex(t2['im'], -t2['re']); - }, - - /** - * Calculate the complex arcus cosinus - * - * @returns {Complex} - */ - "acos": function() { - - var a = this["re"]; - var b = this["im"]; - - var t1 = new Complex( - b * b - a * a + 1, - -2 * a * b)['sqrt'](); - - var t2 = new Complex( - t1["re"] - b, - t1["im"] + a)['log'](); - - return new Complex(Math.PI / 2 - t2["im"], t2["re"]); - }, - - /** - * Calculate the complex arcus tangent - * - * @returns {Complex} - */ - "atan": function() { - - var a = this["re"]; - var b = this["im"]; - - if (a === 0) { - - if (b === 1) { - return new Complex(0, Infinity); - } - - if (b === -1) { - return new Complex(0, -Infinity); - } - } - - var d = a * a + (1.0 - b) * (1.0 - b); - - var t1 = new Complex( - (1 - b * b - a * a) / d, - -2 * a / d).log(); - - return new Complex(-0.5 * t1["im"], 0.5 * t1["re"]); - }, - - /** - * Calculate the complex arcus cotangent - * - * @returns {Complex} - */ - "acot": function() { - - var a = this["re"]; - var b = this["im"]; - - if (b === 0) { - return new Complex(Math.atan2(1, a), 0); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).atan() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).atan(); - }, - - /** - * Calculate the complex arcus secant - * - * @returns {Complex} - */ - "asec": function() { - - var a = this["re"]; - var b = this["im"]; - - if (a === 0 && b === 0) { - return new Complex(0, Infinity); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).acos() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).acos(); - }, - - /** - * Calculate the complex arcus cosecans - * - * @returns {Complex} - */ - "acsc": function() { - - var a = this["re"]; - var b = this["im"]; - - if (a === 0 && b === 0) { - return new Complex(Math.PI / 2, Infinity); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).asin() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).asin(); - }, - - /** - * Calculate the complex sinh - * - * @returns {Complex} - */ - "sinh": function() { - - var a = this["re"]; - var b = this["im"]; - - return new Complex( - Math.sinh(a) * Math.cos(b), - Math.cosh(a) * Math.sin(b)); - }, - - /** - * Calculate the complex cosh - * - * @returns {Complex} - */ - "cosh": function() { - - var a = this["re"]; - var b = this["im"]; - - return new Complex( - Math.cosh(a) * Math.cos(b), - Math.sinh(a) * Math.sin(b)); - }, - - /** - * Calculate the complex tanh - * - * @returns {Complex} - */ - "tanh": function() { - - var a = 2 * this["re"]; - var b = 2 * this["im"]; - var d = Math.cosh(a) + Math.cos(b); - - return new Complex( - Math.sinh(a) / d, - Math.sin(b) / d); - }, - - /** - * Calculate the complex coth - * - * @returns {Complex} - */ - "coth": function() { - - var a = 2 * this["re"]; - var b = 2 * this["im"]; - var d = Math.cosh(a) - Math.cos(b); - - return new Complex( - Math.sinh(a) / d, - -Math.sin(b) / d); - }, - - /** - * Calculate the complex coth - * - * @returns {Complex} - */ - "csch": function() { - - var a = this["re"]; - var b = this["im"]; - var d = Math.cos(2 * b) - Math.cosh(2 * a); - - return new Complex( - -2 * Math.sinh(a) * Math.cos(b) / d, - 2 * Math.cosh(a) * Math.sin(b) / d); - }, - - /** - * Calculate the complex sech - * - * @returns {Complex} - */ - "sech": function() { - - var a = this["re"]; - var b = this["im"]; - var d = Math.cos(2 * b) + Math.cosh(2 * a); - - return new Complex( - 2 * Math.cosh(a) * Math.cos(b) / d, - -2 * Math.sinh(a) * Math.sin(b) / d); - }, - - /** - * Calculate the complex asinh - * - * @returns {Complex} - */ - "asinh": function() { - - 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; - }, - - /** - * Calculate the complex asinh - * - * @returns {Complex} - */ - "acosh": function() { - - var tmp; - var res = this["acos"](); - if (res["im"] <= 0) { - tmp = res["re"]; - res["re"] = -res["im"]; - res["im"] = tmp; - } else { - tmp = res["im"]; - res["im"] = -res["re"]; - res["re"] = tmp; - } - return res; - }, - - /** - * Calculate the complex atanh - * - * @returns {Complex} - */ - "atanh": function() { - - var a = this["re"]; - var b = this["im"]; - - var noIM = a > 1 && b === 0; - var oneMinus = 1 - a; - var onePlus = 1 + a; - var d = oneMinus * oneMinus + b * b; - - var x = (d !== 0) - ? new Complex( - (onePlus * oneMinus - b * b) / d, - (b * oneMinus + onePlus * b) / d) - : new Complex( - (a !== -1) ? (a / 0) : 0, - (b !== 0) ? (b / 0) : 0); - - var temp = x["re"]; - x["re"] = logHypot(x["re"], x["im"]) / 2; - x["im"] = Math.atan2(x["im"], temp) / 2; - if (noIM) { - x["im"] = -x["im"]; - } - return x; - }, - - /** - * Calculate the complex acoth - * - * @returns {Complex} - */ - "acoth": function() { - - var a = this["re"]; - var b = this["im"]; - - if (a === 0 && b === 0) { - - return new Complex(0, Math.PI / 2); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).atanh() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).atanh(); - }, - - /** - * Calculate the complex acsch - * - * @returns {Complex} - */ - "acsch": function() { - - var a = this["re"]; - var b = this["im"]; - - if (b === 0) { - - return new Complex( - (a !== 0) - ? Math.log(a + Math.sqrt(a * a + 1)) - : Infinity, 0); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).asinh() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).asinh(); - }, - - /** - * Calculate the complex asech - * - * @returns {Complex} - */ - "asech": function() { - - var a = this["re"]; - var b = this["im"]; - - if (a === 0 && b === 0) { - return new Complex(Infinity, 0); - } - - var d = a * a + b * b; - return (d !== 0) - ? new Complex( - a / d, - -b / d).acosh() - : new Complex( - (a !== 0) ? a / 0 : 0, - (b !== 0) ?-b / 0 : 0).acosh(); - }, - - /** - * Calculate the complex inverse 1/z - * - * @returns {Complex} - */ - "inverse": function() { - - var a = this["re"]; - var b = this["im"]; - - var d = a * a + b * b; - - return new Complex( - a !== 0 ? a / d : 0, - b !== 0 ?-b / d : 0); - }, - - /** - * Returns the complex conjugate - * - * @returns {Complex} - */ - "conjugate": function() { - - return new Complex(this["re"], -this["im"]); - }, - - /** - * Gets the negated complex number - * - * @returns {Complex} - */ - "neg": function() { - - return new Complex(-this["re"], -this["im"]); - }, - - /** - * Ceils the actual complex number - * - * @returns {Complex} - */ - "ceil": function(places) { - - places = Math.pow(10, places || 0); - - return new Complex( - Math.ceil(this["re"] * places) / places, - Math.ceil(this["im"] * places) / places); - }, - - /** - * Floors the actual complex number - * - * @returns {Complex} - */ - "floor": function(places) { - - places = Math.pow(10, places || 0); - - return new Complex( - Math.floor(this["re"] * places) / places, - Math.floor(this["im"] * places) / places); - }, - - /** - * Ceils the actual complex number - * - * @returns {Complex} - */ - "round": function(places) { - - places = Math.pow(10, places || 0); - - return new Complex( - Math.round(this["re"] * places) / places, - Math.round(this["im"] * places) / places); - }, - - /** - * Compares two complex numbers - * - * @returns {boolean} - */ - "equals": function(a, b) { - - parse(a, b); // mutates P - - return Math.abs(P["re"] - this["re"]) <= Complex["EPSILON"] && - Math.abs(P["im"] - this["im"]) <= Complex["EPSILON"]; - }, - - /** - * Clones the actual object - * - * @returns {Complex} - */ - "clone": function() { - - return new Complex(this["re"], this["im"]); - }, - - /** - * Gets a string of the actual complex number - * - * @returns {string} - */ - "toString": function() { - - var a = this["re"]; - var b = this["im"]; - var ret = ""; - - if (isNaN(a) || isNaN(b)) { - return "NaN"; - } - - if (a !== 0) { - ret+= a; - } - - if (b !== 0) { - - if (a !== 0) { - ret+= b < 0 ? " - " : " + "; - } else if (b < 0) { - ret+= "-"; - } - - b = Math.abs(b); - - if (1 !== b) { - ret+= b; - } - ret+= "i"; - } - - if (!ret) - return "0"; - - return ret; - }, - - /** - * Returns the actual number as a vector - * - * @returns {Array} - */ - "toVector": function() { - - return [this["re"], this["im"]]; - }, - - /** - * Returns the actual real value of the current object - * - * @returns {number|null} - */ - "valueOf": function() { - - if (this["im"] === 0) { - return this["re"]; - } - return null; - }, - - /** - * Checks if the given complex number is not a number - * - * @returns {boolean} - */ - isNaN: function() { - return isNaN(this['re']) || isNaN(this['im']); - } - }; - - Complex["ZERO"] = new Complex(0, 0); - Complex["ONE"] = new Complex(1, 0); - Complex["I"] = new Complex(0, 1); - Complex["PI"] = new Complex(Math.PI, 0); - Complex["E"] = new Complex(Math.E, 0); - Complex['EPSILON'] = 1e-16; - - if ("function" === "function" && __webpack_require__(30)["amd"]) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { - return Complex; - }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (true) { - module["exports"] = Complex; - } else { - root["Complex"] = Complex; - } - - })(this); - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(29)(module))) - -/***/ }, -/* 29 */ -/***/ function(module, exports) { - - module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - module.children = []; - module.webpackPolyfill = 1; - } - return module; - } - - -/***/ }, -/* 30 */ -/***/ function(module, exports) { - - module.exports = function() { throw new Error("define cannot be used indirect"); }; - - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - /** - * Create a complex value or convert a value to a complex value. - * - * Syntax: - * - * math.complex() // creates a complex value with zero - * // as real and imaginary part. - * math.complex(re : number, im : string) // creates a complex value with provided - * // values for real and imaginary part. - * math.complex(re : number) // creates a complex value with provided - * // real value and zero imaginary part. - * math.complex(complex : Complex) // clones the provided complex value. - * math.complex(arg : string) // parses a string into a complex value. - * math.complex(array : Array) // converts the elements of the array - * // or matrix element wise into a - * // complex value. - * math.complex({re: number, im: number}) // creates a complex value with provided - * // values for real an imaginary part. - * math.complex({r: number, phi: number}) // creates a complex value with provided - * // polar coordinates - * - * Examples: - * - * var a = math.complex(3, -4); // a = Complex 3 - 4i - * a.re = 5; // a = Complex 5 - 4i - * var i = a.im; // Number -4; - * var b = math.complex('2 + 6i'); // Complex 2 + 6i - * var c = math.complex(); // Complex 0 + 0i - * var d = math.add(a, b); // Complex 5 + 2i - * - * See also: - * - * bignumber, boolean, index, matrix, number, string, unit - * - * @param {* | Array | Matrix} [args] - * Arguments specifying the real and imaginary part of the complex number - * @return {Complex | Array | Matrix} Returns a complex value - */ - var complex = typed('complex', { - '': function () { - return type.Complex.ZERO; - }, - - 'number': function (x) { - return new type.Complex(x, 0); - }, - - 'number, number': function (re, im) { - return new type.Complex(re, im); - }, - - // TODO: this signature should be redundant - 'BigNumber, BigNumber': function (re, im) { - return new type.Complex(re.toNumber(), im.toNumber()); - }, - - 'Complex': function (x) { - return x.clone(); - }, - - 'string': function (x) { - return type.Complex(x); // for example '2 + 3i' - }, - - 'Object': function (x) { - if('re' in x && 'im' in x) { - return new type.Complex(x.re, x.im); - } - - if ('r' in x && 'phi' in x) { - return new type.Complex(x); - } - - throw new Error('Expected object with either properties re and im, or properties r and phi.'); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, complex); - } - }); - - complex.toTex = { - 0: '0', - 1: '\\left(${args[0]}\\right)', - 2: '\\left(\\left(${args[0]}\\right)+' - + latex.symbols['i'] + '\\cdot\\left(${args[1]}\\right)\\right)' - }; - - return complex; - } - - exports.name = 'complex'; - exports.factory = factory; - - -/***/ }, -/* 32 */ -/***/ function(module, exports) { - - 'use strict'; - - exports.symbols = { - // GREEK LETTERS - Alpha: 'A', alpha: '\\alpha', - Beta: 'B', beta: '\\beta', - Gamma: '\\Gamma', gamma: '\\gamma', - Delta: '\\Delta', delta: '\\delta', - Epsilon: 'E', epsilon: '\\epsilon', varepsilon: '\\varepsilon', - Zeta: 'Z', zeta: '\\zeta', - Eta: 'H', eta: '\\eta', - Theta: '\\Theta', theta: '\\theta', vartheta: '\\vartheta', - Iota: 'I', iota: '\\iota', - Kappa: 'K', kappa: '\\kappa', varkappa: '\\varkappa', - Lambda: '\\Lambda', lambda: '\\lambda', - Mu: 'M', mu: '\\mu', - Nu: 'N', nu: '\\nu', - Xi: '\\Xi', xi: '\\xi', - Omicron: 'O', omicron: 'o', - Pi: '\\Pi', pi: '\\pi', varpi: '\\varpi', - Rho: 'P', rho: '\\rho', varrho: '\\varrho', - Sigma: '\\Sigma', sigma: '\\sigma', varsigma: '\\varsigma', - Tau: 'T', tau: '\\tau', - Upsilon: '\\Upsilon', upsilon: '\\upsilon', - Phi: '\\Phi', phi: '\\phi', varphi: '\\varphi', - Chi: 'X', chi: '\\chi', - Psi: '\\Psi', psi: '\\psi', - Omega: '\\Omega', omega: '\\omega', - //logic - 'true': '\\mathrm{True}', - 'false': '\\mathrm{False}', - //other - i: 'i', //TODO use \i ?? - inf: '\\infty', - Inf: '\\infty', - infinity: '\\infty', - Infinity: '\\infty', - oo: '\\infty', - lim: '\\lim', - 'undefined': '\\mathbf{?}' - }; - - exports.operators = { - 'transpose': '^\\top', - 'factorial': '!', - 'pow': '^', - 'dotPow': '.^\\wedge', //TODO find ideal solution - 'unaryPlus': '+', - 'unaryMinus': '-', - 'bitNot': '~', //TODO find ideal solution - 'not': '\\neg', - 'multiply': '\\cdot', - 'divide': '\\frac', //TODO how to handle that properly? - 'dotMultiply': '.\\cdot', //TODO find ideal solution - 'dotDivide': '.:', //TODO find ideal solution - 'mod': '\\mod', - 'add': '+', - 'subtract': '-', - 'to': '\\rightarrow', - 'leftShift': '<<', - 'rightArithShift': '>>', - 'rightLogShift': '>>>', - 'equal': '=', - 'unequal': '\\neq', - 'smaller': '<', - 'larger': '>', - 'smallerEq': '\\leq', - 'largerEq': '\\geq', - 'bitAnd': '\\&', - 'bitXor': '\\underline{|}', - 'bitOr': '|', - 'and': '\\wedge', - 'xor': '\\veebar', - 'or': '\\vee' - }; - - exports.defaultTemplate = '\\mathrm{${name}}\\left(${args}\\right)'; - - var units = { - deg: '^\\circ' - }; - - //@param {string} name - //@param {boolean} isUnit - exports.toSymbol = function (name, isUnit) { - isUnit = typeof isUnit === 'undefined' ? false : isUnit; - if (isUnit) { - if (units.hasOwnProperty(name)) { - return units[name]; - } - return '\\mathrm{' + name + '}'; - } - - if (exports.symbols.hasOwnProperty(name)) { - return exports.symbols[name]; - } - else if (name.indexOf('_') !== -1) { - //symbol with index (eg. alpha_1) - var index = name.indexOf('_'); - return exports.toSymbol(name.substring(0, index)) + '_{' - + exports.toSymbol(name.substring(index + 1)) + '}'; - } - return name; - }; - - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(34), - - // construction function - __webpack_require__(36) - ]; - - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - var Fraction = __webpack_require__(35); - - /** - * Attach type information - */ - Fraction.prototype.type = 'Fraction'; - Fraction.prototype.isFraction = true; - - /** - * Get a JSON representation of a Fraction containing type information - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Fraction", "n": 3, "d": 8}` - */ - Fraction.prototype.toJSON = function () { - return { - mathjs: 'Fraction', - n: this.s * this.n, - d: this.d - }; - }; - - /** - * Instantiate a Fraction from a JSON object - * @param {Object} json a JSON object structured as: - * `{"mathjs": "Fraction", "n": 3, "d": 8}` - * @return {BigNumber} - */ - Fraction.fromJSON = function (json) { - return new Fraction(json); - }; - - - function factory (type, config, load, typed) { - return Fraction; - } - - exports.name = 'Fraction'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** - * @license Fraction.js v3.3.1 09/09/2015 - * http://www.xarg.org/2014/03/precise-calculations-in-javascript/ - * - * Copyright (c) 2015, Robert Eisele (robert@xarg.org) - * Dual licensed under the MIT or GPL Version 2 licenses. - **/ - - - /** - * - * This class offers the possibility to calculate fractions. - * You can pass a fraction in different formats. Either as array, as double, as string or as an integer. - * - * Array/Object form - * [ 0 => , 1 => ] - * [ n => , d => ] - * - * Integer form - * - Single integer value - * - * Double form - * - Single double value - * - * String form - * 123.456 - a simple double - * 123/456 - a string fraction - * 123.'456' - a double with repeating decimal places - * 123.(456) - synonym - * 123.45'6' - a double with repeating last place - * 123.45(6) - synonym - * - * Example: - * - * var f = new Fraction("9.4'31'"); - * f.mul([-4, 3]).div(4.9); - * - */ - - (function(root) { - - "use strict"; - - // Maximum search depth for cyclic rational numbers. 2000 should be more than enough. - // Example: 1/7 = 0.(142857) has 6 repeating decimal places. - // If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits - var MAX_CYCLE_LEN = 2000; - - // Parsed data to avoid calling "new" all the time - var P = { - "s": 1, - "n": 0, - "d": 1 - }; - - function assign(n, s) { - - if (isNaN(n = parseInt(n, 10))) { - throwInvalidParam(); - } - return n * s; - } - - function throwInvalidParam() { - throw "Invalid Param"; - } - - var parse = function(p1, p2) { - - var n = 0, d = 1, s = 1; - var v = 0, w = 0, x = 0, y = 1, z = 1; - - var A = 0, B = 1; - var C = 1, D = 1; - - var N = 10000000; - var M; - - if (p1 === undefined || p1 === null) { - /* void */ - } else if (p2 !== undefined) { - n = p1; - d = p2; - s = n * d; - } else - switch (typeof p1) { - - case "object": - { - if ("d" in p1 && "n" in p1) { - n = p1["n"]; - d = p1["d"]; - if ("s" in p1) - n*= p1["s"]; - } else if (0 in p1) { - n = p1[0]; - if (1 in p1) - d = p1[1]; - } else { - throwInvalidParam(); - } - s = n * d; - break; - } - case "number": - { - if (p1 < 0) { - s = p1; - p1 = -p1; - } - - if (p1 % 1 === 0) { - n = p1; - } else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow - - if (p1 >= 1) { - z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10)); - p1/= z; - } - - // Using Farey Sequences - // http://www.johndcook.com/blog/2010/10/20/best-rational-approximation/ - - while (B <= N && D <= N) { - M = (A + C) / (B + D); - - if (p1 === M) { - if (B + D <= N) { - n = A + C; - d = B + D; - } else if (D > B) { - n = C; - d = D; - } else { - n = A; - d = B; - } - break; - - } else { - - if (p1 > M) { - A+= C; - B+= D; - } else { - C+= A; - D+= B; - } - - if (B > N) { - n = C; - d = D; - } else { - n = A; - d = B; - } - } - } - n*= z; - } else if (isNaN(p1) || isNaN(p2)) { - d = n = NaN; - } - break; - } - case "string": - { - B = p1.match(/\d+|./g); - - if (B[A] === '-') {// Check for minus sign at the beginning - s = -1; - A++; - } else if (B[A] === '+') {// Check for plus sign at the beginning - A++; - } - - if (B.length === A + 1) { // Check if it's just a simple number "1234" - w = assign(B[A++], s); - } else if (B[A + 1] === '.' || B[A] === '.') { // Check if it's a decimal number - - if (B[A] !== '.') { // Handle 0.5 and .5 - v = assign(B[A++], s); - } - A++; - - // Check for decimal places - if (A + 1 === B.length || B[A + 1] === '(' && B[A + 3] === ')' || B[A + 1] === "'" && B[A + 3] === "'") { - w = assign(B[A], s); - y = Math.pow(10, B[A].length); - A++; - } - - // Check for repeating places - if (B[A] === '(' && B[A + 2] === ')' || B[A] === "'" && B[A + 2] === "'") { - x = assign(B[A + 1], s); - z = Math.pow(10, B[A + 1].length) - 1; - A+= 3; - } - - } else if (B[A + 1] === '/' || B[A + 1] === ':') { // Check for a simple fraction "123/456" or "123:456" - w = assign(B[A], s); - y = assign(B[A + 2], 1); - A+= 3; - } else if (B[A + 3] === '/' && B[A + 1] === ' ') { // Check for a complex fraction "123 1/2" - v = assign(B[A], s); - w = assign(B[A + 2], s); - y = assign(B[A + 4], 1); - A+= 5; - } - - if (B.length <= A) { // Check for more tokens on the stack - d = y * z; - s = /* void */ - n = x + d * v + z * w; - break; - } - - /* Fall through on error */ - } - default: - throwInvalidParam(); - } - - if (d === 0) { - throw "DIV/0"; - } - - P["s"] = s < 0 ? -1 : 1; - P["n"] = Math.abs(n); - P["d"] = Math.abs(d); - }; - - var modpow = function(b, e, m) { - - for (var r = 1; e > 0; b = (b * b) % m, e >>= 1) { - - if (e & 1) { - r = (r * b) % m; - } - } - return r; - }; - - var cycleLen = function(n, d) { - - for (; d % 2 === 0; - d/= 2) {} - - for (; d % 5 === 0; - d/= 5) {} - - if (d === 1) // Catch non-cyclic numbers - return 0; - - // If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem: - // 10^(d-1) % d == 1 - // However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone, - // as we want to translate the numbers to strings. - - var rem = 10 % d; - - for (var t = 1; rem !== 1; t++) { - rem = rem * 10 % d; - - if (t > MAX_CYCLE_LEN) - return 0; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1` - } - return t; - }; - - var cycleStart = function(n, d, len) { - - var rem1 = 1; - var rem2 = modpow(10, len, d); - - for (var t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE) - // Solve 10^s == 10^(s+t) (mod d) - - if (rem1 === rem2) - return t; - - rem1 = rem1 * 10 % d; - rem2 = rem2 * 10 % d; - } - return 0; - }; - - var gcd = function(a, b) { - - if (!a) return b; - if (!b) return a; - - while (1) { - a%= b; - if (!a) return b; - b%= a; - if (!b) return a; - } - }; - - /** - * Module constructor - * - * @constructor - * @param {number|Fraction} a - * @param {number=} b - */ - function Fraction(a, b) { - - if (!(this instanceof Fraction)) { - return new Fraction(a, b); - } - - parse(a, b); - - if (Fraction['REDUCE']) { - a = gcd(P["d"], P["n"]); // Abuse a - } else { - a = 1; - } - - this["s"] = P["s"]; - this["n"] = P["n"] / a; - this["d"] = P["d"] / a; - } - - /** - * Boolean global variable to be able to disable automatic reduction of the fraction - * - */ - Fraction['REDUCE'] = 1; - - Fraction.prototype = { - - "s": 1, - "n": 0, - "d": 1, - - /** - * Calculates the absolute value - * - * Ex: new Fraction(-4).abs() => 4 - **/ - "abs": function() { - - return new Fraction(this["n"], this["d"]); - }, - - /** - * Inverts the sign of the current fraction - * - * Ex: new Fraction(-4).neg() => 4 - **/ - "neg": function() { - - return new Fraction(-this["s"] * this["n"], this["d"]); - }, - - /** - * Adds two rational numbers - * - * Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30 - **/ - "add": function(a, b) { - - parse(a, b); - return new Fraction( - this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"], - this["d"] * P["d"] - ); - }, - - /** - * Subtracts two rational numbers - * - * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30 - **/ - "sub": function(a, b) { - - parse(a, b); - return new Fraction( - this["s"] * this["n"] * P["d"] - P["s"] * this["d"] * P["n"], - this["d"] * P["d"] - ); - }, - - /** - * Multiplies two rational numbers - * - * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111 - **/ - "mul": function(a, b) { - - parse(a, b); - return new Fraction( - this["s"] * P["s"] * this["n"] * P["n"], - this["d"] * P["d"] - ); - }, - - /** - * Divides two rational numbers - * - * Ex: new Fraction("-17.(345)").inverse().div(3) - **/ - "div": function(a, b) { - - parse(a, b); - return new Fraction( - this["s"] * P["s"] * this["n"] * P["d"], - this["d"] * P["n"] - ); - }, - - /** - * Clones the actual object - * - * Ex: new Fraction("-17.(345)").clone() - **/ - "clone": function() { - return new Fraction(this); - }, - - /** - * Calculates the modulo of two rational numbers - a more precise fmod - * - * Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6) - **/ - "mod": function(a, b) { - - if (isNaN(this['n']) || isNaN(this['d'])) { - return new Fraction(NaN); - } - - if (a === undefined) { - return new Fraction(this["s"] * this["n"] % this["d"], 1); - } - - parse(a, b); - if (0 === P["n"] && 0 === this["d"]) { - Fraction(0, 0); // Throw div/0 - } - - /* - * First silly attempt, kinda slow - * - return that["sub"]({ - "n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)), - "d": num["d"], - "s": this["s"] - });*/ - - /* - * New attempt: a1 / b1 = a2 / b2 * q + r - * => b2 * a1 = a2 * b1 * q + b1 * b2 * r - * => (b2 * a1 % a2 * b1) / (b1 * b2) - */ - return new Fraction( - (this["s"] * P["d"] * this["n"]) % (P["n"] * this["d"]), - P["d"] * this["d"] - ); - }, - - /** - * Calculates the fractional gcd of two rational numbers - * - * Ex: new Fraction(5,8).gcd(3,7) => 1/56 - */ - "gcd": function(a, b) { - - parse(a, b); - - // gcd(a / b, c / d) = gcd(a, c) / lcm(b, d) - - return new Fraction(gcd(P["n"], this["n"]), P["d"] * this["d"] / gcd(P["d"], this["d"])); - }, - - /** - * Calculates the fractional lcm of two rational numbers - * - * Ex: new Fraction(5,8).lcm(3,7) => 15 - */ - "lcm": function(a, b) { - - parse(a, b); - - // lcm(a / b, c / d) = lcm(a, c) / gcd(b, d) - - if (P["n"] === 0 && this["n"] === 0) { - return new Fraction; - } - return new Fraction(P["n"] * this["n"] / gcd(P["n"], this["n"]), gcd(P["d"], this["d"])); - }, - - /** - * Calculates the ceil of a rational number - * - * Ex: new Fraction('4.(3)').ceil() => (5 / 1) - **/ - "ceil": function(places) { - - places = Math.pow(10, places || 0); - - if (isNaN(this["n"]) || isNaN(this["d"])) { - return new Fraction(NaN); - } - return new Fraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places); - }, - - /** - * Calculates the floor of a rational number - * - * Ex: new Fraction('4.(3)').floor() => (4 / 1) - **/ - "floor": function(places) { - - places = Math.pow(10, places || 0); - - if (isNaN(this["n"]) || isNaN(this["d"])) { - return new Fraction(NaN); - } - return new Fraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places); - }, - - /** - * Rounds a rational numbers - * - * Ex: new Fraction('4.(3)').round() => (4 / 1) - **/ - "round": function(places) { - - places = Math.pow(10, places || 0); - - if (isNaN(this["n"]) || isNaN(this["d"])) { - return new Fraction(NaN); - } - return new Fraction(Math.round(places * this["s"] * this["n"] / this["d"]), places); - }, - - /** - * Gets the inverse of the fraction, means numerator and denumerator are exchanged - * - * Ex: new Fraction([-3, 4]).inverse() => -4 / 3 - **/ - "inverse": function() { - - return new Fraction(this["s"] * this["d"], this["n"]); - }, - - /** - * Calculates the fraction to some integer exponent - * - * Ex: new Fraction(-1,2).pow(-3) => -8 - */ - "pow": function(m) { - - if (m < 0) { - return new Fraction(Math.pow(this['s'] * this["d"],-m), Math.pow(this["n"],-m)); - } else { - return new Fraction(Math.pow(this['s'] * this["n"], m), Math.pow(this["d"], m)); - } - }, - - /** - * Check if two rational numbers are the same - * - * Ex: new Fraction(19.6).equals([98, 5]); - **/ - "equals": function(a, b) { - - parse(a, b); - return this["s"] * this["n"] * P["d"] === P["s"] * P["n"] * this["d"]; // Same as compare() === 0 - }, - - /** - * Check if two rational numbers are the same - * - * Ex: new Fraction(19.6).equals([98, 5]); - **/ - "compare": function(a, b) { - - parse(a, b); - var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]); - return (0 < t) - (t < 0); - }, - - /** - * Check if two rational numbers are divisible - * - * Ex: new Fraction(19.6).divisible(1.5); - */ - "divisible": function(a, b) { - - parse(a, b); - return !(!(P["n"] * this["d"]) || ((this["n"] * P["d"]) % (P["n"] * this["d"]))); - }, - - /** - * Returns a decimal representation of the fraction - * - * Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183 - **/ - 'valueOf': function() { - - return this["s"] * this["n"] / this["d"]; - }, - - /** - * Returns a string-fraction representation of a Fraction object - * - * Ex: new Fraction("1.'3'").toFraction() => "4 1/3" - **/ - 'toFraction': function(excludeWhole) { - - var whole, str = ""; - var n = this["n"]; - var d = this["d"]; - if (this["s"] < 0) { - str+= '-'; - } - - if (d === 1) { - str+= n; - } else { - - if (excludeWhole && (whole = Math.floor(n / d)) > 0) { - str+= whole; - str+= " "; - n%= d; - } - - str+= n; - str+= '/'; - str+= d; - } - return str; - }, - - /** - * Returns a latex representation of a Fraction object - * - * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}" - **/ - 'toLatex': function(excludeWhole) { - - var whole, str = ""; - var n = this["n"]; - var d = this["d"]; - if (this["s"] < 0) { - str+= '-'; - } - - if (d === 1) { - str+= n; - } else { - - if (excludeWhole && (whole = Math.floor(n / d)) > 0) { - str+= whole; - n%= d; - } - - str+= "\\frac{"; - str+= n; - str+= '}{'; - str+= d; - str+= '}'; - } - return str; - }, - - /** - * Returns an array of continued fraction elements - * - * Ex: new Fraction("7/8").toContinued() => [0,1,7] - */ - 'toContinued': function() { - - var t; - var a = this['n']; - var b = this['d']; - var res = []; - - do { - res.push(Math.floor(a / b)); - t = a % b; - a = b; - b = t; - } while (a !== 1); - - return res; - }, - - /** - * Creates a string representation of a fraction with all digits - * - * Ex: new Fraction("100.'91823'").toString() => "100.(91823)" - **/ - 'toString': function() { - - var g; - var N = this["n"]; - var D = this["d"]; - - if (isNaN(N) || isNaN(D)) { - return "NaN"; - } - - if (!Fraction['REDUCE']) { - g = gcd(N, D); - N/= g; - D/= g; - } - - var p = String(N).split(""); // Numerator chars - var t = 0; // Tmp var - - var ret = [~this["s"] ? "" : "-", "", ""]; // Return array, [0] is zero sign, [1] before comma, [2] after - var zeros = ""; // Collection variable for zeros - - var cycLen = cycleLen(N, D); // Cycle length - var cycOff = cycleStart(N, D, cycLen); // Cycle start - - var j = -1; - var n = 1; // str index - - // rough estimate to fill zeros - var length = 15 + cycLen + cycOff + p.length; // 15 = decimal places when no repitation - - for (var i = 0; i < length; i++, t*= 10) { - - if (i < p.length) { - t+= Number(p[i]); - } else { - n = 2; - j++; // Start now => after comma - } - - if (cycLen > 0) { // If we have a repeating part - if (j === cycOff) { - ret[n]+= zeros + "("; - zeros = ""; - } else if (j === cycLen + cycOff) { - ret[n]+= zeros + ")"; - break; - } - } - - if (t >= D) { - ret[n]+= zeros + ((t / D) | 0); // Flush zeros, Add current digit - zeros = ""; - t = t % D; - } else if (n > 1) { // Add zeros to the zero buffer - zeros+= "0"; - } else if (ret[n]) { // If before comma, add zero only if already something was added - ret[n]+= "0"; - } - } - - // If it's empty, it's a leading zero only - ret[0]+= ret[1] || "0"; - - // If there is something after the comma, add the comma sign - if (ret[2]) { - return ret[0] + "." + ret[2]; - } - return ret[0]; - } - }; - - if ("function" === "function" && __webpack_require__(30)["amd"]) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { - return Fraction; - }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (true) { - module["exports"] = Fraction; - } else { - root['Fraction'] = Fraction; - } - - })(this); - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(29)(module))) - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Create a fraction convert a value to a fraction. - * - * Syntax: - * math.fraction(numerator, denominator) - * math.fraction({n: numerator, d: denominator}) - * math.fraction(matrix: Array | Matrix) Turn all matrix entries - * into fractions - * - * Examples: - * - * math.fraction(1, 3); - * math.fraction('2/3'); - * math.fraction({n: 2, d: 3}); - * math.fraction([0.2, 0.25, 1.25]); - * - * See also: - * - * bignumber, number, string, unit - * - * @param {number | string | Fraction | BigNumber | Array | Matrix} [args] - * Arguments specifying the numerator and denominator of - * the fraction - * @return {Fraction | Array | Matrix} Returns a fraction - */ - var fraction = typed('fraction', { - 'number': function (x) { - if (!isFinite(x) || isNaN(x)) { - throw new Error(x + ' cannot be represented as a fraction'); - } - - return new type.Fraction(x); - }, - - 'string': function (x) { - return new type.Fraction(x); - }, - - 'number, number': function (numerator, denominator) { - return new type.Fraction(numerator, denominator); - }, - - 'BigNumber': function (x) { - return new type.Fraction(x.toString()); - }, - - 'Fraction': function (x) { - return x; // fractions are immutable - }, - - 'Object': function (x) { - return new type.Fraction(x); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, fraction); - } - }); - - return fraction; - } - - exports.name = 'fraction'; - exports.factory = factory; - - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // types - __webpack_require__(38), - __webpack_require__(46), - __webpack_require__(47), - __webpack_require__(50), - __webpack_require__(59), - __webpack_require__(65), - __webpack_require__(66), - __webpack_require__(67), - - // construction functions - __webpack_require__(68), - __webpack_require__(52), - __webpack_require__(69) - ]; - - -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - - var string = util.string; - - var isString = string.isString; - - function factory (type, config, load, typed) { - /** - * @constructor Matrix - * - * A Matrix is a wrapper around an Array. A matrix can hold a multi dimensional - * array. A matrix can be constructed as: - * var matrix = math.matrix(data) - * - * Matrix contains the functions to resize, get and set values, get the size, - * clone the matrix and to convert the matrix to a vector, array, or scalar. - * Furthermore, one can iterate over the matrix using map and forEach. - * The internal Array of the Matrix can be accessed using the function valueOf. - * - * Example usage: - * var matrix = math.matrix([[1, 2], [3, 4]]); - * matix.size(); // [2, 2] - * matrix.resize([3, 2], 5); - * matrix.valueOf(); // [[1, 2], [3, 4], [5, 5]] - * matrix.subset([1,2]) // 3 (indexes are zero-based) - * - */ - function Matrix() { - if (!(this instanceof Matrix)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - } - - /** - * Attach type information - */ - Matrix.prototype.type = 'Matrix'; - Matrix.prototype.isMatrix = true; - - /** - * Get the Matrix storage constructor for the given format. - * - * @param {string} format The Matrix storage format. - * - * @return {Function} The Matrix storage constructor. - */ - Matrix.storage = function (format) { - // check storage format is a string - if (!isString(format)) { - throw new TypeError('format must be a string value'); - } - - // get storage format constructor - var constructor = Matrix._storage[format]; - if (!constructor) { - throw new SyntaxError('Unsupported matrix storage format: ' + format); - } - - // return storage constructor - return constructor; - }; - - // a map with all constructors for all storage types - Matrix._storage = {}; - - /** - * Get the storage format used by the matrix. - * - * Usage: - * var format = matrix.storage() // retrieve storage format - * - * @return {string} The storage format. - */ - Matrix.prototype.storage = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke storage on a Matrix interface'); - }; - - /** - * Get the datatype of the data stored in the matrix. - * - * Usage: - * var format = matrix.datatype() // retrieve matrix datatype - * - * @return {string} The datatype. - */ - Matrix.prototype.datatype = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke datatype on a Matrix interface'); - }; - - /** - * Create a new Matrix With the type of the current matrix instance - * @param {Array | Object} data - * @param {string} [datatype] - */ - Matrix.prototype.create = function (data, datatype) { - throw new Error('Cannot invoke create on a Matrix interface'); - }; - - /** - * Get a subset of the matrix, or replace a subset of the matrix. - * - * Usage: - * var subset = matrix.subset(index) // retrieve subset - * var value = matrix.subset(index, replacement) // replace subset - * - * @param {Index} index - * @param {Array | Matrix | *} [replacement] - * @param {*} [defaultValue=0] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be filled with zeros. - */ - Matrix.prototype.subset = function (index, replacement, defaultValue) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke subset on a Matrix interface'); - }; - - /** - * Get a single element from the matrix. - * @param {number[]} index Zero-based index - * @return {*} value - */ - Matrix.prototype.get = function (index) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke get on a Matrix interface'); - }; - - /** - * Replace a single element in the matrix. - * @param {number[]} index Zero-based index - * @param {*} value - * @param {*} [defaultValue] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be left undefined. - * @return {Matrix} self - */ - Matrix.prototype.set = function (index, value, defaultValue) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke set on a Matrix interface'); - }; - - /** - * Resize the matrix to the given size. Returns a copy of the matrix when - * `copy=true`, otherwise return the matrix itself (resize in place). - * - * @param {number[]} size The new size the matrix should have. - * @param {*} [defaultValue=0] Default value, filled in on new entries. - * If not provided, the matrix elements will - * be filled with zeros. - * @param {boolean} [copy] Return a resized copy of the matrix - * - * @return {Matrix} The resized matrix - */ - Matrix.prototype.resize = function (size, defaultValue) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke resize on a Matrix interface'); - }; - - /** - * Create a clone of the matrix - * @return {Matrix} clone - */ - Matrix.prototype.clone = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke clone on a Matrix interface'); - }; - - /** - * Retrieve the size of the matrix. - * @returns {number[]} size - */ - Matrix.prototype.size = function() { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke size on a Matrix interface'); - }; - - /** - * Create a new matrix with the results of the callback function executed on - * each entry of the matrix. - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. - * - * @return {Matrix} matrix - */ - Matrix.prototype.map = function (callback, skipZeros) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke map on a Matrix interface'); - }; - - /** - * Execute a callback function on each entry of the matrix. - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - */ - Matrix.prototype.forEach = function (callback) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke forEach on a Matrix interface'); - }; - - /** - * Create an Array with a copy of the data of the Matrix - * @returns {Array} array - */ - Matrix.prototype.toArray = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke toArray on a Matrix interface'); - }; - - /** - * Get the primitive value of the Matrix: a multidimensional array - * @returns {Array} array - */ - Matrix.prototype.valueOf = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke valueOf on a Matrix interface'); - }; - - /** - * Get a string representation of the matrix, with optional formatting options. - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @returns {string} str - */ - Matrix.prototype.format = function (options) { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke format on a Matrix interface'); - }; - - /** - * Get a string representation of the matrix - * @returns {string} str - */ - Matrix.prototype.toString = function () { - // must be implemented by each of the Matrix implementations - throw new Error('Cannot invoke toString on a Matrix interface'); - }; - - // exports - return Matrix; - } - - exports.name = 'Matrix'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.array = __webpack_require__(40); - exports['boolean'] = __webpack_require__(44); - exports['function'] = __webpack_require__(45); - exports.number = __webpack_require__(6); - exports.object = __webpack_require__(3); - exports.string = __webpack_require__(23); - exports.types = __webpack_require__(41); - exports.emitter = __webpack_require__(8); - - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(6); - var string = __webpack_require__(23); - var object = __webpack_require__(3); - var types = __webpack_require__(41); - - var DimensionError = __webpack_require__(42); - var IndexError = __webpack_require__(43); - - /** - * Calculate the size of a multi dimensional array. - * This function checks the size of the first entry, it does not validate - * whether all dimensions match. (use function `validate` for that) - * @param {Array} x - * @Return {Number[]} size - */ - exports.size = function (x) { - var s = []; - - while (Array.isArray(x)) { - s.push(x.length); - x = x[0]; - } - - return s; - }; - - /** - * Recursively validate whether each element in a multi dimensional array - * has a size corresponding to the provided size array. - * @param {Array} array Array to be validated - * @param {number[]} size Array with the size of each dimension - * @param {number} dim Current dimension - * @throws DimensionError - * @private - */ - function _validate(array, size, dim) { - var i; - var len = array.length; - - if (len != size[dim]) { - throw new DimensionError(len, size[dim]); - } - - if (dim < size.length - 1) { - // recursively validate each child array - var dimNext = dim + 1; - for (i = 0; i < len; i++) { - var child = array[i]; - if (!Array.isArray(child)) { - throw new DimensionError(size.length - 1, size.length, '<'); - } - _validate(array[i], size, dimNext); - } - } - else { - // last dimension. none of the childs may be an array - for (i = 0; i < len; i++) { - if (Array.isArray(array[i])) { - throw new DimensionError(size.length + 1, size.length, '>'); - } - } - } - } - - /** - * Validate whether each element in a multi dimensional array has - * a size corresponding to the provided size array. - * @param {Array} array Array to be validated - * @param {number[]} size Array with the size of each dimension - * @throws DimensionError - */ - exports.validate = function(array, size) { - var isScalar = (size.length == 0); - if (isScalar) { - // scalar - if (Array.isArray(array)) { - throw new DimensionError(array.length, 0); - } - } - else { - // array - _validate(array, size, 0); - } - }; - - /** - * Test whether index is an integer number with index >= 0 and index < length - * when length is provided - * @param {number} index Zero-based index - * @param {number} [length] Length of the array - */ - exports.validateIndex = function(index, length) { - if (!number.isNumber(index) || !number.isInteger(index)) { - throw new TypeError('Index must be an integer (value: ' + index + ')'); - } - if (index < 0 || (typeof length === 'number' && index >= length)) { - throw new IndexError(index, length); - } - }; - - // a constant used to specify an undefined defaultValue - exports.UNINITIALIZED = {}; - - /** - * Resize a multi dimensional array. The resized array is returned. - * @param {Array} array Array to be resized - * @param {Array.} size Array with the size of each dimension - * @param {*} [defaultValue=0] Value to be filled in in new entries, - * zero by default. To leave new entries undefined, - * specify array.UNINITIALIZED as defaultValue - * @return {Array} array The resized array - */ - exports.resize = function(array, size, defaultValue) { - // TODO: add support for scalars, having size=[] ? - - // check the type of the arguments - if (!Array.isArray(array) || !Array.isArray(size)) { - throw new TypeError('Array expected'); - } - if (size.length === 0) { - throw new Error('Resizing to scalar is not supported'); - } - - // check whether size contains positive integers - size.forEach(function (value) { - if (!number.isNumber(value) || !number.isInteger(value) || value < 0) { - throw new TypeError('Invalid size, must contain positive integers ' + - '(size: ' + string.format(size) + ')'); - } - }); - - // recursively resize the array - var _defaultValue = (defaultValue !== undefined) ? defaultValue : 0; - _resize(array, size, 0, _defaultValue); - - return array; - }; - - /** - * Recursively resize a multi dimensional array - * @param {Array} array Array to be resized - * @param {number[]} size Array with the size of each dimension - * @param {number} dim Current dimension - * @param {*} [defaultValue] Value to be filled in in new entries, - * undefined by default. - * @private - */ - function _resize (array, size, dim, defaultValue) { - var i; - var elem; - var oldLen = array.length; - var newLen = size[dim]; - var minLen = Math.min(oldLen, newLen); - - // apply new length - array.length = newLen; - - if (dim < size.length - 1) { - // non-last dimension - var dimNext = dim + 1; - - // resize existing child arrays - for (i = 0; i < minLen; i++) { - // resize child array - elem = array[i]; - if (!Array.isArray(elem)) { - elem = [elem]; // add a dimension - array[i] = elem; - } - _resize(elem, size, dimNext, defaultValue); - } - - // create new child arrays - for (i = minLen; i < newLen; i++) { - // get child array - elem = []; - array[i] = elem; - - // resize new child array - _resize(elem, size, dimNext, defaultValue); - } - } - else { - // last dimension - - // remove dimensions of existing values - for (i = 0; i < minLen; i++) { - while (Array.isArray(array[i])) { - array[i] = array[i][0]; - } - } - - if(defaultValue !== exports.UNINITIALIZED) { - // fill new elements with the default value - for (i = minLen; i < newLen; i++) { - array[i] = defaultValue; - } - } - } - } - - /** - * Squeeze a multi dimensional array - * @param {Array} array - * @param {Array} [size] - * @returns {Array} returns the array itself - */ - exports.squeeze = function(array, size) { - var s = size || exports.size(array); - - // squeeze outer dimensions - while (Array.isArray(array) && array.length === 1) { - array = array[0]; - s.shift(); - } - - // find the first dimension to be squeezed - var dims = s.length; - while (s[dims - 1] === 1) { - dims--; - } - - // squeeze inner dimensions - if (dims < s.length) { - array = _squeeze(array, dims, 0); - s.length = dims; - } - - return array; - }; - - /** - * Recursively squeeze a multi dimensional array - * @param {Array} array - * @param {number} dims Required number of dimensions - * @param {number} dim Current dimension - * @returns {Array | *} Returns the squeezed array - * @private - */ - function _squeeze (array, dims, dim) { - var i, ii; - - if (dim < dims) { - var next = dim + 1; - for (i = 0, ii = array.length; i < ii; i++) { - array[i] = _squeeze(array[i], dims, next); - } - } - else { - while (Array.isArray(array)) { - array = array[0]; - } - } - - return array; - } - - /** - * Unsqueeze a multi dimensional array: add dimensions when missing - * - * Paramter `size` will be mutated to match the new, unqueezed matrix size. - * - * @param {Array} array - * @param {number} dims Desired number of dimensions of the array - * @param {number} [outer] Number of outer dimensions to be added - * @param {Array} [size] Current size of array. - * @returns {Array} returns the array itself - * @private - */ - exports.unsqueeze = function(array, dims, outer, size) { - var s = size || exports.size(array); - - // unsqueeze outer dimensions - if (outer) { - for (var i = 0; i < outer; i++) { - array = [array]; - s.unshift(1); - } - } - - // unsqueeze inner dimensions - array = _unsqueeze(array, dims, 0); - while (s.length < dims) { - s.push(1); - } - - return array; - }; - - /** - * Recursively unsqueeze a multi dimensional array - * @param {Array} array - * @param {number} dims Required number of dimensions - * @param {number} dim Current dimension - * @returns {Array | *} Returns the squeezed array - * @private - */ - function _unsqueeze (array, dims, dim) { - var i, ii; - - if (Array.isArray(array)) { - var next = dim + 1; - for (i = 0, ii = array.length; i < ii; i++) { - array[i] = _unsqueeze(array[i], dims, next); - } - } - else { - for (var d = dim; d < dims; d++) { - array = [array]; - } - } - - return array; - } - /** - * Flatten a multi dimensional array, put all elements in a one dimensional - * array - * @param {Array} array A multi dimensional array - * @return {Array} The flattened array (1 dimensional) - */ - exports.flatten = function(array) { - if (!Array.isArray(array)) { - //if not an array, return as is - return array; - } - var flat = []; - - array.forEach(function callback(value) { - if (Array.isArray(value)) { - value.forEach(callback); //traverse through sub-arrays recursively - } - else { - flat.push(value); - } - }); - - return flat; - }; - - /** - * Test whether an object is an array - * @param {*} value - * @return {boolean} isArray - */ - exports.isArray = Array.isArray; - - -/***/ }, -/* 41 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Determine the type of a variable - * - * type(x) - * - * The following types are recognized: - * - * 'undefined' - * 'null' - * 'boolean' - * 'number' - * 'string' - * 'Array' - * 'Function' - * 'Date' - * 'RegExp' - * 'Object' - * - * @param {*} x - * @return {string} Returns the name of the type. Primitive types are lower case, - * non-primitive types are upper-camel-case. - * For example 'number', 'string', 'Array', 'Date'. - */ - exports.type = function(x) { - var type = typeof x; - - if (type === 'object') { - if (x === null) return 'null'; - if (x instanceof Boolean) return 'boolean'; - if (x instanceof Number) return 'number'; - if (x instanceof String) return 'string'; - if (Array.isArray(x)) return 'Array'; - if (x instanceof Date) return 'Date'; - if (x instanceof RegExp) return 'RegExp'; - - return 'Object'; - } - - if (type === 'function') return 'Function'; - - return type; - }; - - /** - * Test whether a value is a scalar - * @param x - * @return {boolean} Returns true when x is a scalar, returns false when - * x is a Matrix or Array. - */ - exports.isScalar = function (x) { - return !((x && x.isMatrix) || Array.isArray(x)); - }; - - -/***/ }, -/* 42 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Create a range error with the message: - * 'Dimension mismatch ( != )' - * @param {number | number[]} actual The actual size - * @param {number | number[]} expected The expected size - * @param {string} [relation='!='] Optional relation between actual - * and expected size: '!=', '<', etc. - * @extends RangeError - */ - function DimensionError(actual, expected, relation) { - if (!(this instanceof DimensionError)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.actual = actual; - this.expected = expected; - this.relation = relation; - - this.message = 'Dimension mismatch (' + - (Array.isArray(actual) ? ('[' + actual.join(', ') + ']') : actual) + - ' ' + (this.relation || '!=') + ' ' + - (Array.isArray(expected) ? ('[' + expected.join(', ') + ']') : expected) + - ')'; - - this.stack = (new Error()).stack; - } - - DimensionError.prototype = new RangeError(); - DimensionError.prototype.constructor = RangeError; - DimensionError.prototype.name = 'DimensionError'; - DimensionError.prototype.isDimensionError = true; - - module.exports = DimensionError; - - -/***/ }, -/* 43 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Create a range error with the message: - * 'Index out of range (index < min)' - * 'Index out of range (index < max)' - * - * @param {number} index The actual index - * @param {number} [min=0] Minimum index (included) - * @param {number} [max] Maximum index (excluded) - * @extends RangeError - */ - function IndexError(index, min, max) { - if (!(this instanceof IndexError)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.index = index; - if (arguments.length < 3) { - this.min = 0; - this.max = min; - } - else { - this.min = min; - this.max = max; - } - - if (this.min !== undefined && this.index < this.min) { - this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')'; - } - else if (this.max !== undefined && this.index >= this.max) { - this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')'; - } - else { - this.message = 'Index out of range (' + this.index + ')'; - } - - this.stack = (new Error()).stack; - } - - IndexError.prototype = new RangeError(); - IndexError.prototype.constructor = RangeError; - IndexError.prototype.name = 'IndexError'; - IndexError.prototype.isIndexError = true; - - module.exports = IndexError; - - -/***/ }, -/* 44 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Test whether value is a boolean - * @param {*} value - * @return {boolean} isBoolean - */ - exports.isBoolean = function(value) { - return typeof value == 'boolean'; - }; - - -/***/ }, -/* 45 */ -/***/ function(module, exports) { - - // function utils - - /* - * Memoize a given function by caching the computed result. - * The cache of a memoized function can be cleared by deleting the `cache` - * property of the function. - * - * @param {function} fn The function to be memoized. - * Must be a pure function. - * @param {function(args: Array)} [hasher] A custom hash builder. - * Is JSON.stringify by default. - * @return {function} Returns the memoized function - */ - exports.memoize = function(fn, hasher) { - return function memoize() { - if (typeof memoize.cache !== 'object') { - memoize.cache = {}; - } - - var args = []; - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } - - var hash = hasher ? hasher(args) : JSON.stringify(args); - if (!(hash in memoize.cache)) { - return memoize.cache[hash] = fn.apply(fn, args); - } - return memoize.cache[hash]; - }; - }; - - -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - var DimensionError = __webpack_require__(42); - - var string = util.string; - var array = util.array; - var object = util.object; - var number = util.number; - - var isArray = Array.isArray; - var isNumber = number.isNumber; - var isInteger = number.isInteger; - var isString = string.isString; - - var validateIndex = array.validateIndex; - - function factory (type, config, load, typed) { - var Matrix = load(__webpack_require__(38)); // force loading Matrix (do not use via type.Matrix) - - /** - * Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type. - * @class DenseMatrix - */ - function DenseMatrix(data, datatype) { - if (!(this instanceof DenseMatrix)) - throw new SyntaxError('Constructor must be called with the new operator'); - if (datatype && !isString(datatype)) - throw new Error('Invalid datatype: ' + datatype); - - if (data && data.isMatrix === true) { - // check data is a DenseMatrix - if (data.type === 'DenseMatrix') { - // clone data & size - this._data = object.clone(data._data); - this._size = object.clone(data._size); - this._datatype = datatype || data._datatype; - } - else { - // build data from existing matrix - this._data = data.toArray(); - this._size = data.size(); - this._datatype = datatype || data._datatype; - } - } - else if (data && isArray(data.data) && isArray(data.size)) { - // initialize fields from JSON representation - this._data = data.data; - this._size = data.size; - this._datatype = datatype || data.datatype; - } - else if (isArray(data)) { - // replace nested Matrices with Arrays - this._data = preprocess(data); - // get the dimensions of the array - this._size = array.size(this._data); - // verify the dimensions of the array, TODO: compute size while processing array - array.validate(this._data, this._size); - // data type unknown - this._datatype = datatype; - } - else if (data) { - // unsupported type - throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); - } - else { - // nothing provided - this._data = []; - this._size = [0]; - this._datatype = datatype; - } - } - - DenseMatrix.prototype = new Matrix(); - - /** - * Attach type information - */ - DenseMatrix.prototype.type = 'DenseMatrix'; - DenseMatrix.prototype.isDenseMatrix = true; - - /** - * Get the storage format used by the matrix. - * - * Usage: - * var format = matrix.storage() // retrieve storage format - * - * @memberof DenseMatrix - * @return {string} The storage format. - */ - DenseMatrix.prototype.storage = function () { - return 'dense'; - }; - - /** - * Get the datatype of the data stored in the matrix. - * - * Usage: - * var format = matrix.datatype() // retrieve matrix datatype - * - * @memberof DenseMatrix - * @return {string} The datatype. - */ - DenseMatrix.prototype.datatype = function () { - return this._datatype; - }; - - /** - * Create a new DenseMatrix - * @memberof DenseMatrix - * @param {Array} data - * @param {string} [datatype] - */ - DenseMatrix.prototype.create = function (data, datatype) { - return new DenseMatrix(data, datatype); - }; - - /** - * Get a subset of the matrix, or replace a subset of the matrix. - * - * Usage: - * var subset = matrix.subset(index) // retrieve subset - * var value = matrix.subset(index, replacement) // replace subset - * - * @memberof DenseMatrix - * @param {Index} index - * @param {Array | DenseMatrix | *} [replacement] - * @param {*} [defaultValue=0] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be filled with zeros. - */ - DenseMatrix.prototype.subset = function (index, replacement, defaultValue) { - switch (arguments.length) { - case 1: - return _get(this, index); - - // intentional fall through - case 2: - case 3: - return _set(this, index, replacement, defaultValue); - - default: - throw new SyntaxError('Wrong number of arguments'); - } - }; - - /** - * Get a single element from the matrix. - * @memberof DenseMatrix - * @param {number[]} index Zero-based index - * @return {*} value - */ - DenseMatrix.prototype.get = function (index) { - if (!isArray(index)) - throw new TypeError('Array expected'); - if (index.length != this._size.length) - throw new DimensionError(index.length, this._size.length); - - // check index - for (var x = 0; x < index.length; x++) - validateIndex(index[x], this._size[x]); - - var data = this._data; - for (var i = 0, ii = index.length; i < ii; i++) { - var index_i = index[i]; - validateIndex(index_i, data.length); - data = data[index_i]; - } - - return data; - }; - - /** - * Replace a single element in the matrix. - * @memberof DenseMatrix - * @param {number[]} index Zero-based index - * @param {*} value - * @param {*} [defaultValue] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be left undefined. - * @return {DenseMatrix} self - */ - DenseMatrix.prototype.set = function (index, value, defaultValue) { - if (!isArray(index)) - throw new TypeError('Array expected'); - if (index.length < this._size.length) - throw new DimensionError(index.length, this._size.length, '<'); - - var i, ii, index_i; - - // enlarge matrix when needed - var size = index.map(function (i) { - return i + 1; - }); - _fit(this, size, defaultValue); - - // traverse over the dimensions - var data = this._data; - for (i = 0, ii = index.length - 1; i < ii; i++) { - index_i = index[i]; - validateIndex(index_i, data.length); - data = data[index_i]; - } - - // set new value - index_i = index[index.length - 1]; - validateIndex(index_i, data.length); - data[index_i] = value; - - return this; - }; - - /** - * Get a submatrix of this matrix - * @memberof DenseMatrix - * @param {DenseMatrix} matrix - * @param {Index} index Zero-based index - * @private - */ - function _get (matrix, index) { - if (!index || index.isIndex !== true) { - throw new TypeError('Invalid index'); - } - - var isScalar = index.isScalar(); - if (isScalar) { - // return a scalar - return matrix.get(index.min()); - } - else { - // validate dimensions - var size = index.size(); - if (size.length != matrix._size.length) { - throw new DimensionError(size.length, matrix._size.length); - } - - // validate if any of the ranges in the index is out of range - var min = index.min(); - var max = index.max(); - for (var i = 0, ii = matrix._size.length; i < ii; i++) { - validateIndex(min[i], matrix._size[i]); - validateIndex(max[i], matrix._size[i]); - } - - // retrieve submatrix - // TODO: more efficient when creating an empty matrix and setting _data and _size manually - return new DenseMatrix(_getSubmatrix(matrix._data, index, size.length, 0), matrix._datatype); - } - } - - /** - * Recursively get a submatrix of a multi dimensional matrix. - * Index is not checked for correct number or length of dimensions. - * @memberof DenseMatrix - * @param {Array} data - * @param {Index} index - * @param {number} dims Total number of dimensions - * @param {number} dim Current dimension - * @return {Array} submatrix - * @private - */ - function _getSubmatrix (data, index, dims, dim) { - var last = (dim == dims - 1); - var range = index.dimension(dim); - - if (last) { - return range.map(function (i) { - return data[i]; - }).valueOf(); - } - else { - return range.map(function (i) { - var child = data[i]; - return _getSubmatrix(child, index, dims, dim + 1); - }).valueOf(); - } - } - - /** - * Replace a submatrix in this matrix - * Indexes are zero-based. - * @memberof DenseMatrix - * @param {DenseMatrix} matrix - * @param {Index} index - * @param {DenseMatrix | Array | *} submatrix - * @param {*} defaultValue Default value, filled in on new entries when - * the matrix is resized. - * @return {DenseMatrix} matrix - * @private - */ - function _set (matrix, index, submatrix, defaultValue) { - if (!index || index.isIndex !== true) { - throw new TypeError('Invalid index'); - } - - // get index size and check whether the index contains a single value - var iSize = index.size(), - isScalar = index.isScalar(); - - // calculate the size of the submatrix, and convert it into an Array if needed - var sSize; - if (submatrix && submatrix.isMatrix === true) { - sSize = submatrix.size(); - submatrix = submatrix.valueOf(); - } - else { - sSize = array.size(submatrix); - } - - if (isScalar) { - // set a scalar - - // check whether submatrix is a scalar - if (sSize.length !== 0) { - throw new TypeError('Scalar expected'); - } - - matrix.set(index.min(), submatrix, defaultValue); - } - else { - // set a submatrix - - // validate dimensions - if (iSize.length < matrix._size.length) { - throw new DimensionError(iSize.length, matrix._size.length, '<'); - } - - if (sSize.length < iSize.length) { - // calculate number of missing outer dimensions - var i = 0; - var outer = 0; - while (iSize[i] === 1 && sSize[i] === 1) { - i++; - } - while (iSize[i] === 1) { - outer++; - i++; - } - - // unsqueeze both outer and inner dimensions - submatrix = array.unsqueeze(submatrix, iSize.length, outer, sSize); - } - - // check whether the size of the submatrix matches the index size - if (!object.deepEqual(iSize, sSize)) { - throw new DimensionError(iSize, sSize, '>'); - } - - // enlarge matrix when needed - var size = index.max().map(function (i) { - return i + 1; - }); - _fit(matrix, size, defaultValue); - - // insert the sub matrix - var dims = iSize.length, - dim = 0; - _setSubmatrix (matrix._data, index, submatrix, dims, dim); - } - - return matrix; - } - - /** - * Replace a submatrix of a multi dimensional matrix. - * @memberof DenseMatrix - * @param {Array} data - * @param {Index} index - * @param {Array} submatrix - * @param {number} dims Total number of dimensions - * @param {number} dim - * @private - */ - function _setSubmatrix (data, index, submatrix, dims, dim) { - var last = (dim == dims - 1), - range = index.dimension(dim); - - if (last) { - range.forEach(function (dataIndex, subIndex) { - validateIndex(dataIndex); - data[dataIndex] = submatrix[subIndex[0]]; - }); - } - else { - range.forEach(function (dataIndex, subIndex) { - validateIndex(dataIndex); - _setSubmatrix(data[dataIndex], index, submatrix[subIndex[0]], dims, dim + 1); - }); - } - } - - /** - * Resize the matrix to the given size. Returns a copy of the matrix when - * `copy=true`, otherwise return the matrix itself (resize in place). - * - * @memberof DenseMatrix - * @param {number[]} size The new size the matrix should have. - * @param {*} [defaultValue=0] Default value, filled in on new entries. - * If not provided, the matrix elements will - * be filled with zeros. - * @param {boolean} [copy] Return a resized copy of the matrix - * - * @return {Matrix} The resized matrix - */ - DenseMatrix.prototype.resize = function (size, defaultValue, copy) { - // validate arguments - if (!isArray(size)) - throw new TypeError('Array expected'); - - // matrix to resize - var m = copy ? this.clone() : this; - // resize matrix - return _resize(m, size, defaultValue); - }; - - var _resize = function (matrix, size, defaultValue) { - // check size - if (size.length === 0) { - // first value in matrix - var v = matrix._data; - // go deep - while (isArray(v)) { - v = v[0]; - } - return v; - } - // resize matrix - matrix._size = size.slice(0); // copy the array - matrix._data = array.resize(matrix._data, matrix._size, defaultValue); - // return matrix - return matrix; - }; - - /** - * Enlarge the matrix when it is smaller than given size. - * If the matrix is larger or equal sized, nothing is done. - * @memberof DenseMatrix - * @param {DenseMatrix} matrix The matrix to be resized - * @param {number[]} size - * @param {*} defaultValue Default value, filled in on new entries. - * @private - */ - function _fit(matrix, size, defaultValue) { - var newSize = matrix._size.slice(0), // copy the array - changed = false; - - // add dimensions when needed - while (newSize.length < size.length) { - newSize.push(0); - changed = true; - } - - // enlarge size when needed - for (var i = 0, ii = size.length; i < ii; i++) { - if (size[i] > newSize[i]) { - newSize[i] = size[i]; - changed = true; - } - } - - if (changed) { - // resize only when size is changed - _resize(matrix, newSize, defaultValue); - } - } - - /** - * Create a clone of the matrix - * @memberof DenseMatrix - * @return {DenseMatrix} clone - */ - DenseMatrix.prototype.clone = function () { - var m = new DenseMatrix({ - data: object.clone(this._data), - size: object.clone(this._size), - datatype: this._datatype - }); - return m; - }; - - /** - * Retrieve the size of the matrix. - * @memberof DenseMatrix - * @returns {number[]} size - */ - DenseMatrix.prototype.size = function() { - return this._size.slice(0); // return a clone of _size - }; - - /** - * Create a new matrix with the results of the callback function executed on - * each entry of the matrix. - * @memberof DenseMatrix - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * - * @return {DenseMatrix} matrix - */ - DenseMatrix.prototype.map = function (callback) { - // matrix instance - var me = this; - var recurse = function (value, index) { - if (isArray(value)) { - return value.map(function (child, i) { - return recurse(child, index.concat(i)); - }); - } - else { - return callback(value, index, me); - } - }; - // return dense format - return new DenseMatrix({ - data: recurse(this._data, []), - size: object.clone(this._size), - datatype: this._datatype - }); - }; - - /** - * Execute a callback function on each entry of the matrix. - * @memberof DenseMatrix - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - */ - DenseMatrix.prototype.forEach = function (callback) { - // matrix instance - var me = this; - var recurse = function (value, index) { - if (isArray(value)) { - value.forEach(function (child, i) { - recurse(child, index.concat(i)); - }); - } - else { - callback(value, index, me); - } - }; - recurse(this._data, []); - }; - - /** - * Create an Array with a copy of the data of the DenseMatrix - * @memberof DenseMatrix - * @returns {Array} array - */ - DenseMatrix.prototype.toArray = function () { - return object.clone(this._data); - }; - - /** - * Get the primitive value of the DenseMatrix: a multidimensional array - * @memberof DenseMatrix - * @returns {Array} array - */ - DenseMatrix.prototype.valueOf = function () { - return this._data; - }; - - /** - * Get a string representation of the matrix, with optional formatting options. - * @memberof DenseMatrix - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @returns {string} str - */ - DenseMatrix.prototype.format = function (options) { - return string.format(this._data, options); - }; - - /** - * Get a string representation of the matrix - * @memberof DenseMatrix - * @returns {string} str - */ - DenseMatrix.prototype.toString = function () { - return string.format(this._data); - }; - - /** - * Get a JSON representation of the matrix - * @memberof DenseMatrix - * @returns {Object} - */ - DenseMatrix.prototype.toJSON = function () { - return { - mathjs: 'DenseMatrix', - data: this._data, - size: this._size, - datatype: this._datatype - }; - }; - - /** - * Get the kth Matrix diagonal. - * - * @memberof DenseMatrix - * @param {number | BigNumber} [k=0] The kth diagonal where the vector will retrieved. - * - * @returns {Array} The array vector with the diagonal values. - */ - DenseMatrix.prototype.diagonal = function(k) { - // validate k if any - if (k) { - // convert BigNumber to a number - if (k.isBigNumber === true) - k = k.toNumber(); - // is must be an integer - if (!isNumber(k) || !isInteger(k)) { - throw new TypeError ('The parameter k must be an integer number'); - } - } - else { - // default value - k = 0; - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // rows & columns - var rows = this._size[0]; - var columns = this._size[1]; - - // number diagonal values - var n = Math.min(rows - kSub, columns - kSuper); - - // x is a matrix get diagonal from matrix - var data = []; - - // loop rows - for (var i = 0; i < n; i++) { - data[i] = this._data[i + kSub][i + kSuper]; - } - - // create DenseMatrix - return new DenseMatrix({ - data: data, - size: [n], - datatype: this._datatype - }); - }; - - /** - * Create a diagonal matrix. - * - * @memberof DenseMatrix - * @param {Array} size The matrix size. - * @param {number | Array} value The values for the diagonal. - * @param {number | BigNumber} [k=0] The kth diagonal where the vector will be filled in. - * @param {number} [defaultValue] The default value for non-diagonal - * - * @returns {DenseMatrix} - */ - DenseMatrix.diagonal = function (size, value, k, defaultValue, datatype) { - if (!isArray(size)) - throw new TypeError('Array expected, size parameter'); - if (size.length !== 2) - throw new Error('Only two dimensions matrix are supported'); - - // map size & validate - size = size.map(function (s) { - // check it is a big number - if (s && s.isBigNumber === true) { - // convert it - s = s.toNumber(); - } - // validate arguments - if (!isNumber(s) || !isInteger(s) || s < 1) { - throw new Error('Size values must be positive integers'); - } - return s; - }); - - // validate k if any - if (k) { - // convert BigNumber to a number - if (k && k.isBigNumber === true) - k = k.toNumber(); - // is must be an integer - if (!isNumber(k) || !isInteger(k)) { - throw new TypeError ('The parameter k must be an integer number'); - } - } - else { - // default value - k = 0; - } - - if (defaultValue && isString(datatype)) { - // convert defaultValue to the same datatype - defaultValue = typed.convert(defaultValue, datatype); - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // rows and columns - var rows = size[0]; - var columns = size[1]; - - // number of non-zero items - var n = Math.min(rows - kSub, columns - kSuper); - - // value extraction function - var _value; - - // check value - if (isArray(value)) { - // validate array - if (value.length !== n) { - // number of values in array must be n - throw new Error('Invalid value array length'); - } - // define function - _value = function (i) { - // return value @ i - return value[i]; - }; - } - else if (value && value.isMatrix === true) { - // matrix size - var ms = value.size(); - // validate matrix - if (ms.length !== 1 || ms[0] !== n) { - // number of values in array must be n - throw new Error('Invalid matrix length'); - } - // define function - _value = function (i) { - // return value @ i - return value.get([i]); - }; - } - else { - // define function - _value = function () { - // return value - return value; - }; - } - - // discover default value if needed - if (!defaultValue) { - // check first value in array - defaultValue = (_value(0) && _value(0).isBigNumber === true) ? new type.BigNumber(0) : 0; - } - - // empty array - var data = []; - - // check we need to resize array - if (size.length > 0) { - // resize array - data = array.resize(data, size, defaultValue); - // fill diagonal - for (var d = 0; d < n; d++) { - data[d + kSub][d + kSuper] = _value(d); - } - } - - // create DenseMatrix - return new DenseMatrix({ - data: data, - size: [rows, columns] - }); - }; - - /** - * Generate a matrix from a JSON object - * @memberof DenseMatrix - * @param {Object} json An object structured like - * `{"mathjs": "DenseMatrix", data: [], size: []}`, - * where mathjs is optional - * @returns {DenseMatrix} - */ - DenseMatrix.fromJSON = function (json) { - return new DenseMatrix(json); - }; - - /** - * Swap rows i and j in Matrix. - * - * @memberof DenseMatrix - * @param {number} i Matrix row index 1 - * @param {number} j Matrix row index 2 - * - * @return {Matrix} The matrix reference - */ - DenseMatrix.prototype.swapRows = function (i, j) { - // check index - if (!isNumber(i) || !isInteger(i) || !isNumber(j) || !isInteger(j)) { - throw new Error('Row index must be positive integers'); - } - // check dimensions - if (this._size.length !== 2) { - throw new Error('Only two dimensional matrix is supported'); - } - // validate index - validateIndex(i, this._size[0]); - validateIndex(j, this._size[0]); - - // swap rows - DenseMatrix._swapRows(i, j, this._data); - // return current instance - return this; - }; - - /** - * Swap rows i and j in Dense Matrix data structure. - * - * @param {number} i Matrix row index 1 - * @param {number} j Matrix row index 2 - */ - DenseMatrix._swapRows = function (i, j, data) { - // swap values i <-> j - var vi = data[i]; - data[i] = data[j]; - data[j] = vi; - }; - - /** - * Preprocess data, which can be an Array or DenseMatrix with nested Arrays and - * Matrices. Replaces all nested Matrices with Arrays - * @memberof DenseMatrix - * @param {Array} data - * @return {Array} data - */ - function preprocess(data) { - for (var i = 0, ii = data.length; i < ii; i++) { - var elem = data[i]; - if (isArray(elem)) { - data[i] = preprocess(elem); - } - else if (elem && elem.isMatrix === true) { - data[i] = preprocess(elem.valueOf()); - } - } - - return data; - } - - // register this type in the base class Matrix - type.Matrix._storage.dense = DenseMatrix; - type.Matrix._storage['default'] = DenseMatrix; - - // exports - return DenseMatrix; - } - - exports.name = 'DenseMatrix'; - exports.path = 'type'; - exports.factory = factory; - exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage - -/***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - var DimensionError = __webpack_require__(42); - - var array = util.array; - var object = util.object; - var string = util.string; - var number = util.number; - - var isArray = Array.isArray; - var isNumber = number.isNumber; - var isInteger = number.isInteger; - var isString = string.isString; - - var validateIndex = array.validateIndex; - - function factory (type, config, load, typed) { - var Matrix = load(__webpack_require__(38)); // force loading Matrix (do not use via type.Matrix) - var equalScalar = load(__webpack_require__(48)); - - /** - * Sparse Matrix implementation. This type implements a Compressed Column Storage format - * for sparse matrices. - * @class SparseMatrix - */ - function SparseMatrix(data, datatype) { - if (!(this instanceof SparseMatrix)) - throw new SyntaxError('Constructor must be called with the new operator'); - if (datatype && !isString(datatype)) - throw new Error('Invalid datatype: ' + datatype); - - if (data && data.isMatrix === true) { - // create from matrix - _createFromMatrix(this, data, datatype); - } - else if (data && isArray(data.index) && isArray(data.ptr) && isArray(data.size)) { - // initialize fields - this._values = data.values; - this._index = data.index; - this._ptr = data.ptr; - this._size = data.size; - this._datatype = datatype || data.datatype; - } - else if (isArray(data)) { - // create from array - _createFromArray(this, data, datatype); - } - else if (data) { - // unsupported type - throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); - } - else { - // nothing provided - this._values = []; - this._index = []; - this._ptr = [0]; - this._size = [0, 0]; - this._datatype = datatype; - } - } - - var _createFromMatrix = function (matrix, source, datatype) { - // check matrix type - if (source.type === 'SparseMatrix') { - // clone arrays - matrix._values = source._values ? object.clone(source._values) : undefined; - matrix._index = object.clone(source._index); - matrix._ptr = object.clone(source._ptr); - matrix._size = object.clone(source._size); - matrix._datatype = datatype || source._datatype; - } - else { - // build from matrix data - _createFromArray(matrix, source.valueOf(), datatype || source._datatype); - } - }; - - var _createFromArray = function (matrix, data, datatype) { - // initialize fields - matrix._values = []; - matrix._index = []; - matrix._ptr = []; - matrix._datatype = datatype; - // discover rows & columns, do not use math.size() to avoid looping array twice - var rows = data.length; - var columns = 0; - - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - if (isString(datatype)) { - // find signature that matches (datatype, datatype) - eq = typed.find(equalScalar, [datatype, datatype]) || equalScalar; - // convert 0 to the same datatype - zero = typed.convert(0, datatype); - } - - // check we have rows (empty array) - if (rows > 0) { - // column index - var j = 0; - do { - // store pointer to values index - matrix._ptr.push(matrix._index.length); - // loop rows - for (var i = 0; i < rows; i++) { - // current row - var row = data[i]; - // check row is an array - if (isArray(row)) { - // update columns if needed (only on first column) - if (j === 0 && columns < row.length) - columns = row.length; - // check row has column - if (j < row.length) { - // value - var v = row[j]; - // check value != 0 - if (!eq(v, zero)) { - // store value - matrix._values.push(v); - // index - matrix._index.push(i); - } - } - } - else { - // update columns if needed (only on first column) - if (j === 0 && columns < 1) - columns = 1; - // check value != 0 (row is a scalar) - if (!eq(row, zero)) { - // store value - matrix._values.push(row); - // index - matrix._index.push(i); - } - } - } - // increment index - j++; - } - while (j < columns); - } - // store number of values in ptr - matrix._ptr.push(matrix._index.length); - // size - matrix._size = [rows, columns]; - }; - - SparseMatrix.prototype = new Matrix(); - - /** - * Attach type information - */ - SparseMatrix.prototype.type = 'SparseMatrix'; - SparseMatrix.prototype.isSparseMatrix = true; - - /** - * Get the storage format used by the matrix. - * - * Usage: - * var format = matrix.storage() // retrieve storage format - * - * @memberof SparseMatrix - * @return {string} The storage format. - */ - SparseMatrix.prototype.storage = function () { - return 'sparse'; - }; - - /** - * Get the datatype of the data stored in the matrix. - * - * Usage: - * var format = matrix.datatype() // retrieve matrix datatype - * - * @memberof SparseMatrix - * @return {string} The datatype. - */ - SparseMatrix.prototype.datatype = function () { - return this._datatype; - }; - - /** - * Create a new SparseMatrix - * @memberof SparseMatrix - * @param {Array} data - * @param {string} [datatype] - */ - SparseMatrix.prototype.create = function (data, datatype) { - return new SparseMatrix(data, datatype); - }; - - /** - * Get the matrix density. - * - * Usage: - * var density = matrix.density() // retrieve matrix density - * - * @memberof SparseMatrix - * @return {number} The matrix density. - */ - SparseMatrix.prototype.density = function () { - // rows & columns - var rows = this._size[0]; - var columns = this._size[1]; - // calculate density - return rows !== 0 && columns !== 0 ? (this._index.length / (rows * columns)) : 0; - }; - - /** - * Get a subset of the matrix, or replace a subset of the matrix. - * - * Usage: - * var subset = matrix.subset(index) // retrieve subset - * var value = matrix.subset(index, replacement) // replace subset - * - * @memberof SparseMatrix - * @param {Index} index - * @param {Array | Maytrix | *} [replacement] - * @param {*} [defaultValue=0] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be filled with zeros. - */ - SparseMatrix.prototype.subset = function (index, replacement, defaultValue) { // check it is a pattern matrix - if (!this._values) - throw new Error('Cannot invoke subset on a Pattern only matrix'); - - // check arguments - switch (arguments.length) { - case 1: - return _getsubset(this, index); - - // intentional fall through - case 2: - case 3: - return _setsubset(this, index, replacement, defaultValue); - - default: - throw new SyntaxError('Wrong number of arguments'); - } - }; - - var _getsubset = function (matrix, idx) { - // check idx - if (!idx || idx.isIndex !== true) { - throw new TypeError('Invalid index'); - } - - var isScalar = idx.isScalar(); - if (isScalar) { - // return a scalar - return matrix.get(idx.min()); - } - // validate dimensions - var size = idx.size(); - if (size.length != matrix._size.length) { - throw new DimensionError(size.length, matrix._size.length); - } - - // vars - var i, ii, k, kk; - - // validate if any of the ranges in the index is out of range - var min = idx.min(); - var max = idx.max(); - for (i = 0, ii = matrix._size.length; i < ii; i++) { - validateIndex(min[i], matrix._size[i]); - validateIndex(max[i], matrix._size[i]); - } - - // matrix arrays - var mvalues = matrix._values; - var mindex = matrix._index; - var mptr = matrix._ptr; - - // rows & columns dimensions for result matrix - var rows = idx.dimension(0); - var columns = idx.dimension(1); - - // workspace & permutation vector - var w = []; - var pv = []; - - // loop rows in resulting matrix - rows.forEach(function (i, r) { - // update permutation vector - pv[i] = r[0]; - // mark i in workspace - w[i] = true; - }); - - // result matrix arrays - var values = mvalues ? [] : undefined; - var index = []; - var ptr = []; - - // loop columns in result matrix - columns.forEach(function (j) { - // update ptr - ptr.push(index.length); - // loop values in column j - for (k = mptr[j], kk = mptr[j + 1]; k < kk; k++) { - // row - i = mindex[k]; - // check row is in result matrix - if (w[i] === true) { - // push index - index.push(pv[i]); - // check we need to process values - if (values) - values.push(mvalues[k]); - } - } - }); - // update ptr - ptr.push(index.length); - - // return matrix - return new SparseMatrix({ - values: values, - index: index, - ptr: ptr, - size: size, - datatype: matrix._datatype - }); - }; - - var _setsubset = function (matrix, index, submatrix, defaultValue) { - // check index - if (!index || index.isIndex !== true) { - throw new TypeError('Invalid index'); - } - - // get index size and check whether the index contains a single value - var iSize = index.size(), - isScalar = index.isScalar(); - - // calculate the size of the submatrix, and convert it into an Array if needed - var sSize; - if (submatrix && submatrix.isMatrix === true) { - // submatrix size - sSize = submatrix.size(); - // use array representation - submatrix = submatrix.toArray(); - } - else { - // get submatrix size (array, scalar) - sSize = array.size(submatrix); - } - - // check index is a scalar - if (isScalar) { - // verify submatrix is a scalar - if (sSize.length !== 0) { - throw new TypeError('Scalar expected'); - } - // set value - matrix.set(index.min(), submatrix, defaultValue); - } - else { - // validate dimensions, index size must be one or two dimensions - if (iSize.length !== 1 && iSize.length !== 2) { - throw new DimensionError(iSize.length, matrix._size.length, '<'); - } - - // check submatrix and index have the same dimensions - if (sSize.length < iSize.length) { - // calculate number of missing outer dimensions - var i = 0; - var outer = 0; - while (iSize[i] === 1 && sSize[i] === 1) { - i++; - } - while (iSize[i] === 1) { - outer++; - i++; - } - // unsqueeze both outer and inner dimensions - submatrix = array.unsqueeze(submatrix, iSize.length, outer, sSize); - } - - // check whether the size of the submatrix matches the index size - if (!object.deepEqual(iSize, sSize)) { - throw new DimensionError(iSize, sSize, '>'); - } - - // offsets - var x0 = index.min()[0]; - var y0 = index.min()[1]; - - // submatrix rows and columns - var m = sSize[0]; - var n = sSize[1]; - - // loop submatrix - for (var x = 0; x < m; x++) { - // loop columns - for (var y = 0; y < n; y++) { - // value at i, j - var v = submatrix[x][y]; - // invoke set (zero value will remove entry from matrix) - matrix.set([x + x0, y + y0], v, defaultValue); - } - } - } - return matrix; - }; - - /** - * Get a single element from the matrix. - * @memberof SparseMatrix - * @param {number[]} index Zero-based index - * @return {*} value - */ - SparseMatrix.prototype.get = function (index) { - if (!isArray(index)) - throw new TypeError('Array expected'); - if (index.length != this._size.length) - throw new DimensionError(index.length, this._size.length); - - // check it is a pattern matrix - if (!this._values) - throw new Error('Cannot invoke get on a Pattern only matrix'); - - // row and column - var i = index[0]; - var j = index[1]; - - // check i, j are valid - validateIndex(i, this._size[0]); - validateIndex(j, this._size[1]); - - // find value index - var k = _getValueIndex(i, this._ptr[j], this._ptr[j + 1], this._index); - // check k is prior to next column k and it is in the correct row - if (k < this._ptr[j + 1] && this._index[k] === i) - return this._values[k]; - - return 0; - }; - - /** - * Replace a single element in the matrix. - * @memberof SparseMatrix - * @param {number[]} index Zero-based index - * @param {*} value - * @param {*} [defaultValue] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be set to zero. - * @return {SparseMatrix} self - */ - SparseMatrix.prototype.set = function (index, v, defaultValue) { - if (!isArray(index)) - throw new TypeError('Array expected'); - if (index.length != this._size.length) - throw new DimensionError(index.length, this._size.length); - - // check it is a pattern matrix - if (!this._values) - throw new Error('Cannot invoke set on a Pattern only matrix'); - - // row and column - var i = index[0]; - var j = index[1]; - - // rows & columns - var rows = this._size[0]; - var columns = this._size[1]; - - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - if (isString(this._datatype)) { - // find signature that matches (datatype, datatype) - eq = typed.find(equalScalar, [this._datatype, this._datatype]) || equalScalar; - // convert 0 to the same datatype - zero = typed.convert(0, this._datatype); - } - - // check we need to resize matrix - if (i > rows - 1 || j > columns - 1) { - // resize matrix - _resize(this, Math.max(i + 1, rows), Math.max(j + 1, columns), defaultValue); - // update rows & columns - rows = this._size[0]; - columns = this._size[1]; - } - - // check i, j are valid - validateIndex(i, rows); - validateIndex(j, columns); - - // find value index - var k = _getValueIndex(i, this._ptr[j], this._ptr[j + 1], this._index); - // check k is prior to next column k and it is in the correct row - if (k < this._ptr[j + 1] && this._index[k] === i) { - // check value != 0 - if (!eq(v, zero)) { - // update value - this._values[k] = v; - } - else { - // remove value from matrix - _remove(k, j, this._values, this._index, this._ptr); - } - } - else { - // insert value @ (i, j) - _insert(k, i, j, v, this._values, this._index, this._ptr); - } - - return this; - }; - - var _getValueIndex = function(i, top, bottom, index) { - // check row is on the bottom side - if (bottom - top === 0) - return bottom; - // loop rows [top, bottom[ - for (var r = top; r < bottom; r++) { - // check we found value index - if (index[r] === i) - return r; - } - // we did not find row - return top; - }; - - var _remove = function (k, j, values, index, ptr) { - // remove value @ k - values.splice(k, 1); - index.splice(k, 1); - // update pointers - for (var x = j + 1; x < ptr.length; x++) - ptr[x]--; - }; - - var _insert = function (k, i, j, v, values, index, ptr) { - // insert value - values.splice(k, 0, v); - // update row for k - index.splice(k, 0, i); - // update column pointers - for (var x = j + 1; x < ptr.length; x++) - ptr[x]++; - }; - - /** - * Resize the matrix to the given size. Returns a copy of the matrix when - * `copy=true`, otherwise return the matrix itself (resize in place). - * - * @memberof SparseMatrix - * @param {number[]} size The new size the matrix should have. - * @param {*} [defaultValue=0] Default value, filled in on new entries. - * If not provided, the matrix elements will - * be filled with zeros. - * @param {boolean} [copy] Return a resized copy of the matrix - * - * @return {Matrix} The resized matrix - */ - SparseMatrix.prototype.resize = function (size, defaultValue, copy) { - // validate arguments - if (!isArray(size)) - throw new TypeError('Array expected'); - if (size.length !== 2) - throw new Error('Only two dimensions matrix are supported'); - - // check sizes - size.forEach(function (value) { - if (!number.isNumber(value) || !number.isInteger(value) || value < 0) { - throw new TypeError('Invalid size, must contain positive integers ' + - '(size: ' + string.format(size) + ')'); - } - }); - - // matrix to resize - var m = copy ? this.clone() : this; - // resize matrix - return _resize(m, size[0], size[1], defaultValue); - }; - - var _resize = function (matrix, rows, columns, defaultValue) { - // value to insert at the time of growing matrix - var value = defaultValue || 0; - - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - if (isString(matrix._datatype)) { - // find signature that matches (datatype, datatype) - eq = typed.find(equalScalar, [matrix._datatype, matrix._datatype]) || equalScalar; - // convert 0 to the same datatype - zero = typed.convert(0, matrix._datatype); - // convert value to the same datatype - value = typed.convert(value, matrix._datatype); - } - - // should we insert the value? - var ins = !eq(value, zero); - - // old columns and rows - var r = matrix._size[0]; - var c = matrix._size[1]; - - var i, j, k; - - // check we need to increase columns - if (columns > c) { - // loop new columns - for (j = c; j < columns; j++) { - // update matrix._ptr for current column - matrix._ptr[j] = matrix._values.length; - // check we need to insert matrix._values - if (ins) { - // loop rows - for (i = 0; i < r; i++) { - // add new matrix._values - matrix._values.push(value); - // update matrix._index - matrix._index.push(i); - } - } - } - // store number of matrix._values in matrix._ptr - matrix._ptr[columns] = matrix._values.length; - } - else if (columns < c) { - // truncate matrix._ptr - matrix._ptr.splice(columns + 1, c - columns); - // truncate matrix._values and matrix._index - matrix._values.splice(matrix._ptr[columns], matrix._values.length); - matrix._index.splice(matrix._ptr[columns], matrix._index.length); - } - // update columns - c = columns; - - // check we need to increase rows - if (rows > r) { - // check we have to insert values - if (ins) { - // inserts - var n = 0; - // loop columns - for (j = 0; j < c; j++) { - // update matrix._ptr for current column - matrix._ptr[j] = matrix._ptr[j] + n; - // where to insert matrix._values - k = matrix._ptr[j + 1] + n; - // pointer - var p = 0; - // loop new rows, initialize pointer - for (i = r; i < rows; i++, p++) { - // add value - matrix._values.splice(k + p, 0, value); - // update matrix._index - matrix._index.splice(k + p, 0, i); - // increment inserts - n++; - } - } - // store number of matrix._values in matrix._ptr - matrix._ptr[c] = matrix._values.length; - } - } - else if (rows < r) { - // deletes - var d = 0; - // loop columns - for (j = 0; j < c; j++) { - // update matrix._ptr for current column - matrix._ptr[j] = matrix._ptr[j] - d; - // where matrix._values start for next column - var k0 = matrix._ptr[j]; - var k1 = matrix._ptr[j + 1] - d; - // loop matrix._index - for (k = k0; k < k1; k++) { - // row - i = matrix._index[k]; - // check we need to delete value and matrix._index - if (i > rows - 1) { - // remove value - matrix._values.splice(k, 1); - // remove item from matrix._index - matrix._index.splice(k, 1); - // increase deletes - d++; - } - } - } - // update matrix._ptr for current column - matrix._ptr[j] = matrix._values.length; - } - // update matrix._size - matrix._size[0] = rows; - matrix._size[1] = columns; - // return matrix - return matrix; - }; - - /** - * Create a clone of the matrix - * @memberof SparseMatrix - * @return {SparseMatrix} clone - */ - SparseMatrix.prototype.clone = function () { - var m = new SparseMatrix({ - values: this._values ? object.clone(this._values) : undefined, - index: object.clone(this._index), - ptr: object.clone(this._ptr), - size: object.clone(this._size), - datatype: this._datatype - }); - return m; - }; - - /** - * Retrieve the size of the matrix. - * @memberof SparseMatrix - * @returns {number[]} size - */ - SparseMatrix.prototype.size = function() { - return this._size.slice(0); // copy the Array - }; - - /** - * Create a new matrix with the results of the callback function executed on - * each entry of the matrix. - * @memberof SparseMatrix - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. - * - * @return {SparseMatrix} matrix - */ - SparseMatrix.prototype.map = function (callback, skipZeros) { - // check it is a pattern matrix - if (!this._values) - throw new Error('Cannot invoke map on a Pattern only matrix'); - // matrix instance - var me = this; - // rows and columns - var rows = this._size[0]; - var columns = this._size[1]; - // invoke callback - var invoke = function (v, i, j) { - // invoke callback - return callback(v, [i, j], me); - }; - // invoke _map - return _map(this, 0, rows - 1, 0, columns - 1, invoke, skipZeros); - }; - - /** - * Create a new matrix with the results of the callback function executed on the interval - * [minRow..maxRow, minColumn..maxColumn]. - */ - var _map = function (matrix, minRow, maxRow, minColumn, maxColumn, callback, skipZeros) { - // result arrays - var values = []; - var index = []; - var ptr = []; - - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - if (isString(matrix._datatype)) { - // find signature that matches (datatype, datatype) - eq = typed.find(equalScalar, [matrix._datatype, matrix._datatype]) || equalScalar; - // convert 0 to the same datatype - zero = typed.convert(0, matrix._datatype); - } - - // invoke callback - var invoke = function (v, x, y) { - // invoke callback - v = callback(v, x, y); - // check value != 0 - if (!eq(v, zero)) { - // store value - values.push(v); - // index - index.push(x); - } - }; - // loop columns - for (var j = minColumn; j <= maxColumn; j++) { - // store pointer to values index - ptr.push(values.length); - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = matrix._ptr[j]; - var k1 = matrix._ptr[j + 1]; - // row pointer - var p = minRow; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - var i = matrix._index[k]; - // check i is in range - if (i >= minRow && i <= maxRow) { - // zero values - if (!skipZeros) { - for (var x = p; x < i; x++) - invoke(0, x - minRow, j - minColumn); - } - // value @ k - invoke(matrix._values[k], i - minRow, j - minColumn); - } - // update pointer - p = i + 1; - } - // zero values - if (!skipZeros) { - for (var y = p; y <= maxRow; y++) - invoke(0, y - minRow, j - minColumn); - } - } - // store number of values in ptr - ptr.push(values.length); - // return sparse matrix - return new SparseMatrix({ - values: values, - index: index, - ptr: ptr, - size: [maxRow - minRow + 1, maxColumn - minColumn + 1] - }); - }; - - /** - * Execute a callback function on each entry of the matrix. - * @memberof SparseMatrix - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. - */ - SparseMatrix.prototype.forEach = function (callback, skipZeros) { - // check it is a pattern matrix - if (!this._values) - throw new Error('Cannot invoke forEach on a Pattern only matrix'); - // matrix instance - var me = this; - // rows and columns - var rows = this._size[0]; - var columns = this._size[1]; - // loop columns - for (var j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = this._ptr[j]; - var k1 = this._ptr[j + 1]; - // column pointer - var p = 0; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - var i = this._index[k]; - // check we need to process zeros - if (!skipZeros) { - // zero values - for (var x = p; x < i; x++) - callback(0, [x, j], me); - } - // value @ k - callback(this._values[k], [i, j], me); - // update pointer - p = i + 1; - } - // check we need to process zeros - if (!skipZeros) { - // zero values - for (var y = p; y < rows; y++) - callback(0, [y, j], me); - } - } - }; - - /** - * Create an Array with a copy of the data of the SparseMatrix - * @memberof SparseMatrix - * @returns {Array} array - */ - SparseMatrix.prototype.toArray = function () { - return _toArray(this._values, this._index, this._ptr, this._size, true); - }; - - /** - * Get the primitive value of the SparseMatrix: a two dimensions array - * @memberof SparseMatrix - * @returns {Array} array - */ - SparseMatrix.prototype.valueOf = function () { - return _toArray(this._values, this._index, this._ptr, this._size, false); - }; - - var _toArray = function (values, index, ptr, size, copy) { - // rows and columns - var rows = size[0]; - var columns = size[1]; - // result - var a = []; - // vars - var i, j; - // initialize array - for (i = 0; i < rows; i++) { - a[i] = []; - for (j = 0; j < columns; j++) - a[i][j] = 0; - } - - // loop columns - for (j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - i = index[k]; - // set value (use one for pattern matrix) - a[i][j] = values ? (copy ? object.clone(values[k]) : values[k]) : 1; - } - } - return a; - }; - - /** - * Get a string representation of the matrix, with optional formatting options. - * @memberof SparseMatrix - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @returns {string} str - */ - SparseMatrix.prototype.format = function (options) { - // rows and columns - var rows = this._size[0]; - var columns = this._size[1]; - // density - var density = this.density(); - // rows & columns - var str = 'Sparse Matrix [' + string.format(rows, options) + ' x ' + string.format(columns, options) + '] density: ' + string.format(density, options) + '\n'; - // loop columns - for (var j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = this._ptr[j]; - var k1 = this._ptr[j + 1]; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - var i = this._index[k]; - // append value - str += '\n (' + string.format(i, options) + ', ' + string.format(j, options) + ') ==> ' + (this._values ? string.format(this._values[k], options) : 'X'); - } - } - return str; - }; - - /** - * Get a string representation of the matrix - * @memberof SparseMatrix - * @returns {string} str - */ - SparseMatrix.prototype.toString = function () { - return string.format(this.toArray()); - }; - - /** - * Get a JSON representation of the matrix - * @memberof SparseMatrix - * @returns {Object} - */ - SparseMatrix.prototype.toJSON = function () { - return { - mathjs: 'SparseMatrix', - values: this._values, - index: this._index, - ptr: this._ptr, - size: this._size, - datatype: this._datatype - }; - }; - - /** - * Get the kth Matrix diagonal. - * - * @memberof SparseMatrix - * @param {number | BigNumber} [k=0] The kth diagonal where the vector will retrieved. - * - * @returns {Matrix} The matrix vector with the diagonal values. - */ - SparseMatrix.prototype.diagonal = function(k) { - // validate k if any - if (k) { - // convert BigNumber to a number - if (k.isBigNumber === true) - k = k.toNumber(); - // is must be an integer - if (!isNumber(k) || !isInteger(k)) { - throw new TypeError ('The parameter k must be an integer number'); - } - } - else { - // default value - k = 0; - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // rows & columns - var rows = this._size[0]; - var columns = this._size[1]; - - // number diagonal values - var n = Math.min(rows - kSub, columns - kSuper); - - // diagonal arrays - var values = []; - var index = []; - var ptr = []; - // initial ptr value - ptr[0] = 0; - // loop columns - for (var j = kSuper; j < columns && values.length < n; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = this._ptr[j]; - var k1 = this._ptr[j + 1]; - // loop x within [k0, k1[ - for (var x = k0; x < k1; x++) { - // row index - var i = this._index[x]; - // check row - if (i === j - kSuper + kSub) { - // value on this column - values.push(this._values[x]); - // store row - index[values.length - 1] = i - kSub; - // exit loop - break; - } - } - } - // close ptr - ptr.push(values.length); - // return matrix - return new SparseMatrix({ - values: values, - index: index, - ptr: ptr, - size: [n, 1] - }); - }; - - /** - * Generate a matrix from a JSON object - * @memberof SparseMatrix - * @param {Object} json An object structured like - * `{"mathjs": "SparseMatrix", "values": [], "index": [], "ptr": [], "size": []}`, - * where mathjs is optional - * @returns {SparseMatrix} - */ - SparseMatrix.fromJSON = function (json) { - return new SparseMatrix(json); - }; - - /** - * Create a diagonal matrix. - * - * @memberof SparseMatrix - * @param {Array} size The matrix size. - * @param {number | Array | Matrix } value The values for the diagonal. - * @param {number | BigNumber} [k=0] The kth diagonal where the vector will be filled in. - * @param {string} [datatype] The Matrix datatype, values must be of this datatype. - * - * @returns {SparseMatrix} - */ - SparseMatrix.diagonal = function (size, value, k, defaultValue, datatype) { - if (!isArray(size)) - throw new TypeError('Array expected, size parameter'); - if (size.length !== 2) - throw new Error('Only two dimensions matrix are supported'); - - // map size & validate - size = size.map(function (s) { - // check it is a big number - if (s && s.isBigNumber === true) { - // convert it - s = s.toNumber(); - } - // validate arguments - if (!isNumber(s) || !isInteger(s) || s < 1) { - throw new Error('Size values must be positive integers'); - } - return s; - }); - - // validate k if any - if (k) { - // convert BigNumber to a number - if (k.isBigNumber === true) - k = k.toNumber(); - // is must be an integer - if (!isNumber(k) || !isInteger(k)) { - throw new TypeError ('The parameter k must be an integer number'); - } - } - else { - // default value - k = 0; - } - - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - if (isString(datatype)) { - // find signature that matches (datatype, datatype) - eq = typed.find(equalScalar, [datatype, datatype]) || equalScalar; - // convert 0 to the same datatype - zero = typed.convert(0, datatype); - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // rows and columns - var rows = size[0]; - var columns = size[1]; - - // number of non-zero items - var n = Math.min(rows - kSub, columns - kSuper); - - // value extraction function - var _value; - - // check value - if (isArray(value)) { - // validate array - if (value.length !== n) { - // number of values in array must be n - throw new Error('Invalid value array length'); - } - // define function - _value = function (i) { - // return value @ i - return value[i]; - }; - } - else if (value && value.isMatrix === true) { - // matrix size - var ms = value.size(); - // validate matrix - if (ms.length !== 1 || ms[0] !== n) { - // number of values in array must be n - throw new Error('Invalid matrix length'); - } - // define function - _value = function (i) { - // return value @ i - return value.get([i]); - }; - } - else { - // define function - _value = function () { - // return value - return value; - }; - } - - // create arrays - var values = []; - var index = []; - var ptr = []; - - // loop items - for (var j = 0; j < columns; j++) { - // number of rows with value - ptr.push(values.length); - // diagonal index - var i = j - kSuper; - // check we need to set diagonal value - if (i >= 0 && i < n) { - // get value @ i - var v = _value(i); - // check for zero - if (!eq(v, zero)) { - // column - index.push(i + kSub); - // add value - values.push(v); - } - } - } - // last value should be number of values - ptr.push(values.length); - // create SparseMatrix - return new SparseMatrix({ - values: values, - index: index, - ptr: ptr, - size: [rows, columns] - }); - }; - - /** - * Swap rows i and j in Matrix. - * - * @memberof SparseMatrix - * @param {number} i Matrix row index 1 - * @param {number} j Matrix row index 2 - * - * @return {Matrix} The matrix reference - */ - SparseMatrix.prototype.swapRows = function (i, j) { - // check index - if (!isNumber(i) || !isInteger(i) || !isNumber(j) || !isInteger(j)) { - throw new Error('Row index must be positive integers'); - } - // check dimensions - if (this._size.length !== 2) { - throw new Error('Only two dimensional matrix is supported'); - } - // validate index - validateIndex(i, this._size[0]); - validateIndex(j, this._size[0]); - - // swap rows - SparseMatrix._swapRows(i, j, this._size[1], this._values, this._index, this._ptr); - // return current instance - return this; - }; - - /** - * Loop rows with data in column j. - * - * @param {number} j Column - * @param {Array} values Matrix values - * @param {Array} index Matrix row indeces - * @param {Array} ptr Matrix column pointers - * @param {Function} callback Callback function invoked for every row in column j - */ - SparseMatrix._forEachRow = function (j, values, index, ptr, callback) { - // indeces for column j - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // loop - for (var k = k0; k < k1; k++) { - // invoke callback - callback(index[k], values[k]); - } - }; - - /** - * Swap rows x and y in Sparse Matrix data structures. - * - * @param {number} x Matrix row index 1 - * @param {number} y Matrix row index 2 - * @param {number} columns Number of columns in matrix - * @param {Array} values Matrix values - * @param {Array} index Matrix row indeces - * @param {Array} ptr Matrix column pointers - */ - SparseMatrix._swapRows = function (x, y, columns, values, index, ptr) { - // loop columns - for (var j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // find value index @ x - var kx = _getValueIndex(x, k0, k1, index); - // find value index @ x - var ky = _getValueIndex(y, k0, k1, index); - // check both rows exist in matrix - if (kx < k1 && ky < k1 && index[kx] === x && index[ky] === y) { - // swap values (check for pattern matrix) - if (values) { - var v = values[kx]; - values[kx] = values[ky]; - values[ky] = v; - } - // next column - continue; - } - // check x row exist & no y row - if (kx < k1 && index[kx] === x && (ky >= k1 || index[ky] !== y)) { - // value @ x (check for pattern matrix) - var vx = values ? values[kx] : undefined; - // insert value @ y - index.splice(ky, 0, y); - if (values) - values.splice(ky, 0, vx); - // remove value @ x (adjust array index if needed) - index.splice(ky <= kx ? kx + 1 : kx, 1); - if (values) - values.splice(ky <= kx ? kx + 1 : kx, 1); - // next column - continue; - } - // check y row exist & no x row - if (ky < k1 && index[ky] === y && (kx >= k1 || index[kx] !== x)) { - // value @ y (check for pattern matrix) - var vy = values ? values[ky] : undefined; - // insert value @ x - index.splice(kx, 0, x); - if (values) - values.splice(kx, 0, vy); - // remove value @ y (adjust array index if needed) - index.splice(kx <= ky ? ky + 1 : ky, 1); - if (values) - values.splice(kx <= ky ? ky + 1 : ky, 1); - } - } - }; - - // register this type in the base class Matrix - type.Matrix._storage.sparse = SparseMatrix; - - return SparseMatrix; - } - - exports.name = 'SparseMatrix'; - exports.path = 'type'; - exports.factory = factory; - exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage - - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - /** - * Test whether two values are equal. - * - * @param {number | BigNumber | Fraction | boolean | Complex | Unit} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Complex} y Second value to compare - * @return {boolean} Returns true when the compared values are equal, else returns false - * @private - */ - var equalScalar = typed('equalScalar', { - - 'boolean, boolean': function (x, y) { - return x === y; - }, - - 'number, number': function (x, y) { - return x === y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.eq(y) || bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return x.equals(y); - }, - - 'Complex, Complex': function (x, y) { - return x.equals(y); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return equalScalar(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x === y; - } - }); - - return equalScalar; - } - - exports.factory = factory; - - -/***/ }, -/* 49 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Compares two BigNumbers. - * @param {BigNumber} x First value to compare - * @param {BigNumber} y Second value to compare - * @param {number} [epsilon] The maximum relative difference between x and y - * If epsilon is undefined or null, the function will - * test whether x and y are exactly equal. - * @return {boolean} whether the two numbers are nearly equal - */ - module.exports = function nearlyEqual(x, y, epsilon) { - // if epsilon is null or undefined, test whether x and y are exactly equal - if (epsilon == null) { - return x.eq(y); - } - - - // use "==" operator, handles infinities - if (x.eq(y)) { - return true; - } - - // NaN - if (x.isNaN() || y.isNaN()) { - return false; - } - - // at this point x and y should be finite - if(x.isFinite() && y.isFinite()) { - // check numbers are very close, needed when comparing numbers near zero - var diff = x.minus(y).abs(); - if (diff.isZero()) { - return true; - } - else { - // use relative error - var max = x.constructor.max(x.abs(), y.abs()); - return diff.lte(max.times(epsilon)); - } - } - - // Infinite and Number or negative Infinite and positive Infinite cases - return false; - }; - - -/***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var add = load(__webpack_require__(51)); - var equalScalar = load(__webpack_require__(48)); - - /** - * An ordered Sparse Accumulator is a representation for a sparse vector that includes a dense array - * of the vector elements and an ordered list of non-zero elements. - */ - function Spa() { - if (!(this instanceof Spa)) - throw new SyntaxError('Constructor must be called with the new operator'); - - // allocate vector, TODO use typed arrays - this._values = []; - this._heap = new type.FibonacciHeap(); - } - - /** - * Attach type information - */ - Spa.prototype.type = 'Spa'; - Spa.prototype.isSpa = true; - - /** - * Set the value for index i. - * - * @param {number} i The index - * @param {number | BigNumber | Complex} The value at index i - */ - Spa.prototype.set = function (i, v) { - // check we have a value @ i - if (!this._values[i]) { - // insert in heap - var node = this._heap.insert(i, v); - // set the value @ i - this._values[i] = node; - } - else { - // update the value @ i - this._values[i].value = v; - } - }; - - Spa.prototype.get = function (i) { - var node = this._values[i]; - if (node) - return node.value; - return 0; - }; - - Spa.prototype.accumulate = function (i, v) { - // node @ i - var node = this._values[i]; - if (!node) { - // insert in heap - node = this._heap.insert(i, v); - // initialize value - this._values[i] = node; - } - else { - // accumulate value - node.value = add(node.value, v); - } - }; - - Spa.prototype.forEach = function (from, to, callback) { - // references - var heap = this._heap; - var values = this._values; - // nodes - var nodes = []; - // node with minimum key, save it - var node = heap.extractMinimum(); - if (node) - nodes.push(node); - // extract nodes from heap (ordered) - while (node && node.key <= to) { - // check it is in range - if (node.key >= from) { - // check value is not zero - if (!equalScalar(node.value, 0)) { - // invoke callback - callback(node.key, node.value, this); - } - } - // extract next node, save it - node = heap.extractMinimum(); - if (node) - nodes.push(node); - } - // reinsert all nodes in heap - for (var i = 0; i < nodes.length; i++) { - // current node - var n = nodes[i]; - // insert node in heap - node = heap.insert(n.key, n.value); - // update values - values[node.key] = node; - } - }; - - Spa.prototype.swap = function (i, j) { - // node @ i and j - var nodei = this._values[i]; - var nodej = this._values[j]; - // check we need to insert indeces - if (!nodei && nodej) { - // insert in heap - nodei = this._heap.insert(i, nodej.value); - // remove from heap - this._heap.remove(nodej); - // set values - this._values[i] = nodei; - this._values[j] = undefined; - } - else if (nodei && !nodej) { - // insert in heap - nodej = this._heap.insert(j, nodei.value); - // remove from heap - this._heap.remove(nodei); - // set values - this._values[j] = nodej; - this._values[i] = undefined; - } - else if (nodei && nodej) { - // swap values - var v = nodei.value; - nodei.value = nodej.value; - nodej.value = v; - } - }; - - return Spa; - } - - exports.name = 'Spa'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 51 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var extend = __webpack_require__(3).extend; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var addScalar = load(__webpack_require__(53)); - var latex = __webpack_require__(32); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm04 = load(__webpack_require__(55)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Add two values, `x + y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.add(x, y) - * - * Examples: - * - * math.add(2, 3); // returns number 5 - * - * var a = math.complex(2, 3); - * var b = math.complex(-4, 1); - * math.add(a, b); // returns Complex -2 + 4i - * - * math.add([1, 2, 3], 4); // returns Array [5, 6, 7] - * - * var c = math.unit('5 cm'); - * var d = math.unit('2.1 mm'); - * math.add(c, d); // returns Unit 52.1 mm - * - * math.add("2.3", "4"); // returns number 6.3 - * - * See also: - * - * subtract - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First value to add - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second value to add - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Sum of `x` and `y` - */ - var add = typed('add', extend({ - // we extend the signatures of addScalar with signatures dealing with matrices - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm04(x, y, addScalar); - break; - default: - // sparse + dense - c = algorithm01(y, x, addScalar, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm01(x, y, addScalar, false); - break; - default: - // dense + dense - c = algorithm13(x, y, addScalar); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return add(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return add(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return add(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm10(x, y, addScalar, false); - break; - default: - c = algorithm14(x, y, addScalar, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, addScalar, true); - break; - default: - c = algorithm14(y, x, addScalar, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, addScalar, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, addScalar, true).valueOf(); - } - }, addScalar.signatures)); - - add.toTex = { - 2: '\\left(${args[0]}' + latex.operators['add'] + '${args[1]}\\right)' - }; - - return add; - } - - exports.name = 'add'; - exports.factory = factory; - - -/***/ }, -/* 52 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create a Matrix. The function creates a new `math.type.Matrix` object from - * an `Array`. A Matrix has utility functions to manipulate the data in the - * matrix, like getting the size and getting or setting values in the matrix. - * Supported storage formats are 'dense' and 'sparse'. - * - * Syntax: - * - * math.matrix() // creates an empty matrix using default storage format (dense). - * math.matrix(data) // creates a matrix with initial data using default storage format (dense). - * math.matrix('dense') // creates an empty matrix using the given storage format. - * math.matrix(data, 'dense') // creates a matrix with initial data using the given storage format. - * math.matrix(data, 'sparse') // creates a sparse matrix with initial data. - * math.matrix(data, 'sparse', 'number') // creates a sparse matrix with initial data, number data type. - * - * Examples: - * - * var m = math.matrix([[1, 2], [3, 4]]); - * m.size(); // Array [2, 2] - * m.resize([3, 2], 5); - * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] - * m.get([1, 0]) // number 3 - * - * See also: - * - * bignumber, boolean, complex, index, number, string, unit, sparse - * - * @param {Array | Matrix} [data] A multi dimensional array - * @param {string} [format] The Matrix storage format - * - * @return {Matrix} The created matrix - */ - var matrix = typed('matrix', { - '': function () { - return _create([]); - }, - - 'string': function (format) { - return _create([], format); - }, - - 'string, string': function (format, datatype) { - return _create([], format, datatype); - }, - - 'Array': function (data) { - return _create(data); - }, - - 'Matrix': function (data) { - return _create(data, data.storage()); - }, - - 'Array | Matrix, string': _create, - - 'Array | Matrix, string, string': _create - }); - - matrix.toTex = { - 0: '\\begin{bmatrix}\\end{bmatrix}', - 1: '\\left(${args[0]}\\right)', - 2: '\\left(${args[0]}\\right)' - }; - - return matrix; - - /** - * Create a new Matrix with given storage format - * @param {Array} data - * @param {string} [format] - * @param {string} [datatype] - * @returns {Matrix} Returns a new Matrix - * @private - */ - function _create(data, format, datatype) { - // get storage format constructor - var M = type.Matrix.storage(format || 'default'); - - // create instance - return new M(data, datatype); - } - } - - exports.name = 'matrix'; - exports.factory = factory; - - -/***/ }, -/* 53 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory(type, config, load, typed) { - - /** - * Add two scalar values, `x + y`. - * This function is meant for internal use: it is used by the public function - * `add` - * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. - * - * @param {number | BigNumber | Fraction | Complex | Unit} x First value to add - * @param {number | BigNumber | Fraction | Complex} y Second value to add - * @return {number | BigNumber | Fraction | Complex | Unit} Sum of `x` and `y` - * @private - */ - var add = typed('add', { - - 'number, number': function (x, y) { - return x + y; - }, - - 'Complex, Complex': function (x, y) { - return x.add(y); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.plus(y); - }, - - 'Fraction, Fraction': function (x, y) { - return x.add(y); - }, - - 'Unit, Unit': function (x, y) { - if (x.value == null) throw new Error('Parameter x contains a unit with undefined value'); - if (y.value == null) throw new Error('Parameter y contains a unit with undefined value'); - if (!x.equalBase(y)) throw new Error('Units do not match'); - - var res = x.clone(); - res.value = add(res.value, y.value); - res.fixPrefix = false; - return res; - } - }); - - return add; - } - - exports.factory = factory; - - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). - * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). - * - * - * ┌ f(Dij, Sij) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ Dij ; otherwise - * - * - * @param {Matrix} denseMatrix The DenseMatrix instance (D) - * @param {Matrix} sparseMatrix The SparseMatrix instance (S) - * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) - * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) - * - * @return {Matrix} DenseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 - */ - var algorithm01 = function (denseMatrix, sparseMatrix, callback, inverse) { - // dense matrix arrays - var adata = denseMatrix._data; - var asize = denseMatrix._size; - var adt = denseMatrix._datatype; - // sparse matrix arrays - var bvalues = sparseMatrix._values; - var bindex = sparseMatrix._index; - var bptr = sparseMatrix._ptr; - var bsize = sparseMatrix._size; - var bdt = sparseMatrix._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // sparse matrix cannot be a Pattern matrix - if (!bvalues) - throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // process data types - var dt = typeof adt === 'string' && adt === bdt ? adt : undefined; - // callback function - var cf = dt ? typed.find(callback, [dt, dt]) : callback; - - // vars - var i, j; - - // result (DenseMatrix) - var cdata = []; - // initialize c - for (i = 0; i < rows; i++) - cdata[i] = []; - - // workspace - var x = []; - // marks indicating we have a value in x for a given column - var w = []; - - // loop columns in b - for (j = 0; j < columns; j++) { - // column mark - var mark = j + 1; - // values in column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - i = bindex[k]; - // update workspace - x[i] = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); - // mark i as updated - w[i] = mark; - } - // loop rows - for (i = 0; i < rows; i++) { - // check row is in workspace - if (w[i] === mark) { - // c[i][j] was already calculated - cdata[i][j] = x[i]; - } - else { - // item does not exist in S - cdata[i][j] = adata[i][j]; - } - } - } - - // return dense matrix - return new DenseMatrix({ - data: cdata, - size: [rows, columns], - datatype: dt - }); - }; - - return algorithm01; - } - - exports.name = 'algorithm01'; - exports.factory = factory; - - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). - * Callback function invoked MAX(NNZA, NNZB) times - * - * - * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 - * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 - * └ B(i,j) ; B(i,j) !== 0 - * - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm04 = function (a, b, callback) { - // sparse matrix arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = avalues && bvalues ? [] : undefined; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // workspace - var xa = avalues && bvalues ? [] : undefined; - var xb = avalues && bvalues ? [] : undefined; - // marks indicating we have a value in x for a given column - var wa = []; - var wb = []; - - // vars - var i, j, k, k0, k1; - - // loop columns - for (j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // columns mark - var mark = j + 1; - // loop A(:,j) - for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - i = aindex[k]; - // update c - cindex.push(i); - // update workspace - wa[i] = mark; - // check we need to process values - if (xa) - xa[i] = avalues[k]; - } - // loop B(:,j) - for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - i = bindex[k]; - // check row exists in A - if (wa[i] === mark) { - // update record in xa @ i - if (xa) { - // invoke callback - var v = cf(xa[i], bvalues[k]); - // check for zero - if (!eq(v, zero)) { - // update workspace - xa[i] = v; - } - else { - // remove mark (index will be removed later) - wa[i] = null; - } - } - } - else { - // update c - cindex.push(i); - // update workspace - wb[i] = mark; - // check we need to process values - if (xb) - xb[i] = bvalues[k]; - } - } - // check we need to process values (non pattern matrix) - if (xa && xb) { - // initialize first index in j - k = cptr[j]; - // loop index in j - while (k < cindex.length) { - // row - i = cindex[k]; - // check workspace has value @ i - if (wa[i] === mark) { - // push value (Aij != 0 || (Aij != 0 && Bij != 0)) - cvalues[k] = xa[i]; - // increment pointer - k++; - } - else if (wb[i] === mark) { - // push value (bij != 0) - cvalues[k] = xb[i]; - // increment pointer - k++; - } - else { - // remove index @ k - cindex.splice(k, 1); - } - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm04; - } - - exports.name = 'algorithm04'; - exports.factory = factory; - - -/***/ }, -/* 56 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). - * Callback function invoked NZ times (number of nonzero items in S). - * - * - * ┌ f(Sij, b) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ b ; otherwise - * - * - * @param {Matrix} s The SparseMatrix instance (S) - * @param {Scalar} b The Scalar value - * @param {Function} callback The f(Aij,b) operation to invoke - * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) - * - * @return {Matrix} DenseMatrix (C) - * - * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 - */ - var algorithm10 = function (s, b, callback, inverse) { - // sparse matrix arrays - var avalues = s._values; - var aindex = s._index; - var aptr = s._ptr; - var asize = s._size; - var adt = s._datatype; - - // sparse matrix cannot be a Pattern matrix - if (!avalues) - throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string') { - // datatype - dt = adt; - // convert b to the same datatype - b = typed.convert(b, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cdata = []; - // matrix - var c = new DenseMatrix({ - data: cdata, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var x = []; - // marks indicating we have a value in x for a given column - var w = []; - - // loop columns - for (var j = 0; j < columns; j++) { - // columns mark - var mark = j + 1; - // values in j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - var r = aindex[k]; - // update workspace - x[r] = avalues[k]; - w[r] = mark; - } - // loop rows - for (var i = 0; i < rows; i++) { - // initialize C on first column - if (j === 0) { - // create row array - cdata[i] = []; - } - // check sparse matrix has a value @ i,j - if (w[i] === mark) { - // invoke callback, update C - cdata[i][j] = inverse ? cf(b, x[i]) : cf(x[i], b); - } - else { - // dense matrix value @ i, j - cdata[i][j] = b; - } - } - } - - // return sparse matrix - return c; - }; - - return algorithm10; - } - - exports.name = 'algorithm10'; - exports.factory = factory; - - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - var DimensionError = __webpack_require__(42); - - var string = util.string, - isString = string.isString; - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, Bij..z). - * Callback function invoked MxN times. - * - * C(i,j,...z) = f(Aij..z, Bij..z) - * - * @param {Matrix} a The DenseMatrix instance (A) - * @param {Matrix} b The DenseMatrix instance (B) - * @param {Function} callback The f(Aij..z,Bij..z) operation to invoke - * - * @return {Matrix} DenseMatrix (C) - * - * https://github.com/josdejong/mathjs/pull/346#issuecomment-97658658 - */ - var algorithm13 = function (a, b, callback) { - // a arrays - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b arrays - var bdata = b._data; - var bsize = b._size; - var bdt = b._datatype; - // c arrays - var csize = []; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // validate each one of the dimension sizes - for (var s = 0; s < asize.length; s++) { - // must match - if (asize[s] !== bsize[s]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // update dimension in c - csize[s] = asize[s]; - } - - // datatype - var dt; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // convert b to the same datatype - b = typed.convert(b, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // populate cdata, iterate through dimensions - var cdata = csize.length > 0 ? _iterate(cf, 0, csize, csize[0], adata, bdata) : []; - - // c matrix - return new DenseMatrix({ - data: cdata, - size: csize, - datatype: dt - }); - }; - - // recursive function - var _iterate = function (f, level, s, n, av, bv) { - // initialize array for this level - var cv = []; - // check we reach the last level - if (level === s.length - 1) { - // loop arrays in last level - for (var i = 0; i < n; i++) { - // invoke callback and store value - cv[i] = f(av[i], bv[i]); - } - } - else { - // iterate current level - for (var j = 0; j < n; j++) { - // iterate next level - cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv[j]); - } - } - return cv; - }; - - return algorithm13; - } - - exports.name = 'algorithm13'; - exports.factory = factory; - - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, b). - * Callback function invoked MxN times. - * - * C(i,j,...z) = f(Aij..z, b) - * - * @param {Matrix} a The DenseMatrix instance (A) - * @param {Scalar} b The Scalar value - * @param {Function} callback The f(Aij..z,b) operation to invoke - * @param {boolean} inverse A true value indicates callback should be invoked f(b,Aij..z) - * - * @return {Matrix} DenseMatrix (C) - * - * https://github.com/josdejong/mathjs/pull/346#issuecomment-97659042 - */ - var algorithm14 = function (a, b, callback, inverse) { - // a arrays - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - - // datatype - var dt; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string') { - // datatype - dt = adt; - // convert b to the same datatype - b = typed.convert(b, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // populate cdata, iterate through dimensions - var cdata = asize.length > 0 ? _iterate(cf, 0, asize, asize[0], adata, b, inverse) : []; - - // c matrix - return new DenseMatrix({ - data: cdata, - size: clone(asize), - datatype: dt - }); - }; - - // recursive function - var _iterate = function (f, level, s, n, av, bv, inverse) { - // initialize array for this level - var cv = []; - // check we reach the last level - if (level === s.length - 1) { - // loop arrays in last level - for (var i = 0; i < n; i++) { - // invoke callback and store value - cv[i] = inverse ? f(bv, av[i]) : f(av[i], bv); - } - } - else { - // iterate current level - for (var j = 0; j < n; j++) { - // iterate next level - cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv, inverse); - } - } - return cv; - }; - - return algorithm14; - } - - exports.name = 'algorithm14'; - exports.factory = factory; - - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var smaller = load(__webpack_require__(60)); - var larger = load(__webpack_require__(64)); - - var oneOverLogPhi = 1.0 / Math.log((1.0 + Math.sqrt(5.0)) / 2.0); - - /** - * Fibonacci Heap implementation, used interally for Matrix math. - * @class FibonacciHeap - * @constructor FibonacciHeap - */ - function FibonacciHeap() { - if (!(this instanceof FibonacciHeap)) - throw new SyntaxError('Constructor must be called with the new operator'); - - // initialize fields - this._minimum = null; - this._size = 0; - } - - /** - * Attach type information - */ - FibonacciHeap.prototype.type = 'FibonacciHeap'; - FibonacciHeap.prototype.isFibonacciHeap = true; - - /** - * Inserts a new data element into the heap. No heap consolidation is - * performed at this time, the new node is simply inserted into the root - * list of this heap. Running time: O(1) actual. - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.insert = function (key, value) { - // create node - var node = { - key: key, - value: value, - degree: 0 - }; - // check we have a node in the minimum - if (this._minimum) { - // minimum node - var minimum = this._minimum; - // update left & right of node - node.left = minimum; - node.right = minimum.right; - minimum.right = node; - node.right.left = node; - // update minimum node in heap if needed - if (smaller(key, minimum.key)) { - // node has a smaller key, use it as minimum - this._minimum = node; - } - } - else { - // set left & right - node.left = node; - node.right = node; - // this is the first node - this._minimum = node; - } - // increment number of nodes in heap - this._size++; - // return node - return node; - }; - - /** - * Returns the number of nodes in heap. Running time: O(1) actual. - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.size = function () { - return this._size; - }; - - /** - * Removes all elements from this heap. - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.clear = function () { - this._minimum = null; - this._size = 0; - }; - - /** - * Returns true if the heap is empty, otherwise false. - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.isEmpty = function () { - return !!this._minimum; - }; - - /** - * Extracts the node with minimum key from heap. Amortized running - * time: O(log n). - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.extractMinimum = function () { - // node to remove - var node = this._minimum; - // check we have a minimum - if (node === null) - return node; - // current minimum - var minimum = this._minimum; - // get number of children - var numberOfChildren = node.degree; - // pointer to the first child - var x = node.child; - // for each child of node do... - while (numberOfChildren > 0) { - // store node in right side - var tempRight = x.right; - // remove x from child list - x.left.right = x.right; - x.right.left = x.left; - // add x to root list of heap - x.left = minimum; - x.right = minimum.right; - minimum.right = x; - x.right.left = x; - // set Parent[x] to null - x.parent = null; - x = tempRight; - numberOfChildren--; - } - // remove node from root list of heap - node.left.right = node.right; - node.right.left = node.left; - // update minimum - if (node == node.right) { - // empty - minimum = null; - } - else { - // update minimum - minimum = node.right; - // we need to update the pointer to the root with minimum key - minimum = _findMinimumNode(minimum, this._size); - } - // decrement size of heap - this._size--; - // update minimum - this._minimum = minimum; - // return node - return node; - }; - - /** - * Removes a node from the heap given the reference to the node. The trees - * in the heap will be consolidated, if necessary. This operation may fail - * to remove the correct element if there are nodes with key value -Infinity. - * Running time: O(log n) amortized. - * @memberof FibonacciHeap - */ - FibonacciHeap.prototype.remove = function (node) { - // decrease key value - this._minimum = _decreaseKey(this._minimum, node, -1); - // remove the smallest - this.extractMinimum(); - }; - - /** - * Decreases the key value for a heap node, given the new value to take on. - * The structure of the heap may be changed and will not be consolidated. - * Running time: O(1) amortized. - * @memberof FibonacciHeap - */ - var _decreaseKey = function (minimum, node, key) { - // set node key - node.key = key; - // get parent node - var parent = node.parent; - if (parent && smaller(node.key, parent.key)) { - // remove node from parent - _cut(minimum, node, parent); - // remove all nodes from parent to the root parent - _cascadingCut(minimum, parent); - } - // update minimum node if needed - if (smaller(node.key, minimum.key)) - minimum = node; - // return minimum - return minimum; - }; - - /** - * The reverse of the link operation: removes node from the child list of parent. - * This method assumes that min is non-null. Running time: O(1). - * @memberof FibonacciHeap - */ - var _cut = function (minimum, node, parent) { - // remove node from parent children and decrement Degree[parent] - node.left.right = node.right; - node.right.left = node.left; - parent.degree--; - // reset y.child if necessary - if (parent.child == node) - parent.child = node.right; - // remove child if degree is 0 - if (parent.degree === 0) - parent.child = null; - // add node to root list of heap - node.left = minimum; - node.right = minimum.right; - minimum.right = node; - node.right.left = node; - // set parent[node] to null - node.parent = null; - // set mark[node] to false - node.mark = false; - }; - - /** - * Performs a cascading cut operation. This cuts node from its parent and then - * does the same for its parent, and so on up the tree. - * Running time: O(log n); O(1) excluding the recursion. - * @memberof FibonacciHeap - */ - var _cascadingCut= function (minimum, node) { - // store parent node - var parent = node.parent; - // if there's a parent... - if (!parent) - return; - // if node is unmarked, set it marked - if (!node.mark) { - node.mark = true; - } - else { - // it's marked, cut it from parent - _cut(minimum, node, parent); - // cut its parent as well - _cascadingCut(parent); - } - }; - - /** - * Make the first node a child of the second one. Running time: O(1) actual. - * @memberof FibonacciHeap - */ - var _linkNodes = function (node, parent) { - // remove node from root list of heap - node.left.right = node.right; - node.right.left = node.left; - // make node a Child of parent - node.parent = parent; - if (!parent.child) { - parent.child = node; - node.right = node; - node.left = node; - } - else { - node.left = parent.child; - node.right = parent.child.right; - parent.child.right = node; - node.right.left = node; - } - // increase degree[parent] - parent.degree++; - // set mark[node] false - node.mark = false; - }; - - var _findMinimumNode = function (minimum, size) { - // to find trees of the same degree efficiently we use an array of length O(log n) in which we keep a pointer to one root of each degree - var arraySize = Math.floor(Math.log(size) * oneOverLogPhi) + 1; - // create list with initial capacity - var array = new Array(arraySize); - // find the number of root nodes. - var numRoots = 0; - var x = minimum; - if (x) { - numRoots++; - x = x.right; - while (x !== minimum) { - numRoots++; - x = x.right; - } - } - // vars - var y; - // For each node in root list do... - while (numRoots > 0) { - // access this node's degree.. - var d = x.degree; - // get next node - var next = x.right; - // check if there is a node already in array with the same degree - while (true) { - // get node with the same degree is any - y = array[d]; - if (!y) - break; - // make one node with the same degree a child of the other, do this based on the key value. - if (larger(x.key, y.key)) { - var temp = y; - y = x; - x = temp; - } - // make y a child of x - _linkNodes(y, x); - // we have handled this degree, go to next one. - array[d] = null; - d++; - } - // save this node for later when we might encounter another of the same degree. - array[d] = x; - // move forward through list. - x = next; - numRoots--; - } - // Set min to null (effectively losing the root list) and reconstruct the root list from the array entries in array[]. - minimum = null; - // loop nodes in array - for (var i = 0; i < arraySize; i++) { - // get current node - y = array[i]; - if (!y) - continue; - // check if we have a linked list - if (minimum) { - // First remove node from root list. - y.left.right = y.right; - y.right.left = y.left; - // now add to root list, again. - y.left = minimum; - y.right = minimum.right; - minimum.right = y; - y.right.left = y; - // check if this is a new min. - if (smaller(y.key, minimum.key)) - minimum = y; - } - else - minimum = y; - } - return minimum; - }; - - return FibonacciHeap; - } - - exports.name = 'FibonacciHeap'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether value x is smaller than y. - * - * The function returns true when x is smaller than y and the relative - * difference between x and y is smaller than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.smaller(x, y) - * - * Examples: - * - * math.smaller(2, 3); // returns true - * math.smaller(5, 2 * 2); // returns false - * - * var a = math.unit('5 cm'); - * var b = math.unit('2 inch'); - * math.smaller(a, b); // returns true - * - * See also: - * - * equal, unequal, smallerEq, smaller, smallerEq, compare - * - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false - */ - var smaller = typed('smaller', { - - 'boolean, boolean': function (x, y) { - return x < y; - }, - - 'number, number': function (x, y) { - return x < y && !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.lt(y) && !bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return x.compare(y) === -1; - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return smaller(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x < y; - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, smaller); - break; - default: - // sparse + dense - c = algorithm03(y, x, smaller, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, smaller, false); - break; - default: - // dense + dense - c = algorithm13(x, y, smaller); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return smaller(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return smaller(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return smaller(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, smaller, false); - break; - default: - c = algorithm14(x, y, smaller, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, smaller, true); - break; - default: - c = algorithm14(y, x, smaller, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, smaller, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, smaller, true).valueOf(); - } - }); - - smaller.toTex = { - 2: '\\left(${args[0]}' + latex.operators['smaller'] + '${args[1]}\\right)' - }; - - return smaller; - } - - exports.name = 'smaller'; - exports.factory = factory; - - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over SparseMatrix items and invokes the callback function f(Dij, Sij). - * Callback function invoked M*N times. - * - * - * ┌ f(Dij, Sij) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ f(Dij, 0) ; otherwise - * - * - * @param {Matrix} denseMatrix The DenseMatrix instance (D) - * @param {Matrix} sparseMatrix The SparseMatrix instance (C) - * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) - * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) - * - * @return {Matrix} DenseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 - */ - var algorithm03 = function (denseMatrix, sparseMatrix, callback, inverse) { - // dense matrix arrays - var adata = denseMatrix._data; - var asize = denseMatrix._size; - var adt = denseMatrix._datatype; - // sparse matrix arrays - var bvalues = sparseMatrix._values; - var bindex = sparseMatrix._index; - var bptr = sparseMatrix._ptr; - var bsize = sparseMatrix._size; - var bdt = sparseMatrix._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // sparse matrix cannot be a Pattern matrix - if (!bvalues) - throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result (DenseMatrix) - var cdata = []; - - // initialize dense matrix - for (var z = 0; z < rows; z++) { - // initialize row - cdata[z] = []; - } - - // workspace - var x = []; - // marks indicating we have a value in x for a given column - var w = []; - - // loop columns in b - for (var j = 0; j < columns; j++) { - // column mark - var mark = j + 1; - // values in column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - var i = bindex[k]; - // update workspace - x[i] = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); - w[i] = mark; - } - // process workspace - for (var y = 0; y < rows; y++) { - // check we have a calculated value for current row - if (w[y] === mark) { - // use calculated value - cdata[y][j] = x[y]; - } - else { - // calculate value - cdata[y][j] = inverse ? cf(zero, adata[y][j]) : cf(adata[y][j], zero); - } - } - } - - // return dense matrix - return new DenseMatrix({ - data: cdata, - size: [rows, columns], - datatype: dt - }); - }; - - return algorithm03; - } - - exports.name = 'algorithm03'; - exports.factory = factory; - - -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over SparseMatrix A and SparseMatrix B items (zero and nonzero) and invokes the callback function f(Aij, Bij). - * Callback function invoked MxN times. - * - * C(i,j) = f(Aij, Bij) - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} DenseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm07 = function (a, b, callback) { - // sparse matrix arrays - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // vars - var i, j; - - // result arrays - var cdata = []; - // initialize c - for (i = 0; i < rows; i++) - cdata[i] = []; - - // matrix - var c = new DenseMatrix({ - data: cdata, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var xa = []; - var xb = []; - // marks indicating we have a value in x for a given column - var wa = []; - var wb = []; - - // loop columns - for (j = 0; j < columns; j++) { - // columns mark - var mark = j + 1; - // scatter the values of A(:,j) into workspace - _scatter(a, j, wa, xa, mark); - // scatter the values of B(:,j) into workspace - _scatter(b, j, wb, xb, mark); - // loop rows - for (i = 0; i < rows; i++) { - // matrix values @ i,j - var va = wa[i] === mark ? xa[i] : zero; - var vb = wb[i] === mark ? xb[i] : zero; - // invoke callback - cdata[i][j] = cf(va, vb); - } - } - - // return sparse matrix - return c; - }; - - var _scatter = function (m, j, w, x, mark) { - // a arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // loop values in column j - for (var k = ptr[j], k1 = ptr[j + 1]; k < k1; k++) { - // row - var i = index[k]; - // update workspace - w[i] = mark; - x[i] = values[k]; - } - }; - - return algorithm07; - } - - exports.name = 'algorithm07'; - exports.factory = factory; - - -/***/ }, -/* 63 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). - * Callback function invoked MxN times. - * - * - * ┌ f(Sij, b) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ f(0, b) ; otherwise - * - * - * @param {Matrix} s The SparseMatrix instance (S) - * @param {Scalar} b The Scalar value - * @param {Function} callback The f(Aij,b) operation to invoke - * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) - * - * @return {Matrix} DenseMatrix (C) - * - * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 - */ - var algorithm12 = function (s, b, callback, inverse) { - // sparse matrix arrays - var avalues = s._values; - var aindex = s._index; - var aptr = s._ptr; - var asize = s._size; - var adt = s._datatype; - - // sparse matrix cannot be a Pattern matrix - if (!avalues) - throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string') { - // datatype - dt = adt; - // convert b to the same datatype - b = typed.convert(b, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cdata = []; - // matrix - var c = new DenseMatrix({ - data: cdata, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var x = []; - // marks indicating we have a value in x for a given column - var w = []; - - // loop columns - for (var j = 0; j < columns; j++) { - // columns mark - var mark = j + 1; - // values in j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - var r = aindex[k]; - // update workspace - x[r] = avalues[k]; - w[r] = mark; - } - // loop rows - for (var i = 0; i < rows; i++) { - // initialize C on first column - if (j === 0) { - // create row array - cdata[i] = []; - } - // check sparse matrix has a value @ i,j - if (w[i] === mark) { - // invoke callback, update C - cdata[i][j] = inverse ? cf(b, x[i]) : cf(x[i], b); - } - else { - // dense matrix value @ i, j - cdata[i][j] = inverse ? cf(b, 0) : cf(0, b); - } - } - } - - // return sparse matrix - return c; - }; - - return algorithm12; - } - - exports.name = 'algorithm12'; - exports.factory = factory; - - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether value x is larger than y. - * - * The function returns true when x is larger than y and the relative - * difference between x and y is larger than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.larger(x, y) - * - * Examples: - * - * math.larger(2, 3); // returns false - * math.larger(5, 2 + 2); // returns true - * - * var a = math.unit('5 cm'); - * var b = math.unit('2 inch'); - * math.larger(a, b); // returns false - * - * See also: - * - * equal, unequal, smaller, smallerEq, largerEq, compare - * - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the x is larger than y, else returns false - */ - var larger = typed('larger', { - - 'boolean, boolean': function (x, y) { - return x > y; - }, - - 'number, number': function (x, y) { - return x > y && !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.gt(y) && !bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return x.compare(y) === 1; - }, - - 'Complex, Complex': function () { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return larger(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x > y; - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, larger); - break; - default: - // sparse + dense - c = algorithm03(y, x, larger, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, larger, false); - break; - default: - // dense + dense - c = algorithm13(x, y, larger); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return larger(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return larger(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return larger(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, larger, false); - break; - default: - c = algorithm14(x, y, larger, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, larger, true); - break; - default: - c = algorithm14(y, x, larger, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, larger, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, larger, true).valueOf(); - } - }); - - larger.toTex = { - 2: '\\left(${args[0]}' + latex.operators['larger'] + '${args[1]}\\right)' - }; - - return larger; - } - - exports.name = 'larger'; - exports.factory = factory; - - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - - var string = util.string; - var object = util.object; - - var isArray = Array.isArray; - var isString = string.isString; - - function factory (type, config, load) { - - var DenseMatrix = load(__webpack_require__(46)); - - var smaller = load(__webpack_require__(60)); - - function ImmutableDenseMatrix(data, datatype) { - if (!(this instanceof ImmutableDenseMatrix)) - throw new SyntaxError('Constructor must be called with the new operator'); - if (datatype && !isString(datatype)) - throw new Error('Invalid datatype: ' + datatype); - - if ((data && data.isMatrix === true) || isArray(data)) { - // use DenseMatrix implementation - var matrix = new DenseMatrix(data, datatype); - // internal structures - this._data = matrix._data; - this._size = matrix._size; - this._datatype = matrix._datatype; - this._min = null; - this._max = null; - } - else if (data && isArray(data.data) && isArray(data.size)) { - // initialize fields from JSON representation - this._data = data.data; - this._size = data.size; - this._datatype = data.datatype; - this._min = typeof data.min !== 'undefined' ? data.min : null; - this._max = typeof data.max !== 'undefined' ? data.max : null; - } - else if (data) { - // unsupported type - throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); - } - else { - // nothing provided - this._data = []; - this._size = [0]; - this._datatype = datatype; - this._min = null; - this._max = null; - } - } - - ImmutableDenseMatrix.prototype = new DenseMatrix(); - - /** - * Attach type information - */ - ImmutableDenseMatrix.prototype.type = 'ImmutableDenseMatrix'; - ImmutableDenseMatrix.prototype.isImmutableDenseMatrix = true; - - /** - * Get a subset of the matrix, or replace a subset of the matrix. - * - * Usage: - * var subset = matrix.subset(index) // retrieve subset - * var value = matrix.subset(index, replacement) // replace subset - * - * @param {Index} index - * @param {Array | ImmutableDenseMatrix | *} [replacement] - * @param {*} [defaultValue=0] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be filled with zeros. - */ - ImmutableDenseMatrix.prototype.subset = function (index) { - switch (arguments.length) { - case 1: - // use base implementation - var m = DenseMatrix.prototype.subset.call(this, index); - // check result is a matrix - if (m.isMatrix) { - // return immutable matrix - return new ImmutableDenseMatrix({ - data: m._data, - size: m._size, - datatype: m._datatype - }); - } - return m; - - // intentional fall through - case 2: - case 3: - throw new Error('Cannot invoke set subset on an Immutable Matrix instance'); - - default: - throw new SyntaxError('Wrong number of arguments'); - } - }; - - /** - * Replace a single element in the matrix. - * @param {Number[]} index Zero-based index - * @param {*} value - * @param {*} [defaultValue] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * new matrix elements will be left undefined. - * @return {ImmutableDenseMatrix} self - */ - ImmutableDenseMatrix.prototype.set = function () { - throw new Error('Cannot invoke set on an Immutable Matrix instance'); - }; - - /** - * Resize the matrix to the given size. Returns a copy of the matrix when - * `copy=true`, otherwise return the matrix itself (resize in place). - * - * @param {Number[]} size The new size the matrix should have. - * @param {*} [defaultValue=0] Default value, filled in on new entries. - * If not provided, the matrix elements will - * be filled with zeros. - * @param {boolean} [copy] Return a resized copy of the matrix - * - * @return {Matrix} The resized matrix - */ - ImmutableDenseMatrix.prototype.resize = function () { - throw new Error('Cannot invoke resize on an Immutable Matrix instance'); - }; - - /** - * Create a clone of the matrix - * @return {ImmutableDenseMatrix} clone - */ - ImmutableDenseMatrix.prototype.clone = function () { - var m = new ImmutableDenseMatrix({ - data: object.clone(this._data), - size: object.clone(this._size), - datatype: this._datatype - }); - return m; - }; - - /** - * Get a JSON representation of the matrix - * @returns {Object} - */ - ImmutableDenseMatrix.prototype.toJSON = function () { - return { - mathjs: 'ImmutableDenseMatrix', - data: this._data, - size: this._size, - datatype: this._datatype - }; - }; - - /** - * Generate a matrix from a JSON object - * @param {Object} json An object structured like - * `{"mathjs": "ImmutableDenseMatrix", data: [], size: []}`, - * where mathjs is optional - * @returns {ImmutableDenseMatrix} - */ - ImmutableDenseMatrix.fromJSON = function (json) { - return new ImmutableDenseMatrix(json); - }; - - /** - * Swap rows i and j in Matrix. - * - * @param {Number} i Matrix row index 1 - * @param {Number} j Matrix row index 2 - * - * @return {Matrix} The matrix reference - */ - ImmutableDenseMatrix.prototype.swapRows = function () { - throw new Error('Cannot invoke swapRows on an Immutable Matrix instance'); - }; - - /** - * Calculate the minimum value in the set - * @return {Number | undefined} min - */ - ImmutableDenseMatrix.prototype.min = function () { - // check min has been calculated before - if (this._min === null) { - // minimum - var m = null; - // compute min - this.forEach(function (v) { - if (m === null || smaller(v, m)) - m = v; - }); - this._min = m !== null ? m : undefined; - } - return this._min; - }; - - /** - * Calculate the maximum value in the set - * @return {Number | undefined} max - */ - ImmutableDenseMatrix.prototype.max = function () { - // check max has been calculated before - if (this._max === null) { - // maximum - var m = null; - // compute max - this.forEach(function (v) { - if (m === null || smaller(m, v)) - m = v; - }); - this._max = m !== null ? m : undefined; - } - return this._max; - }; - - // exports - return ImmutableDenseMatrix; - } - - exports.name = 'ImmutableDenseMatrix'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var isInteger = __webpack_require__(6).isInteger; - - function factory (type) { - - /** - * Create an index. An Index can store ranges and sets for multiple dimensions. - * Matrix.get, Matrix.set, and math.subset accept an Index as input. - * - * Usage: - * var index = new Index(range1, range2, matrix1, array1, ...); - * - * Where each parameter can be any of: - * A number - * A string (containing a name of an object property) - * An instance of Range - * An Array with the Set values - * A Matrix with the Set values - * - * The parameters start, end, and step must be integer numbers. - * - * @class Index - * @Constructor Index - * @param {...*} ranges - */ - function Index(ranges) { - if (!(this instanceof Index)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this._dimensions = []; - this._isScalar = true; - - for (var i = 0, ii = arguments.length; i < ii; i++) { - var arg = arguments[i]; - - if (arg && (arg.isRange === true)) { - this._dimensions.push(arg); - this._isScalar = false; - } - else if (arg && (Array.isArray(arg) || arg.isMatrix === true)) { - // create matrix - var m = _createImmutableMatrix(arg.valueOf()); - this._dimensions.push(m); - // size - var size = m.size(); - // scalar - if (size.length !== 1 || size[0] !== 1) { - this._isScalar = false; - } - } - else if (typeof arg === 'number') { - this._dimensions.push(_createImmutableMatrix([arg])); - } - else if (typeof arg === 'string') { - // object property (arguments.count should be 1) - this._dimensions.push(arg); - } - // TODO: implement support for wildcard '*' - else { - throw new TypeError('Dimension must be an Array, Matrix, number, string, or Range'); - } - } - } - - /** - * Attach type information - */ - Index.prototype.type = 'Index'; - Index.prototype.isIndex = true; - - function _createImmutableMatrix(arg) { - // loop array elements - for (var i = 0, l = arg.length; i < l; i++) { - if (typeof arg[i] !== 'number' || !isInteger(arg[i])) { - throw new TypeError('Index parameters must be positive integer numbers'); - } - } - // create matrix - return new type.ImmutableDenseMatrix(arg); - } - - /** - * Create a clone of the index - * @memberof Index - * @return {Index} clone - */ - Index.prototype.clone = function () { - var index = new Index(); - index._dimensions = clone(this._dimensions); - index._isScalar = this._isScalar; - return index; - }; - - /** - * Create an index from an array with ranges/numbers - * @memberof Index - * @param {Array.} ranges - * @return {Index} index - * @private - */ - Index.create = function (ranges) { - var index = new Index(); - Index.apply(index, ranges); - return index; - }; - - /** - * Retrieve the size of the index, the number of elements for each dimension. - * @memberof Index - * @returns {number[]} size - */ - Index.prototype.size = function () { - var size = []; - - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - var d = this._dimensions[i]; - size[i] = (typeof d === 'string') ? 1 : d.size()[0]; - } - - return size; - }; - - /** - * Get the maximum value for each of the indexes ranges. - * @memberof Index - * @returns {number[]} max - */ - Index.prototype.max = function () { - var values = []; - - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - var range = this._dimensions[i]; - values[i] = (typeof range === 'string') ? range : range.max(); - } - - return values; - }; - - /** - * Get the minimum value for each of the indexes ranges. - * @memberof Index - * @returns {number[]} min - */ - Index.prototype.min = function () { - var values = []; - - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - var range = this._dimensions[i]; - values[i] = (typeof range === 'string') ? range : range.min(); - } - - return values; - }; - - /** - * Loop over each of the ranges of the index - * @memberof Index - * @param {Function} callback Called for each range with a Range as first - * argument, the dimension as second, and the - * index object as third. - */ - Index.prototype.forEach = function (callback) { - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - callback(this._dimensions[i], i, this); - } - }; - - /** - * Retrieve the dimension for the given index - * @memberof Index - * @param {Number} dim Number of the dimension - * @returns {Range | null} range - */ - Index.prototype.dimension = function (dim) { - return this._dimensions[dim] || null; - }; - - /** - * Test whether this index contains an object property - * @returns {boolean} Returns true if the index is an object property - */ - Index.prototype.isObjectProperty = function () { - return this._dimensions.length === 1 && typeof this._dimensions[0] === 'string'; - }; - - /** - * Returns the object property name when the Index holds a single object property, - * else returns null - * @returns {string | null} - */ - Index.prototype.getObjectProperty = function () { - return this.isObjectProperty() ? this._dimensions[0] : null; - }; - - /** - * Test whether this index contains only a single value. - * - * This is the case when the index is created with only scalar values as ranges, - * not for ranges resolving into a single value. - * @memberof Index - * @return {boolean} isScalar - */ - Index.prototype.isScalar = function () { - return this._isScalar; - }; - - /** - * Expand the Index into an array. - * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] - * @memberof Index - * @returns {Array} array - */ - Index.prototype.toArray = function () { - var array = []; - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - var dimension = this._dimensions[i]; - array.push((typeof dimension === 'string') ? dimension : dimension.toArray()); - } - return array; - }; - - /** - * Get the primitive value of the Index, a two dimensional array. - * Equivalent to Index.toArray(). - * @memberof Index - * @returns {Array} array - */ - Index.prototype.valueOf = Index.prototype.toArray; - - /** - * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7, [1,2,3]]' - * @memberof Index - * @returns {String} str - */ - Index.prototype.toString = function () { - var strings = []; - - for (var i = 0, ii = this._dimensions.length; i < ii; i++) { - var dimension = this._dimensions[i]; - if (typeof dimension === 'string') { - strings.push(JSON.stringify(dimension)); - } - else { - strings.push(dimension.toString()); - } - } - - return '[' + strings.join(', ') + ']'; - }; - - /** - * Get a JSON representation of the Index - * @memberof Index - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` - */ - Index.prototype.toJSON = function () { - return { - mathjs: 'Index', - dimensions: this._dimensions - }; - }; - - /** - * Instantiate an Index from a JSON object - * @memberof Index - * @param {Object} json A JSON object structured as: - * `{"mathjs": "Index", "dimensions": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` - * @return {Index} - */ - Index.fromJSON = function (json) { - return Index.create(json.dimensions); - }; - - return Index; - } - - exports.name = 'Index'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Create a range. A range has a start, step, and end, and contains functions - * to iterate over the range. - * - * A range can be constructed as: - * var range = new Range(start, end); - * var range = new Range(start, end, step); - * - * To get the result of the range: - * range.forEach(function (x) { - * console.log(x); - * }); - * range.map(function (x) { - * return math.sin(x); - * }); - * range.toArray(); - * - * Example usage: - * var c = new Range(2, 6); // 2:1:5 - * c.toArray(); // [2, 3, 4, 5] - * var d = new Range(2, -3, -1); // 2:-1:-2 - * d.toArray(); // [2, 1, 0, -1, -2] - * - * @class Range - * @constructor Range - * @param {number} start included lower bound - * @param {number} end excluded upper bound - * @param {number} [step] step size, default value is 1 - */ - function Range(start, end, step) { - if (!(this instanceof Range)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (start != null) { - if (start.isBigNumber === true) - start = start.toNumber(); - else if (typeof start !== 'number') - throw new TypeError('Parameter start must be a number'); - } - if (end != null) { - if (end.isBigNumber === true) - end = end.toNumber(); - else if (typeof end !== 'number') - throw new TypeError('Parameter end must be a number'); - } - if (step != null) { - if (step.isBigNumber === true) - step = step.toNumber(); - else if (typeof step !== 'number') - throw new TypeError('Parameter step must be a number'); - } - - this.start = (start != null) ? parseFloat(start) : 0; - this.end = (end != null) ? parseFloat(end) : 0; - this.step = (step != null) ? parseFloat(step) : 1; - } - - /** - * Attach type information - */ - Range.prototype.type = 'Range'; - Range.prototype.isRange = true; - - /** - * Parse a string into a range, - * The string contains the start, optional step, and end, separated by a colon. - * If the string does not contain a valid range, null is returned. - * For example str='0:2:11'. - * @memberof Range - * @param {string} str - * @return {Range | null} range - */ - Range.parse = function (str) { - if (typeof str !== 'string') { - return null; - } - - var args = str.split(':'); - var nums = args.map(function (arg) { - return parseFloat(arg); - }); - - var invalid = nums.some(function (num) { - return isNaN(num); - }); - if (invalid) { - return null; - } - - switch (nums.length) { - case 2: - return new Range(nums[0], nums[1]); - case 3: - return new Range(nums[0], nums[2], nums[1]); - default: - return null; - } - }; - - /** - * Create a clone of the range - * @return {Range} clone - */ - Range.prototype.clone = function () { - return new Range(this.start, this.end, this.step); - }; - - /** - * Retrieve the size of the range. - * Returns an array containing one number, the number of elements in the range. - * @memberof Range - * @returns {number[]} size - */ - Range.prototype.size = function () { - var len = 0, - start = this.start, - step = this.step, - end = this.end, - diff = end - start; - - if (number.sign(step) == number.sign(diff)) { - len = Math.ceil((diff) / step); - } - else if (diff == 0) { - len = 0; - } - - if (isNaN(len)) { - len = 0; - } - return [len]; - }; - - /** - * Calculate the minimum value in the range - * @memberof Range - * @return {number | undefined} min - */ - Range.prototype.min = function () { - var size = this.size()[0]; - - if (size > 0) { - if (this.step > 0) { - // positive step - return this.start; - } - else { - // negative step - return this.start + (size - 1) * this.step; - } - } - else { - return undefined; - } - }; - - /** - * Calculate the maximum value in the range - * @memberof Range - * @return {number | undefined} max - */ - Range.prototype.max = function () { - var size = this.size()[0]; - - if (size > 0) { - if (this.step > 0) { - // positive step - return this.start + (size - 1) * this.step; - } - else { - // negative step - return this.start; - } - } - else { - return undefined; - } - }; - - - /** - * Execute a callback function for each value in the range. - * @memberof Range - * @param {function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the Range being traversed. - */ - Range.prototype.forEach = function (callback) { - var x = this.start; - var step = this.step; - var end = this.end; - var i = 0; - - if (step > 0) { - while (x < end) { - callback(x, [i], this); - x += step; - i++; - } - } - else if (step < 0) { - while (x > end) { - callback(x, [i], this); - x += step; - i++; - } - } - }; - - /** - * Execute a callback function for each value in the Range, and return the - * results as an array - * @memberof Range - * @param {function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * @returns {Array} array - */ - Range.prototype.map = function (callback) { - var array = []; - this.forEach(function (value, index, obj) { - array[index[0]] = callback(value, index, obj); - }); - return array; - }; - - /** - * Create an Array with a copy of the Ranges data - * @memberof Range - * @returns {Array} array - */ - Range.prototype.toArray = function () { - var array = []; - this.forEach(function (value, index) { - array[index[0]] = value; - }); - return array; - }; - - /** - * Get the primitive value of the Range, a one dimensional array - * @memberof Range - * @returns {Array} array - */ - Range.prototype.valueOf = function () { - // TODO: implement a caching mechanism for range.valueOf() - return this.toArray(); - }; - - /** - * Get a string representation of the range, with optional formatting options. - * Output is formatted as 'start:step:end', for example '2:6' or '0:0.2:11' - * @memberof Range - * @param {Object | number | function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @returns {string} str - */ - Range.prototype.format = function (options) { - var str = number.format(this.start, options); - - if (this.step != 1) { - str += ':' + number.format(this.step, options); - } - str += ':' + number.format(this.end, options); - return str; - }; - - /** - * Get a string representation of the range. - * @memberof Range - * @returns {string} - */ - Range.prototype.toString = function () { - return this.format(); - }; - - /** - * Get a JSON representation of the range - * @memberof Range - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` - */ - Range.prototype.toJSON = function () { - return { - mathjs: 'Range', - start: this.start, - end: this.end, - step: this.step - }; - }; - - /** - * Instantiate a Range from a JSON object - * @memberof Range - * @param {Object} json A JSON object structured as: - * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` - * @return {Range} - */ - Range.fromJSON = function (json) { - return new Range(json.start, json.end, json.step); - }; - - return Range; - } - - exports.name = 'Range'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 68 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create an index. An Index can store ranges having start, step, and end - * for multiple dimensions. - * Matrix.get, Matrix.set, and math.subset accept an Index as input. - * - * Syntax: - * - * math.index(range1, range2, ...) - * - * Where each range can be any of: - * - * - A number - * - A string for getting/setting an object property - * - An instance of `Range` - * - A one-dimensional Array or a Matrix with numbers - * - * Indexes must be zero-based, integer numbers. - * - * Examples: - * - * var math = math.js - * - * var b = [1, 2, 3, 4, 5]; - * math.subset(b, math.index([1, 2, 3])); // returns [2, 3, 4] - * - * var a = math.matrix([[1, 2], [3, 4]]); - * a.subset(math.index(0, 1)); // returns 2 - * - * See also: - * - * bignumber, boolean, complex, matrix, number, string, unit - * - * @param {...*} ranges Zero or more ranges or numbers. - * @return {Index} Returns the created index - */ - return typed('index', { - '...number | string | BigNumber | Range | Array | Matrix': function (args) { - var ranges = args.map(function (arg) { - if (arg && arg.isBigNumber === true) { - return arg.toNumber(); // convert BigNumber to Number - } - else if (arg && (Array.isArray(arg) || arg.isMatrix === true)) { - return arg.map(function (elem) { - // convert BigNumber to Number - return (elem && elem.isBigNumber === true) ? elem.toNumber() : elem; - }); - } - else { - return arg; - } - }); - - var res = new type.Index(); - type.Index.apply(res, ranges); - return res; - } - }); - } - - exports.name = 'index'; - exports.factory = factory; - - -/***/ }, -/* 69 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var SparseMatrix = type.SparseMatrix; - - /** - * Create a Sparse Matrix. The function creates a new `math.type.Matrix` object from - * an `Array`. A Matrix has utility functions to manipulate the data in the - * matrix, like getting the size and getting or setting values in the matrix. - * - * Syntax: - * - * math.sparse() // creates an empty sparse matrix. - * math.sparse(data) // creates a sparse matrix with initial data. - * math.sparse(data, 'number') // creates a sparse matrix with initial data, number datatype. - * - * Examples: - * - * var m = math.sparse([[1, 2], [3, 4]]); - * m.size(); // Array [2, 2] - * m.resize([3, 2], 5); - * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] - * m.get([1, 0]) // number 3 - * - * See also: - * - * bignumber, boolean, complex, index, number, string, unit, matrix - * - * @param {Array | Matrix} [data] A two dimensional array - * - * @return {Matrix} The created matrix - */ - var sparse = typed('sparse', { - '': function () { - return new SparseMatrix([]); - }, - - 'string': function (datatype) { - return new SparseMatrix([], datatype); - }, - - 'Array | Matrix': function (data) { - return new SparseMatrix(data); - }, - - 'Array | Matrix, string': function (data, datatype) { - return new SparseMatrix(data, datatype); - } - }); - - sparse.toTex = { - 0: '\\begin{bsparse}\\end{bsparse}', - 1: '\\left(${args[0]}\\right)' - }; - - return sparse; - } - - exports.name = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 70 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Create a number or convert a string, boolean, or unit to a number. - * When value is a matrix, all elements will be converted to number. - * - * Syntax: - * - * math.number(value) - * math.number(unit, valuelessUnit) - * - * Examples: - * - * math.number(2); // returns number 2 - * math.number('7.2'); // returns number 7.2 - * math.number(true); // returns number 1 - * math.number([true, false, true, true]); // returns [1, 0, 1, 1] - * math.number(math.unit('52cm'), 'm'); // returns 0.52 - * - * See also: - * - * bignumber, boolean, complex, index, matrix, string, unit - * - * @param {string | number | BigNumber | Fraction | boolean | Array | Matrix | Unit | null} [value] Value to be converted - * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number - * @return {number | Array | Matrix} The created number - */ - var number = typed('number', { - '': function () { - return 0; - }, - - 'number': function (x) { - return x; - }, - - 'string': function (x) { - var num = Number(x); - if (isNaN(num)) { - throw new SyntaxError('String "' + x + '" is no valid number'); - } - return num; - }, - - 'BigNumber': function (x) { - return x.toNumber(); - }, - - 'Fraction': function (x) { - return x.valueOf(); - }, - - 'Unit': function (x) { - throw new Error('Second argument with valueless unit expected'); - }, - - 'Unit, string | Unit': function (unit, valuelessUnit) { - return unit.toNumber(valuelessUnit); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, number); - } - }); - - number.toTex = { - 0: '0', - 1: '\\left(${args[0]}\\right)', - 2: '\\left(\\left(${args[0]}\\right)${args[1]}\\right)' - }; - - return number; - } - - exports.name = 'number'; - exports.factory = factory; - - -/***/ }, -/* 71 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(72) - ]; - - -/***/ }, -/* 72 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * A ResultSet contains a list or results - * @class ResultSet - * @param {Array} entries - * @constructor ResultSet - */ - function ResultSet(entries) { - if (!(this instanceof ResultSet)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.entries = entries || []; - } - - /** - * Attach type information - */ - ResultSet.prototype.type = 'ResultSet'; - ResultSet.prototype.isResultSet = true; - - /** - * Returns the array with results hold by this ResultSet - * @memberof ResultSet - * @returns {Array} entries - */ - ResultSet.prototype.valueOf = function () { - return this.entries; - }; - - /** - * Returns the stringified results of the ResultSet - * @memberof ResultSet - * @returns {string} string - */ - ResultSet.prototype.toString = function () { - return '[' + this.entries.join(', ') + ']'; - }; - - /** - * Get a JSON representation of the ResultSet - * @memberof ResultSet - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "ResultSet", "entries": [...]}` - */ - ResultSet.prototype.toJSON = function () { - return { - mathjs: 'ResultSet', - entries: this.entries - }; - }; - - /** - * Instantiate a ResultSet from a JSON object - * @memberof ResultSet - * @param {Object} json A JSON object structured as: - * `{"mathjs": "ResultSet", "entries": [...]}` - * @return {ResultSet} - */ - ResultSet.fromJSON = function (json) { - return new ResultSet(json.entries); - }; - - return ResultSet; - } - - exports.name = 'ResultSet'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 73 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Create a string or convert any object into a string. - * Elements of Arrays and Matrices are processed element wise. - * - * Syntax: - * - * math.string(value) - * - * Examples: - * - * math.string(4.2); // returns string '4.2' - * math.string(math.complex(3, 2); // returns string '3 + 2i' - * - * var u = math.unit(5, 'km'); - * math.string(u.to('m')); // returns string '5000 m' - * - * math.string([true, false]); // returns ['true', 'false'] - * - * See also: - * - * bignumber, boolean, complex, index, matrix, number, unit - * - * @param {* | Array | Matrix | null} [value] A value to convert to a string - * @return {string | Array | Matrix} The created string - */ - var string = typed('string', { - '': function () { - return ''; - }, - - 'number': number.format, - - 'null': function (x) { - return 'null'; - }, - - 'boolean': function (x) { - return x + ''; - }, - - 'string': function (x) { - return x; - }, - - 'Array | Matrix': function (x) { - return deepMap(x, string); - }, - - 'any': function (x) { - return String(x); - } - }); - - string.toTex = { - 0: '\\mathtt{""}', - 1: '\\mathrm{string}\\left(${args[0]}\\right)' - }; - - return string; - } - - exports.name = 'string'; - exports.factory = factory; - - -/***/ }, -/* 74 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // type - __webpack_require__(75), - - // construction function - __webpack_require__(91), - - // physical constants - __webpack_require__(92) - ]; - - -/***/ }, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var endsWith = __webpack_require__(23).endsWith; - var clone = __webpack_require__(3).clone; - var constants = __webpack_require__(76); - - function factory (type, config, load, typed, math) { - var add = load(__webpack_require__(53)); - var subtract = load(__webpack_require__(77)); - var multiply = load(__webpack_require__(80)); - var divide = load(__webpack_require__(81)); - var pow = load(__webpack_require__(82)); - var abs = load(__webpack_require__(86)); - var equal = load(__webpack_require__(87)); - var isNumeric = load(__webpack_require__(88)); - var format = load(__webpack_require__(89)); - var getTypeOf = load(__webpack_require__(90)); - var toNumber = load(__webpack_require__(70)); - var Complex = load(__webpack_require__(27)); - - /** - * A unit can be constructed in the following ways: - * var a = new Unit(value, name); - * var b = new Unit(null, name); - * var c = Unit.parse(str); - * - * Example usage: - * var a = new Unit(5, 'cm'); // 50 mm - * var b = Unit.parse('23 kg'); // 23 kg - * var c = math.in(a, new Unit(null, 'm'); // 0.05 m - * var d = new Unit(9.81, "m/s^2"); // 9.81 m/s^2 - * - * @class Unit - * @constructor Unit - * @param {number | BigNumber | Fraction | Complex | boolean} [value] A value like 5.2 - * @param {string} [name] A unit name like "cm" or "inch", or a derived unit of the form: "u1[^ex1] [u2[^ex2] ...] [/ u3[^ex3] [u4[^ex4]]]", such as "kg m^2/s^2", where each unit appearing after the forward slash is taken to be in the denominator. "kg m^2 s^-2" is a synonym and is also acceptable. Any of the units can include a prefix. - */ - function Unit(value, name) { - if (!(this instanceof Unit)) { - throw new Error('Constructor must be called with the new operator'); - } - - if (!(value === undefined || isNumeric(value) || value.isComplex)) { - throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined'); - } - if (name != undefined && (typeof name !== 'string' || name == '')) { - throw new TypeError('Second parameter in Unit constructor must be a string'); - } - - if (name != undefined) { - var u = Unit.parse(name); - this.units = u.units; - this.dimensions = u.dimensions; - } - else { - this.units = [ - { - unit: UNIT_NONE, - prefix: PREFIXES.NONE, // link to a list with supported prefixes - power: 0 - } - ]; - this.dimensions = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - } - - this.value = (value != undefined) ? this._normalize(value) : null; - - this.fixPrefix = false; // if true, function format will not search for the - // best prefix but leave it as initially provided. - // fixPrefix is set true by the method Unit.to - - // The justification behind this is that if the constructor is explicitly called, - // the caller wishes the units to be returned exactly as he supplied. - this.isUnitListSimplified = true; - - } - - /** - * Attach type information - */ - Unit.prototype.type = 'Unit'; - Unit.prototype.isUnit = true; - - // private variables and functions for the Unit parser - var text, index, c; - - function skipWhitespace() { - while (c == ' ' || c == '\t') { - next(); - } - } - - function isDigitDot(c) { - return ((c >= '0' && c <= '9') || c == '.'); - } - - function isDigit(c) { - return ((c >= '0' && c <= '9')); - } - - function next() { - index++; - c = text.charAt(index); - } - - function revert(oldIndex) { - index = oldIndex; - c = text.charAt(index); - } - - function parseNumber() { - var number = ''; - var oldIndex; - oldIndex = index; - - if (c == '+') { - next(); - } - else if (c == '-') { - number += c; - next(); - } - - if (!isDigitDot(c)) { - // a + or - must be followed by a digit - revert(oldIndex); - return null; - } - - // get number, can have a single dot - if (c == '.') { - number += c; - next(); - if (!isDigit(c)) { - // this is no legal number, it is just a dot - revert(oldIndex); - return null; - } - } - else { - while (isDigit(c)) { - number += c; - next(); - } - if (c == '.') { - number += c; - next(); - } - } - while (isDigit(c)) { - number += c; - next(); - } - - // check for exponential notation like "2.3e-4" or "1.23e50" - if (c == 'E' || c == 'e') { - // The grammar branches here. This could either be part of an exponent or the start of a unit that begins with the letter e, such as "4exabytes" - - var tentativeNumber = ''; - var tentativeIndex = index; - - tentativeNumber += c; - next(); - - if (c == '+' || c == '-') { - tentativeNumber += c; - next(); - } - - // Scientific notation MUST be followed by an exponent (otherwise we assume it is not scientific notation) - if (!isDigit(c)) { - // The e or E must belong to something else, so return the number without the e or E. - revert(tentativeIndex); - return number; - } - - // We can now safely say that this is scientific notation. - number = number + tentativeNumber; - while (isDigit(c)) { - number += c; - next(); - } - } - - return number; - } - - function parseUnit() { - var unitName = ''; - - // Alphanumeric characters only; matches [a-zA-Z0-9] - var code = text.charCodeAt(index); - while ( (code >= 48 && code <= 57) || - (code >= 65 && code <= 90) || - (code >= 97 && code <= 122)) { - unitName += c; - next(); - code = text.charCodeAt(index); - } - - // Must begin with [a-zA-Z] - code = unitName.charCodeAt(0); - if ((code >= 65 && code <= 90) || - (code >= 97 && code <= 122)) { - return unitName || null; - } - else { - return null; - } - } - - function parseCharacter(toFind) { - if (c === toFind) { - next(); - return toFind; - } - else { - return null; - } - } - - /** - * Parse a string into a unit. The value of the unit is parsed as number, - * BigNumber, or Fraction depending on the math.js config setting `number`. - * - * Throws an exception if the provided string does not contain a valid unit or - * cannot be parsed. - * @memberof Unit - * @param {string} str A string like "5.2 inch", "4e2 cm/s^2" - * @return {Unit} unit - */ - Unit.parse = function (str) { - text = str; - index = -1; - c = ''; - - if (typeof text !== 'string') { - throw new TypeError('Invalid argument in Unit.parse, string expected'); - } - - var unit = new Unit(); - unit.units = []; - - // A unit should follow this pattern: - // [number]unit[^number] [unit[^number]]...[/unit[^number] [unit[^number]]] - - // Rules: - // number is any floating point number. - // unit is any alphanumeric string beginning with an alpha. Units with names like e3 should be avoided because they look like the exponent of a floating point number! - // The string may optionally begin with a number. - // Each unit may optionally be followed by ^number. - // Whitespace or a forward slash is recommended between consecutive units, although the following technically is parseable: - // 2m^2kg/s^2 - // it is not good form. If a unit starts with e, then it could be confused as a floating point number: - // 4erg - - next(); - skipWhitespace(); - // Optional number at the start of the string - var valueStr = parseNumber(); - var value = null; - if(valueStr) { - if (config.number === 'BigNumber') { - value = new type.BigNumber(valueStr); - } - else if (config.number === 'Fraction') { - value = new type.Fraction(valueStr); - } - else { // number - value = parseFloat(valueStr); - } - } - skipWhitespace(); // Whitespace is not required here - - // Next, we read any number of unit[^number] - var powerMultiplierCurrent = 1; - var expectingUnit = false; - - // Stack to keep track of powerMultipliers applied to each parentheses group - var powerMultiplierStack = []; - - // Running product of all elements in powerMultiplierStack - var powerMultiplierStackProduct = 1; - - while (true) { - skipWhitespace(); - - // Check for and consume opening parentheses, pushing powerMultiplierCurrent to the stack - // A '(' will always appear directly before a unit. - while (c === '(') { - powerMultiplierStack.push(powerMultiplierCurrent); - powerMultiplierStackProduct *= powerMultiplierCurrent; - powerMultiplierCurrent = 1; - next(); - skipWhitespace(); - } - - // Is there something here? - if(c) { - var oldC = c; - var uStr = parseUnit(); - if(uStr == null) { - throw new SyntaxError('Unexpected "' + oldC + '" in "' + text + '" at index ' + index.toString()); - } - } - else { - // End of input. - break; - } - - // Verify the unit exists and get the prefix (if any) - var res = _findUnit(uStr); - if(res == null) { - // Unit not found. - throw new SyntaxError('Unit "' + uStr + '" not found.'); - } - - var power = powerMultiplierCurrent * powerMultiplierStackProduct; - // Is there a "^ number"? - skipWhitespace(); - if (parseCharacter('^')) { - skipWhitespace(); - var p = parseNumber(); - if(p == null) { - // No valid number found for the power! - throw new SyntaxError('In "' + str + '", "^" must be followed by a floating-point number'); - } - power *= p; - } - - // Add the unit to the list - unit.units.push( { - unit: res.unit, - prefix: res.prefix, - power: power - }); - for(var i=0; i 1 || Math.abs(this.units[0].power - 1.0) > 1e-15; - }; - - /** - * Normalize a value, based on its currently set unit(s) - * @memberof Unit - * @param {number | BigNumber | Fraction | boolean} value - * @return {number | BigNumber | Fraction | boolean} normalized value - * @private - */ - Unit.prototype._normalize = function (value) { - var unitValue, unitOffset, unitPower, unitPrefixValue; - var convert; - - if (value == null || this.units.length === 0) { - return value; - } - else if (this._isDerived()) { - // This is a derived unit, so do not apply offsets. - // For example, with J kg^-1 degC^-1 you would NOT want to apply the offset. - var res = value; - convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed - - for(var i=0; i < this.units.length; i++) { - unitValue = convert(this.units[i].unit.value); - unitPrefixValue = convert(this.units[i].prefix.value); - unitPower = convert(this.units[i].power); - res = multiply(res, pow(multiply(unitValue, unitPrefixValue), unitPower)); - } - - return res; - } - else { - // This is a single unit of power 1, like kg or degC - convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed - - unitValue = convert(this.units[0].unit.value); - unitOffset = convert(this.units[0].unit.offset); - unitPrefixValue = convert(this.units[0].prefix.value); - - return multiply(add(value, unitOffset), multiply(unitValue, unitPrefixValue)); - } - }; - - /** - * Denormalize a value, based on its currently set unit(s) - * @memberof Unit - * @param {number} value - * @param {number} [prefixValue] Optional prefix value to be used (ignored if this is a derived unit) - * @return {number} denormalized value - * @private - */ - Unit.prototype._denormalize = function (value, prefixValue) { - var unitValue, unitOffset, unitPower, unitPrefixValue; - var convert; - - if (value == null || this.units.length === 0) { - return value; - } - else if (this._isDerived()) { - // This is a derived unit, so do not apply offsets. - // For example, with J kg^-1 degC^-1 you would NOT want to apply the offset. - // Also, prefixValue is ignored--but we will still use the prefix value stored in each unit, since kg is usually preferable to g unless the user decides otherwise. - var res = value; - convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed - - for (var i = 0; i < this.units.length; i++) { - unitValue = convert(this.units[i].unit.value); - unitPrefixValue = convert(this.units[i].prefix.value); - unitPower = convert(this.units[i].power); - res = divide(res, pow(multiply(unitValue, unitPrefixValue), unitPower)); - } - - return res; - } - else { - // This is a single unit of power 1, like kg or degC - convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed - - unitValue = convert(this.units[0].unit.value); - unitPrefixValue = convert(this.units[0].prefix.value); - unitOffset = convert(this.units[0].unit.offset); - - if (prefixValue == undefined) { - return subtract(divide(divide(value, unitValue), unitPrefixValue), unitOffset); - } - else { - return subtract(divide(divide(value, unitValue), prefixValue), unitOffset); - } - } - }; - - /** - * Find a unit from a string - * @memberof Unit - * @param {string} str A string like 'cm' or 'inch' - * @returns {Object | null} result When found, an object with fields unit and - * prefix is returned. Else, null is returned. - * @private - */ - function _findUnit(str) { - for (var name in UNITS) { - if (UNITS.hasOwnProperty(name)) { - if (endsWith(str, name)) { - var unit = UNITS[name]; - var prefixLen = (str.length - name.length); - var prefixName = str.substring(0, prefixLen); - var prefix = unit.prefixes[prefixName]; - if (prefix !== undefined) { - // store unit, prefix, and value - return { - unit: unit, - prefix: prefix - }; - } - } - } - } - - return null; - } - - /** - * Test if the given expression is a unit. - * The unit can have a prefix but cannot have a value. - * @memberof Unit - * @param {string} name A string to be tested whether it is a value less unit. - * The unit can have prefix, like "cm" - * @return {boolean} true if the given string is a unit - */ - Unit.isValuelessUnit = function (name) { - return (_findUnit(name) != null); - }; - - /** - * check if this unit has given base unit - * If this unit is a derived unit, this will ALWAYS return false, since by definition base units are not derived. - * @memberof Unit - * @param {BASE_UNITS | string | undefined} base - */ - Unit.prototype.hasBase = function (base) { - - if(typeof(base) === "string") { - base = BASE_UNITS[base]; - } - - if(!base) - return false; - - - // All dimensions must be the same - for(var i=0; i 1e-12) { - return false; - } - } - return true; - - }; - - /** - * Check if this unit has a base or bases equal to another base or bases - * For derived units, the exponent on each base also must match - * @memberof Unit - * @param {Unit} other - * @return {boolean} true if equal base - */ - Unit.prototype.equalBase = function (other) { - // All dimensions must be the same - for(var i=0; i 1e-12) { - return false; - } - } - return true; - }; - - /** - * Check if this unit equals another unit - * @memberof Unit - * @param {Unit} other - * @return {boolean} true if both units are equal - */ - Unit.prototype.equals = function (other) { - return (this.equalBase(other) && equal(this.value, other.value)); - }; - - /** - * Multiply this unit with another one - * @memberof Unit - * @param {Unit} other - * @return {Unit} product of this unit and the other unit - */ - Unit.prototype.multiply = function (other) { - var res = this.clone(); - - for(var i = 0; i 1e-12) { - proposedUnitList.push({ - unit: currentUnitSystem[baseDim].unit, - prefix: currentUnitSystem[baseDim].prefix, - power: this.dimensions[i] - }); - } - } - - // Is the proposed unit list "simpler" than the existing one? - if(proposedUnitList.length < this.units.length) { - // Replace this unit list with the proposed list - this.units = proposedUnitList; - } - } - } - - this.isUnitListSimplified = true; - }; - - /** - * Get a string representation of the units of this Unit, without the value. - * @memberof Unit - * @return {string} - */ - Unit.prototype.formatUnits = function () { - - // Lazy evaluation of the unit list - this.simplifyUnitListLazy(); - - var strNum = ""; - var strDen = ""; - var nNum = 0; - var nDen = 0; - - for(var i=0; i 0) { - nNum++; - strNum += " " + this.units[i].prefix.name + this.units[i].unit.name; - if(Math.abs(this.units[i].power - 1.0) > 1e-15) { - strNum += "^" + this.units[i].power; - } - } - else if(this.units[i].power < 0) { - nDen++; - } - } - - if(nDen > 0) { - for(var i=0; i 0) { - strDen += " " + this.units[i].prefix.name + this.units[i].unit.name; - if(Math.abs(this.units[i].power + 1.0) > 1e-15) { - strDen += "^" + (-this.units[i].power); - } - } - else { - strDen += " " + this.units[i].prefix.name + this.units[i].unit.name; - strDen += "^" + (this.units[i].power); - } - } - } - } - // Remove leading " " - strNum = strNum.substr(1); - strDen = strDen.substr(1); - - // Add parans for better copy/paste back into the eval, for example, or for better pretty print formatting - if(nNum > 1 && nDen > 0) { - strNum = "(" + strNum + ")"; - } - if(nDen > 1 && nNum > 0) { - strDen = "(" + strDen + ")"; - } - - var str = strNum; - if(nNum > 0 && nDen > 0) { - str += " / "; - } - str += strDen; - - return str; - }; - - /** - * Get a string representation of the Unit, with optional formatting options. - * @memberof Unit - * @param {Object | number | Function} [options] Formatting options. See - * lib/utils/number:format for a - * description of the available - * options. - * @return {string} - */ - Unit.prototype.format = function (options) { - - // Simplfy the unit list, if necessary - this.simplifyUnitListLazy(); - - // Apply some custom logic for handling VA and VAR. The goal is to express the value of the unit as a real value, if possible. Otherwise, use a real-valued unit instead of a complex-valued one. - var isImaginary = false; - var isReal = true; - if(typeof(this.value) !== 'undefined' && this.value !== null && this.value.isComplex) { - // TODO: Make this better, for example, use relative magnitude of re and im rather than absolute - isImaginary = Math.abs(this.value.re) < 1e-14; - isReal = Math.abs(this.value.im) < 1e-14; - } - - for(var i in this.units) { - if(this.units[i].unit) { - if(this.units[i].unit.name === 'VA' && isImaginary) { - this.units[i].unit = UNITS["VAR"]; - } - else if(this.units[i].unit.name === 'VAR' && !isImaginary) { - this.units[i].unit = UNITS["VA"]; - } - } - } - - - // Now apply the best prefix - // Units must have only one unit and not have the fixPrefix flag set - if (this.units.length === 1 && !this.fixPrefix) { - // Units must have integer powers, otherwise the prefix will change the - // outputted value by not-an-integer-power-of-ten - if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) < 1e-14) { - // Apply the best prefix - this.units[0].prefix = this._bestPrefix(); - } - } - - var value = this._denormalize(this.value); - var str = (this.value !== null) ? format(value, options || {}) : ''; - var unitStr = this.formatUnits(); - if(this.value && this.value.isComplex) { - str = "(" + str + ")"; // Surround complex values with ( ) to enable better parsing - } - if(unitStr.length > 0 && str.length > 0) { - str += " "; - } - str += unitStr; - - return str; - }; - - /** - * Calculate the best prefix using current value. - * @memberof Unit - * @returns {Object} prefix - * @private - */ - Unit.prototype._bestPrefix = function () { - if (this.units.length !== 1) { - throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!"); - } - if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) >= 1e-14) { - throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!"); - } - - // find the best prefix value (resulting in the value of which - // the absolute value of the log10 is closest to zero, - // though with a little offset of 1.2 for nicer values: you get a - // sequence 1mm 100mm 500mm 0.6m 1m 10m 100m 500m 0.6km 1km ... - - // Note: the units value can be any numeric type, but to find the best - // prefix it's enough to work with limited precision of a regular number - // Update: using mathjs abs since we also allow complex numbers - var absValue = abs(this.value); - var absUnitValue = abs(this.units[0].unit.value); - var bestPrefix = this.units[0].prefix; - if (absValue === 0) { - return bestPrefix; - } - var power = this.units[0].power; - var bestDiff = Math.abs( - Math.log(absValue / Math.pow(bestPrefix.value * absUnitValue, power)) / Math.LN10 - 1.2); - - var prefixes = this.units[0].unit.prefixes; - for (var p in prefixes) { - if (prefixes.hasOwnProperty(p)) { - var prefix = prefixes[p]; - if (prefix.scientific) { - - var diff = Math.abs( - Math.log(absValue / Math.pow(prefix.value * absUnitValue, power)) / Math.LN10 - 1.2); - - if (diff < bestDiff - || (diff === bestDiff && prefix.name.length < bestPrefix.name.length)) { - // choose the prefix with the smallest diff, or if equal, choose the one - // with the shortest name (can happen with SHORTLONG for example) - bestPrefix = prefix; - bestDiff = diff; - } - } - } - } - - return bestPrefix; - }; - - var PREFIXES = { - NONE: { - '': {name: '', value: 1, scientific: true} - }, - SHORT: { - '': {name: '', value: 1, scientific: true}, - - 'da': {name: 'da', value: 1e1, scientific: false}, - 'h': {name: 'h', value: 1e2, scientific: false}, - 'k': {name: 'k', value: 1e3, scientific: true}, - 'M': {name: 'M', value: 1e6, scientific: true}, - 'G': {name: 'G', value: 1e9, scientific: true}, - 'T': {name: 'T', value: 1e12, scientific: true}, - 'P': {name: 'P', value: 1e15, scientific: true}, - 'E': {name: 'E', value: 1e18, scientific: true}, - 'Z': {name: 'Z', value: 1e21, scientific: true}, - 'Y': {name: 'Y', value: 1e24, scientific: true}, - - 'd': {name: 'd', value: 1e-1, scientific: false}, - 'c': {name: 'c', value: 1e-2, scientific: false}, - 'm': {name: 'm', value: 1e-3, scientific: true}, - 'u': {name: 'u', value: 1e-6, scientific: true}, - 'n': {name: 'n', value: 1e-9, scientific: true}, - 'p': {name: 'p', value: 1e-12, scientific: true}, - 'f': {name: 'f', value: 1e-15, scientific: true}, - 'a': {name: 'a', value: 1e-18, scientific: true}, - 'z': {name: 'z', value: 1e-21, scientific: true}, - 'y': {name: 'y', value: 1e-24, scientific: true} - }, - LONG: { - '': {name: '', value: 1, scientific: true}, - - 'deca': {name: 'deca', value: 1e1, scientific: false}, - 'hecto': {name: 'hecto', value: 1e2, scientific: false}, - 'kilo': {name: 'kilo', value: 1e3, scientific: true}, - 'mega': {name: 'mega', value: 1e6, scientific: true}, - 'giga': {name: 'giga', value: 1e9, scientific: true}, - 'tera': {name: 'tera', value: 1e12, scientific: true}, - 'peta': {name: 'peta', value: 1e15, scientific: true}, - 'exa': {name: 'exa', value: 1e18, scientific: true}, - 'zetta': {name: 'zetta', value: 1e21, scientific: true}, - 'yotta': {name: 'yotta', value: 1e24, scientific: true}, - - 'deci': {name: 'deci', value: 1e-1, scientific: false}, - 'centi': {name: 'centi', value: 1e-2, scientific: false}, - 'milli': {name: 'milli', value: 1e-3, scientific: true}, - 'micro': {name: 'micro', value: 1e-6, scientific: true}, - 'nano': {name: 'nano', value: 1e-9, scientific: true}, - 'pico': {name: 'pico', value: 1e-12, scientific: true}, - 'femto': {name: 'femto', value: 1e-15, scientific: true}, - 'atto': {name: 'atto', value: 1e-18, scientific: true}, - 'zepto': {name: 'zepto', value: 1e-21, scientific: true}, - 'yocto': {name: 'yocto', value: 1e-24, scientific: true} - }, - SQUARED: { - '': {name: '', value: 1, scientific: true}, - - 'da': {name: 'da', value: 1e2, scientific: false}, - 'h': {name: 'h', value: 1e4, scientific: false}, - 'k': {name: 'k', value: 1e6, scientific: true}, - 'M': {name: 'M', value: 1e12, scientific: true}, - 'G': {name: 'G', value: 1e18, scientific: true}, - 'T': {name: 'T', value: 1e24, scientific: true}, - 'P': {name: 'P', value: 1e30, scientific: true}, - 'E': {name: 'E', value: 1e36, scientific: true}, - 'Z': {name: 'Z', value: 1e42, scientific: true}, - 'Y': {name: 'Y', value: 1e48, scientific: true}, - - 'd': {name: 'd', value: 1e-2, scientific: false}, - 'c': {name: 'c', value: 1e-4, scientific: false}, - 'm': {name: 'm', value: 1e-6, scientific: true}, - 'u': {name: 'u', value: 1e-12, scientific: true}, - 'n': {name: 'n', value: 1e-18, scientific: true}, - 'p': {name: 'p', value: 1e-24, scientific: true}, - 'f': {name: 'f', value: 1e-30, scientific: true}, - 'a': {name: 'a', value: 1e-36, scientific: true}, - 'z': {name: 'z', value: 1e-42, scientific: true}, - 'y': {name: 'y', value: 1e-48, scientific: true} - }, - CUBIC: { - '': {name: '', value: 1, scientific: true}, - - 'da': {name: 'da', value: 1e3, scientific: false}, - 'h': {name: 'h', value: 1e6, scientific: false}, - 'k': {name: 'k', value: 1e9, scientific: true}, - 'M': {name: 'M', value: 1e18, scientific: true}, - 'G': {name: 'G', value: 1e27, scientific: true}, - 'T': {name: 'T', value: 1e36, scientific: true}, - 'P': {name: 'P', value: 1e45, scientific: true}, - 'E': {name: 'E', value: 1e54, scientific: true}, - 'Z': {name: 'Z', value: 1e63, scientific: true}, - 'Y': {name: 'Y', value: 1e72, scientific: true}, - - 'd': {name: 'd', value: 1e-3, scientific: false}, - 'c': {name: 'c', value: 1e-6, scientific: false}, - 'm': {name: 'm', value: 1e-9, scientific: true}, - 'u': {name: 'u', value: 1e-18, scientific: true}, - 'n': {name: 'n', value: 1e-27, scientific: true}, - 'p': {name: 'p', value: 1e-36, scientific: true}, - 'f': {name: 'f', value: 1e-45, scientific: true}, - 'a': {name: 'a', value: 1e-54, scientific: true}, - 'z': {name: 'z', value: 1e-63, scientific: true}, - 'y': {name: 'y', value: 1e-72, scientific: true} - }, - BINARY_SHORT: { - '': {name: '', value: 1, scientific: true}, - 'k': {name: 'k', value: 1e3, scientific: true}, - 'M': {name: 'M', value: 1e6, scientific: true}, - 'G': {name: 'G', value: 1e9, scientific: true}, - 'T': {name: 'T', value: 1e12, scientific: true}, - 'P': {name: 'P', value: 1e15, scientific: true}, - 'E': {name: 'E', value: 1e18, scientific: true}, - 'Z': {name: 'Z', value: 1e21, scientific: true}, - 'Y': {name: 'Y', value: 1e24, scientific: true}, - - 'Ki': {name: 'Ki', value: 1024, scientific: true}, - 'Mi': {name: 'Mi', value: Math.pow(1024, 2), scientific: true}, - 'Gi': {name: 'Gi', value: Math.pow(1024, 3), scientific: true}, - 'Ti': {name: 'Ti', value: Math.pow(1024, 4), scientific: true}, - 'Pi': {name: 'Pi', value: Math.pow(1024, 5), scientific: true}, - 'Ei': {name: 'Ei', value: Math.pow(1024, 6), scientific: true}, - 'Zi': {name: 'Zi', value: Math.pow(1024, 7), scientific: true}, - 'Yi': {name: 'Yi', value: Math.pow(1024, 8), scientific: true} - }, - BINARY_LONG: { - '': {name: '', value: 1, scientific: true}, - 'kilo': {name: 'kilo', value: 1e3, scientific: true}, - 'mega': {name: 'mega', value: 1e6, scientific: true}, - 'giga': {name: 'giga', value: 1e9, scientific: true}, - 'tera': {name: 'tera', value: 1e12, scientific: true}, - 'peta': {name: 'peta', value: 1e15, scientific: true}, - 'exa': {name: 'exa', value: 1e18, scientific: true}, - 'zetta': {name: 'zetta', value: 1e21, scientific: true}, - 'yotta': {name: 'yotta', value: 1e24, scientific: true}, - - 'kibi': {name: 'kibi', value: 1024, scientific: true}, - 'mebi': {name: 'mebi', value: Math.pow(1024, 2), scientific: true}, - 'gibi': {name: 'gibi', value: Math.pow(1024, 3), scientific: true}, - 'tebi': {name: 'tebi', value: Math.pow(1024, 4), scientific: true}, - 'pebi': {name: 'pebi', value: Math.pow(1024, 5), scientific: true}, - 'exi': {name: 'exi', value: Math.pow(1024, 6), scientific: true}, - 'zebi': {name: 'zebi', value: Math.pow(1024, 7), scientific: true}, - 'yobi': {name: 'yobi', value: Math.pow(1024, 8), scientific: true} - }, - BTU: { - '': {name: '', value: 1, scientific: true}, - 'MM': {name: 'MM', value: 1e6, scientific: true} - } - }; - - // Add a prefix list for both short and long prefixes (for ohm in particular, since Mohm and megaohm are both acceptable): - PREFIXES.SHORTLONG = {}; - for (var key in PREFIXES.SHORT) { - if(PREFIXES.SHORT.hasOwnProperty(key)) { - PREFIXES.SHORTLONG[key] = PREFIXES.SHORT[key]; - } - } - for (var key in PREFIXES.LONG) { - if(PREFIXES.LONG.hasOwnProperty(key)) { - PREFIXES.SHORTLONG[key] = PREFIXES.LONG[key]; - } - } - - /* Internally, each unit is represented by a value and a dimension array. The elements of the dimensions array have the following meaning: - * Index Dimension - * ----- --------- - * 0 Length - * 1 Mass - * 2 Time - * 3 Current - * 4 Temperature - * 5 Luminous intensity - * 6 Amount of substance - * 7 Angle - * 8 Bit (digital) - * For example, the unit "298.15 K" is a pure temperature and would have a value of 298.15 and a dimension array of [0, 0, 0, 0, 1, 0, 0, 0, 0]. The unit "1 cal / (gm °C)" can be written in terms of the 9 fundamental dimensions as [length^2] / ([time^2] * [temperature]), and would a value of (after conversion to SI) 4184.0 and a dimensions array of [2, 0, -2, 0, -1, 0, 0, 0, 0]. - * - */ - - var BASE_DIMENSIONS = ["MASS", "LENGTH", "TIME", "CURRENT", "TEMPERATURE", "LUMINOUS_INTENSITY", "AMOUNT_OF_SUBSTANCE", "ANGLE", "BIT"]; - - var BASE_UNITS = { - NONE: { - dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - MASS: { - dimensions: [1, 0, 0, 0, 0, 0, 0, 0, 0] - }, - LENGTH: { - dimensions: [0, 1, 0, 0, 0, 0, 0, 0, 0] - }, - TIME: { - dimensions: [0, 0, 1, 0, 0, 0, 0, 0, 0] - }, - CURRENT: { - dimensions: [0, 0, 0, 1, 0, 0, 0, 0, 0] - }, - TEMPERATURE: { - dimensions: [0, 0, 0, 0, 1, 0, 0, 0, 0] - }, - LUMINOUS_INTENSITY: { - dimensions: [0, 0, 0, 0, 0, 1, 0, 0, 0] - }, - AMOUNT_OF_SUBSTANCE: { - dimensions: [0, 0, 0, 0, 0, 0, 1, 0, 0] - }, - - FORCE: { - dimensions: [1, 1, -2, 0, 0, 0, 0, 0, 0] - }, - SURFACE: { - dimensions: [0, 2, 0, 0, 0, 0, 0, 0, 0] - }, - VOLUME: { - dimensions: [0, 3, 0, 0, 0, 0, 0, 0, 0] - }, - ENERGY: { - dimensions: [1, 2, -2, 0, 0, 0, 0, 0, 0] - }, - POWER: { - dimensions: [1, 2, -3, 0, 0, 0, 0, 0, 0] - }, - PRESSURE: { - dimensions: [1, -1, -2, 0, 0, 0, 0, 0, 0] - }, - - ELECTRIC_CHARGE: { - dimensions: [0, 0, 1, 1, 0, 0, 0, 0, 0] - }, - ELECTRIC_CAPACITANCE: { - dimensions: [-1, -2, 4, 2, 0, 0, 0, 0, 0] - }, - ELECTRIC_POTENTIAL: { - dimensions: [1, 2, -3, -1, 0, 0, 0, 0, 0] - }, - ELECTRIC_RESISTANCE: { - dimensions: [1, 2, -3, -2, 0, 0, 0, 0, 0] - }, - ELECTRIC_INDUCTANCE: { - dimensions: [1, 2, -2, -2, 0, 0, 0, 0, 0] - }, - ELECTRIC_CONDUCTANCE: { - dimensions: [-1, -2, 3, 2, 0, 0, 0, 0, 0] - }, - MAGNETIC_FLUX: { - dimensions: [1, 2, -2, -1, 0, 0, 0, 0, 0] - }, - MAGNETIC_FLUX_DENSITY: { - dimensions: [1, 0, -2, -1, 0, 0, 0, 0, 0] - }, - - FREQUENCY: { - dimensions: [0, 0, -1, 0, 0, 0, 0, 0, 0] - }, - ANGLE: { - dimensions: [0, 0, 0, 0, 0, 0, 0, 1, 0] - }, - BIT: { - dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 1] - } - }; - - for(var key in BASE_UNITS) { - BASE_UNITS[key].key = key; - } - - var BASE_UNIT_NONE = {}; - - var UNIT_NONE = {name: '', base: BASE_UNIT_NONE, value: 1, offset: 0, dimensions: [0,0,0,0,0,0,0,0,0]}; - - var UNITS = { - // length - meter: { - name: 'meter', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - inch: { - name: 'inch', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.0254, - offset: 0 - }, - foot: { - name: 'foot', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.3048, - offset: 0 - }, - yard: { - name: 'yard', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.9144, - offset: 0 - }, - mile: { - name: 'mile', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 1609.344, - offset: 0 - }, - link: { - name: 'link', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.201168, - offset: 0 - }, - rod: { - name: 'rod', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 5.029210, - offset: 0 - }, - chain: { - name: 'chain', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 20.1168, - offset: 0 - }, - angstrom: { - name: 'angstrom', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 1e-10, - offset: 0 - }, - - m: { - name: 'm', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - 'in': { - name: 'in', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.0254, - offset: 0 - }, - ft: { - name: 'ft', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.3048, - offset: 0 - }, - yd: { - name: 'yd', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.9144, - offset: 0 - }, - mi: { - name: 'mi', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 1609.344, - offset: 0 - }, - li: { - name: 'li', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.201168, - offset: 0 - }, - rd: { - name: 'rd', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 5.029210, - offset: 0 - }, - ch: { - name: 'ch', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 20.1168, - offset: 0 - }, - mil: { - name: 'mil', - base: BASE_UNITS.LENGTH, - prefixes: PREFIXES.NONE, - value: 0.0000254, - offset: 0 - }, // 1/1000 inch - - // Surface - m2: { - name: 'm2', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.SQUARED, - value: 1, - offset: 0 - }, - sqin: { - name: 'sqin', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 0.00064516, - offset: 0 - }, // 645.16 mm2 - sqft: { - name: 'sqft', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 0.09290304, - offset: 0 - }, // 0.09290304 m2 - sqyd: { - name: 'sqyd', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 0.83612736, - offset: 0 - }, // 0.83612736 m2 - sqmi: { - name: 'sqmi', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 2589988.110336, - offset: 0 - }, // 2.589988110336 km2 - sqrd: { - name: 'sqrd', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 25.29295, - offset: 0 - }, // 25.29295 m2 - sqch: { - name: 'sqch', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 404.6873, - offset: 0 - }, // 404.6873 m2 - sqmil: { - name: 'sqmil', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 6.4516e-10, - offset: 0 - }, // 6.4516 * 10^-10 m2 - acre: { - name: 'acre', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 4046.86, - offset: 0 - }, // 4046.86 m2 - hectare: { - name: 'hectare', - base: BASE_UNITS.SURFACE, - prefixes: PREFIXES.NONE, - value: 10000, - offset: 0 - }, // 10000 m2 - - // Volume - m3: { - name: 'm3', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.CUBIC, - value: 1, - offset: 0 - }, - L: { - name: 'L', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.SHORT, - value: 0.001, - offset: 0 - }, // litre - l: { - name: 'l', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.SHORT, - value: 0.001, - offset: 0 - }, // litre - litre: { - name: 'litre', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.LONG, - value: 0.001, - offset: 0 - }, - cuin: { - name: 'cuin', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 1.6387064e-5, - offset: 0 - }, // 1.6387064e-5 m3 - cuft: { - name: 'cuft', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.028316846592, - offset: 0 - }, // 28.316 846 592 L - cuyd: { - name: 'cuyd', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.764554857984, - offset: 0 - }, // 764.554 857 984 L - teaspoon: { - name: 'teaspoon', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.000005, - offset: 0 - }, // 5 mL - tablespoon: { - name: 'tablespoon', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.000015, - offset: 0 - }, // 15 mL - //{name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup - drop: { - name: 'drop', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 5e-8, - offset: 0 - }, // 0.05 mL = 5e-8 m3 - gtt: { - name: 'gtt', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 5e-8, - offset: 0 - }, // 0.05 mL = 5e-8 m3 - - // Liquid volume - minim: { - name: 'minim', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.00000006161152, - offset: 0 - }, // 0.06161152 mL - fluiddram: { - name: 'fluiddram', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0000036966911, - offset: 0 - }, // 3.696691 mL - fluidounce: { - name: 'fluidounce', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.00002957353, - offset: 0 - }, // 29.57353 mL - gill: { - name: 'gill', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0001182941, - offset: 0 - }, // 118.2941 mL - cc: { - name: 'cc', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 1e-6, - offset: 0 - }, // 1e-6 L - cup: { - name: 'cup', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0002365882, - offset: 0 - }, // 236.5882 mL - pint: { - name: 'pint', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0004731765, - offset: 0 - }, // 473.1765 mL - quart: { - name: 'quart', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0009463529, - offset: 0 - }, // 946.3529 mL - gallon: { - name: 'gallon', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.003785412, - offset: 0 - }, // 3.785412 L - beerbarrel: { - name: 'beerbarrel', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.1173478, - offset: 0 - }, // 117.3478 L - oilbarrel: { - name: 'oilbarrel', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.1589873, - offset: 0 - }, // 158.9873 L - hogshead: { - name: 'hogshead', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.2384810, - offset: 0 - }, // 238.4810 L - - //{name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute - fldr: { - name: 'fldr', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0000036966911, - offset: 0 - }, // 3.696691 mL - floz: { - name: 'floz', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.00002957353, - offset: 0 - }, // 29.57353 mL - gi: { - name: 'gi', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0001182941, - offset: 0 - }, // 118.2941 mL - cp: { - name: 'cp', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0002365882, - offset: 0 - }, // 236.5882 mL - pt: { - name: 'pt', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0004731765, - offset: 0 - }, // 473.1765 mL - qt: { - name: 'qt', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.0009463529, - offset: 0 - }, // 946.3529 mL - gal: { - name: 'gal', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.003785412, - offset: 0 - }, // 3.785412 L - bbl: { - name: 'bbl', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.1173478, - offset: 0 - }, // 117.3478 L - obl: { - name: 'obl', - base: BASE_UNITS.VOLUME, - prefixes: PREFIXES.NONE, - value: 0.1589873, - offset: 0 - }, // 158.9873 L - //{name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh? - - // Mass - g: { - name: 'g', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.SHORT, - value: 0.001, - offset: 0 - }, - gram: { - name: 'gram', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.LONG, - value: 0.001, - offset: 0 - }, - - ton: { - name: 'ton', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.SHORT, - value: 907.18474, - offset: 0 - }, - tonne: { - name: 'tonne', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.SHORT, - value: 1000, - offset: 0 - }, - - grain: { - name: 'grain', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 64.79891e-6, - offset: 0 - }, - dram: { - name: 'dram', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 1.7718451953125e-3, - offset: 0 - }, - ounce: { - name: 'ounce', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 28.349523125e-3, - offset: 0 - }, - poundmass: { - name: 'poundmass', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 453.59237e-3, - offset: 0 - }, - hundredweight: { - name: 'hundredweight', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 45.359237, - offset: 0 - }, - stick: { - name: 'stick', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 115e-3, - offset: 0 - }, - stone: { - name: 'stone', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 6.35029318, - offset: 0 - }, - - gr: { - name: 'gr', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 64.79891e-6, - offset: 0 - }, - dr: { - name: 'dr', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 1.7718451953125e-3, - offset: 0 - }, - oz: { - name: 'oz', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 28.349523125e-3, - offset: 0 - }, - lbm: { - name: 'lbm', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 453.59237e-3, - offset: 0 - }, - cwt: { - name: 'cwt', - base: BASE_UNITS.MASS, - prefixes: PREFIXES.NONE, - value: 45.359237, - offset: 0 - }, - - // Time - s: { - name: 's', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - min: { - name: 'min', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 60, - offset: 0 - }, - h: { - name: 'h', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 3600, - offset: 0 - }, - second: { - name: 'second', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - sec: { - name: 'sec', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - minute: { - name: 'minute', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 60, - offset: 0 - }, - hour: { - name: 'hour', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 3600, - offset: 0 - }, - day: { - name: 'day', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 86400, - offset: 0 - }, - week: { - name: 'week', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 7*86400, - offset: 0 - }, - month: { - name: 'month', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 2629800, //1/12th of Julian year - offset: 0 - }, - year: { - name: 'year', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 31557600, //Julian year - offset: 0 - }, - decade: { - name: 'year', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 315576000, //Julian decade - offset: 0 - }, - century: { - name: 'century', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 3155760000, //Julian century - offset: 0 - }, - millennium: { - name: 'millennium', - base: BASE_UNITS.TIME, - prefixes: PREFIXES.NONE, - value: 31557600000, //Julian millennium - offset: 0 - }, - - // Frequency - hertz: { - name: 'Hertz', - base: BASE_UNITS.FREQUENCY, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0, - reciprocal: true - }, - Hz: { - name: 'Hz', - base: BASE_UNITS.FREQUENCY, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0, - reciprocal: true - }, - - // Angle - rad: { - name: 'rad', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: 1, - offset: 0 - }, - // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888 - deg: { - name: 'deg', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: null, // will be filled in by calculateAngleValues() - offset: 0 - }, - // grad = rad / (2*pi) * 400 = rad / 0.015707963267948966192313216916399 - grad: { - name: 'grad', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: null, // will be filled in by calculateAngleValues() - offset: 0 - }, - // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793 - cycle: { - name: 'cycle', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: null, // will be filled in by calculateAngleValues() - offset: 0 - }, - // arcsec = rad / (3600 * (360 / 2 * pi)) = rad / 0.0000048481368110953599358991410235795 - arcsec: { - name: 'arcsec', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: null, // will be filled in by calculateAngleValues() - offset: 0 - }, - // arcmin = rad / (60 * (360 / 2 * pi)) = rad / 0.00029088820866572159615394846141477 - arcmin: { - name: 'arcmin', - base: BASE_UNITS.ANGLE, - prefixes: PREFIXES.NONE, - value: null, // will be filled in by calculateAngleValues() - offset: 0 - }, - - // Electric current - A: { - name: 'A', - base: BASE_UNITS.CURRENT, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - ampere: { - name: 'ampere', - base: BASE_UNITS.CURRENT, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - - // Temperature - // K(C) = °C + 273.15 - // K(F) = (°F + 459.67) / 1.8 - // K(R) = °R / 1.8 - K: { - name: 'K', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1, - offset: 0 - }, - degC: { - name: 'degC', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1, - offset: 273.15 - }, - degF: { - name: 'degF', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1 / 1.8, - offset: 459.67 - }, - degR: { - name: 'degR', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1 / 1.8, - offset: 0 - }, - kelvin: { - name: 'kelvin', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1, - offset: 0 - }, - celsius: { - name: 'celsius', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1, - offset: 273.15 - }, - fahrenheit: { - name: 'fahrenheit', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1 / 1.8, - offset: 459.67 - }, - rankine: { - name: 'rankine', - base: BASE_UNITS.TEMPERATURE, - prefixes: PREFIXES.NONE, - value: 1 / 1.8, - offset: 0 - }, - - // amount of substance - mol: { - name: 'mol', - base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - mole: { - name: 'mole', - base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - - // luminous intensity - cd: { - name: 'cd', - base: BASE_UNITS.LUMINOUS_INTENSITY, - prefixes: PREFIXES.NONE, - value: 1, - offset: 0 - }, - candela: { - name: 'candela', - base: BASE_UNITS.LUMINOUS_INTENSITY, - prefixes: PREFIXES.NONE, - value: 1, - offset: 0 - }, - // TODO: units STERADIAN - //{name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - //{name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - - // Force - N: { - name: 'N', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - newton: { - name: 'newton', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - dyn: { - name: 'dyn', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.SHORT, - value: 0.00001, - offset: 0 - }, - dyne: { - name: 'dyne', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.LONG, - value: 0.00001, - offset: 0 - }, - lbf: { - name: 'lbf', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.NONE, - value: 4.4482216152605, - offset: 0 - }, - poundforce: { - name: 'poundforce', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.NONE, - value: 4.4482216152605, - offset: 0 - }, - kip: { - name: 'kip', - base: BASE_UNITS.FORCE, - prefixes: PREFIXES.LONG, - value: 4448.2216, - offset: 0 - }, - - // Energy - J: { - name: 'J', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - joule: { - name: 'joule', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - erg: { - name: 'erg', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.NONE, - value: 1e-5, - offset: 0 - }, - Wh: { - name: 'Wh', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.SHORT, - value: 3600, - offset: 0 - }, - BTU: { - name: 'BTU', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.BTU, - value: 1055.05585262, - offset: 0 - }, - eV: { - name: 'eV', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.SHORT, - value: 1.602176565e-19, - offset: 0 - }, - electronvolt: { - name: 'electronvolt', - base: BASE_UNITS.ENERGY, - prefixes: PREFIXES.LONG, - value: 1.602176565e-19, - offset: 0 - }, - - - // Power - W: { - name: 'W', - base: BASE_UNITS.POWER, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - watt: { - name: 'W', - base: BASE_UNITS.POWER, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - hp: { - name: 'hp', - base: BASE_UNITS.POWER, - prefixes: PREFIXES.NONE, - value: 745.6998715386, - offset: 0 - }, - - // Electrical power units - VAR: { - name: 'VAR', - base: BASE_UNITS.POWER, - prefixes: PREFIXES.SHORT, - value: Complex.I, - offset: 0 - }, - - VA: { - name: 'VA', - base: BASE_UNITS.POWER, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - - // Pressure - Pa: { - name: 'Pa', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - psi: { - name: 'psi', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 6894.75729276459, - offset: 0 - }, - atm: { - name: 'atm', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 101325, - offset: 0 - }, - bar: { - name: 'bar', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 100000, - offset: 0 - }, - torr: { - name: 'torr', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 133.322, - offset: 0 - }, - mmHg: { - name: 'mmHg', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 133.322, - offset: 0 - }, - mmH2O: { - name: 'mmH2O', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 9.80665, - offset: 0 - }, - cmH2O: { - name: 'cmH2O', - base: BASE_UNITS.PRESSURE, - prefixes: PREFIXES.NONE, - value: 98.0665, - offset: 0 - }, - - // Electric charge - coulomb: { - name: 'coulomb', - base: BASE_UNITS.ELECTRIC_CHARGE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - C: { - name: 'C', - base: BASE_UNITS.ELECTRIC_CHARGE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Electric capacitance - farad: { - name: 'farad', - base: BASE_UNITS.ELECTRIC_CAPACITANCE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - F: { - name: 'F', - base: BASE_UNITS.ELECTRIC_CAPACITANCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Electric potential - volt: { - name: 'volt', - base: BASE_UNITS.ELECTRIC_POTENTIAL, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - V: { - name: 'V', - base: BASE_UNITS.ELECTRIC_POTENTIAL, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Electric resistance - ohm: { - name: 'ohm', - base: BASE_UNITS.ELECTRIC_RESISTANCE, - prefixes: PREFIXES.SHORTLONG, // Both Mohm and megaohm are acceptable - value: 1, - offset: 0 - }, - /* - * Unicode breaks in browsers if charset is not specified - Ω: { - name: 'Ω', - base: BASE_UNITS.ELECTRIC_RESISTANCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - */ - // Electric inductance - henry: { - name: 'henry', - base: BASE_UNITS.ELECTRIC_INDUCTANCE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - H: { - name: 'H', - base: BASE_UNITS.ELECTRIC_INDUCTANCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Electric conductance - siemens: { - name: 'siemens', - base: BASE_UNITS.ELECTRIC_CONDUCTANCE, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - S: { - name: 'S', - base: BASE_UNITS.ELECTRIC_CONDUCTANCE, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Magnetic flux - weber: { - name: 'weber', - base: BASE_UNITS.MAGNETIC_FLUX, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - Wb: { - name: 'Wb', - base: BASE_UNITS.MAGNETIC_FLUX, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - // Magnetic flux density - tesla: { - name: 'tesla', - base: BASE_UNITS.MAGNETIC_FLUX_DENSITY, - prefixes: PREFIXES.LONG, - value: 1, - offset: 0 - }, - T: { - name: 'T', - base: BASE_UNITS.MAGNETIC_FLUX_DENSITY, - prefixes: PREFIXES.SHORT, - value: 1, - offset: 0 - }, - - // Binary - b: { - name: 'b', - base: BASE_UNITS.BIT, - prefixes: PREFIXES.BINARY_SHORT, - value: 1, - offset: 0 - }, - bits: { - name: 'bits', - base: BASE_UNITS.BIT, - prefixes: PREFIXES.BINARY_LONG, - value: 1, - offset: 0 - }, - B: { - name: 'B', - base: BASE_UNITS.BIT, - prefixes: PREFIXES.BINARY_SHORT, - value: 8, - offset: 0 - }, - bytes: { - name: 'bytes', - base: BASE_UNITS.BIT, - prefixes: PREFIXES.BINARY_LONG, - value: 8, - offset: 0 - } - }; - - // aliases (formerly plurals) - var ALIASES = { - meters: 'meter', - inches: 'inch', - feet: 'foot', - yards: 'yard', - miles: 'mile', - links: 'link', - rods: 'rod', - chains: 'chain', - angstroms: 'angstrom', - - lt: 'l', - litres: 'litre', - liter: 'litre', - liters: 'litre', - teaspoons: 'teaspoon', - tablespoons: 'tablespoon', - minims: 'minim', - fluiddrams: 'fluiddram', - fluidounces: 'fluidounce', - gills: 'gill', - cups: 'cup', - pints: 'pint', - quarts: 'quart', - gallons: 'gallon', - beerbarrels: 'beerbarrel', - oilbarrels: 'oilbarrel', - hogsheads: 'hogshead', - gtts: 'gtt', - - grams: 'gram', - tons: 'ton', - tonnes: 'tonne', - grains: 'grain', - drams: 'dram', - ounces: 'ounce', - poundmasses: 'poundmass', - hundredweights: 'hundredweight', - sticks: 'stick', - lb: 'lbm', - lbs: 'lbm', - - kips: 'kip', - - acres: 'acre', - hectares: 'hectare', - sqfeet: 'sqft', - sqyard: 'sqyd', - sqmile: 'sqmi', - sqmiles: 'sqmi', - - mmhg: 'mmHg', - mmh2o: 'mmH2O', - cmh2o: 'cmH2O', - - seconds: 'second', - secs: 'second', - minutes: 'minute', - mins: 'minute', - hours: 'hour', - hr: 'hour', - hrs: 'hour', - days: 'day', - weeks: 'week', - months: 'month', - years: 'year', - - hertz: 'hertz', - - radians: 'rad', - degree: 'deg', - degrees: 'deg', - gradian: 'grad', - gradians: 'grad', - cycles: 'cycle', - arcsecond: 'arcsec', - arcseconds: 'arcsec', - arcminute: 'arcmin', - arcminutes: 'arcmin', - - BTUs: 'BTU', - watts: 'watt', - joules: 'joule', - - amperes: 'ampere', - coulombs: 'coulomb', - volts: 'volt', - ohms: 'ohm', - farads: 'farad', - webers: 'weber', - teslas: 'tesla', - electronvolts: 'electronvolt', - moles: 'mole' - - }; - - /** - * Calculate the values for the angle units. - * Value is calculated as number or BigNumber depending on the configuration - * @param {{number: 'number' | 'BigNumber'}} config - */ - function calculateAngleValues (config) { - if (config.number === 'BigNumber') { - var pi = constants.pi(type.BigNumber); - UNITS.rad.value = new type.BigNumber(1); - UNITS.deg.value = pi.div(180); // 2 * pi / 360; - UNITS.grad.value = pi.div(200); // 2 * pi / 400; - UNITS.cycle.value = pi.times(2); // 2 * pi - UNITS.arcsec.value = pi.div(648000); // 2 * pi / 360 / 3600 - UNITS.arcmin.value = pi.div(10800); // 2 * pi / 360 / 60 - } - else { // number - UNITS.rad.value = 1; - UNITS.deg.value = Math.PI / 180; // 2 * pi / 360; - UNITS.grad.value = Math.PI / 200; // 2 * pi / 400; - UNITS.cycle.value = Math.PI * 2; // 2 * pi - UNITS.arcsec.value = Math.PI / 648000; // 2 * pi / 360 / 3600; - UNITS.arcmin.value = Math.PI / 10800; // 2 * pi / 360 / 60; - } - } - - // apply the angle values now - calculateAngleValues(config); - - // recalculate the values on change of configuration - math.on('config', function (curr, prev) { - if (curr.number !== prev.number) { - calculateAngleValues(curr); - } - }); - - /** - * A unit system is a set of dimensionally independent base units plus a set of derived units, formed by multiplication and division of the base units, that are by convention used with the unit system. - * A user perhaps could issue a command to select a preferred unit system, or use the default (see below). - * Auto unit system: The default unit system is updated on the fly anytime a unit is parsed. The corresponding unit in the default unit system is updated, so that answers are given in the same units the user supplies. - */ - var UNIT_SYSTEMS = { - si: { - // Base units - NONE: {unit: UNIT_NONE, prefix: PREFIXES.NONE['']}, - LENGTH: {unit: UNITS.m, prefix: PREFIXES.SHORT['']}, - MASS: {unit: UNITS.g, prefix: PREFIXES.SHORT['k']}, - TIME: {unit: UNITS.s, prefix: PREFIXES.SHORT['']}, - CURRENT: {unit: UNITS.A, prefix: PREFIXES.SHORT['']}, - TEMPERATURE: {unit: UNITS.K, prefix: PREFIXES.SHORT['']}, - LUMINOUS_INTENSITY: {unit: UNITS.cd, prefix: PREFIXES.SHORT['']}, - AMOUNT_OF_SUBSTANCE: {unit: UNITS.mol, prefix: PREFIXES.SHORT['']}, - ANGLE: {unit: UNITS.rad, prefix: PREFIXES.SHORT['']}, - BIT: {unit: UNITS.bit, prefix: PREFIXES.SHORT['']}, - - // Derived units - FORCE: {unit: UNITS.N, prefix: PREFIXES.SHORT['']}, - ENERGY: {unit: UNITS.J, prefix: PREFIXES.SHORT['']}, - POWER: {unit: UNITS.W, prefix: PREFIXES.SHORT['']}, - PRESSURE: {unit: UNITS.Pa, prefix: PREFIXES.SHORT['']}, - ELECTRIC_CHARGE: {unit: UNITS.C, prefix: PREFIXES.SHORT['']}, - ELECTRIC_CAPACITANCE: {unit: UNITS.F, prefix: PREFIXES.SHORT['']}, - ELECTRIC_POTENTIAL: {unit: UNITS.V, prefix: PREFIXES.SHORT['']}, - ELECTRIC_RESISTANCE: {unit: UNITS.ohm, prefix: PREFIXES.SHORT['']}, - ELECTRIC_INDUCTANCE: {unit: UNITS.H, prefix: PREFIXES.SHORT['']}, - ELECTRIC_CONDUCTANCE: {unit: UNITS.S, prefix: PREFIXES.SHORT['']}, - MAGNETIC_FLUX: {unit: UNITS.Wb, prefix: PREFIXES.SHORT['']}, - MAGNETIC_FLUX_DENSITY: {unit: UNITS.T, prefix: PREFIXES.SHORT['']}, - FREQUENCY: {unit: UNITS.Hz, prefix: PREFIXES.SHORT['']} - } - }; - - // Clone to create the other unit systems - UNIT_SYSTEMS.cgs = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); - UNIT_SYSTEMS.cgs.LENGTH = {unit: UNITS.m, prefix: PREFIXES.SHORT['c']}; - UNIT_SYSTEMS.cgs.MASS = {unit: UNITS.g, prefix: PREFIXES.SHORT['']}; - UNIT_SYSTEMS.cgs.FORCE = {unit: UNITS.dyn, prefix: PREFIXES.SHORT['']}; - UNIT_SYSTEMS.cgs.ENERGY = {unit: UNITS.erg, prefix: PREFIXES.NONE['']}; - // there are wholly 4 unique cgs systems for electricity and magnetism, - // so let's not worry about it unless somebody complains - - UNIT_SYSTEMS.us = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); - UNIT_SYSTEMS.us.LENGTH = {unit: UNITS.ft, prefix: PREFIXES.NONE['']}; - UNIT_SYSTEMS.us.MASS = {unit: UNITS.lbm, prefix: PREFIXES.NONE['']}; - UNIT_SYSTEMS.us.TEMPERATURE = {unit: UNITS.degF, prefix: PREFIXES.NONE['']}; - UNIT_SYSTEMS.us.FORCE = {unit: UNITS.lbf, prefix: PREFIXES.NONE['']}; - UNIT_SYSTEMS.us.ENERGY = {unit: UNITS.BTU, prefix: PREFIXES.BTU['']}; - UNIT_SYSTEMS.us.POWER = {unit: UNITS.hp, prefix: PREFIXES.NONE['']}; - UNIT_SYSTEMS.us.PRESSURE = {unit: UNITS.psi, prefix: PREFIXES.NONE['']}; - - // Add additional unit systems here. - - - - // Choose a unit system to seed the auto unit system. - UNIT_SYSTEMS.auto = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); - - // Set the current unit system - var currentUnitSystem = UNIT_SYSTEMS.auto; - - /** - * Set a unit system for formatting derived units. - * @param {string} [name] The name of the unit system. - */ - Unit.setUnitSystem = function(name) { - if(UNIT_SYSTEMS.hasOwnProperty(name)) { - currentUnitSystem = UNIT_SYSTEMS[name]; - } - else { - throw new Error('Unit system ' + name + ' does not exist. Choices are: ' + Object.keys(UNIT_SYSTEMS).join(', ')); - } - }; - - /** - * Return the current unit system. - * @return {string} The current unit system. - */ - Unit.getUnitSystem = function() { - for(var key in UNIT_SYSTEMS) { - if(UNIT_SYSTEMS[key] === currentUnitSystem) { - return key; - } - } - }; - - /** - * Converters to convert from number to an other numeric type like BigNumber - * or Fraction - */ - Unit.typeConverters = { - BigNumber: function (x) { - return new type.BigNumber(x + ''); // stringify to prevent constructor error - }, - - Fraction: function (x) { - return new type.Fraction(x); - }, - - Complex: function (x) { - return x; - }, - - number: function (x) { - return x; - } - }; - - /** - * Retrieve the right convertor function corresponding with the type - * of provided exampleValue. - * - * @param {string} type A string 'number', 'BigNumber', or 'Fraction' - * In case of an unknown type, - * @return {Function} - */ - Unit._getNumberConverter = function (type) { - if (!Unit.typeConverters[type]) { - throw new TypeError('Unsupported type "' + type + '"'); - } - - return Unit.typeConverters[type]; - }; - - // Add dimensions to each built-in unit - for (var key in UNITS) { - var unit = UNITS[key]; - unit.dimensions = unit.base.dimensions; - } - - // Create aliases - for (var name in ALIASES) { - /* istanbul ignore next (we cannot really test next statement) */ - if (ALIASES.hasOwnProperty(name)) { - var unit = UNITS[ALIASES[name]]; - var alias = Object.create(unit); - alias.name = name; - UNITS[name] = alias; - } - } - - Unit.PREFIXES = PREFIXES; - Unit.BASE_UNITS = BASE_UNITS; - Unit.UNITS = UNITS; - Unit.UNIT_SYSTEMS = UNIT_SYSTEMS; - - return Unit; - } - - exports.name = 'Unit'; - exports.path = 'type'; - exports.factory = factory; - exports.math = true; // request access to the math namespace - - -/***/ }, -/* 76 */ -/***/ function(module, exports, __webpack_require__) { - - var memoize = __webpack_require__(45).memoize; - - /** - * Calculate BigNumber e - * @param {function} BigNumber BigNumber constructor - * @returns {BigNumber} Returns e - */ - exports.e = memoize(function (BigNumber) { - return new BigNumber(1).exp(); - }, hasher); - - /** - * Calculate BigNumber golden ratio, phi = (1+sqrt(5))/2 - * @param {function} BigNumber BigNumber constructor - * @returns {BigNumber} Returns phi - */ - exports.phi = memoize(function (BigNumber) { - return new BigNumber(1).plus(new BigNumber(5).sqrt()).div(2); - }, hasher); - - /** - * Calculate BigNumber pi. - * @param {function} BigNumber BigNumber constructor - * @returns {BigNumber} Returns pi - */ - exports.pi = memoize(function (BigNumber) { - return pi = BigNumber.acos(-1); - }, hasher); - - /** - * Calculate BigNumber tau, tau = 2 * pi - * @param {function} BigNumber BigNumber constructor - * @returns {BigNumber} Returns tau - */ - exports.tau = memoize(function (BigNumber) { - return exports.pi(BigNumber).times(2); - }, hasher); - - /** - * Create a hash for a BigNumber constructor function. The created has is - * the configured precision - * @param {Array} args Supposed to contain a single entry with - * a BigNumber constructor - * @return {number} precision - * @private - */ - function hasher (args) { - return args[0].precision; - } - - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var addScalar = load(__webpack_require__(53)); - var unaryMinus = load(__webpack_require__(78)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm03 = load(__webpack_require__(61)); - var algorithm05 = load(__webpack_require__(79)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - // TODO: split function subtract in two: subtract and subtractScalar - - /** - * Subtract two values, `x - y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.subtract(x, y) - * - * Examples: - * - * math.subtract(5.3, 2); // returns number 3.3 - * - * var a = math.complex(2, 3); - * var b = math.complex(4, 1); - * math.subtract(a, b); // returns Complex -2 + 2i - * - * math.subtract([5, 7, 4], 4); // returns Array [1, 3, 0] - * - * var c = math.unit('2.1 km'); - * var d = math.unit('500m'); - * math.subtract(c, d); // returns Unit 1.6 km - * - * See also: - * - * add - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x - * Initial value - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y - * Value to subtract from `x` - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} - * Subtraction of `x` and `y` - */ - var subtract = typed('subtract', { - - 'number, number': function (x, y) { - return x - y; - }, - - 'Complex, Complex': function (x, y) { - return x.sub(y); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.minus(y); - }, - - 'Fraction, Fraction': function (x, y) { - return x.sub(y); - }, - - 'Unit, Unit': function (x, y) { - if (x.value == null) { - throw new Error('Parameter x contains a unit with undefined value'); - } - - if (y.value == null) { - throw new Error('Parameter y contains a unit with undefined value'); - } - - if (!x.equalBase(y)) { - throw new Error('Units do not match'); - } - - var res = x.clone(); - res.value = subtract(res.value, y.value); - res.fixPrefix = false; - - return res; - }, - - 'Matrix, Matrix': function (x, y) { - // matrix sizes - var xsize = x.size(); - var ysize = y.size(); - - // check dimensions - if (xsize.length !== ysize.length) - throw new DimensionError(xsize.length, ysize.length); - - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse - sparse - c = algorithm05(x, y, subtract); - break; - default: - // sparse - dense - c = algorithm03(y, x, subtract, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense - sparse - c = algorithm01(x, y, subtract, false); - break; - default: - // dense - dense - c = algorithm13(x, y, subtract); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return subtract(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return subtract(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return subtract(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - // algorithm 7 is faster than 9 since it calls f() for nonzero items only! - c = algorithm10(x, unaryMinus(y), addScalar); - break; - default: - c = algorithm14(x, y, subtract); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, subtract, true); - break; - default: - c = algorithm14(y, x, subtract, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, subtract, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, subtract, true).valueOf(); - } - }); - - subtract.toTex = { - 2: '\\left(${args[0]}' + latex.operators['subtract'] + '${args[1]}\\right)' - }; - - return subtract; - } - - exports.name = 'subtract'; - exports.factory = factory; - - -/***/ }, -/* 78 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - /** - * Inverse the sign of a value, apply a unary minus operation. - * - * For matrices, the function is evaluated element wise. Boolean values and - * strings will be converted to a number. For complex numbers, both real and - * complex value are inverted. - * - * Syntax: - * - * math.unaryMinus(x) - * - * Examples: - * - * math.unaryMinus(3.5); // returns -3.5 - * math.unaryMinus(-4.2); // returns 4.2 - * - * See also: - * - * add, subtract, unaryPlus - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Number to be inverted. - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Returns the value with inverted sign. - */ - var unaryMinus = typed('unaryMinus', { - 'number': function (x) { - return -x; - }, - - 'Complex': function (x) { - return x.neg(); - }, - - 'BigNumber': function (x) { - return x.neg(); - }, - - 'Fraction': function (x) { - return x.neg(); - }, - - 'Unit': function (x) { - var res = x.clone(); - res.value = unaryMinus(x.value); - return res; - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since unaryMinus(0) = 0 - return deepMap(x, unaryMinus, true); - } - - // TODO: add support for string - }); - - unaryMinus.toTex = { - 1: latex.operators['unaryMinus'] + '\\left(${args[0]}\\right)' - }; - - return unaryMinus; - } - - exports.name = 'unaryMinus'; - exports.factory = factory; - - -/***/ }, -/* 79 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). - * Callback function invoked MAX(NNZA, NNZB) times - * - * - * ┌ f(Aij, Bij) ; A(i,j) !== 0 || B(i,j) !== 0 - * C(i,j) = ┤ - * └ 0 ; otherwise - * - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm05 = function (a, b, callback) { - // sparse matrix arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = avalues && bvalues ? [] : undefined; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var xa = cvalues ? [] : undefined; - var xb = cvalues ? [] : undefined; - // marks indicating we have a value in x for a given column - var wa = []; - var wb = []; - - // vars - var i, j, k, k1; - - // loop columns - for (j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // columns mark - var mark = j + 1; - // loop values A(:,j) - for (k = aptr[j], k1 = aptr[j + 1]; k < k1; k++) { - // row - i = aindex[k]; - // push index - cindex.push(i); - // update workspace - wa[i] = mark; - // check we need to process values - if (xa) - xa[i] = avalues[k]; - } - // loop values B(:,j) - for (k = bptr[j], k1 = bptr[j + 1]; k < k1; k++) { - // row - i = bindex[k]; - // check row existed in A - if (wa[i] !== mark) { - // push index - cindex.push(i); - } - // update workspace - wb[i] = mark; - // check we need to process values - if (xb) - xb[i] = bvalues[k]; - } - // check we need to process values (non pattern matrix) - if (cvalues) { - // initialize first index in j - k = cptr[j]; - // loop index in j - while (k < cindex.length) { - // row - i = cindex[k]; - // marks - var wai = wa[i]; - var wbi = wb[i]; - // check Aij or Bij are nonzero - if (wai === mark || wbi === mark) { - // matrix values @ i,j - var va = wai === mark ? xa[i] : zero; - var vb = wbi === mark ? xb[i] : zero; - // Cij - var vc = cf(va, vb); - // check for zero - if (!eq(vc, zero)) { - // push value - cvalues.push(vc); - // increment pointer - k++; - } - else { - // remove value @ i, do not increment pointer - cindex.splice(k, 1); - } - } - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm05; - } - - exports.name = 'algorithm05'; - exports.factory = factory; - - -/***/ }, -/* 80 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory(type, config, load, typed) { - - /** - * Multiply two scalar values, `x * y`. - * This function is meant for internal use: it is used by the public function - * `multiply` - * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. - * - * @param {number | BigNumber | Fraction | Complex | Unit} x First value to multiply - * @param {number | BigNumber | Fraction | Complex} y Second value to multiply - * @return {number | BigNumber | Fraction | Complex | Unit} Multiplication of `x` and `y` - * @private - */ - var multiplyScalar = typed('multiplyScalar', { - - 'number, number': function (x, y) { - return x * y; - }, - - 'Complex, Complex': function (x, y) { - return x.mul(y); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.times(y); - }, - - 'Fraction, Fraction': function (x, y) { - return x.mul(y); - }, - - 'number | Fraction | BigNumber | Complex, Unit': function (x, y) { - var res = y.clone(); - res.value = (res.value === null) ? res._normalize(x) : multiplyScalar(res.value, x); - return res; - }, - - 'Unit, number | Fraction | BigNumber | Complex': function (x, y) { - var res = x.clone(); - res.value = (res.value === null) ? res._normalize(y) : multiplyScalar(res.value, y); - return res; - }, - - 'Unit, Unit': function (x, y) { - return x.multiply(y); - } - - }); - - return multiplyScalar; - } - - exports.factory = factory; - - -/***/ }, -/* 81 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory(type, config, load, typed) { - var multiplyScalar = load(__webpack_require__(80)); - - /** - * Divide two scalar values, `x / y`. - * This function is meant for internal use: it is used by the public functions - * `divide` and `inv`. - * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. - * - * @param {number | BigNumber | Fraction | Complex | Unit} x Numerator - * @param {number | BigNumber | Fraction | Complex} y Denominator - * @return {number | BigNumber | Fraction | Complex | Unit} Quotient, `x / y` - * @private - */ - var divideScalar = typed('divide', { - 'number, number': function (x, y) { - return x / y; - }, - - 'Complex, Complex': function (x, y) { - return x.div(y); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.div(y); - }, - - 'Fraction, Fraction': function (x, y) { - return x.div(y); - }, - - 'Unit, number | Fraction | BigNumber': function (x, y) { - var res = x.clone(); - // TODO: move the divide function to Unit.js, it uses internals of Unit - res.value = divideScalar(((res.value === null) ? res._normalize(1) : res.value), y); - return res; - }, - - 'number | Fraction | BigNumber, Unit': function (x, y) { - var res = y.pow(-1); - // TODO: move the divide function to Unit.js, it uses internals of Unit - res.value = multiplyScalar(((res.value === null) ? res._normalize(1) : res.value), x); - return res; - }, - - 'Unit, Unit': function (x, y) { - return x.divide(y); - } - - }); - - return divideScalar; - } - - exports.factory = factory; - - -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var size = __webpack_require__(40).size; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - var eye = load(__webpack_require__(83)); - var multiply = load(__webpack_require__(84)); - var matrix = load(__webpack_require__(52)); - var fraction = load(__webpack_require__(36)); - var number = load(__webpack_require__(70)); - - /** - * Calculates the power of x to y, `x ^ y`. - * Matrix exponentiation is supported for square matrices `x`, and positive - * integer exponents `y`. - * - * For cubic roots of negative numbers, the function returns the principal - * root by default. In order to let the function return the real root, - * math.js can be configured with `math.config({predictable: true})`. - * To retrieve all cubic roots of a value, use `math.cbrt(x, true)`. - * - * Syntax: - * - * math.pow(x, y) - * - * Examples: - * - * math.pow(2, 3); // returns number 8 - * - * var a = math.complex(2, 3); - * math.pow(a, 2) // returns Complex -5 + 12i - * - * var b = [[1, 2], [4, 3]]; - * math.pow(b, 2); // returns Array [[9, 8], [16, 17]] - * - * See also: - * - * multiply, sqrt, cbrt, nthRoot - * - * @param {number | BigNumber | Complex | Array | Matrix} x The base - * @param {number | BigNumber | Complex} y The exponent - * @return {number | BigNumber | Complex | Array | Matrix} The value of `x` to the power `y` - */ - var pow = typed('pow', { - 'number, number': _pow, - - 'Complex, Complex': function (x, y) { - return x.pow(y); - }, - - 'BigNumber, BigNumber': function (x, y) { - if (y.isInteger() || x >= 0 || config.predictable) { - return x.pow(y); - } - else { - return new type.Complex(x.toNumber(), 0).pow(y.toNumber(), 0); - } - }, - - 'Fraction, Fraction': function (x, y) { - if (y.d !== 1) { - if (config.predictable) { - throw new Error('Function pow does not support non-integer exponents for fractions.'); - } - else { - return _pow(x.valueOf(), y.valueOf()); - } - } - else { - return x.pow(y); - } - }, - - 'Array, number': _powArray, - - 'Array, BigNumber': function (x, y) { - return _powArray(x, y.toNumber()); - }, - - 'Matrix, number': _powMatrix, - - 'Matrix, BigNumber': function (x, y) { - return _powMatrix(x, y.toNumber()); - }, - - 'Unit, number': function (x, y) { - return x.pow(y); - } - - }); - - /** - * Calculates the power of x to y, x^y, for two numbers. - * @param {number} x - * @param {number} y - * @return {number | Complex} res - * @private - */ - function _pow(x, y) { - - // Alternatively could define a 'realmode' config option or something, but - // 'predictable' will work for now - if (config.predictable && !isInteger(y) && x < 0) { - // Check to see if y can be represented as a fraction - try { - var yFrac = fraction(y); - var yNum = number(yFrac); - if(y === yNum || Math.abs((y - yNum) / y) < 1e-14) { - if(yFrac.d % 2 === 1) { - return (yFrac.n % 2 === 0 ? 1 : -1) * Math.pow(-x, y); - } - } - } - catch (ex) { - // fraction() throws an error if y is Infinity, etc. - } - - // Unable to express y as a fraction, so continue on - } - - if (isInteger(y) || x >= 0 || config.predictable) { - return Math.pow(x, y); - } - else { - return new type.Complex(x, 0).pow(y, 0); - } - } - - /** - * Calculate the power of a 2d array - * @param {Array} x must be a 2 dimensional, square matrix - * @param {number} y a positive, integer value - * @returns {Array} - * @private - */ - function _powArray(x, y) { - if (!isInteger(y) || y < 0) { - throw new TypeError('For A^b, b must be a positive integer (value is ' + y + ')'); - } - // verify that A is a 2 dimensional square matrix - var s = size(x); - if (s.length != 2) { - throw new Error('For A^b, A must be 2 dimensional (A has ' + s.length + ' dimensions)'); - } - if (s[0] != s[1]) { - throw new Error('For A^b, A must be square (size is ' + s[0] + 'x' + s[1] + ')'); - } - - var res = eye(s[0]).valueOf(); - var px = x; - while (y >= 1) { - if ((y & 1) == 1) { - res = multiply(px, res); - } - y >>= 1; - px = multiply(px, px); - } - return res; - } - - /** - * Calculate the power of a 2d matrix - * @param {Matrix} x must be a 2 dimensional, square matrix - * @param {number} y a positive, integer value - * @returns {Matrix} - * @private - */ - function _powMatrix (x, y) { - return matrix(_powArray(x.valueOf(), y)); - } - - - - pow.toTex = { - 2: '\\left(${args[0]}\\right)' + latex.operators['pow'] + '{${args[1]}}' - }; - - return pow; - } - - exports.name = 'pow'; - exports.factory = factory; - - -/***/ }, -/* 83 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(40); - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - /** - * Create a 2-dimensional identity matrix with size m x n or n x n. - * The matrix has ones on the diagonal and zeros elsewhere. - * - * Syntax: - * - * math.eye(n) - * math.eye(n, format) - * math.eye(m, n) - * math.eye(m, n, format) - * math.eye([m, n]) - * math.eye([m, n], format) - * - * Examples: - * - * math.eye(3); // returns [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - * math.eye(3, 2); // returns [[1, 0], [0, 1], [0, 0]] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.eye(math.size(A)); // returns [[1, 0, 0], [0, 1, 0]] - * - * See also: - * - * diag, ones, zeros, size, range - * - * @param {...number | Matrix | Array} size The size for the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Matrix | Array | number} A matrix with ones on the diagonal. - */ - var eye = typed('eye', { - '': function () { - return (config.matrix === 'Matrix') ? matrix([]) : []; - }, - - 'string': function (format) { - return matrix(format); - }, - - 'number | BigNumber': function (rows) { - return _eye(rows, rows, config.matrix === 'Matrix' ? 'default' : undefined); - }, - - 'number | BigNumber, string': function (rows, format) { - return _eye(rows, rows, format); - }, - - 'number | BigNumber, number | BigNumber': function (rows, cols) { - return _eye(rows, cols, config.matrix === 'Matrix' ? 'default' : undefined); - }, - - 'number | BigNumber, number | BigNumber, string': function (rows, cols, format) { - return _eye(rows, cols, format); - }, - - 'Array': function (size) { - return _eyeVector(size); - }, - - 'Array, string': function (size, format) { - return _eyeVector(size, format); - }, - - 'Matrix': function (size) { - return _eyeVector(size.valueOf(), size.storage()); - }, - - 'Matrix, string': function (size, format) { - return _eyeVector(size.valueOf(), format); - } - }); - - eye.toTex = undefined; // use default template - - return eye; - - function _eyeVector (size, format) { - switch (size.length) { - case 0: return format ? matrix(format) : []; - case 1: return _eye(size[0], size[0], format); - case 2: return _eye(size[0], size[1], format); - default: throw new Error('Vector containing two values expected'); - } - } - - /** - * Create an identity matrix - * @param {number | BigNumber} rows - * @param {number | BigNumber} cols - * @param {string} [format] - * @returns {Matrix} - * @private - */ - function _eye (rows, cols, format) { - // BigNumber constructor with the right precision - var Big = (rows && rows.isBigNumber === true) - ? type.BigNumber - : (cols && cols.isBigNumber === true) - ? type.BigNumber - : null; - - if (rows && rows.isBigNumber === true) rows = rows.toNumber(); - if (cols && cols.isBigNumber === true) cols = cols.toNumber(); - - if (!isInteger(rows) || rows < 1) { - throw new Error('Parameters in function eye must be positive integers'); - } - if (!isInteger(cols) || cols < 1) { - throw new Error('Parameters in function eye must be positive integers'); - } - - var one = Big ? new type.BigNumber(1) : 1; - var defaultValue = Big ? new Big(0) : 0; - var size = [rows, cols]; - - // check we need to return a matrix - if (format) { - // get matrix storage constructor - var F = type.Matrix.storage(format); - // create diagonal matrix (use optimized implementation for storage format) - return F.diagonal(size, one, 0, defaultValue); - } - - // create and resize array - var res = array.resize([], size, defaultValue); - // fill in ones on the diagonal - var minimum = rows < cols ? rows : cols; - // fill diagonal - for (var d = 0; d < minimum; d++) { - res[d][d] = one; - } - return res; - } - } - - exports.name = 'eye'; - exports.factory = factory; - - -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var extend = __webpack_require__(3).extend; - var array = __webpack_require__(40); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var addScalar = load(__webpack_require__(53)); - var multiplyScalar = load(__webpack_require__(80)); - var equalScalar = load(__webpack_require__(48)); - - var algorithm11 = load(__webpack_require__(85)); - var algorithm14 = load(__webpack_require__(58)); - - var DenseMatrix = type.DenseMatrix; - var SparseMatrix = type.SparseMatrix; - - /** - * Multiply two values, `x * y`. - * For matrices, the matrix product is calculated. - * - * Syntax: - * - * math.multiply(x, y) - * - * Examples: - * - * math.multiply(4, 5.2); // returns number 20.8 - * - * var a = math.complex(2, 3); - * var b = math.complex(4, 1); - * math.multiply(a, b); // returns Complex 5 + 14i - * - * var c = [[1, 2], [4, 3]]; - * var d = [[1, 2, 3], [3, -4, 7]]; - * math.multiply(c, d); // returns Array [[7, -6, 17], [13, -4, 33]] - * - * var e = math.unit('2.1 km'); - * math.multiply(3, e); // returns Unit 6.3 km - * - * See also: - * - * divide - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First value to multiply - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second value to multiply - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` - */ - var multiply = typed('multiply', extend({ - // we extend the signatures of multiplyScalar with signatures dealing with matrices - - 'Array, Array': function (x, y) { - // check dimensions - _validateMatrixDimensions(array.size(x), array.size(y)); - - // use dense matrix implementation - var m = multiply(matrix(x), matrix(y)); - // return array or scalar - return (m && m.isMatrix === true) ? m.valueOf() : m; - }, - - 'Matrix, Matrix': function (x, y) { - // dimensions - var xsize = x.size(); - var ysize = y.size(); - - // check dimensions - _validateMatrixDimensions(xsize, ysize); - - // process dimensions - if (xsize.length === 1) { - // process y dimensions - if (ysize.length === 1) { - // Vector * Vector - return _multiplyVectorVector(x, y, xsize[0]); - } - // Vector * Matrix - return _multiplyVectorMatrix(x, y); - } - // process y dimensions - if (ysize.length === 1) { - // Matrix * Vector - return _multiplyMatrixVector(x, y); - } - // Matrix * Matrix - return _multiplyMatrixMatrix(x, y); - }, - - 'Matrix, Array': function (x, y) { - // use Matrix * Matrix implementation - return multiply(x, matrix(y)); - }, - - 'Array, Matrix': function (x, y) { - // use Matrix * Matrix implementation - return multiply(matrix(x, y.storage()), y); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - - // process storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, multiplyScalar, false); - break; - case 'dense': - c = algorithm14(x, y, multiplyScalar, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm11(y, x, multiplyScalar, true); - break; - case 'dense': - c = algorithm14(y, x, multiplyScalar, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, multiplyScalar, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, multiplyScalar, true).valueOf(); - } - }, multiplyScalar.signatures)); - - var _validateMatrixDimensions = function (size1, size2) { - // check left operand dimensions - switch (size1.length) { - case 1: - // check size2 - switch (size2.length) { - case 1: - // Vector x Vector - if (size1[0] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Vectors must have the same length'); - } - break; - case 2: - // Vector x Matrix - if (size1[0] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Vector length (' + size1[0] + ') must match Matrix rows (' + size2[0] + ')'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); - } - break; - case 2: - // check size2 - switch (size2.length) { - case 1: - // Matrix x Vector - if (size1[1] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Matrix columns (' + size1[1] + ') must match Vector length (' + size2[0] + ')'); - } - break; - case 2: - // Matrix x Matrix - if (size1[1] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Matrix A columns (' + size1[1] + ') must match Matrix B rows (' + size2[0] + ')'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix A has ' + size1.length + ' dimensions)'); - } - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (N) - * @param {Matrix} b Dense Vector (N) - * - * @return {number} Scalar value - */ - var _multiplyVectorVector = function (a, b, n) { - // check empty vector - if (n === 0) - throw new Error('Cannot multiply two empty vectors'); - - // a dense - var adata = a._data; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bdt = b._datatype; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - } - - // result (do not initialize it with zero) - var c = mf(adata[0], bdata[0]); - // loop data - for (var i = 1; i < n; i++) { - // multiply and accumulate - c = af(c, mf(adata[i], bdata[i])); - } - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (M) - * @param {Matrix} b Matrix (MxN) - * - * @return {Matrix} Dense Vector (N) - */ - var _multiplyVectorMatrix = function (a, b) { - // process storage - switch (b.storage()) { - case 'dense': - return _multiplyVectorDenseMatrix(a, b); - } - throw new Error('Not implemented'); - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (M) - * @param {Matrix} b Dense Matrix (MxN) - * - * @return {Matrix} Dense Vector (N) - */ - var _multiplyVectorDenseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bsize = b._size; - var bdt = b._datatype; - // rows & columns - var alength = asize[0]; - var bcolumns = bsize[1]; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - } - - // result - var c = []; - - // loop matrix columns - for (var j = 0; j < bcolumns; j++) { - // sum (do not initialize it with zero) - var sum = mf(adata[0], bdata[0][j]); - // loop vector - for (var i = 1; i < alength; i++) { - // multiply & accumulate - sum = af(sum, mf(adata[i], bdata[i][j])); - } - c[j] = sum; - } - - // return matrix - return new DenseMatrix({ - data: c, - size: [bcolumns], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a Matrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} Dense Vector (M) - */ - var _multiplyMatrixVector = function (a, b) { - // process storage - switch (a.storage()) { - case 'dense': - return _multiplyDenseMatrixVector(a, b); - case 'sparse': - return _multiplySparseMatrixVector(a, b); - } - }; - - /** - * C = A * B - * - * @param {Matrix} a Matrix (MxN) - * @param {Matrix} b Matrix (NxC) - * - * @return {Matrix} Matrix (MxC) - */ - var _multiplyMatrixMatrix = function (a, b) { - // process storage - switch (a.storage()) { - case 'dense': - // process storage - switch (b.storage()) { - case 'dense': - return _multiplyDenseMatrixDenseMatrix(a, b); - case 'sparse': - return _multiplyDenseMatrixSparseMatrix(a, b); - } - break; - case 'sparse': - // process storage - switch (b.storage()) { - case 'dense': - return _multiplySparseMatrixDenseMatrix(a, b); - case 'sparse': - return _multiplySparseMatrixSparseMatrix(a, b); - } - break; - } - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} Dense Vector (M) - */ - var _multiplyDenseMatrixVector = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = asize[0]; - var acolumns = asize[1]; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - } - - // result - var c = []; - - // loop matrix a rows - for (var i = 0; i < arows; i++) { - // current row - var row = adata[i]; - // sum (do not initialize it with zero) - var sum = mf(row[0], bdata[0]); - // loop matrix a columns - for (var j = 1; j < acolumns; j++) { - // multiply & accumulate - sum = af(sum, mf(row[j], bdata[j])); - } - c[i] = sum; - } - - // return matrix - return new DenseMatrix({ - data: c, - size: [arows], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b DenseMatrix (NxC) - * - * @return {Matrix} DenseMatrix (MxC) - */ - var _multiplyDenseMatrixDenseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bsize = b._size; - var bdt = b._datatype; - // rows & columns - var arows = asize[0]; - var acolumns = asize[1]; - var bcolumns = bsize[1]; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - } - - // result - var c = []; - - // loop matrix a rows - for (var i = 0; i < arows; i++) { - // current row - var row = adata[i]; - // initialize row array - c[i] = []; - // loop matrix b columns - for (var j = 0; j < bcolumns; j++) { - // sum (avoid initializing sum to zero) - var sum = mf(row[0], bdata[0][j]); - // loop matrix a columns - for (var x = 1; x < acolumns; x++) { - // multiply & accumulate - sum = af(sum, mf(row[x], bdata[x][j])); - } - c[i][j] = sum; - } - } - - // return matrix - return new DenseMatrix({ - data: c, - size: [arows, bcolumns], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b SparseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplyDenseMatrixSparseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b sparse - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - // validate b matrix - if (!bvalues) - throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix'); - // rows & columns - var arows = asize[0]; - var bcolumns = bsize[1]; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - // equalScalar signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - } - - // result - var cvalues = []; - var cindex = []; - var cptr = []; - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // indeces in column jb - var kb0 = bptr[jb]; - var kb1 = bptr[jb + 1]; - // do not process column jb if no data exists - if (kb1 > kb0) { - // last row mark processed - var last = 0; - // loop a rows - for (var i = 0; i < arows; i++) { - // column mark - var mark = i + 1; - // C[i, jb] - var cij; - // values in b column j - for (var kb = kb0; kb < kb1; kb++) { - // row - var ib = bindex[kb]; - // check value has been initialized - if (last !== mark) { - // first value in column jb - cij = mf(adata[i][ib], bvalues[kb]); - // update mark - last = mark; - } - else { - // accumulate value - cij = af(cij, mf(adata[i][ib], bvalues[kb])); - } - } - // check column has been processed and value != 0 - if (last === mark && !eq(cij, zero)) { - // push row & value - cindex.push(i); - cvalues.push(cij); - } - } - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // return sparse matrix - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} SparseMatrix (M, 1) - */ - var _multiplySparseMatrixVector = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // validate a matrix - if (!avalues) - throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = a._size[0]; - var brows = b._size[0]; - // result - var cvalues = []; - var cindex = []; - var cptr = []; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - // equalScalar signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - } - - // workspace - var x = []; - // vector with marks indicating a value x[i] exists in a given column - var w = []; - - // update ptr - cptr[0] = 0; - // rows in b - for (var ib = 0; ib < brows; ib++) { - // b[ib] - var vbi = bdata[ib]; - // check b[ib] != 0, avoid loops - if (!eq(vbi, zero)) { - // A values & index in ib column - for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // a row - var ia = aindex[ka]; - // check value exists in current j - if (!w[ia]) { - // ia is new entry in j - w[ia] = true; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(vbi, avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(vbi, avalues[ka])); - } - } - } - } - // copy values from x to column jb of c - for (var p1 = cindex.length, p = 0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - // update ptr - cptr[1] = cindex.length; - - // return sparse matrix - return new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, 1], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b DenseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplySparseMatrixDenseMatrix = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // validate a matrix - if (!avalues) - throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = a._size[0]; - var brows = b._size[0]; - var bcolumns = b._size[1]; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - // equalScalar signature to use - var eq = equalScalar; - // zero value - var zero = 0; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - } - - // result - var cvalues = []; - var cindex = []; - var cptr = []; - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - - // workspace - var x = []; - // vector with marks indicating a value x[i] exists in a given column - var w = []; - - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // mark in workspace for current column - var mark = jb + 1; - // rows in jb - for (var ib = 0; ib < brows; ib++) { - // b[ib, jb] - var vbij = bdata[ib][jb]; - // check b[ib, jb] != 0, avoid loops - if (!eq(vbij, zero)) { - // A values & index in ib column - for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // a row - var ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(vbij, avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(vbij, avalues[ka])); - } - } - } - } - // copy values from x to column jb of c - for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // return sparse matrix - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b SparseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplySparseMatrixSparseMatrix = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // b sparse - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bdt = b._datatype; - - // rows & columns - var arows = a._size[0]; - var bcolumns = b._size[1]; - // flag indicating both matrices (a & b) contain data - var values = avalues && bvalues; - - // datatype - var dt; - // addScalar signature to use - var af = addScalar; - // multiplyScalar signature to use - var mf = multiplyScalar; - - // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { - // datatype - dt = adt; - // find signatures that matches (dt, dt) - af = typed.find(addScalar, [dt, dt]); - mf = typed.find(multiplyScalar, [dt, dt]); - } - - // result - var cvalues = values ? [] : undefined; - var cindex = []; - var cptr = []; - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - - // workspace - var x = values ? [] : undefined; - // vector with marks indicating a value x[i] exists in a given column - var w = []; - // variables - var ka, ka0, ka1, kb, kb0, kb1, ia, ib; - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // mark in workspace for current column - var mark = jb + 1; - // B values & index in j - for (kb0 = bptr[jb], kb1 = bptr[jb + 1], kb = kb0; kb < kb1; kb++) { - // b row - ib = bindex[kb]; - // check we need to process values - if (values) { - // loop values in a[:,ib] - for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // row - ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(bvalues[kb], avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(bvalues[kb], avalues[ka])); - } - } - } - else { - // loop values in a[:,ib] - for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // row - ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - } - } - } - } - // check we need to process matrix values (pattern matrix) - if (values) { - // copy values from x to column jb of c - for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // return sparse matrix - return c; - }; - - multiply.toTex = { - 2: '\\left(${args[0]}' + latex.operators['multiply'] + '${args[1]}\\right)' - }; - - return multiply; - } - - exports.name = 'multiply'; - exports.factory = factory; - - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). - * Callback function invoked NZ times (number of nonzero items in S). - * - * - * ┌ f(Sij, b) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ 0 ; otherwise - * - * - * @param {Matrix} s The SparseMatrix instance (S) - * @param {Scalar} b The Scalar value - * @param {Function} callback The f(Aij,b) operation to invoke - * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) - * - * @return {Matrix} SparseMatrix (C) - * - * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 - */ - var algorithm11 = function (s, b, callback, inverse) { - // sparse matrix arrays - var avalues = s._values; - var aindex = s._index; - var aptr = s._ptr; - var asize = s._size; - var adt = s._datatype; - - // sparse matrix cannot be a Pattern matrix - if (!avalues) - throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string') { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // convert b to the same datatype - b = typed.convert(b, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = []; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // loop columns - for (var j = 0; j < columns; j++) { - // initialize ptr - cptr[j] = cindex.length; - // values in j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - var i = aindex[k]; - // invoke callback - var v = inverse ? cf(b, avalues[k]) : cf(avalues[k], b); - // check value is zero - if (!eq(v, zero)) { - // push index & value - cindex.push(i); - cvalues.push(v); - } - } - } - // update ptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm11; - } - - exports.name = 'algorithm11'; - exports.factory = factory; - - -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the absolute value of a number. For matrices, the function is - * evaluated element wise. - * - * Syntax: - * - * math.abs(x) - * - * Examples: - * - * math.abs(3.5); // returns number 3.5 - * math.abs(-4.2); // returns number 4.2 - * - * math.abs([3, -5, -1, 0, 2]); // returns Array [3, 5, 1, 0, 2] - * - * See also: - * - * sign - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x - * A number or matrix for which to get the absolute value - * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} - * Absolute value of `x` - */ - var abs = typed('abs', { - 'number': Math.abs, - - 'Complex': function (x) { - return x.abs(); - }, - - 'BigNumber': function (x) { - return x.abs(); - }, - - 'Fraction': function (x) { - return x.abs(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since abs(0) = 0 - return deepMap(x, abs, true); - }, - - 'Unit': function(x) { - return x.abs(); - } - }); - - abs.toTex = {1: '\\left|${args[0]}\\right|'}; - - return abs; - } - - exports.name = 'abs'; - exports.factory = factory; - - -/***/ }, -/* 87 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var equalScalar = load(__webpack_require__(48)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether two values are equal. - * - * The function tests whether the relative difference between x and y is - * smaller than the configured epsilon. The function cannot be used to - * compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * In case of complex numbers, x.re must equal y.re, and x.im must equal y.im. - * - * Values `null` and `undefined` are compared strictly, thus `null` is only - * equal to `null` and nothing else, and `undefined` is only equal to - * `undefined` and nothing else. - * - * Syntax: - * - * math.equal(x, y) - * - * Examples: - * - * math.equal(2 + 2, 3); // returns false - * math.equal(2 + 2, 4); // returns true - * - * var a = math.unit('50 cm'); - * var b = math.unit('5 m'); - * math.equal(a, b); // returns true - * - * var c = [2, 5, 1]; - * var d = [2, 7, 1]; - * - * math.equal(c, d); // returns [true, false, true] - * math.deepEqual(c, d); // returns false - * - * math.equal(0, null); // returns false - * - * See also: - * - * unequal, smaller, smallerEq, larger, largerEq, compare, deepEqual - * - * @param {number | BigNumber | boolean | Complex | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | boolean | Complex | Unit | string | Array | Matrix} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the compared values are equal, else returns false - */ - var equal = typed('equal', { - - 'any, any': function (x, y) { - // strict equality for null and undefined? - if (x === null) { return y === null; } - if (y === null) { return x === null; } - if (x === undefined) { return y === undefined; } - if (y === undefined) { return x === undefined; } - - return equalScalar(x, y); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, equalScalar); - break; - default: - // sparse + dense - c = algorithm03(y, x, equalScalar, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, equalScalar, false); - break; - default: - // dense + dense - c = algorithm13(x, y, equalScalar); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return equal(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return equal(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return equal(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, equalScalar, false); - break; - default: - c = algorithm14(x, y, equalScalar, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, equalScalar, true); - break; - default: - c = algorithm14(y, x, equalScalar, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, equalScalar, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, equalScalar, true).valueOf(); - } - }); - - equal.toTex = { - 2: '\\left(${args[0]}' + latex.operators['equal'] + '${args[1]}\\right)' - }; - - return equal; - } - - exports.name = 'equal'; - exports.factory = factory; - - -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Test whether a value is an numeric value. - * - * The function is evaluated element-wise in case of Array or Matrix input. - * - * Syntax: - * - * math.isNumeric(x) - * - * Examples: - * - * math.isNumeric(2); // returns true - * math.isNumeric(0); // returns true - * math.isNumeric(math.bignumber(500)); // returns true - * math.isNumeric(math.fraction(4)); // returns true - * math.isNumeric(math.complex('2-4i'); // returns false - * math.isNumeric('3'); // returns false - * math.isNumeric([2.3, 'foo', false]); // returns [true, false, true] - * - * See also: - * - * isZero, isPositive, isNegative, isInteger - * - * @param {*} x Value to be tested - * @return {boolean} Returns true when `x` is a `number`, `BigNumber`, - * `Fraction`, or `boolean`. Returns false for other types. - * Throws an error in case of unknown types. - */ - var isNumeric = typed('isNumeric', { - 'number | BigNumber | Fraction | boolean': function () { - return true; - }, - - 'Complex | Unit | string': function () { - return false; - }, - - 'Array | Matrix': function (x) { - return deepMap(x, isNumeric); - } - }); - - return isNumeric; - } - - exports.name = 'isNumeric'; - exports.factory = factory; - - -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var string = __webpack_require__(23); - - function factory (type, config, load, typed) { - /** - * Format a value of any type into a string. - * - * Syntax: - * - * math.format(value) - * math.format(value, options) - * math.format(value, precision) - * math.format(value, callback) - * - * Where: - * - * - `value: *` - * The value to be formatted - * - `options: Object` - * An object with formatting options. Available options: - * - `notation: string` - * Number notation. Choose from: - * - 'fixed' - * Always use regular number notation. - * For example '123.40' and '14000000' - * - 'exponential' - * Always use exponential notation. - * For example '1.234e+2' and '1.4e+7' - * - 'engineering' - * Always use engineering notation. - * For example '123.4e+0' and '14.0e+6' - * - 'auto' (default) - * Regular number notation for numbers having an absolute value between - * `lower` and `upper` bounds, and uses exponential notation elsewhere. - * Lower bound is included, upper bound is excluded. - * For example '123.4' and '1.4e7'. - * - `precision: number` - * A number between 0 and 16 to round the digits of the number. In case - * of notations 'exponential' and 'auto', `precision` defines the total - * number of significant digits returned and is undefined by default. - * In case of notation 'fixed', `precision` defines the number of - * significant digits after the decimal point, and is 0 by default. - * - `exponential: Object` - * An object containing two parameters, {number} lower and {number} upper, - * used by notation 'auto' to determine when to return exponential - * notation. Default values are `lower=1e-3` and `upper=1e5`. Only - * applicable for notation `auto`. - * - `fraction: string`. Available values: 'ratio' (default) or 'decimal'. - * For example `format(fraction(1, 3))` will output '1/3' when 'ratio' is - * configured, and will output `0.(3)` when 'decimal' is configured. - * - `callback: function` - * A custom formatting function, invoked for all numeric elements in `value`, - * for example all elements of a matrix, or the real and imaginary - * parts of a complex number. This callback can be used to override the - * built-in numeric notation with any type of formatting. Function `callback` - * is called with `value` as parameter and must return a string. - * - * When `value` is an Object: - * - * - When the object contains a property `format` being a function, this function - * is invoked as `value.format(options)` and the result is returned. - * - When the object has its own `toString` method, this method is invoked - * and the result is returned. - * - In other cases the function will loop over all object properties and - * return JSON object notation like '{"a": 2, "b": 3}'. - * - * When value is a function: - * - * - When the function has a property `syntax`, it returns this - * syntax description. - * - In other cases, a string `'function'` is returned. - * - * Examples: - * - * math.format(6.4); // returns '6.4' - * math.format(1240000); // returns '1.24e6' - * math.format(1/3); // returns '0.3333333333333333' - * math.format(1/3, 3); // returns '0.333' - * math.format(21385, 2); // returns '21000' - * math.format(12.071, {notation: 'fixed'}); // returns '12' - * math.format(2.3, {notation: 'fixed', precision: 2}); // returns '2.30' - * math.format(52.8, {notation: 'exponential'}); // returns '5.28e+1' - * math.format(12400, {notation: 'engineering'}); // returns '12.400e+3' - * - * function formatCurrency(value) { - * // return currency notation with two digits: - * return '$' + value.toFixed(2); - * - * // you could also use math.format inside the callback: - * // return '$' + math.format(value, {notation: 'fixed', precision: 2}); - * } - * math.format([2.1, 3, 0.016], formatCurrency}; // returns '[$2.10, $3.00, $0.02]' - * - * See also: - * - * print - * - * @param {*} value Value to be stringified - * @param {Object | Function | number} [options] Formatting options - * @return {string} The formatted value - */ - var format = typed('format', { - 'any': string.format, - 'any, Object | function | number': string.format - }); - - format.toTex = undefined; // use default template - - return format; - } - - exports.name = 'format'; - exports.factory = factory; - - -/***/ }, -/* 90 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var types = __webpack_require__(41); - - function factory (type, config, load, typed) { - /** - * Determine the type of a variable. - * - * Function `typeof` recognizes the following types of objects: - * - * Object | Returns | Example - * ---------------------- | ------------- | ------------------------------------------ - * null | `'null'` | `math.typeof(null)` - * number | `'number'` | `math.typeof(3.5)` - * boolean | `'boolean'` | `math.typeof (true)` - * string | `'string'` | `math.typeof ('hello world')` - * Array | `'Array'` | `math.typeof ([1, 2, 3])` - * Date | `'Date'` | `math.typeof (new Date())` - * Function | `'Function'` | `math.typeof (function () {})` - * Object | `'Object'` | `math.typeof ({a: 2, b: 3})` - * RegExp | `'RegExp'` | `math.typeof (/a regexp/)` - * undefined | `'undefined'` | `math.typeof(undefined)` - * math.type.BigNumber | `'BigNumber'` | `math.typeof (math.bignumber('2.3e500'))` - * math.type.Chain | `'Chain'` | `math.typeof (math.chain(2))` - * math.type.Complex | `'Complex'` | `math.typeof (math.complex(2, 3))` - * math.type.Fraction | `'Fraction'` | `math.typeof (math.fraction(1, 3))` - * math.type.Help | `'Help'` | `math.typeof (math.help('sqrt'))` - * math.type.Index | `'Index'` | `math.typeof (math.index(1, 3))` - * math.type.Matrix | `'Matrix'` | `math.typeof (math.matrix([[1,2], [3, 4]]))` - * math.type.Range | `'Range'` | `math.typeof (math.range(0, 10))` - * math.type.Unit | `'Unit'` | `math.typeof (math.unit('45 deg'))` - * - * Syntax: - * - * math.typeof(x) - * - * Examples: - * - * math.typeof(3.5); // returns 'number' - * math.typeof(math.complex('2-4i')); // returns 'Complex' - * math.typeof(math.unit('45 deg')); // returns 'Unit' - * math.typeof('hello world'); // returns 'string' - * - * @param {*} x The variable for which to test the type. - * @return {string} Returns the name of the type. Primitive types are lower case, - * non-primitive types are upper-camel-case. - * For example 'number', 'string', 'Array', 'Date'. - */ - var _typeof = typed('_typeof', { - 'any': function (x) { - // JavaScript types - var t = types.type(x); - - // math.js types - if (t === 'Object') { - if (x.isBigNumber === true) return 'BigNumber'; - if (x.isComplex === true) return 'Complex'; - if (x.isFraction === true) return 'Fraction'; - if (x.isMatrix === true) return 'Matrix'; - if (x.isUnit === true) return 'Unit'; - if (x.isIndex === true) return 'Index'; - if (x.isRange === true) return 'Range'; - if (x.isChain === true) return 'Chain'; - if (x.isHelp === true) return 'Help'; - } - - return t; - } - }); - - _typeof.toTex = undefined; // use default template - - return _typeof; - } - - exports.name = 'typeof'; - exports.factory = factory; - - -/***/ }, -/* 91 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Create a unit. Depending on the passed arguments, the function - * will create and return a new math.type.Unit object. - * When a matrix is provided, all elements will be converted to units. - * - * Syntax: - * - * math.unit(unit : string) - * math.unit(value : number, unit : string) - * - * Examples: - * - * var a = math.unit(5, 'cm'); // returns Unit 50 mm - * var b = math.unit('23 kg'); // returns Unit 23 kg - * a.to('m'); // returns Unit 0.05 m - * - * See also: - * - * bignumber, boolean, complex, index, matrix, number, string - * - * @param {* | Array | Matrix} args A number and unit. - * @return {Unit | Array | Matrix} The created unit - */ - - var unit = typed('unit', { - 'Unit': function (x) { - return x.clone(); - }, - - 'string': function (x) { - if (type.Unit.isValuelessUnit(x)) { - return new type.Unit(null, x); // a pure unit - } - - return type.Unit.parse(x); // a unit with value, like '5cm' - }, - - 'number | BigNumber | Fraction | Complex, string': function (value, unit) { - return new type.Unit(value, unit); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, unit); - } - }); - - unit.toTex = { - 1: '\\left(${args[0]}\\right)', - 2: '\\left(\\left(${args[0]}\\right)${args[1]}\\right)' - }; - - return unit; - } - - exports.name = 'unit'; - exports.factory = factory; - - -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { - - var lazy = __webpack_require__(3).lazy; - - - function factory (type, config, load, typed, math) { - - // helper function to create a unit with a fixed prefix - function fixedUnit(str) { - var unit = type.Unit.parse(str); - unit.fixPrefix = true; - return unit; - } - - // Source: http://www.wikiwand.com/en/Physical_constant - - // Universal constants - lazy(math, 'speedOfLight', function () {return fixedUnit('299792458 m s^-1')}); - lazy(math, 'gravitationConstant', function () {return fixedUnit('6.6738480e-11 m^3 kg^-1 s^-2')}); - lazy(math, 'planckConstant', function () {return fixedUnit('6.626069311e-34 J s')}); - lazy(math, 'reducedPlanckConstant',function () {return fixedUnit('1.05457172647e-34 J s')}); - - // Electromagnetic constants - lazy(math, 'magneticConstant', function () {return fixedUnit('1.2566370614e-6 N A^-2')}); - lazy(math, 'electricConstant', function () {return fixedUnit('8.854187817e-12 F m^-1')}); - lazy(math, 'vacuumImpedance', function () {return fixedUnit('376.730313461 ohm')}); - lazy(math, 'coulomb', function () {return fixedUnit('8.9875517873681764e9 N m^2 C^-2')}); - lazy(math, 'elementaryCharge', function () {return fixedUnit('1.60217656535e-19 C')}); - lazy(math, 'bohrMagneton', function () {return fixedUnit('9.2740096820e-24 J T^-1')}); - lazy(math, 'conductanceQuantum', function () {return fixedUnit('7.748091734625e-5 S')}); - lazy(math, 'inverseConductanceQuantum', function () {return fixedUnit('12906.403721742 ohm')}); - lazy(math, 'magneticFluxQuantum', function () {return fixedUnit('2.06783375846e-15 Wb')}); - lazy(math, 'nuclearMagneton', function () {return fixedUnit('5.0507835311e-27 J T^-1')}); - lazy(math, 'klitzing', function () {return fixedUnit('25812.807443484 ohm')}); - //lazy(math, 'josephson', function () {return fixedUnit('4.8359787011e-14 Hz V^-1')}); // TODO: support for Hz needed - - // Atomic and nuclear constants - lazy(math, 'bohrRadius', function () {return fixedUnit('5.291772109217e-11 m')}); - lazy(math, 'classicalElectronRadius', function () {return fixedUnit('2.817940326727e-15 m')}); - lazy(math, 'electronMass', function () {return fixedUnit('9.1093829140e-31 kg')}); - lazy(math, 'fermiCoupling', function () {return fixedUnit('1.1663645e-5 GeV^-2')}); - lazy(math, 'fineStructure', function () {return 7.297352569824e-3}); - lazy(math, 'hartreeEnergy', function () {return fixedUnit('4.3597443419e-18 J')}); - lazy(math, 'protonMass', function () {return fixedUnit('1.67262177774e-27 kg')}); - lazy(math, 'deuteronMass', function () {return fixedUnit('3.3435830926e-27 kg')}); - lazy(math, 'neutronMass', function () {return fixedUnit('1.6749271613e-27 kg')}); - lazy(math, 'quantumOfCirculation', function () {return fixedUnit('3.636947552024e-4 m^2 s^-1')}); - lazy(math, 'rydberg', function () {return fixedUnit('10973731.56853955 m^-1')}); - lazy(math, 'thomsonCrossSection', function () {return fixedUnit('6.65245873413e-29 m^2')}); - lazy(math, 'weakMixingAngle', function () {return 0.222321}); - lazy(math, 'efimovFactor', function () {return 22.7}); - - // Physico-chemical constants - lazy(math, 'atomicMass', function () {return fixedUnit('1.66053892173e-27 kg')}); - lazy(math, 'avogadro', function () {return fixedUnit('6.0221412927e23 mol^-1')}); - lazy(math, 'boltzmann', function () {return fixedUnit('1.380648813e-23 J K^-1')}); - lazy(math, 'faraday', function () {return fixedUnit('96485.336521 C mol^-1')}); - lazy(math, 'firstRadiation', function () {return fixedUnit('3.7417715317e-16 W m^2')}); - // lazy(math, 'spectralRadiance', function () {return fixedUnit('1.19104286953e-16 W m^2 sr^-1')}); // TODO spectralRadiance - lazy(math, 'loschmidt', function () {return fixedUnit('2.686780524e25 m^-3')}); - lazy(math, 'gasConstant', function () {return fixedUnit('8.314462175 J K^-1 mol^-1')}); - lazy(math, 'molarPlanckConstant', function () {return fixedUnit('3.990312717628e-10 J s mol^-1')}); - lazy(math, 'molarVolume', function () {return fixedUnit('2.241396820e-10 m^3 mol^-1')}); - lazy(math, 'sackurTetrode', function () {return -1.164870823}); - lazy(math, 'secondRadiation', function () {return fixedUnit('1.438777013e-2 m K')}); - lazy(math, 'stefanBoltzmann', function () {return fixedUnit('5.67037321e-8 W m^-2 K^-4')}); - lazy(math, 'wienDisplacement', function () {return fixedUnit('2.897772126e-3 m K')}); - - // Adopted values - lazy(math, 'molarMass', function () {return fixedUnit('1e-3 kg mol^-1')}); - lazy(math, 'molarMassC12', function () {return fixedUnit('1.2e-2 kg mol^-1')}); - lazy(math, 'gravity', function () {return fixedUnit('9.80665 m s^-2')}); - // atm is defined in Unit.js - - // Natural units - lazy(math, 'planckLength', function () {return fixedUnit('1.61619997e-35 m')}); - lazy(math, 'planckMass', function () {return fixedUnit('2.1765113e-8 kg')}); - lazy(math, 'planckTime', function () {return fixedUnit('5.3910632e-44 s')}); - lazy(math, 'planckCharge', function () {return fixedUnit('1.87554595641e-18 C')}); - lazy(math, 'planckTemperature', function () {return fixedUnit('1.41683385e+32 K')}); - - } - - exports.factory = factory; - exports.lazy = false; // no lazy loading of constants, the constants themselves are lazy when needed - exports.math = true; // request access to the math namespace - - -/***/ }, -/* 93 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(3); - var bigConstants = __webpack_require__(76); - - function factory (type, config, load, typed, math) { - // listen for changed in the configuration, automatically reload - // constants when needed - math.on('config', function (curr, prev) { - if (curr.number !== prev.number) { - factory(type, config, load, typed, math); - } - }); - - math['true'] = true; - math['false'] = false; - math['null'] = null; - math['uninitialized'] = __webpack_require__(40).UNINITIALIZED; - - if (config.number === 'BigNumber') { - math['Infinity'] = new type.BigNumber(Infinity); - math['NaN'] = new type.BigNumber(NaN); - - object.lazy(math, 'pi', function () {return bigConstants.pi(type.BigNumber)}); - object.lazy(math, 'tau', function () {return bigConstants.tau(type.BigNumber)}); - object.lazy(math, 'e', function () {return bigConstants.e(type.BigNumber)}); - object.lazy(math, 'phi', function () {return bigConstants.phi(type.BigNumber)}); // golden ratio, (1+sqrt(5))/2 - - // uppercase constants (for compatibility with built-in Math) - object.lazy(math, 'E', function () {return math.e;}); - object.lazy(math, 'LN2', function () {return new type.BigNumber(2).ln();}); - object.lazy(math, 'LN10', function () {return new type.BigNumber(10).ln()}); - object.lazy(math, 'LOG2E', function () {return new type.BigNumber(1).div(new type.BigNumber(2).ln());}); - object.lazy(math, 'LOG10E', function () {return new type.BigNumber(1).div(new type.BigNumber(10).ln())}); - object.lazy(math, 'PI', function () {return math.pi}); - object.lazy(math, 'SQRT1_2', function () {return new type.BigNumber('0.5').sqrt()}); - object.lazy(math, 'SQRT2', function () {return new type.BigNumber(2).sqrt()}); - } - else { - math['Infinity'] = Infinity; - math['NaN'] = NaN; - - math.pi = Math.PI; - math.tau = Math.PI * 2; - math.e = Math.E; - math.phi = 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2 - - // uppercase constants (for compatibility with built-in Math) - math.E = math.e; - math.LN2 = Math.LN2; - math.LN10 = Math.LN10; - math.LOG2E = Math.LOG2E; - math.LOG10E = Math.LOG10E; - math.PI = math.pi; - math.SQRT1_2 = Math.SQRT1_2; - math.SQRT2 = Math.SQRT2; - } - - // complex i - math.i = type.Complex.I; - - // meta information - math.version = __webpack_require__(94); - } - - exports.factory = factory; - exports.lazy = false; // no lazy loading of constants, the constants themselves are lazy when needed - exports.math = true; // request access to the math namespace - -/***/ }, -/* 94 */ -/***/ function(module, exports) { - - module.exports = '3.2.1'; - // Note: This file is automatically generated when building math.js. - // Changes made in this file will be overwritten. - - -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(96), - __webpack_require__(268), - __webpack_require__(297), - __webpack_require__(299), - - __webpack_require__(325), - __webpack_require__(270), - __webpack_require__(296) - ]; - - -/***/ }, -/* 96 */ -/***/ function(module, exports, __webpack_require__) { - - function factory (construction, config, load, typed) { - var docs = {}; - - - // construction functions - docs.bignumber = __webpack_require__(97); - docs['boolean'] = __webpack_require__(98); - docs.complex = __webpack_require__(99); - docs.fraction = __webpack_require__(100); - docs.index = __webpack_require__(101); - docs.matrix = __webpack_require__(102); - docs.number = __webpack_require__(103); - docs.sparse = __webpack_require__(104); - docs.string = __webpack_require__(105); - docs.unit = __webpack_require__(106); - - // constants - docs.e = __webpack_require__(107); - docs.E = __webpack_require__(107); - docs['false'] = __webpack_require__(108); - docs.i = __webpack_require__(109); - docs['Infinity'] = __webpack_require__(110); - docs.LN2 = __webpack_require__(111); - docs.LN10 = __webpack_require__(112); - docs.LOG2E = __webpack_require__(113); - docs.LOG10E = __webpack_require__(114); - docs.NaN = __webpack_require__(115); - docs['null'] = __webpack_require__(116); - docs.pi = __webpack_require__(117); - docs.PI = __webpack_require__(117); - docs.phi = __webpack_require__(118); - docs.SQRT1_2 = __webpack_require__(119); - docs.SQRT2 = __webpack_require__(120); - docs.tau = __webpack_require__(121); - docs['true'] = __webpack_require__(122); - docs.version = __webpack_require__(123); - - // physical constants - // TODO: more detailed docs for physical constants - docs.speedOfLight = {description: 'Speed of light in vacuum', examples: ['speedOfLight']}; - docs.gravitationConstant = {description: 'Newtonian constant of gravitation', examples: ['gravitationConstant']}; - docs.planckConstant = {description: 'Planck constant', examples: ['planckConstant']}; - docs.reducedPlanckConstant = {description: 'Reduced Planck constant', examples: ['reducedPlanckConstant']}; - - docs.magneticConstant = {description: 'Magnetic constant (vacuum permeability)', examples: ['magneticConstant']}; - docs.electricConstant = {description: 'Electric constant (vacuum permeability)', examples: ['electricConstant']}; - docs.vacuumImpedance = {description: 'Characteristic impedance of vacuum', examples: ['vacuumImpedance']}; - docs.coulomb = {description: 'Coulomb\'s constant', examples: ['coulomb']}; - docs.elementaryCharge = {description: 'Elementary charge', examples: ['elementaryCharge']}; - docs.bohrMagneton = {description: 'Borh magneton', examples: ['bohrMagneton']}; - docs.conductanceQuantum = {description: 'Conductance quantum', examples: ['conductanceQuantum']}; - docs.inverseConductanceQuantum = {description: 'Inverse conductance quantum', examples: ['inverseConductanceQuantum']}; - //docs.josephson = {description: 'Josephson constant', examples: ['josephson']}; - docs.magneticFluxQuantum = {description: 'Magnetic flux quantum', examples: ['magneticFluxQuantum']}; - docs.nuclearMagneton = {description: 'Nuclear magneton', examples: ['nuclearMagneton']}; - docs.klitzing = {description: 'Von Klitzing constant', examples: ['klitzing']}; - - docs.bohrRadius = {description: 'Borh radius', examples: ['bohrRadius']}; - docs.classicalElectronRadius = {description: 'Classical electron radius', examples: ['classicalElectronRadius']}; - docs.electronMass = {description: 'Electron mass', examples: ['electronMass']}; - docs.fermiCoupling = {description: 'Fermi coupling constant', examples: ['fermiCoupling']}; - docs.fineStructure = {description: 'Fine-structure constant', examples: ['fineStructure']}; - docs.hartreeEnergy = {description: 'Hartree energy', examples: ['hartreeEnergy']}; - docs.protonMass = {description: 'Proton mass', examples: ['protonMass']}; - docs.deuteronMass = {description: 'Deuteron Mass', examples: ['deuteronMass']}; - docs.neutronMass = {description: 'Neutron mass', examples: ['neutronMass']}; - docs.quantumOfCirculation = {description: 'Quantum of circulation', examples: ['quantumOfCirculation']}; - docs.rydberg = {description: 'Rydberg constant', examples: ['rydberg']}; - docs.thomsonCrossSection = {description: 'Thomson cross section', examples: ['thomsonCrossSection']}; - docs.weakMixingAngle = {description: 'Weak mixing angle', examples: ['weakMixingAngle']}; - docs.efimovFactor = {description: 'Efimov factor', examples: ['efimovFactor']}; - - docs.atomicMass = {description: 'Atomic mass constant', examples: ['atomicMass']}; - docs.avogadro = {description: 'Avogadro\'s number', examples: ['avogadro']}; - docs.boltzmann = {description: 'Boltzmann constant', examples: ['boltzmann']}; - docs.faraday = {description: 'Faraday constant', examples: ['faraday']}; - docs.firstRadiation = {description: 'First radiation constant', examples: ['firstRadiation']}; - docs.loschmidt = {description: 'Loschmidt constant at T=273.15 K and p=101.325 kPa', examples: ['loschmidt']}; - docs.gasConstant = {description: 'Gas constant', examples: ['gasConstant']}; - docs.molarPlanckConstant = {description: 'Molar Planck constant', examples: ['molarPlanckConstant']}; - docs.molarVolume = {description: 'Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa', examples: ['molarVolume']}; - docs.sackurTetrode = {description: 'Sackur-Tetrode constant at T=1 K and p=101.325 kPa', examples: ['sackurTetrode']}; - docs.secondRadiation = {description: 'Second radiation constant', examples: ['secondRadiation']}; - docs.stefanBoltzmann = {description: 'Stefan-Boltzmann constant', examples: ['stefanBoltzmann']}; - docs.wienDisplacement = {description: 'Wien displacement law constant', examples: ['wienDisplacement']}; - //docs.spectralRadiance = {description: 'First radiation constant for spectral radiance', examples: ['spectralRadiance']}; - - docs.molarMass = {description: 'Molar mass constant', examples: ['molarMass']}; - docs.molarMassC12 = {description: 'Molar mass constant of carbon-12', examples: ['molarMassC12']}; - docs.gravity = {description: 'Standard acceleration of gravity (standard acceleration of free-fall on Earth)', examples: ['gravity']}; - - docs.planckLength = {description: 'Planck length', examples: ['planckLength']}; - docs.planckMass = {description: 'Planck mass', examples: ['planckMass']}; - docs.planckTime = {description: 'Planck time', examples: ['planckTime']}; - docs.planckCharge = {description: 'Planck charge', examples: ['planckCharge']}; - docs.planckTemperature = {description: 'Planck temperature', examples: ['planckTemperature']}; - - // functions - algebra - docs.lsolve = __webpack_require__(124); - docs.lup = __webpack_require__(125); - docs.lusolve = __webpack_require__(126); - docs.slu = __webpack_require__(127); - docs.usolve = __webpack_require__(128); - - // functions - arithmetic - docs.abs = __webpack_require__(129); - docs.add = __webpack_require__(130); - docs.cbrt = __webpack_require__(131); - docs.ceil = __webpack_require__(132); - docs.cube = __webpack_require__(133); - docs.divide = __webpack_require__(134); - docs.dotDivide = __webpack_require__(135); - docs.dotMultiply = __webpack_require__(136); - docs.dotPow = __webpack_require__(137); - docs.exp = __webpack_require__(138); - docs.fix = __webpack_require__(139); - docs.floor = __webpack_require__(140); - docs.gcd = __webpack_require__(141); - docs.hypot = __webpack_require__(142); - docs.lcm = __webpack_require__(143); - docs.log = __webpack_require__(144); - docs.log10 = __webpack_require__(145); - docs.mod = __webpack_require__(146); - docs.multiply = __webpack_require__(147); - docs.norm = __webpack_require__(148); - docs.nthRoot = __webpack_require__(149); - docs.pow = __webpack_require__(150); - docs.round = __webpack_require__(151); - docs.sign = __webpack_require__(152); - docs.sqrt = __webpack_require__(153); - docs.square = __webpack_require__(154); - docs.subtract = __webpack_require__(155); - docs.unaryMinus = __webpack_require__(156); - docs.unaryPlus = __webpack_require__(157); - docs.xgcd = __webpack_require__(158); - - // functions - bitwise - docs.bitAnd = __webpack_require__(159); - docs.bitNot = __webpack_require__(160); - docs.bitOr = __webpack_require__(161); - docs.bitXor = __webpack_require__(162); - docs.leftShift = __webpack_require__(163); - docs.rightArithShift = __webpack_require__(164); - docs.rightLogShift = __webpack_require__(165); - - // functions - combinatorics - docs.bellNumbers = __webpack_require__(166); - docs.catalan = __webpack_require__(167); - docs.composition = __webpack_require__(168); - docs.stirlingS2 = __webpack_require__(169); - - // functions - core - docs['config'] = __webpack_require__(170); - docs['import'] = __webpack_require__(171); - docs['typed'] = __webpack_require__(172); - - // functions - complex - docs.arg = __webpack_require__(173); - docs.conj = __webpack_require__(174); - docs.re = __webpack_require__(175); - docs.im = __webpack_require__(176); - - // functions - expression - docs['eval'] = __webpack_require__(177); - docs.help = __webpack_require__(178); - - // functions - geometry - docs.distance = __webpack_require__(179); - docs.intersect = __webpack_require__(180); - - // functions - logical - docs['and'] = __webpack_require__(181); - docs['not'] = __webpack_require__(182); - docs['or'] = __webpack_require__(183); - docs['xor'] = __webpack_require__(184); - - // functions - matrix - docs['concat'] = __webpack_require__(185); - docs.cross = __webpack_require__(186); - docs.det = __webpack_require__(187); - docs.diag = __webpack_require__(188); - docs.dot = __webpack_require__(189); - docs.eye = __webpack_require__(190); - docs.filter = __webpack_require__(191); - docs.flatten = __webpack_require__(192); - docs.forEach = __webpack_require__(193); - docs.inv = __webpack_require__(194); - docs.map = __webpack_require__(195); - docs.ones = __webpack_require__(196); - docs.partitionSelect = __webpack_require__(197); - docs.range = __webpack_require__(198); - docs.resize = __webpack_require__(199); - docs.size = __webpack_require__(200); - docs.sort = __webpack_require__(201); - docs.squeeze = __webpack_require__(202); - docs.subset = __webpack_require__(203); - docs.trace = __webpack_require__(204); - docs.transpose = __webpack_require__(205); - docs.zeros = __webpack_require__(206); - - // functions - probability - docs.combinations = __webpack_require__(207); - //docs.distribution = require('./function/probability/distribution'); - docs.factorial = __webpack_require__(208); - docs.gamma = __webpack_require__(209); - docs.kldivergence = __webpack_require__(210); - docs.multinomial = __webpack_require__(211); - docs.permutations = __webpack_require__(212); - docs.pickRandom = __webpack_require__(213); - docs.random = __webpack_require__(214); - docs.randomInt = __webpack_require__(215); - - // functions - relational - docs.compare = __webpack_require__(216); - docs.deepEqual = __webpack_require__(217); - docs['equal'] = __webpack_require__(218); - docs.larger = __webpack_require__(219); - docs.largerEq = __webpack_require__(220); - docs.smaller = __webpack_require__(221); - docs.smallerEq = __webpack_require__(222); - docs.unequal = __webpack_require__(223); - - // functions - statistics - docs.max = __webpack_require__(224); - docs.mean = __webpack_require__(225); - docs.median = __webpack_require__(226); - docs.min = __webpack_require__(227); - docs.mode = __webpack_require__(228); - docs.prod = __webpack_require__(229); - docs.quantileSeq = __webpack_require__(230); - docs.std = __webpack_require__(231); - docs.sum = __webpack_require__(232); - docs['var'] = __webpack_require__(233); - - // functions - trigonometry - docs.acos = __webpack_require__(234); - docs.acosh = __webpack_require__(235); - docs.acot = __webpack_require__(236); - docs.acoth = __webpack_require__(237); - docs.acsc = __webpack_require__(238); - docs.acsch = __webpack_require__(239); - docs.asec = __webpack_require__(240); - docs.asech = __webpack_require__(241); - docs.asin = __webpack_require__(242); - docs.asinh = __webpack_require__(243); - docs.atan = __webpack_require__(244); - docs.atanh = __webpack_require__(245); - docs.atan2 = __webpack_require__(246); - docs.cos = __webpack_require__(247); - docs.cosh = __webpack_require__(248); - docs.cot = __webpack_require__(249); - docs.coth = __webpack_require__(250); - docs.csc = __webpack_require__(251); - docs.csch = __webpack_require__(252); - docs.sec = __webpack_require__(253); - docs.sech = __webpack_require__(254); - docs.sin = __webpack_require__(255); - docs.sinh = __webpack_require__(256); - docs.tan = __webpack_require__(257); - docs.tanh = __webpack_require__(258); - - // functions - units - docs.to = __webpack_require__(259); - - // functions - utils - docs.clone = __webpack_require__(260); - docs.format = __webpack_require__(261); - docs.isInteger = __webpack_require__(262); - docs.isNegative = __webpack_require__(263); - docs.isNumeric = __webpack_require__(264); - docs.isPositive = __webpack_require__(265); - docs.isZero = __webpack_require__(266); - // docs.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects. - docs['typeof'] = __webpack_require__(267); - - return docs; - } - - exports.name = 'docs'; - exports.path = 'expression'; - exports.factory = factory; - - -/***/ }, -/* 97 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bignumber', - 'category': 'Construction', - 'syntax': [ - 'bignumber(x)' - ], - 'description': - 'Create a big number from a number or string.', - 'examples': [ - '0.1 + 0.2', - 'bignumber(0.1) + bignumber(0.2)', - 'bignumber("7.2")', - 'bignumber("7.2e500")', - 'bignumber([0.1, 0.2, 0.3])' - ], - 'seealso': [ - 'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit' - ] - }; - - -/***/ }, -/* 98 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'boolean', - 'category': 'Construction', - 'syntax': [ - 'x', - 'boolean(x)' - ], - 'description': - 'Convert a string or number into a boolean.', - 'examples': [ - 'boolean(0)', - 'boolean(1)', - 'boolean(3)', - 'boolean("true")', - 'boolean("false")', - 'boolean([1, 0, 1, 1])' - ], - 'seealso': [ - 'bignumber', 'complex', 'index', 'matrix', 'number', 'string', 'unit' - ] - }; - - -/***/ }, -/* 99 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'complex', - 'category': 'Construction', - 'syntax': [ - 'complex()', - 'complex(re, im)', - 'complex(string)' - ], - 'description': - 'Create a complex number.', - 'examples': [ - 'complex()', - 'complex(2, 3)', - 'complex("7 - 2i")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'index', 'matrix', 'number', 'string', 'unit' - ] - }; - - -/***/ }, -/* 100 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'fraction', - 'category': 'Construction', - 'syntax': [ - 'fraction(num)', - 'fraction(num,den)' - ], - 'description': - 'Create a fraction from a number or from a numerator and denominator.', - 'examples': [ - 'fraction(0.125)', - 'fraction(1, 3) + fraction(2, 5)' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'string', 'unit' - ] - }; - - -/***/ }, -/* 101 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'index', - 'category': 'Construction', - 'syntax': [ - '[start]', - '[start:end]', - '[start:step:end]', - '[start1, start 2, ...]', - '[start1:end1, start2:end2, ...]', - '[start1:step1:end1, start2:step2:end2, ...]' - ], - 'description': - 'Create an index to get or replace a subset of a matrix', - 'examples': [ - '[]', - '[1, 2, 3]', - 'A = [1, 2, 3; 4, 5, 6]', - 'A[1, :]', - 'A[1, 2] = 50', - 'A[0:2, 0:2] = ones(2, 2)' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'matrix,', 'number', 'range', 'string', 'unit' - ] - }; - - -/***/ }, -/* 102 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'matrix', - 'category': 'Construction', - 'syntax': [ - '[]', - '[a1, b1, ...; a2, b2, ...]', - 'matrix()', - 'matrix("dense")', - 'matrix([...])' - ], - 'description': - 'Create a matrix.', - 'examples': [ - '[]', - '[1, 2, 3]', - '[1, 2, 3; 4, 5, 6]', - 'matrix()', - 'matrix([3, 4])', - 'matrix([3, 4; 5, 6], "sparse")', - 'matrix([3, 4; 5, 6], "sparse", "number")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'sparse' - ] - }; - - -/***/ }, -/* 103 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'number', - 'category': 'Construction', - 'syntax': [ - 'x', - 'number(x)' - ], - 'description': - 'Create a number or convert a string or boolean into a number.', - 'examples': [ - '2', - '2e3', - '4.05', - 'number(2)', - 'number("7.2")', - 'number(true)', - 'number([true, false, true, true])', - 'number("52cm", "m")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit' - ] - }; - - -/***/ }, -/* 104 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sparse', - 'category': 'Construction', - 'syntax': [ - 'sparse()', - 'sparse([a1, b1, ...; a1, b2, ...])', - 'sparse([a1, b1, ...; a1, b2, ...], "number")' - ], - 'description': - 'Create a sparse matrix.', - 'examples': [ - 'sparse()', - 'sparse([3, 4; 5, 6])', - 'sparse([3, 0; 5, 0], "number")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'matrix' - ] - }; - - -/***/ }, -/* 105 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'string', - 'category': 'Construction', - 'syntax': [ - '"text"', - 'string(x)' - ], - 'description': - 'Create a string or convert a value to a string', - 'examples': [ - '"Hello World!"', - 'string(4.2)', - 'string(3 + 2i)' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'unit' - ] - }; - - -/***/ }, -/* 106 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'unit', - 'category': 'Construction', - 'syntax': [ - 'value unit', - 'unit(value, unit)', - 'unit(string)' - ], - 'description': - 'Create a unit.', - 'examples': [ - '5.5 mm', - '3 inch', - 'unit(7.1, "kilogram")', - 'unit("23 deg")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'string' - ] - }; - - -/***/ }, -/* 107 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'e', - 'category': 'Constants', - 'syntax': [ - 'e' - ], - 'description': 'Euler\'s number, the base of the natural logarithm. Approximately equal to 2.71828', - 'examples': [ - 'e', - 'e ^ 2', - 'exp(2)', - 'log(e)' - ], - 'seealso': ['exp'] - }; - - -/***/ }, -/* 108 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'false', - 'category': 'Constants', - 'syntax': [ - 'false' - ], - 'description': 'Boolean value false', - 'examples': [ - 'false' - ], - 'seealso': ['true'] - }; - - -/***/ }, -/* 109 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'i', - 'category': 'Constants', - 'syntax': [ - 'i' - ], - 'description': 'Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.', - 'examples': [ - 'i', - 'i * i', - 'sqrt(-1)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 110 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'Infinity', - 'category': 'Constants', - 'syntax': [ - 'Infinity' - ], - 'description': 'Infinity, a number which is larger than the maximum number that can be handled by a floating point number.', - 'examples': [ - 'Infinity', - '1 / 0' - ], - 'seealso': [] - }; - - -/***/ }, -/* 111 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'LN2', - 'category': 'Constants', - 'syntax': [ - 'LN2' - ], - 'description': 'Returns the natural logarithm of 2, approximately equal to 0.693', - 'examples': [ - 'LN2', - 'log(2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 112 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'LN10', - 'category': 'Constants', - 'syntax': [ - 'LN10' - ], - 'description': 'Returns the natural logarithm of 10, approximately equal to 2.302', - 'examples': [ - 'LN10', - 'log(10)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 113 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'LOG2E', - 'category': 'Constants', - 'syntax': [ - 'LOG2E' - ], - 'description': 'Returns the base-2 logarithm of E, approximately equal to 1.442', - 'examples': [ - 'LOG2E', - 'log(e, 2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 114 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'LOG10E', - 'category': 'Constants', - 'syntax': [ - 'LOG10E' - ], - 'description': 'Returns the base-10 logarithm of E, approximately equal to 0.434', - 'examples': [ - 'LOG10E', - 'log(e, 10)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 115 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'NaN', - 'category': 'Constants', - 'syntax': [ - 'NaN' - ], - 'description': 'Not a number', - 'examples': [ - 'NaN', - '0 / 0' - ], - 'seealso': [] - }; - - -/***/ }, -/* 116 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'null', - 'category': 'Constants', - 'syntax': [ - 'null' - ], - 'description': 'Value null', - 'examples': [ - 'null' - ], - 'seealso': ['true', 'false'] - }; - - -/***/ }, -/* 117 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'pi', - 'category': 'Constants', - 'syntax': [ - 'pi' - ], - 'description': 'The number pi is a mathematical constant that is the ratio of a circle\'s circumference to its diameter, and is approximately equal to 3.14159', - 'examples': [ - 'pi', - 'sin(pi/2)' - ], - 'seealso': ['tau'] - }; - - -/***/ }, -/* 118 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'phi', - 'category': 'Constants', - 'syntax': [ - 'phi' - ], - 'description': 'Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...', - 'examples': [ - 'tau' - ], - 'seealso': [] - }; - - -/***/ }, -/* 119 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'SQRT1_2', - 'category': 'Constants', - 'syntax': [ - 'SQRT1_2' - ], - 'description': 'Returns the square root of 1/2, approximately equal to 0.707', - 'examples': [ - 'SQRT1_2', - 'sqrt(1/2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 120 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'SQRT2', - 'category': 'Constants', - 'syntax': [ - 'SQRT2' - ], - 'description': 'Returns the square root of 2, approximately equal to 1.414', - 'examples': [ - 'SQRT2', - 'sqrt(2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 121 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'tau', - 'category': 'Constants', - 'syntax': [ - 'tau' - ], - 'description': 'Tau is the ratio constant of a circle\'s circumference to radius, equal to 2 * pi, approximately 6.2832.', - 'examples': [ - 'tau', - '2 * pi' - ], - 'seealso': ['pi'] - }; - - -/***/ }, -/* 122 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'true', - 'category': 'Constants', - 'syntax': [ - 'true' - ], - 'description': 'Boolean value true', - 'examples': [ - 'true' - ], - 'seealso': ['false'] - }; - - -/***/ }, -/* 123 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'version', - 'category': 'Constants', - 'syntax': [ - 'version' - ], - 'description': 'A string with the version number of math.js', - 'examples': [ - 'version' - ], - 'seealso': [] - }; - - -/***/ }, -/* 124 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'lsolve', - 'category': 'Algebra', - 'syntax': [ - 'x=lsolve(L, b)' - ], - 'description': - 'Solves the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.', - 'examples': [ - 'a = [-2, 3; 2, 1]', - 'b = [11, 9]', - 'x = lsolve(a, b)' - ], - 'seealso': [ - 'lup', 'lusolve', 'usolve', 'matrix', 'sparse' - ] - }; - - -/***/ }, -/* 125 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'lup', - 'category': 'Algebra', - 'syntax': [ - 'lup(m)' - ], - 'description': - 'Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U', - 'examples': [ - 'lup([[2, 1], [1, 4]])', - 'lup(matrix([[2, 1], [1, 4]]))', - 'lup(sparse([[2, 1], [1, 4]]))' - ], - 'seealso': [ - 'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'slu' - ] - }; - - -/***/ }, -/* 126 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'lusolve', - 'category': 'Algebra', - 'syntax': [ - 'x=lusolve(A, b)', - 'x=lusolve(lu, b)' - ], - 'description': 'Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.', - 'examples': [ - 'a = [-2, 3; 2, 1]', - 'b = [11, 9]', - 'x = lusolve(a, b)' - ], - 'seealso': [ - 'lup', 'slu', 'lsolve', 'usolve', 'matrix', 'sparse' - ] - }; - - -/***/ }, -/* 127 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'slu', - 'category': 'Algebra', - 'syntax': [ - 'slu(A, order, threshold)' - ], - 'description': 'Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U', - 'examples': [ - 'slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)' - ], - 'seealso': [ - 'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'lup' - ] - }; - - -/***/ }, -/* 128 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'usolve', - 'category': 'Algebra', - 'syntax': [ - 'x=usolve(U, b)' - ], - 'description': - 'Solves the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.', - 'examples': [ - 'x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])' - ], - 'seealso': [ - 'lup', 'lusolve', 'lsolve', 'matrix', 'sparse' - ] - }; - - -/***/ }, -/* 129 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'abs', - 'category': 'Arithmetic', - 'syntax': [ - 'abs(x)' - ], - 'description': 'Compute the absolute value.', - 'examples': [ - 'abs(3.5)', - 'abs(-4.2)' - ], - 'seealso': ['sign'] - }; - - -/***/ }, -/* 130 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'add', - 'category': 'Operators', - 'syntax': [ - 'x + y', - 'add(x, y)' - ], - 'description': 'Add two values.', - 'examples': [ - 'a = 2.1 + 3.6', - 'a - 3.6', - '3 + 2i', - '3 cm + 2 inch', - '"2.3" + "4"' - ], - 'seealso': [ - 'subtract' - ] - }; - - -/***/ }, -/* 131 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cbrt', - 'category': 'Arithmetic', - 'syntax': [ - 'cbrt(x)', - 'cbrt(x, allRoots)' - ], - 'description': - 'Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned', - 'examples': [ - 'cbrt(64)', - 'cube(4)', - 'cbrt(-8)', - 'cbrt(2 + 3i)', - 'cbrt(8i)', - 'cbrt(8i, true)', - 'cbrt(27 m^3)' - ], - 'seealso': [ - 'square', - 'sqrt', - 'cube', - 'multiply' - ] - }; - - -/***/ }, -/* 132 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'ceil', - 'category': 'Arithmetic', - 'syntax': [ - 'ceil(x)' - ], - 'description': - 'Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.', - 'examples': [ - 'ceil(3.2)', - 'ceil(3.8)', - 'ceil(-4.2)' - ], - 'seealso': ['floor', 'fix', 'round'] - }; - - -/***/ }, -/* 133 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cube', - 'category': 'Arithmetic', - 'syntax': [ - 'cube(x)' - ], - 'description': 'Compute the cube of a value. The cube of x is x * x * x.', - 'examples': [ - 'cube(2)', - '2^3', - '2 * 2 * 2' - ], - 'seealso': [ - 'multiply', - 'square', - 'pow' - ] - }; - - -/***/ }, -/* 134 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'divide', - 'category': 'Operators', - 'syntax': [ - 'x / y', - 'divide(x, y)' - ], - 'description': 'Divide two values.', - 'examples': [ - 'a = 2 / 3', - 'a * 3', - '4.5 / 2', - '3 + 4 / 2', - '(3 + 4) / 2', - '18 km / 4.5' - ], - 'seealso': [ - 'multiply' - ] - }; - - -/***/ }, -/* 135 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'dotDivide', - 'category': 'Operators', - 'syntax': [ - 'x ./ y', - 'dotDivide(x, y)' - ], - 'description': 'Divide two values element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'b = [2, 1, 1; 3, 2, 5]', - 'a ./ b' - ], - 'seealso': [ - 'multiply', - 'dotMultiply', - 'divide' - ] - }; - - -/***/ }, -/* 136 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'dotMultiply', - 'category': 'Operators', - 'syntax': [ - 'x .* y', - 'dotMultiply(x, y)' - ], - 'description': 'Multiply two values element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'b = [2, 1, 1; 3, 2, 5]', - 'a .* b' - ], - 'seealso': [ - 'multiply', - 'divide', - 'dotDivide' - ] - }; - - -/***/ }, -/* 137 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'dotpow', - 'category': 'Operators', - 'syntax': [ - 'x .^ y', - 'dotpow(x, y)' - ], - 'description': - 'Calculates the power of x to y element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'a .^ 2' - ], - 'seealso': [ - 'pow' - ] - }; - - -/***/ }, -/* 138 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'exp', - 'category': 'Arithmetic', - 'syntax': [ - 'exp(x)' - ], - 'description': 'Calculate the exponent of a value.', - 'examples': [ - 'exp(1.3)', - 'e ^ 1.3', - 'log(exp(1.3))', - 'x = 2.4', - '(exp(i*x) == cos(x) + i*sin(x)) # Euler\'s formula' - ], - 'seealso': [ - 'pow', - 'log' - ] - }; - - -/***/ }, -/* 139 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'fix', - 'category': 'Arithmetic', - 'syntax': [ - 'fix(x)' - ], - 'description': - 'Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.', - 'examples': [ - 'fix(3.2)', - 'fix(3.8)', - 'fix(-4.2)', - 'fix(-4.8)' - ], - 'seealso': ['ceil', 'floor', 'round'] - }; - - -/***/ }, -/* 140 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'floor', - 'category': 'Arithmetic', - 'syntax': [ - 'floor(x)' - ], - 'description': - 'Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.', - 'examples': [ - 'floor(3.2)', - 'floor(3.8)', - 'floor(-4.2)' - ], - 'seealso': ['ceil', 'fix', 'round'] - }; - - -/***/ }, -/* 141 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'gcd', - 'category': 'Arithmetic', - 'syntax': [ - 'gcd(a, b)', - 'gcd(a, b, c, ...)' - ], - 'description': 'Compute the greatest common divisor.', - 'examples': [ - 'gcd(8, 12)', - 'gcd(-4, 6)', - 'gcd(25, 15, -10)' - ], - 'seealso': [ 'lcm', 'xgcd' ] - }; - - -/***/ }, -/* 142 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'hypot', - 'category': 'Arithmetic', - 'syntax': [ - 'hypot(a, b, c, ...)', - 'hypot([a, b, c, ...])' - ], - 'description': 'Calculate the hypotenusa of a list with values. ', - 'examples': [ - 'hypot(3, 4)', - 'sqrt(3^2 + 4^2)', - 'hypot(-2)', - 'hypot([3, 4, 5])' - ], - 'seealso': [ 'abs', 'norm' ] - }; - - -/***/ }, -/* 143 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'lcm', - 'category': 'Arithmetic', - 'syntax': [ - 'lcm(x, y)' - ], - 'description': 'Compute the least common multiple.', - 'examples': [ - 'lcm(4, 6)', - 'lcm(6, 21)', - 'lcm(6, 21, 5)' - ], - 'seealso': [ 'gcd' ] - }; - - -/***/ }, -/* 144 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'log', - 'category': 'Arithmetic', - 'syntax': [ - 'log(x)', - 'log(x, base)' - ], - 'description': 'Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).', - 'examples': [ - 'log(3.5)', - 'a = log(2.4)', - 'exp(a)', - '10 ^ 4', - 'log(10000, 10)', - 'log(10000) / log(10)', - 'b = log(1024, 2)', - '2 ^ b' - ], - 'seealso': [ - 'exp', - 'log10' - ] - }; - -/***/ }, -/* 145 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'log10', - 'category': 'Arithmetic', - 'syntax': [ - 'log10(x)' - ], - 'description': 'Compute the 10-base logarithm of a value.', - 'examples': [ - 'log10(0.00001)', - 'log10(10000)', - '10 ^ 4', - 'log(10000) / log(10)', - 'log(10000, 10)' - ], - 'seealso': [ - 'exp', - 'log' - ] - }; - - -/***/ }, -/* 146 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'mod', - 'category': 'Operators', - 'syntax': [ - 'x % y', - 'x mod y', - 'mod(x, y)' - ], - 'description': - 'Calculates the modulus, the remainder of an integer division.', - 'examples': [ - '7 % 3', - '11 % 2', - '10 mod 4', - 'function isOdd(x) = x % 2', - 'isOdd(2)', - 'isOdd(3)' - ], - 'seealso': ['divide'] - }; - - -/***/ }, -/* 147 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'multiply', - 'category': 'Operators', - 'syntax': [ - 'x * y', - 'multiply(x, y)' - ], - 'description': 'multiply two values.', - 'examples': [ - 'a = 2.1 * 3.4', - 'a / 3.4', - '2 * 3 + 4', - '2 * (3 + 4)', - '3 * 2.1 km' - ], - 'seealso': [ - 'divide' - ] - }; - - -/***/ }, -/* 148 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'norm', - 'category': 'Arithmetic', - 'syntax': [ - 'norm(x)', - 'norm(x, p)' - ], - 'description': 'Calculate the norm of a number, vector or matrix.', - 'examples': [ - 'abs(-3.5)', - 'norm(-3.5)', - 'norm(3 - 4i))', - 'norm([1, 2, -3], Infinity)', - 'norm([1, 2, -3], -Infinity)', - 'norm([3, 4], 2)', - 'norm([[1, 2], [3, 4]], 1)', - 'norm([[1, 2], [3, 4]], \'inf\')', - 'norm([[1, 2], [3, 4]], \'fro\')' - ] - }; - - -/***/ }, -/* 149 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'nthRoot', - 'category': 'Arithmetic', - 'syntax': [ - 'nthRoot(a)', - 'nthRoot(a, root)' - ], - 'description': 'Calculate the nth root of a value. ' + - 'The principal nth root of a positive real number A, ' + - 'is the positive real solution of the equation "x^root = A".', - 'examples': [ - '4 ^ 3', - 'nthRoot(64, 3)', - 'nthRoot(9, 2)', - 'sqrt(9)' - ], - 'seealso': [ - 'sqrt', - 'pow' - ] - }; - -/***/ }, -/* 150 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'pow', - 'category': 'Operators', - 'syntax': [ - 'x ^ y', - 'pow(x, y)' - ], - 'description': - 'Calculates the power of x to y, x^y.', - 'examples': [ - '2^3 = 8', - '2*2*2', - '1 + e ^ (pi * i)' - ], - 'seealso': [ 'multiply' ] - }; - - -/***/ }, -/* 151 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'round', - 'category': 'Arithmetic', - 'syntax': [ - 'round(x)', - 'round(x, n)' - ], - 'description': - 'round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.', - 'examples': [ - 'round(3.2)', - 'round(3.8)', - 'round(-4.2)', - 'round(-4.8)', - 'round(pi, 3)', - 'round(123.45678, 2)' - ], - 'seealso': ['ceil', 'floor', 'fix'] - }; - - -/***/ }, -/* 152 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sign', - 'category': 'Arithmetic', - 'syntax': [ - 'sign(x)' - ], - 'description': - 'Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.', - 'examples': [ - 'sign(3.5)', - 'sign(-4.2)', - 'sign(0)' - ], - 'seealso': [ - 'abs' - ] - }; - - -/***/ }, -/* 153 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sqrt', - 'category': 'Arithmetic', - 'syntax': [ - 'sqrt(x)' - ], - 'description': - 'Compute the square root value. If x = y * y, then y is the square root of x.', - 'examples': [ - 'sqrt(25)', - '5 * 5', - 'sqrt(-1)' - ], - 'seealso': [ - 'square', - 'multiply' - ] - }; - - -/***/ }, -/* 154 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'square', - 'category': 'Arithmetic', - 'syntax': [ - 'square(x)' - ], - 'description': - 'Compute the square of a value. The square of x is x * x.', - 'examples': [ - 'square(3)', - 'sqrt(9)', - '3^2', - '3 * 3' - ], - 'seealso': [ - 'multiply', - 'pow', - 'sqrt', - 'cube' - ] - }; - - -/***/ }, -/* 155 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'subtract', - 'category': 'Operators', - 'syntax': [ - 'x - y', - 'subtract(x, y)' - ], - 'description': 'subtract two values.', - 'examples': [ - 'a = 5.3 - 2', - 'a + 2', - '2/3 - 1/6', - '2 * 3 - 3', - '2.1 km - 500m' - ], - 'seealso': [ - 'add' - ] - }; - - -/***/ }, -/* 156 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'unaryMinus', - 'category': 'Operators', - 'syntax': [ - '-x', - 'unaryMinus(x)' - ], - 'description': - 'Inverse the sign of a value. Converts booleans and strings to numbers.', - 'examples': [ - '-4.5', - '-(-5.6)', - '-"22"' - ], - 'seealso': [ - 'add', 'subtract', 'unaryPlus' - ] - }; - - -/***/ }, -/* 157 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'unaryPlus', - 'category': 'Operators', - 'syntax': [ - '+x', - 'unaryPlus(x)' - ], - 'description': - 'Converts booleans and strings to numbers.', - 'examples': [ - '+true', - '+"2"' - ], - 'seealso': [ - 'add', 'subtract', 'unaryMinus' - ] - }; - - -/***/ }, -/* 158 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'xgcd', - 'category': 'Arithmetic', - 'syntax': [ - 'xgcd(a, b)' - ], - 'description': 'Calculate the extended greatest common divisor for two values', - 'examples': [ - 'xgcd(8, 12)', - 'gcd(8, 12)', - 'xgcd(36163, 21199)' - ], - 'seealso': [ 'gcd', 'lcm' ] - }; - - -/***/ }, -/* 159 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bitAnd', - 'category': 'Bitwise', - 'syntax': [ - 'x & y', - 'bitAnd(x, y)' - ], - 'description': 'Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0', - 'examples': [ - '5 & 3', - 'bitAnd(53, 131)', - '[1, 12, 31] & 42' - ], - 'seealso': [ - 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 160 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bitNot', - 'category': 'Bitwise', - 'syntax': [ - '~x', - 'bitNot(x)' - ], - 'description': 'Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.', - 'examples': [ - '~1', - '~2', - 'bitNot([2, -3, 4])' - ], - 'seealso': [ - 'bitAnd', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 161 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bitOr', - 'category': 'Bitwise', - 'syntax': [ - 'x | y', - 'bitOr(x, y)' - ], - 'description': 'Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.', - 'examples': [ - '5 | 3', - 'bitOr([1, 2, 3], 4)' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 162 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bitXor', - 'category': 'Bitwise', - 'syntax': [ - 'bitXor(x, y)' - ], - 'description': 'Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.', - 'examples': [ - 'bitOr(1, 2)', - 'bitXor([2, 3, 4], 4)' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 163 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'leftShift', - 'category': 'Bitwise', - 'syntax': [ - 'x << y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise left logical shift of a value x by y number of bits.', - 'examples': [ - '4 << 1', - '8 >> 1' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 164 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'rightArithShift', - 'category': 'Bitwise', - 'syntax': [ - 'x >> y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise right arithmetic shift of a value x by y number of bits.', - 'examples': [ - '8 >> 1', - '4 << 1', - '-12 >> 2' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 165 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'rightLogShift', - 'category': 'Bitwise', - 'syntax': [ - 'x >> y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise right logical shift of a value x by y number of bits.', - 'examples': [ - '8 >>> 1', - '4 << 1', - '-12 >>> 2' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift' - ] - }; - - -/***/ }, -/* 166 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'bellNumbers', - 'category': 'Combinatorics', - 'syntax': [ - 'bellNumbers(n)' - ], - 'description': 'The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.', - 'examples': [ - 'bellNumbers(3)', - 'bellNumbers(8)' - ], - 'seealso': ['stirlingS2'] - }; - -/***/ }, -/* 167 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'catalan', - 'category': 'Combinatorics', - 'syntax': [ - 'catalan(n)' - ], - 'description': 'The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.', - 'examples': [ - 'catalan(3)', - 'catalan(8)' - ], - 'seealso': ['bellNumbers'] - }; - -/***/ }, -/* 168 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'composition', - 'category': 'Combinatorics', - 'syntax': [ - 'composition(n, k)' - ], - 'description': 'The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.', - 'examples': [ - 'composition(5, 3)' - ], - 'seealso': ['combinations'] - }; - -/***/ }, -/* 169 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'stirlingS2', - 'category': 'Combinatorics', - 'syntax': [ - 'stirlingS2(n, k)' - ], - 'description': 'he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.', - 'examples': [ - 'stirlingS2(5, 3)' - ], - 'seealso': ['bellNumbers'] - }; - - -/***/ }, -/* 170 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'config', - 'category': 'Core', - 'syntax': [ - 'config()', - 'config(options)' - ], - 'description': 'Get configuration or change configuration.', - 'examples': [ - 'config()', - '1/3 + 1/4', - 'config({number: "Fraction"})', - '1/3 + 1/4' - ], - 'seealso': [] - }; - - -/***/ }, -/* 171 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'import', - 'category': 'Core', - 'syntax': [ - 'import(functions)', - 'import(functions, options)' - ], - 'description': 'Import functions or constants from an object.', - 'examples': [ - 'import({myFn: f(x)=x^2, myConstant: 32 })', - 'myFn(2)', - 'myConstant' - ], - 'seealso': [] - }; - - -/***/ }, -/* 172 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'typed', - 'category': 'Core', - 'syntax': [ - 'typed(signatures)', - 'typed(name, signatures)' - ], - 'description': 'Create a typed function.', - 'examples': [ - 'double = typed({ "number, number": f(x)=x+x })', - 'double(2)', - 'double("hello")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 173 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'arg', - 'category': 'Complex', - 'syntax': [ - 'arg(x)' - ], - 'description': - 'Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).', - 'examples': [ - 'arg(2 + 2i)', - 'atan2(3, 2)', - 'arg(2 + 3i)' - ], - 'seealso': [ - 're', - 'im', - 'conj', - 'abs' - ] - }; - - -/***/ }, -/* 174 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'conj', - 'category': 'Complex', - 'syntax': [ - 'conj(x)' - ], - 'description': - 'Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.', - 'examples': [ - 'conj(2 + 3i)', - 'conj(2 - 3i)', - 'conj(-5.2i)' - ], - 'seealso': [ - 're', - 'im', - 'abs', - 'arg' - ] - }; - - -/***/ }, -/* 175 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 're', - 'category': 'Complex', - 'syntax': [ - 're(x)' - ], - 'description': 'Get the real part of a complex number.', - 'examples': [ - 're(2 + 3i)', - 'im(2 + 3i)', - 're(-5.2i)', - 're(2.4)' - ], - 'seealso': [ - 'im', - 'conj', - 'abs', - 'arg' - ] - }; - - -/***/ }, -/* 176 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'im', - 'category': 'Complex', - 'syntax': [ - 'im(x)' - ], - 'description': 'Get the imaginary part of a complex number.', - 'examples': [ - 'im(2 + 3i)', - 're(2 + 3i)', - 'im(-5.2i)', - 'im(2.4)' - ], - 'seealso': [ - 're', - 'conj', - 'abs', - 'arg' - ] - }; - - -/***/ }, -/* 177 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'eval', - 'category': 'Expression', - 'syntax': [ - 'eval(expression)', - 'eval([expr1, expr2, expr3, ...])' - ], - 'description': 'Evaluate an expression or an array with expressions.', - 'examples': [ - 'eval("2 + 3")', - 'eval("sqrt(" + 4 + ")")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 178 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'help', - 'category': 'Expression', - 'syntax': [ - 'help(object)', - 'help(string)' - ], - 'description': 'Display documentation on a function or data type.', - 'examples': [ - 'help(sqrt)', - 'help("complex")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 179 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'distance', - 'category': 'Geometry', - 'syntax': [ - 'distance([x1, y1], [x2, y2])', - 'distance([[x1, y1], [x2, y2])' - ], - 'description': 'Calculates the Euclidean distance between two points.', - 'examples': [ - 'distance([0,0], [4,4])', - 'distance([[0,0], [4,4]])' - ], - 'seealso': [] - }; - - -/***/ }, -/* 180 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'intersect', - 'category': 'Geometry', - 'syntax': [ - 'intersect(expr1, expr2, expr3, expr4)', - 'intersect(expr1, expr2, expr3)' - ], - 'description': 'Computes the intersection point of lines and/or planes.', - 'examples': [ - 'intersect([0, 0], [10, 10], [10, 0], [0, 10])', - 'intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])' - ], - 'seealso': [] - }; - - -/***/ }, -/* 181 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'and', - 'category': 'Logical', - 'syntax': [ - 'x and y', - 'and(x, y)' - ], - 'description': 'Logical and. Test whether two values are both defined with a nonzero/nonempty value.', - 'examples': [ - 'true and false', - 'true and true', - '2 and 4' - ], - 'seealso': [ - 'not', 'or', 'xor' - ] - }; - - -/***/ }, -/* 182 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'not', - 'category': 'Logical', - 'syntax': [ - 'not x', - 'not(x)' - ], - 'description': 'Logical not. Flips the boolean value of given argument.', - 'examples': [ - 'not true', - 'not false', - 'not 2', - 'not 0' - ], - 'seealso': [ - 'and', 'or', 'xor' - ] - }; - - -/***/ }, -/* 183 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'or', - 'category': 'Logical', - 'syntax': [ - 'x or y', - 'or(x, y)' - ], - 'description': 'Logical or. Test if at least one value is defined with a nonzero/nonempty value.', - 'examples': [ - 'true or false', - 'false or false', - '0 or 4' - ], - 'seealso': [ - 'not', 'and', 'xor' - ] - }; - - -/***/ }, -/* 184 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'xor', - 'category': 'Logical', - 'syntax': [ - 'x or y', - 'or(x, y)' - ], - 'description': 'Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.', - 'examples': [ - 'true xor false', - 'false xor false', - 'true xor true', - '0 or 4' - ], - 'seealso': [ - 'not', 'and', 'or' - ] - }; - - -/***/ }, -/* 185 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'concat', - 'category': 'Matrix', - 'syntax': [ - 'concat(A, B, C, ...)', - 'concat(A, B, C, ..., dim)' - ], - 'description': 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.', - 'examples': [ - 'A = [1, 2; 5, 6]', - 'B = [3, 4; 7, 8]', - 'concat(A, B)', - 'concat(A, B, 1)', - 'concat(A, B, 2)' - ], - 'seealso': [ - 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 186 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cross', - 'category': 'Matrix', - 'syntax': [ - 'cross(A, B)' - ], - 'description': 'Calculate the cross product for two vectors in three dimensional space.', - 'examples': [ - 'cross([1, 1, 0], [0, 1, 1])', - 'cross([3, -3, 1], [4, 9, 2])', - 'cross([2, 3, 4], [5, 6, 7])' - ], - 'seealso': [ - 'multiply', - 'dot' - ] - }; - - -/***/ }, -/* 187 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'det', - 'category': 'Matrix', - 'syntax': [ - 'det(x)' - ], - 'description': 'Calculate the determinant of a matrix', - 'examples': [ - 'det([1, 2; 3, 4])', - 'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])' - ], - 'seealso': [ - 'concat', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 188 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'diag', - 'category': 'Matrix', - 'syntax': [ - 'diag(x)', - 'diag(x, k)' - ], - 'description': 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.', - 'examples': [ - 'diag(1:3)', - 'diag(1:3, 1)', - 'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]', - 'diag(a)' - ], - 'seealso': [ - 'concat', 'det', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 189 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'dot', - 'category': 'Matrix', - 'syntax': [ - 'dot(A, B)' - ], - 'description': 'Calculate the dot product of two vectors. ' + - 'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' + - 'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn', - 'examples': [ - 'dot([2, 4, 1], [2, 2, 3])', - '[2, 4, 1] * [2, 2, 3]' - ], - 'seealso': [ - 'multiply', - 'cross' - ] - }; - - -/***/ }, -/* 190 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'eye', - 'category': 'Matrix', - 'syntax': [ - 'eye(n)', - 'eye(m, n)', - 'eye([m, n])', - 'eye' - ], - 'description': 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.', - 'examples': [ - 'eye(3)', - 'eye(3, 5)', - 'a = [1, 2, 3; 4, 5, 6]', - 'eye(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 191 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'filter', - 'category': 'Matrix', - 'syntax': [ - 'filter(x, test)' - ], - 'description': 'Filter items in a matrix.', - 'examples': [ - 'isPositive(x) = x > 0', - 'filter([6, -2, -1, 4, 3], isPositive)', - 'filter([6, -2, 0, 1, 0], x != 0)' - ], - 'seealso': ['sort', 'map', 'forEach'] - }; - - -/***/ }, -/* 192 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'flatten', - 'category': 'Matrix', - 'syntax': [ - 'flatten(x)' - ], - 'description': 'Flatten a multi dimensional matrix into a single dimensional matrix.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'size(a)', - 'b = flatten(a)', - 'size(b)' - ], - 'seealso': [ - 'concat', 'resize', 'size', 'squeeze' - ] - }; - - -/***/ }, -/* 193 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'forEach', - 'category': 'Matrix', - 'syntax': [ - 'forEach(x, callback)' - ], - 'description': 'Iterates over all elements of a matrix/array, and executes the given callback function.', - 'examples': [ - 'forEach([1, 2, 3], function(val) { console.log(val) })' - ], - 'seealso': ['map', 'sort', 'filter'] - }; - - -/***/ }, -/* 194 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'inv', - 'category': 'Matrix', - 'syntax': [ - 'inv(x)' - ], - 'description': 'Calculate the inverse of a matrix', - 'examples': [ - 'inv([1, 2; 3, 4])', - 'inv(4)', - '1 / 4' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 195 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'map', - 'category': 'Matrix', - 'syntax': [ - 'map(x, callback)' - ], - 'description': 'Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.', - 'examples': [ - 'map([1, 2, 3], function(val) { return value * value })' - ], - 'seealso': ['filter', 'forEach'] - }; - - -/***/ }, -/* 196 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'ones', - 'category': 'Matrix', - 'syntax': [ - 'ones(m)', - 'ones(m, n)', - 'ones(m, n, p, ...)', - 'ones([m])', - 'ones([m, n])', - 'ones([m, n, p, ...])', - 'ones' - ], - 'description': 'Create a matrix containing ones.', - 'examples': [ - 'ones(3)', - 'ones(3, 5)', - 'ones([2,3]) * 4.5', - 'a = [1, 2, 3; 4, 5, 6]', - 'ones(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 197 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'partitionSelect', - 'category': 'Matrix', - 'syntax': [ - 'partitionSelect(x, k)', - 'partitionSelect(x, k, compare)' - ], - 'description': 'Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.', - 'examples': [ - 'partitionSelect([5, 10, 1], 2)', - 'partitionSelect(["C", "B", "A", "D"], 1)' - ], - 'seealso': ['sort'] - }; - - -/***/ }, -/* 198 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'range', - 'category': 'Type', - 'syntax': [ - 'start:end', - 'start:step:end', - 'range(start, end)', - 'range(start, end, step)', - 'range(string)' - ], - 'description': - 'Create a range. Lower bound of the range is included, upper bound is excluded.', - 'examples': [ - '1:5', - '3:-1:-3', - 'range(3, 7)', - 'range(0, 12, 2)', - 'range("4:10")', - 'a = [1, 2, 3, 4; 5, 6, 7, 8]', - 'a[1:2, 1:2]' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 199 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'resize', - 'category': 'Matrix', - 'syntax': [ - 'resize(x, size)', - 'resize(x, size, defaultValue)' - ], - 'description': 'Resize a matrix.', - 'examples': [ - 'resize([1,2,3,4,5], [3])', - 'resize([1,2,3], [5])', - 'resize([1,2,3], [5], -1)', - 'resize(2, [2, 3])', - 'resize("hello", [8], "!")' - ], - 'seealso': [ - 'size', 'subset', 'squeeze' - ] - }; - - -/***/ }, -/* 200 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'size', - 'category': 'Matrix', - 'syntax': [ - 'size(x)' - ], - 'description': 'Calculate the size of a matrix.', - 'examples': [ - 'size(2.3)', - 'size("hello world")', - 'a = [1, 2; 3, 4; 5, 6]', - 'size(a)', - 'size(1:6)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 201 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sort', - 'category': 'Matrix', - 'syntax': [ - 'sort(x)', - 'sort(x, compare)' - ], - 'description': 'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.', - 'examples': [ - 'sort([5, 10, 1])', - 'sort(["C", "B", "A", "D"])', - 'sortByLength(a, b) = size(a)[1] - size(b)[1]', - 'sort(["Langdon", "Tom", "Sara"], sortByLength)' - ], - 'seealso': ['map', 'filter', 'forEach'] - }; - - -/***/ }, -/* 202 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'squeeze', - 'category': 'Matrix', - 'syntax': [ - 'squeeze(x)' - ], - 'description': 'Remove inner and outer singleton dimensions from a matrix.', - 'examples': [ - 'a = zeros(3,2,1)', - 'size(squeeze(a))', - 'b = zeros(1,1,3)', - 'size(squeeze(b))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 203 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'subset', - 'category': 'Matrix', - 'syntax': [ - 'value(index)', - 'value(index) = replacement', - 'subset(value, [index])', - 'subset(value, [index], replacement)' - ], - 'description': 'Get or set a subset of a matrix or string. ' + - 'Indexes are one-based. ' + - 'Both the ranges lower-bound and upper-bound are included.', - 'examples': [ - 'd = [1, 2; 3, 4]', - 'e = []', - 'e[1, 1:2] = [5, 6]', - 'e[2, :] = [7, 8]', - 'f = d * e', - 'f[2, 1]', - 'f[:, 1]' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 204 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'trace', - 'category': 'Matrix', - 'syntax': [ - 'trace(A)' - ], - 'description': 'Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.', - 'examples': [ - 'A = [1, 2, 3; -1, 2, 3; 2, 0, 3]', - 'trace(A)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 205 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'transpose', - 'category': 'Matrix', - 'syntax': [ - 'x\'', - 'transpose(x)' - ], - 'description': 'Transpose a matrix', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'a\'', - 'transpose(a)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros' - ] - }; - - -/***/ }, -/* 206 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'zeros', - 'category': 'Matrix', - 'syntax': [ - 'zeros(m)', - 'zeros(m, n)', - 'zeros(m, n, p, ...)', - 'zeros([m])', - 'zeros([m, n])', - 'zeros([m, n, p, ...])', - 'zeros' - ], - 'description': 'Create a matrix containing zeros.', - 'examples': [ - 'zeros(3)', - 'zeros(3, 5)', - 'a = [1, 2, 3; 4, 5, 6]', - 'zeros(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose' - ] - }; - - -/***/ }, -/* 207 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'combinations', - 'category': 'Probability', - 'syntax': [ - 'combinations(n, k)' - ], - 'description': 'Compute the number of combinations of n items taken k at a time', - 'examples': [ - 'combinations(7, 5)' - ], - 'seealso': ['permutations', 'factorial'] - }; - - -/***/ }, -/* 208 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'factorial', - 'category': 'Probability', - 'syntax': [ - 'kldivergence(x, y)' - ], - 'description': 'Compute the factorial of a value', - 'examples': [ - '5!', - '5 * 4 * 3 * 2 * 1', - '3!' - ], - 'seealso': ['combinations', 'permutations', 'gamma'] - }; - - -/***/ }, -/* 209 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'gamma', - 'category': 'Probability', - 'syntax': [ - 'gamma(n)' - ], - 'description': 'Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.', - 'examples': [ - 'gamma(4)', - '3!', - 'gamma(1/2)', - 'sqrt(pi)' - ], - 'seealso': ['factorial'] - }; - - -/***/ }, -/* 210 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'kldivergence', - 'category': 'Probability', - 'syntax': [ - 'n!', - 'factorial(n)' - ], - 'description': 'Calculate the Kullback-Leibler (KL) divergence between two distributions.', - 'examples': [ - 'math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])' - ], - 'seealso': [] - }; - - -/***/ }, -/* 211 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'multinomial', - 'category': 'Probability', - 'syntax': [ - 'multinomial(A)' - ], - 'description': 'Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai <= 0.', - 'examples': [ - 'multinomial([1, 2, 1])' - ], - 'seealso': ['combinations', 'factorial'] - }; - -/***/ }, -/* 212 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'permutations', - 'category': 'Probability', - 'syntax': [ - 'permutations(n)', - 'permutations(n, k)' - ], - 'description': 'Compute the number of permutations of n items taken k at a time', - 'examples': [ - 'permutations(5)', - 'permutations(5, 3)' - ], - 'seealso': ['combinations', 'factorial'] - }; - - -/***/ }, -/* 213 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'pickRandom', - 'category': 'Probability', - 'syntax': [ - 'pickRandom(array)' - ], - 'description': - 'Pick a random entry from a given array.', - 'examples': [ - 'pickRandom(0:10)', - 'pickRandom([1, 3, 1, 6])' - ], - 'seealso': ['random', 'randomInt'] - }; - - -/***/ }, -/* 214 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'random', - 'category': 'Probability', - 'syntax': [ - 'random()', - 'random(max)', - 'random(min, max)', - 'random(size)', - 'random(size, max)', - 'random(size, min, max)' - ], - 'description': - 'Return a random number.', - 'examples': [ - 'random()', - 'random(10, 20)', - 'random([2, 3])' - ], - 'seealso': ['pickRandom', 'randomInt'] - }; - - -/***/ }, -/* 215 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'randInt', - 'category': 'Probability', - 'syntax': [ - 'randInt(max)', - 'randInt(min, max)', - 'randInt(size)', - 'randInt(size, max)', - 'randInt(size, min, max)' - ], - 'description': - 'Return a random integer number', - 'examples': [ - 'randInt(10, 20)', - 'randInt([2, 3], 10)' - ], - 'seealso': ['pickRandom', 'random'] - }; - -/***/ }, -/* 216 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'compare', - 'category': 'Relational', - 'syntax': [ - 'compare(x, y)' - ], - 'description': - 'Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.', - 'examples': [ - 'compare(2, 3)', - 'compare(3, 2)', - 'compare(2, 2)', - 'compare(5cm, 40mm)', - 'compare(2, [1, 2, 3])' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq' - ] - }; - - -/***/ }, -/* 217 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'deepEqual', - 'category': 'Relational', - 'syntax': [ - 'deepEqual(x, y)' - ], - 'description': - 'Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.', - 'examples': [ - '[1,3,4] == [1,3,4]', - '[1,3,4] == [1,3]' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 218 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'equal', - 'category': 'Relational', - 'syntax': [ - 'x == y', - 'equal(x, y)' - ], - 'description': - 'Check equality of two values. Returns true if the values are equal, and false if not.', - 'examples': [ - '2+2 == 3', - '2+2 == 4', - 'a = 3.2', - 'b = 6-2.8', - 'a == b', - '50cm == 0.5m' - ], - 'seealso': [ - 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' - ] - }; - - -/***/ }, -/* 219 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'larger', - 'category': 'Relational', - 'syntax': [ - 'x > y', - 'larger(x, y)' - ], - 'description': - 'Check if value x is larger than y. Returns true if x is larger than y, and false if not.', - 'examples': [ - '2 > 3', - '5 > 2*2', - 'a = 3.3', - 'b = 6-2.8', - '(a > b)', - '(b < a)', - '5 cm > 2 inch' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 220 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'largerEq', - 'category': 'Relational', - 'syntax': [ - 'x >= y', - 'largerEq(x, y)' - ], - 'description': - 'Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.', - 'examples': [ - '2 > 1+1', - '2 >= 1+1', - 'a = 3.2', - 'b = 6-2.8', - '(a > b)' - ], - 'seealso': [ - 'equal', 'unequal', 'smallerEq', 'smaller', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 221 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'smaller', - 'category': 'Relational', - 'syntax': [ - 'x < y', - 'smaller(x, y)' - ], - 'description': - 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.', - 'examples': [ - '2 < 3', - '5 < 2*2', - 'a = 3.3', - 'b = 6-2.8', - '(a < b)', - '5 cm < 2 inch' - ], - 'seealso': [ - 'equal', 'unequal', 'larger', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 222 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'smallerEq', - 'category': 'Relational', - 'syntax': [ - 'x <= y', - 'smallerEq(x, y)' - ], - 'description': - 'Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.', - 'examples': [ - '2 < 1+1', - '2 <= 1+1', - 'a = 3.2', - 'b = 6-2.8', - '(a < b)' - ], - 'seealso': [ - 'equal', 'unequal', 'larger', 'smaller', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 223 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'unequal', - 'category': 'Relational', - 'syntax': [ - 'x != y', - 'unequal(x, y)' - ], - 'description': - 'Check unequality of two values. Returns true if the values are unequal, and false if they are equal.', - 'examples': [ - '2+2 != 3', - '2+2 != 4', - 'a = 3.2', - 'b = 6-2.8', - 'a != b', - '50cm != 0.5m', - '5 cm != 2 inch' - ], - 'seealso': [ - 'equal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' - ] - }; - - -/***/ }, -/* 224 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'max', - 'category': 'Statistics', - 'syntax': [ - 'max(a, b, c, ...)', - 'max(A)', - 'max(A, dim)' - ], - 'description': 'Compute the maximum value of a list of values.', - 'examples': [ - 'max(2, 3, 4, 1)', - 'max([2, 3, 4, 1])', - 'max([2, 5; 4, 3])', - 'max([2, 5; 4, 3], 1)', - 'max([2, 5; 4, 3], 2)', - 'max(2.7, 7.1, -4.5, 2.0, 4.1)', - 'min(2.7, 7.1, -4.5, 2.0, 4.1)' - ], - 'seealso': [ - 'mean', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 225 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'mean', - 'category': 'Statistics', - 'syntax': [ - 'mean(a, b, c, ...)', - 'mean(A)', - 'mean(A, dim)' - ], - 'description': 'Compute the arithmetic mean of a list of values.', - 'examples': [ - 'mean(2, 3, 4, 1)', - 'mean([2, 3, 4, 1])', - 'mean([2, 5; 4, 3])', - 'mean([2, 5; 4, 3], 1)', - 'mean([2, 5; 4, 3], 2)', - 'mean([1.0, 2.7, 3.2, 4.0])' - ], - 'seealso': [ - 'max', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 226 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'median', - 'category': 'Statistics', - 'syntax': [ - 'median(a, b, c, ...)', - 'median(A)' - ], - 'description': 'Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.', - 'examples': [ - 'median(5, 2, 7)', - 'median([3, -1, 5, 7])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 227 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'min', - 'category': 'Statistics', - 'syntax': [ - 'min(a, b, c, ...)', - 'min(A)', - 'min(A, dim)' - ], - 'description': 'Compute the minimum value of a list of values.', - 'examples': [ - 'min(2, 3, 4, 1)', - 'min([2, 3, 4, 1])', - 'min([2, 5; 4, 3])', - 'min([2, 5; 4, 3], 1)', - 'min([2, 5; 4, 3], 2)', - 'min(2.7, 7.1, -4.5, 2.0, 4.1)', - 'max(2.7, 7.1, -4.5, 2.0, 4.1)' - ], - 'seealso': [ - 'max', - 'mean', - 'median', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 228 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'mode', - 'category': 'Statistics', - 'syntax': [ - 'mode(a, b, c, ...)', - 'mode(A)', - 'mode(A, a, b, B, c, ...)' - ], - 'description': 'Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.', - 'examples': [ - 'mode(5, 2, 7)', - 'mode([3, -1, 5, 7])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 229 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'prod', - 'category': 'Statistics', - 'syntax': [ - 'prod(a, b, c, ...)', - 'prod(A)' - ], - 'description': 'Compute the product of all values.', - 'examples': [ - 'prod(2, 3, 4)', - 'prod([2, 3, 4])', - 'prod([2, 5; 4, 3])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 230 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'quantileSeq', - 'category': 'Statistics', - 'syntax': [ - 'quantileSeq(A, prob[, sorted])', - 'quantileSeq(A, [prob1, prob2, ...][, sorted])', - 'quantileSeq(A, N[, sorted])' - ], - 'description': 'Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.', - 'examples': [ - 'quantileSeq([3, -1, 5, 7], 0.5)', - 'quantileSeq([3, -1, 5, 7], [1/3, 2/3])', - 'quantileSeq([3, -1, 5, 7], 2)', - 'quantileSeq([-1, 3, 5, 7], 0.5, true)' - ], - 'seealso': [ - 'mean', - 'median', - 'min', - 'max', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - -/***/ }, -/* 231 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'std', - 'category': 'Statistics', - 'syntax': [ - 'std(a, b, c, ...)', - 'std(A)', - 'std(A, normalization)' - ], - 'description': 'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', - 'examples': [ - 'std(2, 4, 6)', - 'std([2, 4, 6, 8])', - 'std([2, 4, 6, 8], "uncorrected")', - 'std([2, 4, 6, 8], "biased")', - 'std([1, 2, 3; 4, 5, 6])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'prod', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 232 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sum', - 'category': 'Statistics', - 'syntax': [ - 'sum(a, b, c, ...)', - 'sum(A)' - ], - 'description': 'Compute the sum of all values.', - 'examples': [ - 'sum(2, 3, 4, 1)', - 'sum([2, 3, 4, 1])', - 'sum([2, 5; 4, 3])' - ], - 'seealso': [ - 'max', - 'mean', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 233 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'var', - 'category': 'Statistics', - 'syntax': [ - 'var(a, b, c, ...)', - 'var(A)', - 'var(A, normalization)' - ], - 'description': 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', - 'examples': [ - 'var(2, 4, 6)', - 'var([2, 4, 6, 8])', - 'var([2, 4, 6, 8], "uncorrected")', - 'var([2, 4, 6, 8], "biased")', - 'var([1, 2, 3; 4, 5, 6])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'prod', - 'std', - 'sum' - ] - }; - - -/***/ }, -/* 234 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acos', - 'category': 'Trigonometry', - 'syntax': [ - 'acos(x)' - ], - 'description': 'Compute the inverse cosine of a value in radians.', - 'examples': [ - 'acos(0.5)', - 'acos(cos(2.3))' - ], - 'seealso': [ - 'cos', - 'atan', - 'asin' - ] - }; - - -/***/ }, -/* 235 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acosh', - 'category': 'Trigonometry', - 'syntax': [ - 'acosh(x)' - ], - 'description': 'Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.', - 'examples': [ - 'acosh(1.5)' - ], - 'seealso': [ - 'cosh', - 'asinh', - 'atanh' - ] - }; - -/***/ }, -/* 236 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acot', - 'category': 'Trigonometry', - 'syntax': [ - 'acot(x)' - ], - 'description': 'Calculate the inverse cotangent of a value.', - 'examples': [ - 'acot(0.5)', - 'acot(cot(0.5))', - 'acot(2)' - ], - 'seealso': [ - 'cot', - 'atan' - ] - }; - - -/***/ }, -/* 237 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acoth', - 'category': 'Trigonometry', - 'syntax': [ - 'acoth(x)' - ], - 'description': 'Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.', - 'examples': [ - 'acoth(0.5)' - ], - 'seealso': [ - 'acsch', - 'asech' - ] - }; - -/***/ }, -/* 238 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acsc', - 'category': 'Trigonometry', - 'syntax': [ - 'acsc(x)' - ], - 'description': 'Calculate the inverse cotangent of a value.', - 'examples': [ - 'acsc(0.5)', - 'acsc(csc(0.5))', - 'acsc(2)' - ], - 'seealso': [ - 'csc', - 'asin', - 'asec' - ] - }; - - -/***/ }, -/* 239 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'acsch', - 'category': 'Trigonometry', - 'syntax': [ - 'acsch(x)' - ], - 'description': 'Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.', - 'examples': [ - 'acsch(0.5)' - ], - 'seealso': [ - 'asech', - 'acoth' - ] - }; - - -/***/ }, -/* 240 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'asec', - 'category': 'Trigonometry', - 'syntax': [ - 'asec(x)' - ], - 'description': 'Calculate the inverse secant of a value.', - 'examples': [ - 'asec(0.5)', - 'asec(sec(0.5))', - 'asec(2)' - ], - 'seealso': [ - 'acos', - 'acot', - 'acsc' - ] - }; - - -/***/ }, -/* 241 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'asech', - 'category': 'Trigonometry', - 'syntax': [ - 'asech(x)' - ], - 'description': 'Calculate the inverse secant of a value.', - 'examples': [ - 'asech(0.5)' - ], - 'seealso': [ - 'acsch', - 'acoth' - ] - }; - - -/***/ }, -/* 242 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'asin', - 'category': 'Trigonometry', - 'syntax': [ - 'asin(x)' - ], - 'description': 'Compute the inverse sine of a value in radians.', - 'examples': [ - 'asin(0.5)', - 'asin(sin(2.3))' - ], - 'seealso': [ - 'sin', - 'acos', - 'atan' - ] - }; - - -/***/ }, -/* 243 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'asinh', - 'category': 'Trigonometry', - 'syntax': [ - 'asinh(x)' - ], - 'description': 'Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.', - 'examples': [ - 'asinh(0.5)' - ], - 'seealso': [ - 'acosh', - 'atanh' - ] - }; - - -/***/ }, -/* 244 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'atan', - 'category': 'Trigonometry', - 'syntax': [ - 'atan(x)' - ], - 'description': 'Compute the inverse tangent of a value in radians.', - 'examples': [ - 'atan(0.5)', - 'atan(tan(2.3))' - ], - 'seealso': [ - 'tan', - 'acos', - 'asin' - ] - }; - - -/***/ }, -/* 245 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'atanh', - 'category': 'Trigonometry', - 'syntax': [ - 'atanh(x)' - ], - 'description': 'Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.', - 'examples': [ - 'atanh(0.5)' - ], - 'seealso': [ - 'acosh', - 'asinh' - ] - }; - - -/***/ }, -/* 246 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'atan2', - 'category': 'Trigonometry', - 'syntax': [ - 'atan2(y, x)' - ], - 'description': - 'Computes the principal value of the arc tangent of y/x in radians.', - 'examples': [ - 'atan2(2, 2) / pi', - 'angle = 60 deg in rad', - 'x = cos(angle)', - 'y = sin(angle)', - 'atan2(y, x)' - ], - 'seealso': [ - 'sin', - 'cos', - 'tan' - ] - }; - - -/***/ }, -/* 247 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cos', - 'category': 'Trigonometry', - 'syntax': [ - 'cos(x)' - ], - 'description': 'Compute the cosine of x in radians.', - 'examples': [ - 'cos(2)', - 'cos(pi / 4) ^ 2', - 'cos(180 deg)', - 'cos(60 deg)', - 'sin(0.2)^2 + cos(0.2)^2' - ], - 'seealso': [ - 'acos', - 'sin', - 'tan' - ] - }; - - -/***/ }, -/* 248 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cosh', - 'category': 'Trigonometry', - 'syntax': [ - 'cosh(x)' - ], - 'description': 'Compute the hyperbolic cosine of x in radians.', - 'examples': [ - 'cosh(0.5)' - ], - 'seealso': [ - 'sinh', - 'tanh', - 'coth' - ] - }; - - -/***/ }, -/* 249 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'cot', - 'category': 'Trigonometry', - 'syntax': [ - 'cot(x)' - ], - 'description': 'Compute the cotangent of x in radians. Defined as 1/tan(x)', - 'examples': [ - 'cot(2)', - '1 / tan(2)' - ], - 'seealso': [ - 'sec', - 'csc', - 'tan' - ] - }; - - -/***/ }, -/* 250 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'coth', - 'category': 'Trigonometry', - 'syntax': [ - 'coth(x)' - ], - 'description': 'Compute the hyperbolic cotangent of x in radians.', - 'examples': [ - 'coth(2)', - '1 / tanh(2)' - ], - 'seealso': [ - 'sech', - 'csch', - 'tanh' - ] - }; - - -/***/ }, -/* 251 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'csc', - 'category': 'Trigonometry', - 'syntax': [ - 'csc(x)' - ], - 'description': 'Compute the cosecant of x in radians. Defined as 1/sin(x)', - 'examples': [ - 'csc(2)', - '1 / sin(2)' - ], - 'seealso': [ - 'sec', - 'cot', - 'sin' - ] - }; - - -/***/ }, -/* 252 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'csch', - 'category': 'Trigonometry', - 'syntax': [ - 'csch(x)' - ], - 'description': 'Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)', - 'examples': [ - 'csch(2)', - '1 / sinh(2)' - ], - 'seealso': [ - 'sech', - 'coth', - 'sinh' - ] - }; - - -/***/ }, -/* 253 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sec', - 'category': 'Trigonometry', - 'syntax': [ - 'sec(x)' - ], - 'description': 'Compute the secant of x in radians. Defined as 1/cos(x)', - 'examples': [ - 'sec(2)', - '1 / cos(2)' - ], - 'seealso': [ - 'cot', - 'csc', - 'cos' - ] - }; - - -/***/ }, -/* 254 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sech', - 'category': 'Trigonometry', - 'syntax': [ - 'sech(x)' - ], - 'description': 'Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)', - 'examples': [ - 'sech(2)', - '1 / cosh(2)' - ], - 'seealso': [ - 'coth', - 'csch', - 'cosh' - ] - }; - - -/***/ }, -/* 255 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sin', - 'category': 'Trigonometry', - 'syntax': [ - 'sin(x)' - ], - 'description': 'Compute the sine of x in radians.', - 'examples': [ - 'sin(2)', - 'sin(pi / 4) ^ 2', - 'sin(90 deg)', - 'sin(30 deg)', - 'sin(0.2)^2 + cos(0.2)^2' - ], - 'seealso': [ - 'asin', - 'cos', - 'tan' - ] - }; - - -/***/ }, -/* 256 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'sinh', - 'category': 'Trigonometry', - 'syntax': [ - 'sinh(x)' - ], - 'description': 'Compute the hyperbolic sine of x in radians.', - 'examples': [ - 'sinh(0.5)' - ], - 'seealso': [ - 'cosh', - 'tanh' - ] - }; - - -/***/ }, -/* 257 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'tan', - 'category': 'Trigonometry', - 'syntax': [ - 'tan(x)' - ], - 'description': 'Compute the tangent of x in radians.', - 'examples': [ - 'tan(0.5)', - 'sin(0.5) / cos(0.5)', - 'tan(pi / 4)', - 'tan(45 deg)' - ], - 'seealso': [ - 'atan', - 'sin', - 'cos' - ] - }; - - -/***/ }, -/* 258 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'tanh', - 'category': 'Trigonometry', - 'syntax': [ - 'tanh(x)' - ], - 'description': 'Compute the hyperbolic tangent of x in radians.', - 'examples': [ - 'tanh(0.5)', - 'sinh(0.5) / cosh(0.5)' - ], - 'seealso': [ - 'sinh', - 'cosh' - ] - }; - - -/***/ }, -/* 259 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'to', - 'category': 'Units', - 'syntax': [ - 'x to unit', - 'to(x, unit)' - ], - 'description': 'Change the unit of a value.', - 'examples': [ - '5 inch to cm', - '3.2kg to g', - '16 bytes in bits' - ], - 'seealso': [] - }; - - -/***/ }, -/* 260 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'clone', - 'category': 'Utils', - 'syntax': [ - 'clone(x)' - ], - 'description': 'Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices', - 'examples': [ - 'clone(3.5)', - 'clone(2 - 4i)', - 'clone(45 deg)', - 'clone([1, 2; 3, 4])', - 'clone("hello world")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 261 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'format', - 'category': 'Utils', - 'syntax': [ - 'format(value)', - 'format(value, precision)' - ], - 'description': 'Format a value of any type as string.', - 'examples': [ - 'format(2.3)', - 'format(3 - 4i)', - 'format([])', - 'format(pi, 3)' - ], - 'seealso': ['print'] - }; - - -/***/ }, -/* 262 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'isInteger', - 'category': 'Utils', - 'syntax': [ - 'isInteger(x)' - ], - 'description': 'Test whether a value is an integer number.', - 'examples': [ - 'isInteger(2)', - 'isInteger(3.5)', - 'isInteger([3, 0.5, -2])' - ], - 'seealso': ['isNegative', 'isNumeric', 'isPositive', 'isZero'] - }; - - -/***/ }, -/* 263 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'isNegative', - 'category': 'Utils', - 'syntax': [ - 'isNegative(x)' - ], - 'description': 'Test whether a value is negative: smaller than zero.', - 'examples': [ - 'isNegative(2)', - 'isNegative(0)', - 'isNegative(-4)', - 'isNegative([3, 0.5, -2])' - ], - 'seealso': ['isInteger', 'isNumeric', 'isPositive', 'isZero'] - }; - - -/***/ }, -/* 264 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'isNumeric', - 'category': 'Utils', - 'syntax': [ - 'isNumeric(x)' - ], - 'description': 'Test whether a value is a numeric value. ' + - 'Returns true when the input is a number, BigNumber, Fraction, or boolean.', - 'examples': [ - 'isNumeric(2)', - 'isNumeric(0)', - 'isNumeric(bignumber(500))', - 'isNumeric(fraction(0.125))', - 'isNumeric("3")', - 'isNumeric(2 + 3i)', - 'isNumeric([2.3, "foo", false])' - ], - 'seealso': ['isInteger', 'isZero', 'isNegative', 'isPositive'] - }; - - -/***/ }, -/* 265 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'isPositive', - 'category': 'Utils', - 'syntax': [ - 'isPositive(x)' - ], - 'description': 'Test whether a value is positive: larger than zero.', - 'examples': [ - 'isPositive(2)', - 'isPositive(0)', - 'isPositive(-4)', - 'isPositive([3, 0.5, -2])' - ], - 'seealso': ['isInteger', 'isNumeric', 'isNegative', 'isZero'] - }; - - -/***/ }, -/* 266 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'isZero', - 'category': 'Utils', - 'syntax': [ - 'isZero(x)' - ], - 'description': 'Test whether a value is zero.', - 'examples': [ - 'isZero(2)', - 'isZero(0)', - 'isZero(-4)', - 'isZero([3, 0, -2, 0])' - ], - 'seealso': ['isInteger', 'isNumeric', 'isNegative', 'isPositive'] - }; - - -/***/ }, -/* 267 */ -/***/ function(module, exports) { - - module.exports = { - 'name': 'typeof', - 'category': 'Utils', - 'syntax': [ - 'typeof(x)' - ], - 'description': 'Get the type of a variable.', - 'examples': [ - 'typeof(3.5)', - 'typeof(2 - 4i)', - 'typeof(45 deg)', - 'typeof("hello world")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 268 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(269), - __webpack_require__(292), - __webpack_require__(293), - __webpack_require__(294), - __webpack_require__(295) - ]; - - -/***/ }, -/* 269 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var parse = load(__webpack_require__(270)); - - /** - * Parse and compile an expression. - * Returns a an object with a function `eval([scope])` to evaluate the - * compiled expression. - * - * Syntax: - * - * math.compile(expr) // returns one node - * math.compile([expr1, expr2, expr3, ...]) // returns an array with nodes - * - * Examples: - * - * var code = math.compile('sqrt(3^2 + 4^2)'); - * code.eval(); // 5 - * - * var scope = {a: 3, b: 4} - * var code = math.compile('a * b'); // 12 - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.compile(['a = 3', 'b = 4', 'a * b']); - * nodes[2].eval(); // 12 - * - * See also: - * - * parse, eval - * - * @param {string | string[] | Array | Matrix} expr - * The expression to be compiled - * @return {{eval: Function} | Array.<{eval: Function}>} code - * An object with the compiled expression - * @throws {Error} - */ - return typed('compile', { - 'string': function (expr) { - return parse(expr).compile(); - }, - - 'Array | Matrix': function (expr) { - return deepMap(expr, function (entry) { - return parse(entry).compile(); - }); - } - }); - } - - exports.name = 'compile'; - exports.factory = factory; - - -/***/ }, -/* 270 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var ArgumentsError = __webpack_require__(11); - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var AccessorNode = load(__webpack_require__(271)); - var ArrayNode = load(__webpack_require__(277)); - var AssignmentNode = load(__webpack_require__(278)); - var BlockNode = load(__webpack_require__(281)); - var ConditionalNode = load(__webpack_require__(282)); - var ConstantNode = load(__webpack_require__(283)); - var FunctionAssignmentNode = load(__webpack_require__(284)); - var IndexNode = load(__webpack_require__(285)); - var ObjectNode = load(__webpack_require__(288)); - var OperatorNode = load(__webpack_require__(289)); - var ParenthesisNode = load(__webpack_require__(291)); - var FunctionNode = load(__webpack_require__(290)); - var RangeNode = load(__webpack_require__(286)); - var SymbolNode = load(__webpack_require__(287)); - - - /** - * Parse an expression. Returns a node tree, which can be evaluated by - * invoking node.eval(); - * - * Syntax: - * - * parse(expr) - * parse(expr, options) - * parse([expr1, expr2, expr3, ...]) - * parse([expr1, expr2, expr3, ...], options) - * - * Example: - * - * var node = parse('sqrt(3^2 + 4^2)'); - * node.compile(math).eval(); // 5 - * - * var scope = {a:3, b:4} - * var node = parse('a * b'); // 12 - * var code = node.compile(math); - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); - * nodes[2].compile(math).eval(); // 12 - * - * @param {string | string[] | Matrix} expr - * @param {{nodes: Object}} [options] Available options: - * - `nodes` a set of custom nodes - * @return {Node | Node[]} node - * @throws {Error} - */ - function parse (expr, options) { - if (arguments.length != 1 && arguments.length != 2) { - throw new ArgumentsError('parse', arguments.length, 1, 2); - } - - // pass extra nodes - extra_nodes = (options && options.nodes) ? options.nodes : {}; - - if (typeof expr === 'string') { - // parse a single expression - expression = expr; - return parseStart(); - } - else if (Array.isArray(expr) || expr instanceof type.Matrix) { - // parse an array or matrix with expressions - return deepMap(expr, function (elem) { - if (typeof elem !== 'string') throw new TypeError('String expected'); - - expression = elem; - return parseStart(); - }); - } - else { - // oops - throw new TypeError('String or matrix expected'); - } - } - - // token types enumeration - var TOKENTYPE = { - NULL : 0, - DELIMITER : 1, - NUMBER : 2, - SYMBOL : 3, - UNKNOWN : 4 - }; - - // map with all delimiters - var DELIMITERS = { - ',': true, - '(': true, - ')': true, - '[': true, - ']': true, - '{': true, - '}': true, - '\"': true, - ';': true, - - '+': true, - '-': true, - '*': true, - '.*': true, - '/': true, - './': true, - '%': true, - '^': true, - '.^': true, - '~': true, - '!': true, - '&': true, - '|': true, - '^|': true, - '\'': true, - '=': true, - ':': true, - '?': true, - - '==': true, - '!=': true, - '<': true, - '>': true, - '<=': true, - '>=': true, - - '<<': true, - '>>': true, - '>>>': true - }; - - // map with all named delimiters - var NAMED_DELIMITERS = { - 'mod': true, - 'to': true, - 'in': true, - 'and': true, - 'xor': true, - 'or': true, - 'not': true - }; - - var extra_nodes = {}; // current extra nodes - var expression = ''; // current expression - var index = 0; // current index in expr - var c = ''; // current token character in expr - var token = ''; // current token - var token_type = TOKENTYPE.NULL; // type of the token - var nesting_level = 0; // level of nesting inside parameters, used to ignore newline characters - var conditional_level = null; // when a conditional is being parsed, the level of the conditional is stored here - - /** - * Get the first character from the expression. - * The character is stored into the char c. If the end of the expression is - * reached, the function puts an empty string in c. - * @private - */ - function first() { - index = 0; - c = expression.charAt(0); - nesting_level = 0; - conditional_level = null; - } - - /** - * Get the next character from the expression. - * The character is stored into the char c. If the end of the expression is - * reached, the function puts an empty string in c. - * @private - */ - function next() { - index++; - c = expression.charAt(index); - } - - /** - * Preview the next character from the expression. - * @return {string} cNext - * @private - */ - function nextPreview() { - return expression.charAt(index + 1); - } - - /** - * Preview the second next character from the expression. - * @return {string} cNext - * @private - */ - function nextNextPreview() { - return expression.charAt(index + 2); - } - - /** - * Get next token in the current string expr. - * The token and token type are available as token and token_type - * @private - */ - function getToken() { - token_type = TOKENTYPE.NULL; - token = ''; - - // skip over whitespaces - // space, tab, and newline when inside parameters - while (c == ' ' || c == '\t' || (c == '\n' && nesting_level)) { - // TODO: also take '\r' carriage return as newline? Or does that give problems on mac? - next(); - } - - // skip comment - if (c == '#') { - while (c != '\n' && c != '') { - next(); - } - } - - // check for end of expression - if (c == '') { - // token is still empty - token_type = TOKENTYPE.DELIMITER; - return; - } - - // check for new line character - if (c == '\n' && !nesting_level) { - token_type = TOKENTYPE.DELIMITER; - token = c; - next(); - return; - } - - // check for delimiters consisting of 3 characters - var c2 = c + nextPreview(); - var c3 = c2 + nextNextPreview(); - if (c3.length == 3 && DELIMITERS[c3]) { - token_type = TOKENTYPE.DELIMITER; - token = c3; - next(); - next(); - next(); - return; - } - - // check for delimiters consisting of 2 characters - if (c2.length == 2 && DELIMITERS[c2]) { - token_type = TOKENTYPE.DELIMITER; - token = c2; - next(); - next(); - return; - } - - // check for delimiters consisting of 1 character - if (DELIMITERS[c]) { - token_type = TOKENTYPE.DELIMITER; - token = c; - next(); - return; - } - - // check for a number - if (isDigitDot(c)) { - token_type = TOKENTYPE.NUMBER; - - // get number, can have a single dot - if (c == '.') { - token += c; - next(); - - if (!isDigit(c)) { - // this is no legal number, it is just a dot (can be dot notation) - token_type = TOKENTYPE.UNKNOWN; - } - } - else { - while (isDigit(c)) { - token += c; - next(); - } - if (c == '.') { - token += c; - next(); - } - } - while (isDigit(c)) { - token += c; - next(); - } - - // check for exponential notation like "2.3e-4", "1.23e50" or "2e+4" - c2 = nextPreview(); - if (c == 'E' || c == 'e') { - if (isDigit(c2) || c2 == '-' || c2 == '+') { - token += c; - next(); - - if (c == '+' || c == '-') { - token += c; - next(); - } - - // Scientific notation MUST be followed by an exponent - if (!isDigit(c)) { - throw createSyntaxError('Digit expected, got "' + c + '"'); - } - - while (isDigit(c)) { - token += c; - next(); - } - - if (c == '.') { - throw createSyntaxError('Digit expected, got "' + c + '"'); - } - } - else if (c2 == '.') { - next(); - throw createSyntaxError('Digit expected, got "' + c + '"'); - } - } - - return; - } - - // check for variables, functions, named operators - if (currentIsAlpha()) { - while (currentIsAlpha() || isDigit(c)) { - token += c; - next(); - } - - if (NAMED_DELIMITERS.hasOwnProperty(token)) { - token_type = TOKENTYPE.DELIMITER; - } - else { - token_type = TOKENTYPE.SYMBOL; - } - - return; - } - - // something unknown is found, wrong characters -> a syntax error - token_type = TOKENTYPE.UNKNOWN; - while (c != '') { - token += c; - next(); - } - throw createSyntaxError('Syntax error in part "' + token + '"'); - } - - /** - * Get next token and skip newline tokens - */ - function getTokenSkipNewline () { - do { - getToken(); - } - while (token == '\n'); - } - - /** - * Open parameters. - * New line characters will be ignored until closeParams() is called - */ - function openParams() { - nesting_level++; - } - - /** - * Close parameters. - * New line characters will no longer be ignored - */ - function closeParams() { - nesting_level--; - } - - /** - * Checks whether the current character `c` is a valid alpha character: - * - * - A latin letter (upper or lower case) Ascii: a-z, A-Z - * - A underscore Ascii: _ - * - A latin letter with accents Unicode: \u00C0 - \u02AF - * - A greek letter Unicode: \u0370 - \u03FF - * - A mathematical alphanumeric symbol Unicode: \u{1D400} - \u{1D7FF} excluding invalid code points - * - * @return {boolean} - * @private - */ - function currentIsAlpha () { - // http://unicode-table.com/en/ - // http://www.wikiwand.com/en/Mathematical_operators_and_symbols_in_Unicode - // - // Note: In ES6 will be unicode aware: - // http://stackoverflow.com/questions/280712/javascript-unicode-regexes - // https://mathiasbynens.be/notes/es6-unicode-regex - var cPrev = expression.charAt(index - 1); - var cNext = expression.charAt(index + 1); - - var isValidLatinOrGreek = function (p) { - return /^[a-zA-Z_\u00C0-\u02AF\u0370-\u03FF]$/.test(p); - }; - - var isValidMathSymbol = function (high, low) { - return /^[\uD835]$/.test(high) && - /^[\uDC00-\uDFFF]$/.test(low) && - /^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(low); - }; - - return isValidLatinOrGreek(c) - || isValidMathSymbol(c, cNext) - || isValidMathSymbol(cPrev, c); - } - - /** - * checks if the given char c is a digit or dot - * @param {string} c a string with one character - * @return {boolean} - * @private - */ - function isDigitDot (c) { - return ((c >= '0' && c <= '9') || c == '.'); - } - - /** - * checks if the given char c is a digit - * @param {string} c a string with one character - * @return {boolean} - * @private - */ - function isDigit (c) { - return (c >= '0' && c <= '9'); - } - - /** - * Start of the parse levels below, in order of precedence - * @return {Node} node - * @private - */ - function parseStart () { - // get the first character in expression - first(); - - getToken(); - - var node = parseBlock(); - - // check for garbage at the end of the expression - // an expression ends with a empty character '' and token_type DELIMITER - if (token != '') { - if (token_type == TOKENTYPE.DELIMITER) { - // user entered a not existing operator like "//" - - // TODO: give hints for aliases, for example with "<>" give as hint " did you mean != ?" - throw createError('Unexpected operator ' + token); - } - else { - throw createSyntaxError('Unexpected part "' + token + '"'); - } - } - - return node; - } - - /** - * Parse a block with expressions. Expressions can be separated by a newline - * character '\n', or by a semicolon ';'. In case of a semicolon, no output - * of the preceding line is returned. - * @return {Node} node - * @private - */ - function parseBlock () { - var node; - var blocks = []; - var visible; - - if (token == '') { - // empty expression - return new ConstantNode('undefined', 'undefined'); - } - - if (token != '\n' && token != ';') { - node = parseAssignment(); - } - - // TODO: simplify this loop - while (token == '\n' || token == ';') { - if (blocks.length == 0 && node) { - visible = (token != ';'); - blocks.push({ - node: node, - visible: visible - }); - } - - getToken(); - if (token != '\n' && token != ';' && token != '') { - node = parseAssignment(); - - visible = (token != ';'); - blocks.push({ - node: node, - visible: visible - }); - } - } - - if (blocks.length > 0) { - return new BlockNode(blocks); - } - else { - return node; - } - } - - /** - * Assignment of a function or variable, - * - can be a variable like 'a=2.3' - * - or a updating an existing variable like 'matrix(2,3:5)=[6,7,8]' - * - defining a function like 'f(x) = x^2' - * @return {Node} node - * @private - */ - function parseAssignment () { - var name, args, value, valid; - - var node = parseConditional(); - - if (token == '=') { - if (node && node.isSymbolNode) { - // parse a variable assignment like 'a = 2/3' - name = node.name; - getTokenSkipNewline(); - value = parseAssignment(); - return new AssignmentNode(new SymbolNode(name), value); - } - else if (node && node.isAccessorNode) { - // parse a matrix subset assignment like 'A[1,2] = 4' - getTokenSkipNewline(); - value = parseAssignment(); - return new AssignmentNode(node.object, node.index, value); - } - else if (node && node.isFunctionNode) { - // parse function assignment like 'f(x) = x^2' - valid = true; - args = []; - - name = node.name; - node.args.forEach(function (arg, index) { - if (arg && arg.isSymbolNode) { - args[index] = arg.name; - } - else { - valid = false; - } - }); - - if (valid) { - getTokenSkipNewline(); - value = parseAssignment(); - return new FunctionAssignmentNode(name, args, value); - } - } - - throw createSyntaxError('Invalid left hand side of assignment operator ='); - } - - return node; - } - - /** - * conditional operation - * - * condition ? truePart : falsePart - * - * Note: conditional operator is right-associative - * - * @return {Node} node - * @private - */ - function parseConditional () { - var node = parseLogicalOr(); - - while (token == '?') { - // set a conditional level, the range operator will be ignored as long - // as conditional_level == nesting_level. - var prev = conditional_level; - conditional_level = nesting_level; - getTokenSkipNewline(); - - var condition = node; - var trueExpr = parseAssignment(); - - if (token != ':') throw createSyntaxError('False part of conditional expression expected'); - - conditional_level = null; - getTokenSkipNewline(); - - var falseExpr = parseAssignment(); // Note: check for conditional operator again, right associativity - - node = new ConditionalNode(condition, trueExpr, falseExpr); - - // restore the previous conditional level - conditional_level = prev; - } - - return node; - } - - /** - * logical or, 'x or y' - * @return {Node} node - * @private - */ - function parseLogicalOr() { - var node = parseLogicalXor(); - - while (token == 'or') { - getTokenSkipNewline(); - node = new OperatorNode('or', 'or', [node, parseLogicalXor()]); - } - - return node; - } - - /** - * logical exclusive or, 'x xor y' - * @return {Node} node - * @private - */ - function parseLogicalXor() { - var node = parseLogicalAnd(); - - while (token == 'xor') { - getTokenSkipNewline(); - node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd()]); - } - - return node; - } - - /** - * logical and, 'x and y' - * @return {Node} node - * @private - */ - function parseLogicalAnd() { - var node = parseBitwiseOr(); - - while (token == 'and') { - getTokenSkipNewline(); - node = new OperatorNode('and', 'and', [node, parseBitwiseOr()]); - } - - return node; - } - - /** - * bitwise or, 'x | y' - * @return {Node} node - * @private - */ - function parseBitwiseOr() { - var node = parseBitwiseXor(); - - while (token == '|') { - getTokenSkipNewline(); - node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor()]); - } - - return node; - } - - /** - * bitwise exclusive or (xor), 'x ^| y' - * @return {Node} node - * @private - */ - function parseBitwiseXor() { - var node = parseBitwiseAnd(); - - while (token == '^|') { - getTokenSkipNewline(); - node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd()]); - } - - return node; - } - - /** - * bitwise and, 'x & y' - * @return {Node} node - * @private - */ - function parseBitwiseAnd () { - var node = parseRelational(); - - while (token == '&') { - getTokenSkipNewline(); - node = new OperatorNode('&', 'bitAnd', [node, parseRelational()]); - } - - return node; - } - - /** - * relational operators - * @return {Node} node - * @private - */ - function parseRelational () { - var node, operators, name, fn, params; - - node = parseShift(); - - operators = { - '==': 'equal', - '!=': 'unequal', - '<': 'smaller', - '>': 'larger', - '<=': 'smallerEq', - '>=': 'largerEq' - }; - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseShift()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift - * @return {Node} node - * @private - */ - function parseShift () { - var node, operators, name, fn, params; - - node = parseConversion(); - - operators = { - '<<' : 'leftShift', - '>>' : 'rightArithShift', - '>>>' : 'rightLogShift' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseConversion()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * conversion operators 'to' and 'in' - * @return {Node} node - * @private - */ - function parseConversion () { - var node, operators, name, fn, params; - - node = parseRange(); - - operators = { - 'to' : 'to', - 'in' : 'to' // alias of 'to' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - - if (name === 'in' && token === '') { - // end of expression -> this is the unit 'in' ('inch') - node = new OperatorNode('*', 'multiply', [node, new SymbolNode('in')], true); - } - else { - // operator 'a to b' or 'a in b' - params = [node, parseRange()]; - node = new OperatorNode(name, fn, params); - } - } - - return node; - } - - /** - * parse range, "start:end", "start:step:end", ":", "start:", ":end", etc - * @return {Node} node - * @private - */ - function parseRange () { - var node, params = []; - - if (token == ':') { - // implicit start=1 (one-based) - node = new ConstantNode('1', 'number'); - } - else { - // explicit start - node = parseAddSubtract(); - } - - if (token == ':' && (conditional_level !== nesting_level)) { - // we ignore the range operator when a conditional operator is being processed on the same level - params.push(node); - - // parse step and end - while (token == ':' && params.length < 3) { - getTokenSkipNewline(); - - if (token == ')' || token == ']' || token == ',' || token == '') { - // implicit end - params.push(new SymbolNode('end')); - } - else { - // explicit end - params.push(parseAddSubtract()); - } - } - - if (params.length == 3) { - // params = [start, step, end] - node = new RangeNode(params[0], params[2], params[1]); // start, end, step - } - else { // length == 2 - // params = [start, end] - node = new RangeNode(params[0], params[1]); // start, end - } - } - - return node; - } - - /** - * add or subtract - * @return {Node} node - * @private - */ - function parseAddSubtract () { - var node, operators, name, fn, params; - - node = parseMultiplyDivide(); - - operators = { - '+': 'add', - '-': 'subtract' - }; - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseMultiplyDivide()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * multiply, divide, modulus - * @return {Node} node - * @private - */ - function parseMultiplyDivide () { - var node, last, operators, name, fn; - - node = parseUnary(); - last = node; - - operators = { - '*': 'multiply', - '.*': 'dotMultiply', - '/': 'divide', - './': 'dotDivide', - '%': 'mod', - 'mod': 'mod' - }; - - while (true) { - if (token in operators) { - // explicit operators - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - - last = parseUnary(); - node = new OperatorNode(name, fn, [node, last]); - } - else if ((token_type == TOKENTYPE.SYMBOL) || - (token == 'in' && (node && node.isConstantNode)) || - (token_type == TOKENTYPE.NUMBER && !last.isConstantNode) || - (token == '(')) { - // parse implicit multiplication - // - // symbol: implicit multiplication like '2a', '(2+3)a', 'a b' - // number: implicit multiplication like '(2+3)2' - // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)' - last = parseUnary(); - node = new OperatorNode('*', 'multiply', [node, last], true /*implicit*/); - } - else { - break; - } - } - - return node; - } - - /** - * Unary plus and minus, and logical and bitwise not - * @return {Node} node - * @private - */ - function parseUnary () { - var name, params; - var fn = { - '-': 'unaryMinus', - '+': 'unaryPlus', - '~': 'bitNot', - 'not': 'not' - }[token]; - - if (fn) { - name = token; - - getTokenSkipNewline(); - params = [parseUnary()]; - - return new OperatorNode(name, fn, params); - } - - return parsePow(); - } - - /** - * power - * Note: power operator is right associative - * @return {Node} node - * @private - */ - function parsePow () { - var node, name, fn, params; - - node = parseLeftHandOperators(); - - if (token == '^' || token == '.^') { - name = token; - fn = (name == '^') ? 'pow' : 'dotPow'; - - getTokenSkipNewline(); - params = [node, parseUnary()]; // Go back to unary, we can have '2^-3' - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * Left hand operators: factorial x!, transpose x' - * @return {Node} node - * @private - */ - function parseLeftHandOperators () { - var node, operators, name, fn, params; - - node = parseCustomNodes(); - - operators = { - '!': 'factorial', - '\'': 'transpose' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getToken(); - params = [node]; - - node = new OperatorNode(name, fn, params); - node = parseAccessors(node); - } - - return node; - } - - /** - * Parse a custom node handler. A node handler can be used to process - * nodes in a custom way, for example for handling a plot. - * - * A handler must be passed as second argument of the parse function. - * - must extend math.expression.node.Node - * - must contain a function _compile(defs: Object) : string - * - must contain a function find(filter: Object) : Node[] - * - must contain a function toString() : string - * - the constructor is called with a single argument containing all parameters - * - * For example: - * - * nodes = { - * 'plot': PlotHandler - * }; - * - * The constructor of the handler is called as: - * - * node = new PlotHandler(params); - * - * The handler will be invoked when evaluating an expression like: - * - * node = math.parse('plot(sin(x), x)', nodes); - * - * @return {Node} node - * @private - */ - function parseCustomNodes () { - var params = [], handler; - - if (token_type == TOKENTYPE.SYMBOL && extra_nodes[token]) { - handler = extra_nodes[token]; - - getToken(); - - // parse parameters - if (token == '(') { - params = []; - - openParams(); - getToken(); - - if (token != ')') { - params.push(parseAssignment()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseAssignment()); - } - } - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - } - - // create a new node handler - //noinspection JSValidateTypes - return new handler(params); - } - - return parseSymbol(); - } - - /** - * parse symbols: functions, variables, constants, units - * @return {Node} node - * @private - */ - function parseSymbol () { - var node, name; - - if (token_type == TOKENTYPE.SYMBOL || - (token_type == TOKENTYPE.DELIMITER && token in NAMED_DELIMITERS)) { - name = token; - - getToken(); - - // parse function parameters and matrix index - node = new SymbolNode(name); - node = parseAccessors(node); - return node; - } - - return parseString(); - } - - /** - * parse accessors: - * - function invocation in round brackets (...), for example sqrt(2) - * - index enclosed in square brackets [...], for example A[2,3] - * - dot notation for properties, like foo.bar - * @param {Node} node Node on which to apply the parameters. If there - * are no parameters in the expression, the node - * itself is returned - * @param {string[]} [types] Filter the types of notations - * can be ['(', '[', '.'] - * @return {Node} node - * @private - */ - function parseAccessors (node, types) { - var params; - - while ((token == '(' || token == '[' || token == '.') && - (!types || types.indexOf(token) !== -1)) { - params = []; - - if (token == '(') { - if (node.isSymbolNode || node.isAccessorNode) { - // function invocation like fn(2, 3) - openParams(); - getToken(); - - if (token != ')') { - params.push(parseAssignment()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseAssignment()); - } - } - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - - node = new FunctionNode(node, params); - } - else { - // implicit multiplication like (2+3)(4+5) - // don't parse it here but let it be handled by parseMultiplyDivide - // with correct precedence - return node; - } - } - else if (token == '[') { - // index notation like variable[2, 3] - openParams(); - getToken(); - - if (token != ']') { - params.push(parseAssignment()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseAssignment()); - } - } - - if (token != ']') { - throw createSyntaxError('Parenthesis ] expected'); - } - closeParams(); - getToken(); - - node = new AccessorNode(node, new IndexNode(params)); - } - else { - // dot notation like variable.prop - getToken(); - - if (token_type != TOKENTYPE.SYMBOL) { - throw createSyntaxError('Property name expected after dot'); - } - params.push(new ConstantNode(token)); - getToken(); - - var dotNotation = true; - node = new AccessorNode(node, new IndexNode(params, dotNotation)); - } - } - - return node; - } - - /** - * parse a string. - * A string is enclosed by double quotes - * @return {Node} node - * @private - */ - function parseString () { - var node, str; - - if (token == '"') { - str = parseStringToken(); - - // create constant - node = new ConstantNode(str, 'string'); - - // parse index parameters - node = parseAccessors(node); - - return node; - } - - return parseMatrix(); - } - - /** - * Parse a string surrounded by double quotes "..." - * @return {string} - */ - function parseStringToken () { - var str = ''; - - while (c != '' && c != '\"') { - if (c == '\\') { - // escape character - str += c; - next(); - } - - str += c; - next(); - } - - getToken(); - if (token != '"') { - throw createSyntaxError('End of string " expected'); - } - getToken(); - - return str; - } - - /** - * parse the matrix - * @return {Node} node - * @private - */ - function parseMatrix () { - var array, params, rows, cols; - - if (token == '[') { - // matrix [...] - openParams(); - getToken(); - - if (token != ']') { - // this is a non-empty matrix - var row = parseRow(); - - if (token == ';') { - // 2 dimensional array - rows = 1; - params = [row]; - - // the rows of the matrix are separated by dot-comma's - while (token == ';') { - getToken(); - - params[rows] = parseRow(); - rows++; - } - - if (token != ']') { - throw createSyntaxError('End of matrix ] expected'); - } - closeParams(); - getToken(); - - // check if the number of columns matches in all rows - cols = params[0].items.length; - for (var r = 1; r < rows; r++) { - if (params[r].items.length != cols) { - throw createError('Column dimensions mismatch ' + - '(' + params[r].items.length + ' != ' + cols + ')'); - } - } - - array = new ArrayNode(params); - } - else { - // 1 dimensional vector - if (token != ']') { - throw createSyntaxError('End of matrix ] expected'); - } - closeParams(); - getToken(); - - array = row; - } - } - else { - // this is an empty matrix "[ ]" - closeParams(); - getToken(); - array = new ArrayNode([]); - } - - return parseAccessors(array); - } - - return parseObject(); - } - - /** - * Parse a single comma-separated row from a matrix, like 'a, b, c' - * @return {ArrayNode} node - */ - function parseRow () { - var params = [parseAssignment()]; - var len = 1; - - while (token == ',') { - getToken(); - - // parse expression - params[len] = parseAssignment(); - len++; - } - - return new ArrayNode(params); - } - - /** - * parse an object, enclosed in angle brackets{...}, for example {value: 2} - * @return {Node} node - * @private - */ - function parseObject () { - if (token == '{') { - var key; - - var properties = {}; - do { - getToken(); - - if (token != '}') { - // parse key - if (token == '"') { - key = parseStringToken(); - } - else if (token_type == TOKENTYPE.SYMBOL) { - key = token; - getToken(); - } - else { - throw createSyntaxError('Symbol or string expected as object key'); - } - - // parse key/value separator - if (token != ':') { - throw createSyntaxError('Colon : expected after object key'); - } - getToken(); - - // parse key - properties[key] = parseAssignment(); - } - } - while (token == ','); - - if (token != '}') { - throw createSyntaxError('Comma , or bracket } expected after object value'); - } - getToken(); - - var node = new ObjectNode(properties); - - // parse index parameters - node = parseAccessors(node); - - return node; - } - - return parseNumber(); - } - - /** - * parse a number - * @return {Node} node - * @private - */ - function parseNumber () { - var number; - - if (token_type == TOKENTYPE.NUMBER) { - // this is a number - number = token; - getToken(); - - return new ConstantNode(number, 'number'); - } - - return parseParentheses(); - } - - /** - * parentheses - * @return {Node} node - * @private - */ - function parseParentheses () { - var node; - - // check if it is a parenthesized expression - if (token == '(') { - // parentheses (...) - openParams(); - getToken(); - - node = parseAssignment(); // start again - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - - node = new ParenthesisNode(node); - node = parseAccessors(node); - return node; - } - - return parseEnd(); - } - - /** - * Evaluated when the expression is not yet ended but expected to end - * @return {Node} res - * @private - */ - function parseEnd () { - if (token == '') { - // syntax error or unexpected end of expression - throw createSyntaxError('Unexpected end of expression'); - } else { - throw createSyntaxError('Value expected'); - } - } - - /** - * Shortcut for getting the current row value (one based) - * Returns the line of the currently handled expression - * @private - */ - /* TODO: implement keeping track on the row number - function row () { - return null; - } - */ - - /** - * Shortcut for getting the current col value (one based) - * Returns the column (position) where the last token starts - * @private - */ - function col () { - return index - token.length + 1; - } - - /** - * Create an error - * @param {string} message - * @return {SyntaxError} instantiated error - * @private - */ - function createSyntaxError (message) { - var c = col(); - var error = new SyntaxError(message + ' (char ' + c + ')'); - error['char'] = c; - - return error; - } - - /** - * Create an error - * @param {string} message - * @return {Error} instantiated error - * @private - */ - function createError (message) { - var c = col(); - var error = new SyntaxError(message + ' (char ' + c + ')'); - error['char'] = c; - - return error; - } - - return parse; - }; - - exports.name = 'parse'; - exports.path = 'expression'; - exports.factory = factory; - - -/***/ }, -/* 271 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - var access = load(__webpack_require__(274)); - - /** - * @constructor AccessorNode - * @extends {Node} - * Access an object property or get a matrix subset - * - * @param {Node} object The object from which to retrieve - * a property or subset. - * @param {IndexNode} index IndexNode containing ranges - */ - function AccessorNode(object, index) { - if (!(this instanceof AccessorNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (!(object && object.isNode)) { - throw new TypeError('Node expected for parameter "object"'); - } - if (!(index && index.isIndexNode)) { - throw new TypeError('IndexNode expected for parameter "index"'); - } - - this.object = object || null; - this.index = index; - - // readonly property name - Object.defineProperty(this, 'name', { - get: function () { - if (this.index) { - return (this.index.isObjectProperty()) - ? this.index.getObjectProperty() - : ''; - } - else { - return this.object.name || ''; - } - }.bind(this), - set: function () { - throw new Error('Cannot assign a new name, name is read-only'); - } - }); - } - - AccessorNode.prototype = new Node(); - - AccessorNode.prototype.type = 'AccessorNode'; - - AccessorNode.prototype.isAccessorNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - AccessorNode.prototype._compile = function (defs, args) { - defs.access = access; - - var object = this.object._compile(defs, args); - var index = this.index._compile(defs, args); - - if (this.index.isObjectProperty()) { - return object + '["' + this.index.getObjectProperty() + '"]'; - } - else if (this.index.needsSize()) { - // if some parameters use the 'end' parameter, we need to calculate the size - return '(function () {' + - ' var object = ' + object + ';' + - ' var size = math.size(object).valueOf();' + - ' return access(object, ' + index + ');' + - '})()'; - } - else { - return 'access(' + object + ', ' + index + ')'; - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - AccessorNode.prototype.forEach = function (callback) { - callback(this.object, 'object', this); - callback(this.index, 'index', this); - }; - - /** - * Create a new AccessorNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {AccessorNode} Returns a transformed copy of the node - */ - AccessorNode.prototype.map = function (callback) { - return new AccessorNode( - this._ifNode(callback(this.object, 'object', this)), - this._ifNode(callback(this.index, 'index', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {AccessorNode} - */ - AccessorNode.prototype.clone = function () { - return new AccessorNode(this.object, this.index); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} - */ - AccessorNode.prototype._toString = function (options) { - var object = this.object.toString(options); - if (needParenthesis(this.object)) { - object = '(' + object + ')'; - } - - return object + this.index.toString(options); - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} - */ - AccessorNode.prototype._toTex = function (options) { - var object = this.object.toTex(options); - if (needParenthesis(this.object)) { - object = '\\left(' + object + '\\right)'; - } - - return object + this.index.toTex(options); - }; - - /** - * Are parenthesis needed? - * @private - */ - function needParenthesis(node) { - // TODO: maybe make a method on the nodes which tells whether they need parenthesis? - return !(node.isAccessorNode || node.isArrayNode || node.isConstantNode - || node.isFunctionNode || node.isObjectNode || node.isParenthesisNode - || node.isSymbolNode); - } - - return AccessorNode; - } - - exports.name = 'AccessorNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 272 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var keywords = __webpack_require__(273); - var extend = __webpack_require__(3).extend; - - function factory (type, config, load, typed, math) { - /** - * Node - */ - function Node() { - if (!(this instanceof Node)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - } - - /** - * Evaluate the node - * @param {Object} [scope] Scope to read/write variables - * @return {*} Returns the result - */ - Node.prototype.eval = function(scope) { - return this.compile().eval(scope); - }; - - Node.prototype.type = 'Node'; - - Node.prototype.isNode = true; - - /** - * Compile the node to javascript code - * @return {{eval: function}} expr Returns an object with a function 'eval', - * which can be invoked as expr.eval([scope]), - * where scope is an optional object with - * variables. - */ - Node.prototype.compile = function () { - // TODO: calling compile(math) is deprecated since version 2.0.0. Remove this warning some day - if (arguments.length > 0) { - throw new Error('Calling compile(math) is deprecated. Call the function as compile() instead.'); - } - - // definitions globally available inside the closure of the compiled expressions - var defs = { - math: math.expression.transform, - args: {}, // can be filled with names of FunctionAssignment arguments - _validateScope: _validateScope - }; - - // will be used to put local function arguments - var args = {}; - - var code = this._compile(defs, args); - - var defsCode = Object.keys(defs).map(function (name) { - return ' var ' + name + ' = defs["' + name + '"];'; - }); - - var factoryCode = - defsCode.join(' ') + - 'return {' + - ' "eval": function (scope) {' + - ' if (scope) _validateScope(scope);' + - ' scope = scope || {};' + - ' return ' + code + ';' + - ' }' + - '};'; - - var factory = new Function('defs', factoryCode); - return factory(defs); - }; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * and constants globally available inside the closure - * of the compiled expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - Node.prototype._compile = function (defs, args) { - // must be implemented by each of the Node implementations - throw new Error('Cannot compile a Node interface'); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - Node.prototype.forEach = function (callback) { - // must be implemented by each of the Node implementations - throw new Error('Cannot run forEach on a Node interface'); - }; - - /** - * Create a new Node having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {OperatorNode} Returns a transformed copy of the node - */ - Node.prototype.map = function (callback) { - // must be implemented by each of the Node implementations - throw new Error('Cannot run map on a Node interface'); - }; - - /** - * Validate whether an object is a Node, for use with map - * @param {Node} node - * @returns {Node} Returns the input if it's a node, else throws an Error - * @protected - */ - Node.prototype._ifNode = function (node) { - if (!(node && node.isNode)) { - throw new TypeError('Callback function must return a Node'); - } - - return node; - }; - - /** - * Recursively traverse all nodes in a node tree. Executes given callback for - * this node and each of its child nodes. - * @param {function(node: Node, path: string, parent: Node)} callback - * A callback called for every node in the node tree. - */ - Node.prototype.traverse = function (callback) { - // execute callback for itself - callback(this, null, null); - - // recursively traverse over all childs of a node - function _traverse(node, callback) { - node.forEach(function (child, path, parent) { - callback(child, path, parent); - _traverse(child, callback); - }); - } - - _traverse(this, callback); - }; - - /** - * Recursively transform a node tree via a transform function. - * - * For example, to replace all nodes of type SymbolNode having name 'x' with a - * ConstantNode with value 2: - * - * var res = Node.transform(function (node, path, parent) { - * if (node && node.isSymbolNode) && (node.name == 'x')) { - * return new ConstantNode(2); - * } - * else { - * return node; - * } - * }); - * - * @param {function(node: Node, path: string, parent: Node) : Node} callback - * A mapping function accepting a node, and returning - * a replacement for the node or the original node. - * Signature: callback(node: Node, index: string, parent: Node) : Node - * @return {Node} Returns the original node or its replacement - */ - Node.prototype.transform = function (callback) { - // traverse over all childs - function _transform (node, callback) { - return node.map(function(child, path, parent) { - var replacement = callback(child, path, parent); - return _transform(replacement, callback); - }); - } - - var replacement = callback(this, null, null); - return _transform(replacement, callback); - }; - - /** - * Find any node in the node tree matching given filter function. For example, to - * find all nodes of type SymbolNode having name 'x': - * - * var results = Node.filter(function (node) { - * return (node && node.isSymbolNode) && (node.name == 'x'); - * }); - * - * @param {function(node: Node, path: string, parent: Node) : Node} callback - * A test function returning true when a node matches, and false - * otherwise. Function signature: - * callback(node: Node, index: string, parent: Node) : boolean - * @return {Node[]} nodes An array with nodes matching given filter criteria - */ - Node.prototype.filter = function (callback) { - var nodes = []; - - this.traverse(function (node, path, parent) { - if (callback(node, path, parent)) { - nodes.push(node); - } - }); - - return nodes; - }; - - // TODO: deprecated since version 1.1.0, remove this some day - Node.prototype.find = function () { - throw new Error('Function Node.find is deprecated. Use Node.filter instead.'); - }; - - // TODO: deprecated since version 1.1.0, remove this some day - Node.prototype.match = function () { - throw new Error('Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.'); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {Node} - */ - Node.prototype.clone = function () { - // must be implemented by each of the Node implementations - throw new Error('Cannot clone a Node interface'); - }; - - /** - /** - * Get string representation. (wrapper function) - * - * This function can get an object of the following form: - * { - * handler: //This can be a callback function of the form - * // "function callback(node, options)"or - * // a map that maps function names (used in FunctionNodes) - * // to callbacks - * parenthesis: "keep" //the parenthesis option (This is optional) - * } - * - * @param {Object} [options] - * @return {string} - */ - Node.prototype.toString = function (options) { - var customString; - if (options && typeof options == "object") { - switch (typeof options.handler) { - case 'object': - case 'undefined': - break; - case 'function': - customString = options.handler(this, options); - break; - default: - throw new TypeError('Object or function expected as callback'); - } - } - - if (typeof customString !== 'undefined') { - return customString; - } - - return this._toString(options); - }; - - /** - * Internal function to generate the string output. - * This has to be implemented by every Node - * - * @throws {Error} - */ - Node.prototype._toString = function () { - //must be implemented by each of the Node implementations - throw new Error('_toString not implemented for ' + this.type); - }; - - /** - * Get LaTeX representation. (wrapper function) - * - * This function can get an object of the following form: - * { - * handler: //This can be a callback function of the form - * // "function callback(node, options)"or - * // a map that maps function names (used in FunctionNodes) - * // to callbacks - * parenthesis: "keep" //the parenthesis option (This is optional) - * } - * - * @param {Object} [options] - * @return {string} - */ - Node.prototype.toTex = function (options) { - var customTex; - if (options && typeof options == 'object') { - switch (typeof options.handler) { - case 'object': - case 'undefined': - break; - case 'function': - customTex = options.handler(this, options); - break; - default: - throw new TypeError('Object or function expected as callback'); - } - } - - if (typeof customTex !== 'undefined') { - return customTex; - } - - return this._toTex(options); - }; - - /** - * Internal function to generate the LaTeX output. - * This has to be implemented by every Node - * - * @param {Object} [options] - * @throws {Error} - */ - Node.prototype._toTex = function (options) { - //must be implemented by each of the Node implementations - throw new Error('_toTex not implemented for ' + this.type); - }; - - /** - * Get identifier. - * @return {string} - */ - Node.prototype.getIdentifier = function () { - return this.type; - }; - - /** - * Get the content of the current Node. - * @return {Node} node - **/ - Node.prototype.getContent = function () { - return this; - }; - - /** - * Validate the symbol names of a scope. - * Throws an error when the scope contains an illegal symbol. - * @param {Object} scope - */ - function _validateScope(scope) { - for (var symbol in scope) { - if (scope.hasOwnProperty(symbol)) { - if (symbol in keywords) { - throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword'); - } - } - } - } - - return Node; - } - - exports.name = 'Node'; - exports.path = 'expression.node'; - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.factory = factory; - - -/***/ }, -/* 273 */ -/***/ function(module, exports) { - - 'use strict'; - - // Reserved keywords not allowed to use in the parser - module.exports = { - end: true - }; - - -/***/ }, -/* 274 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var errorTransform = __webpack_require__(275).transform; - - function factory (type, config, load, typed) { - var subset = load(__webpack_require__(276)); - var matrix = load(__webpack_require__(52)); - - /** - * Retrieve part of an object: - * - * - Retrieve a property from an object - * - Retrieve a part of a string - * - Retrieve a matrix subset - * - * @param {Object | Array | Matrix | string} object - * @param {Index} index - * @return {Object | Array | Matrix | string} Returns the subset - */ - return function access(object, index) { - try { - if (Array.isArray(object)) { - return matrix(object).subset(index).valueOf(); - } - else if (object && typeof object.subset === 'function') { // Matrix - return object.subset(index); - } - else if (typeof object === 'string') { - // TODO: move getStringSubset into a separate util file, use that - return subset(object, index); - } - else if (typeof object === 'object') { - if (!index.isObjectProperty()) { - throw TypeError('Cannot apply a numeric index as object property'); - } - return object[index.getObjectProperty()]; - } - else { - throw new TypeError('Cannot apply index: unsupported type of object'); - } - } - catch (err) { - throw errorTransform(err); - } - } - } - - exports.factory = factory; - - -/***/ }, -/* 275 */ -/***/ function(module, exports, __webpack_require__) { - - var IndexError = __webpack_require__(43); - - /** - * Transform zero-based indices to one-based indices in errors - * @param {Error} err - * @returns {Error} Returns the transformed error - */ - exports.transform = function (err) { - if (err && err.isIndexError) { - return new IndexError( - err.index + 1, - err.min + 1, - err.max !== undefined ? err.max + 1 : undefined); - } - - return err; - }; - - -/***/ }, -/* 276 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var validateIndex = __webpack_require__(40).validateIndex; - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Get or set a subset of a matrix or string. - * - * Syntax: - * math.subset(value, index) // retrieve a subset - * math.subset(value, index, replacement [, defaultValue]) // replace a subset - * - * Examples: - * - * // get a subset - * var d = [[1, 2], [3, 4]]; - * math.subset(d, math.index(1, 0)); // returns 3 - * math.subset(d, math.index([0, 2], 1)); // returns [[2], [4]] - * - * // replace a subset - * var e = []; - * var f = math.subset(e, math.index(0, [0, 2]), [5, 6]); // f = [[5, 6]] - * var g = math.subset(f, math.index(1, 1), 7, 0); // g = [[5, 6], [0, 7]] - * - * See also: - * - * size, resize, squeeze, index - * - * @param {Array | Matrix | string} matrix An array, matrix, or string - * @param {Index} index An index containing ranges for each - * dimension - * @param {*} [replacement] An array, matrix, or scalar. - * If provided, the subset is replaced with replacement. - * If not provided, the subset is returned - * @param {*} [defaultValue=undefined] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * math.matrix elements will be left undefined. - * @return {Array | Matrix | string} Either the retrieved subset or the updated matrix. - */ - var subset = typed('subset', { - // get subset - 'Array, Index': function (value, index) { - var m = matrix(value); - var subset = m.subset(index); // returns a Matrix - return subset && subset.valueOf(); // return an Array (like the input) - }, - - 'Matrix, Index': function (value, index) { - return value.subset(index); - }, - - 'Object, Index': _getObjectProperty, - - 'string, Index': _getSubstring, - - // set subset - 'Array, Index, any': function (value, index, replacement) { - return matrix(clone(value)) - .subset(index, replacement, undefined) - .valueOf(); - }, - - 'Array, Index, any, any': function (value, index, replacement, defaultValue) { - return matrix(clone(value)) - .subset(index, replacement, defaultValue) - .valueOf(); - }, - - 'Matrix, Index, any': function (value, index, replacement) { - return value.clone().subset(index, replacement); - }, - - 'Matrix, Index, any, any': function (value, index, replacement, defaultValue) { - return value.clone().subset(index, replacement, defaultValue); - }, - - 'string, Index, string': _setSubstring, - 'string, Index, string, string': _setSubstring, - 'Object, Index, any': _setObjectProperty - }); - - subset.toTex = undefined; // use default template - - return subset; - - /** - * Retrieve a subset of a string - * @param {string} str string from which to get a substring - * @param {Index} index An index containing ranges for each dimension - * @returns {string} substring - * @private - */ - function _getSubstring(str, index) { - if (!index || index.isIndex !== true) { - // TODO: better error message - throw new TypeError('Index expected'); - } - if (index.size().length != 1) { - throw new DimensionError(index.size().length, 1); - } - - // validate whether the range is out of range - var strLen = str.length; - validateIndex(index.min()[0], strLen); - validateIndex(index.max()[0], strLen); - - var range = index.dimension(0); - - var substr = ''; - range.forEach(function (v) { - substr += str.charAt(v); - }); - - return substr; - } - - /** - * Replace a substring in a string - * @param {string} str string to be replaced - * @param {Index} index An index containing ranges for each dimension - * @param {string} replacement Replacement string - * @param {string} [defaultValue] Default value to be uses when resizing - * the string. is ' ' by default - * @returns {string} result - * @private - */ - function _setSubstring(str, index, replacement, defaultValue) { - if (!index || index.isIndex !== true) { - // TODO: better error message - throw new TypeError('Index expected'); - } - if (index.size().length != 1) { - throw new DimensionError(index.size().length, 1); - } - if (defaultValue !== undefined) { - if (typeof defaultValue !== 'string' || defaultValue.length !== 1) { - throw new TypeError('Single character expected as defaultValue'); - } - } - else { - defaultValue = ' '; - } - - var range = index.dimension(0); - var len = range.size()[0]; - - if (len != replacement.length) { - throw new DimensionError(range.size()[0], replacement.length); - } - - // validate whether the range is out of range - var strLen = str.length; - validateIndex(index.min()[0]); - validateIndex(index.max()[0]); - - // copy the string into an array with characters - var chars = []; - for (var i = 0; i < strLen; i++) { - chars[i] = str.charAt(i); - } - - range.forEach(function (v, i) { - chars[v] = replacement.charAt(i[0]); - }); - - // initialize undefined characters with a space - if (chars.length > strLen) { - for (i = strLen - 1, len = chars.length; i < len; i++) { - if (!chars[i]) { - chars[i] = defaultValue; - } - } - } - - return chars.join(''); - } - } - - /** - * Retrieve a property from an object - * @param {Object} object - * @param {Index} index - * @return {*} Returns the value of the property - * @private - */ - function _getObjectProperty (object, index) { - if (index.size().length !== 1) { - throw new DimensionError(index.size(), 1); - } - - var key = index.dimension(0); - if (typeof key !== 'string') { - throw new TypeError('String expected as index to retrieve an object property'); - } - - return object[key]; - } - - /** - * Set a property on an object - * @param {Object} object - * @param {Index} index - * @param {*} replacement - * @return {*} Returns the updated object - * @private - */ - function _setObjectProperty (object, index, replacement) { - if (index.size().length !== 1) { - throw new DimensionError(index.size(), 1); - } - - var key = index.dimension(0); - if (typeof key !== 'string') { - throw new TypeError('String expected as index to retrieve an object property'); - } - - // clone the object, and apply the property to the clone - var updated = clone(object); - updated[key] = replacement; - - return updated; - } - - exports.name = 'subset'; - exports.factory = factory; - - -/***/ }, -/* 277 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * @constructor ArrayNode - * @extends {Node} - * Holds an 1-dimensional array with items - * @param {Node[]} [items] 1 dimensional array with items - */ - function ArrayNode(items) { - if (!(this instanceof ArrayNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.items = items || []; - - // validate input - if (!Array.isArray(this.items) - || !this.items.every(function (item) {return item && item.isNode;})) { - throw new TypeError('Array containing Nodes expected'); - } - - // TODO: deprecated since v3, remove some day - var deprecated = function () { - throw new Error('Property `ArrayNode.nodes` is deprecated, use `ArrayNode.items` instead'); - }; - Object.defineProperty(this, 'nodes', { get: deprecated, set: deprecated }); - } - - ArrayNode.prototype = new Node(); - - ArrayNode.prototype.type = 'ArrayNode'; - - ArrayNode.prototype.isArrayNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @private - */ - ArrayNode.prototype._compile = function (defs, args) { - var asMatrix = (defs.math.config().matrix !== 'Array'); - - var items = this.items.map(function (node) { - return node._compile(defs, args); - }); - - return (asMatrix ? 'math.matrix([' : '[') + - items.join(',') + - (asMatrix ? '])' : ']'); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ArrayNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.items.length; i++) { - var node = this.items[i]; - callback(node, 'items[' + i + ']', this); - } - }; - - /** - * Create a new ArrayNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {ArrayNode} Returns a transformed copy of the node - */ - ArrayNode.prototype.map = function (callback) { - var items = []; - for (var i = 0; i < this.items.length; i++) { - items[i] = this._ifNode(callback(this.items[i], 'items[' + i + ']', this)); - } - return new ArrayNode(items); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ArrayNode} - */ - ArrayNode.prototype.clone = function() { - return new ArrayNode(this.items.slice(0)); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - * @override - */ - ArrayNode.prototype._toString = function(options) { - var items = this.items.map(function (node) { - return node.toString(options); - }); - return '[' + items.join(', ') + ']'; - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - ArrayNode.prototype._toTex = function(options) { - var s = '\\begin{bmatrix}'; - - this.items.forEach(function(node) { - if (node.items) { - s += node.items.map(function(childNode) { - return childNode.toTex(options); - }).join('&'); - } - else { - s += node.toTex(options); - } - - // new line - s += '\\\\'; - }); - s += '\\end{bmatrix}'; - return s; - }; - - return ArrayNode; - } - - exports.name = 'ArrayNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 278 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var latex = __webpack_require__(32); - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - var ArrayNode = load(__webpack_require__(277)); - var matrix = load(__webpack_require__(52)); - var assign = load(__webpack_require__(279)); - var access = load(__webpack_require__(274)); - - var keywords = __webpack_require__(273); - var operators = __webpack_require__(280); - - /** - * @constructor AssignmentNode - * @extends {Node} - * - * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or - * replace a subset of a matrix like `A[2,2]=42`. - * - * Syntax: - * - * new AssignmentNode(symbol, value) - * new AssignmentNode(object, index, value) - * - * Usage: - * - * new AssignmentNode(new SymbolNode('a'), new ConstantNode(2)); // a=2 - * new AssignmentNode(new SymbolNode('a'), new IndexNode('b'), new ConstantNode(2)) // a.b=2 - * new AssignmentNode(new SymbolNode('a'), new IndexNode(1, 2), new ConstantNode(3)) // a[1,2]=3 - * - * @param {SymbolNode | AccessorNode} object Object on which to assign a value - * @param {IndexNode} [index=null] Index, property name or matrix - * index. Optional. If not provided - * and `object` is a SymbolNode, - * the property is assigned to the - * global scope. - * @param {Node} value The value to be assigned - */ - function AssignmentNode(object, index, value) { - if (!(this instanceof AssignmentNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.object = object; - this.index = value ? index : null; - this.value = value ? value : index; - - // validate input - if (!object || !(object.isSymbolNode || object.isAccessorNode)) { - throw new TypeError('SymbolNode or AccessorNode expected as "object"'); - } - if (object && object.isSymbolNode && object.name === 'end') { - throw new Error('Cannot assign to symbol "end"'); - } - if (this.index && !this.index.isIndexNode) { - throw new TypeError('IndexNode expected as "index"'); - } - if (!this.value || !this.value.isNode) { - throw new TypeError('Node expected as "value"'); - } - - // readonly property name - Object.defineProperty(this, 'name', { - get: function () { - if (this.index) { - return (this.index.isObjectProperty()) - ? this.index.getObjectProperty() - : ''; - } - else { - return this.object.name || ''; - } - }.bind(this), - set: function () { - throw new Error('Cannot assign a new name, name is read-only'); - } - }); - } - - AssignmentNode.prototype = new Node(); - - AssignmentNode.prototype.type = 'AssignmentNode'; - - AssignmentNode.prototype.isAssignmentNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @private - */ - AssignmentNode.prototype._compile = function (defs, args) { - defs.assign = assign; - defs.access = access; - - var size; - var object = this.object._compile(defs, args); - var index = this.index ? this.index._compile(defs, args) : null; - var value = this.value._compile(defs, args); - - if (!this.index) { - // apply a variable to the scope, for example `a=2` - if (!this.object.isSymbolNode) { - throw new TypeError('SymbolNode expected as object'); - } - - return 'scope["' + this.object.name + '"] = ' + value; - } - else if (this.index.isObjectProperty()) { - // apply an object property for example `a.b=2` - return object + '["' + this.index.getObjectProperty() + '"] = ' + value; - } - else if (this.object.isSymbolNode) { - // update a matrix subset, for example `a[2]=3` - size = this.index.needsSize() ? 'var size = math.size(object).valueOf();' : ''; - - // apply updated object to scope - return '(function () {' + - ' var object = ' + object + ';' + - ' var value = ' + value + ';' + - ' ' + size + - ' scope["' + this.object.name + '"] = assign(object, ' + index + ', value);' + - ' return value;' + - '})()'; - } - else { // this.object.isAccessorNode === true - // update a matrix subset, for example `a.b[2]=3` - size = this.index.needsSize() ? 'var size = math.size(object).valueOf();' : ''; - - // we will not use the _compile of the AccessorNode, but compile it - // ourselves here as we need the parent object of the AccessorNode: - // wee need to apply the updated object to parent object - var parentObject = this.object.object._compile(defs, args); - - if (this.object.index.isObjectProperty()) { - var parentProperty = '["' + this.object.index.getObjectProperty() + '"]'; - return '(function () {' + - ' var parent = ' + parentObject + ';' + - ' var object = parent' + parentProperty + ';' + // parentIndex is a property - ' var value = ' + value + ';' + - size + - ' parent' + parentProperty + ' = assign(object, ' + index + ', value);' + - ' return value;' + - '})()'; - } - else { - // if some parameters use the 'end' parameter, we need to calculate the size - var parentSize = this.object.index.needsSize() ? 'var size = math.size(parent).valueOf();' : ''; - var parentIndex = this.object.index._compile(defs, args); - - return '(function () {' + - ' var parent = ' + parentObject + ';' + - ' ' + parentSize + - ' var parentIndex = ' + parentIndex + ';' + - ' var object = access(parent, parentIndex);' + - ' var value = ' + value + ';' + - ' ' + size + - ' assign(parent, parentIndex, assign(object, ' + index + ', value));' + - ' return value;' + - '})()'; - } - } - }; - - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - AssignmentNode.prototype.forEach = function (callback) { - callback(this.object, 'object', this); - if (this.index) { - callback(this.index, 'index', this); - } - callback(this.value, 'value', this); - }; - - /** - * Create a new AssignmentNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {AssignmentNode} Returns a transformed copy of the node - */ - AssignmentNode.prototype.map = function (callback) { - var object = this._ifNode(callback(this.object, 'object', this)); - var index = this.index - ? this._ifNode(callback(this.index, 'index', this)) - : null; - var value = this._ifNode(callback(this.value, 'value', this)); - - return new AssignmentNode(object, index, value); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {AssignmentNode} - */ - AssignmentNode.prototype.clone = function() { - return new AssignmentNode(this.object, this.index, this.value); - }; - - /* - * Is parenthesis needed? - * @param {node} node - * @param {string} [parenthesis='keep'] - * @private - */ - function needParenthesis(node, parenthesis) { - if (!parenthesis) { - parenthesis = 'keep'; - } - - var precedence = operators.getPrecedence(node, parenthesis); - var exprPrecedence = operators.getPrecedence(node.value, parenthesis); - return (parenthesis === 'all') - || ((exprPrecedence !== null) && (exprPrecedence <= precedence)); - } - - /** - * Get string representation - * @param {Object} options - * @return {string} - */ - AssignmentNode.prototype._toString = function(options) { - var object = this.object.toString(options); - var index = this.index ? this.index.toString(options) : ''; - var value = this.value.toString(options); - if (needParenthesis(this, options && options.parenthesis)) { - value = '(' + value + ')'; - } - - return object + index + ' = ' + value; - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} - */ - AssignmentNode.prototype._toTex = function(options) { - var object = this.object.toTex(options); - var index = this.index ? this.index.toTex(options) : ''; - var value = this.value.toTex(options); - if (needParenthesis(this, options && options.parenthesis)) { - value = '\\left(' + value + '\\right)'; - } - - return object + index + ':=' + value; - }; - - return AssignmentNode; - } - - exports.name = 'AssignmentNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 279 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var errorTransform = __webpack_require__(275).transform; - - function factory (type, config, load, typed) { - var subset = load(__webpack_require__(276)); - var matrix = load(__webpack_require__(52)); - - /** - * Replace part of an object: - * - * - Assign a property to an object - * - Replace a part of a string - * - Replace a matrix subset - * - * @param {Object | Array | Matrix | string} object - * @param {Index} index - * @param {*} value - * @return {Object | Array | Matrix | string} Returns the original object - * except in case of a string - */ - return function assign(object, index, value) { - try { - if (Array.isArray(object)) { - return matrix(object).subset(index, value).valueOf(); - } - else if (object && typeof object.subset === 'function') { // Matrix - return object.subset(index, value); - } - else if (typeof object === 'string') { - // TODO: move setStringSubset into a separate util file, use that - return subset(object, index, value); - } - else if (typeof object === 'object') { - if (!index.isObjectProperty()) { - throw TypeError('Cannot apply a numeric index as object property'); - } - object[index.getObjectProperty()] = value; - return object; - } - else { - throw new TypeError('Cannot apply index: unsupported type of object'); - } - } - catch (err) { - throw errorTransform(err); - } - } - } - - exports.factory = factory; - - -/***/ }, -/* 280 */ -/***/ function(module, exports) { - - 'use strict' - - //list of identifiers of nodes in order of their precedence - //also contains information about left/right associativity - //and which other operator the operator is associative with - //Example: - // addition is associative with addition and subtraction, because: - // (a+b)+c=a+(b+c) - // (a+b)-c=a+(b-c) - // - // postfix operators are left associative, prefix operators - // are right associative - // - //It's also possible to set the following properties: - // latexParens: if set to false, this node doesn't need to be enclosed - // in parentheses when using LaTeX - // latexLeftParens: if set to false, this !OperatorNode's! - // left argument doesn't need to be enclosed - // in parentheses - // latexRightParens: the same for the right argument - var properties = [ - { //assignment - 'AssignmentNode': {}, - 'FunctionAssignmentNode': {} - }, - { //conditional expression - 'ConditionalNode': { - latexLeftParens: false, - latexRightParens: false, - latexParens: false - //conditionals don't need parentheses in LaTeX because - //they are 2 dimensional - } - }, - { //logical or - 'OperatorNode:or': { - associativity: 'left', - associativeWith: [] - } - - }, - { //logical xor - 'OperatorNode:xor': { - associativity: 'left', - associativeWith: [] - } - }, - { //logical and - 'OperatorNode:and': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise or - 'OperatorNode:bitOr': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise xor - 'OperatorNode:bitXor': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise and - 'OperatorNode:bitAnd': { - associativity: 'left', - associativeWith: [] - } - }, - { //relational operators - 'OperatorNode:equal': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:unequal': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:smaller': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:larger': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:smallerEq': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:largerEq': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitshift operators - 'OperatorNode:leftShift': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:rightArithShift': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:rightLogShift': { - associativity: 'left', - associativeWith: [] - } - }, - { //unit conversion - 'OperatorNode:to': { - associativity: 'left', - associativeWith: [] - } - }, - { //range - 'RangeNode': {} - }, - { //addition, subtraction - 'OperatorNode:add': { - associativity: 'left', - associativeWith: ['OperatorNode:add', 'OperatorNode:subtract'] - }, - 'OperatorNode:subtract': { - associativity: 'left', - associativeWith: [] - } - }, - { //multiply, divide, modulus - 'OperatorNode:multiply': { - associativity: 'left', - associativeWith: [ - 'OperatorNode:multiply', - 'OperatorNode:divide', - 'Operator:dotMultiply', - 'Operator:dotDivide' - ] - }, - 'OperatorNode:divide': { - associativity: 'left', - associativeWith: [], - latexLeftParens: false, - latexRightParens: false, - latexParens: false - //fractions don't require parentheses because - //they're 2 dimensional, so parens aren't needed - //in LaTeX - }, - 'OperatorNode:dotMultiply': { - associativity: 'left', - associativeWith: [ - 'OperatorNode:multiply', - 'OperatorNode:divide', - 'OperatorNode:dotMultiply', - 'OperatorNode:doDivide' - ] - }, - 'OperatorNode:dotDivide': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:mod': { - associativity: 'left', - associativeWith: [] - } - }, - { //unary prefix operators - 'OperatorNode:unaryPlus': { - associativity: 'right' - }, - 'OperatorNode:unaryMinus': { - associativity: 'right' - }, - 'OperatorNode:bitNot': { - associativity: 'right' - }, - 'OperatorNode:not': { - associativity: 'right' - } - }, - { //exponentiation - 'OperatorNode:pow': { - associativity: 'right', - associativeWith: [], - latexRightParens: false - //the exponent doesn't need parentheses in - //LaTeX because it's 2 dimensional - //(it's on top) - }, - 'OperatorNode:dotPow': { - associativity: 'right', - associativeWith: [] - } - }, - { //factorial - 'OperatorNode:factorial': { - associativity: 'left' - } - }, - { //matrix transpose - 'OperatorNode:transpose': { - associativity: 'left' - } - } - ]; - - /** - * Get the precedence of a Node. - * Higher number for higher precedence, starting with 0. - * Returns null if the precedence is undefined. - * - * @param {Node} - * @param {string} parenthesis - * @return {number|null} - */ - function getPrecedence (_node, parenthesis) { - var node = _node; - if (parenthesis !== 'keep') { - //ParenthesisNodes are only ignored when not in 'keep' mode - node = _node.getContent(); - } - var identifier = node.getIdentifier(); - for (var i = 0; i < properties.length; i++) { - if (identifier in properties[i]) { - return i; - } - } - return null; - } - - /** - * Get the associativity of an operator (left or right). - * Returns a string containing 'left' or 'right' or null if - * the associativity is not defined. - * - * @param {Node} - * @param {string} parenthesis - * @return {string|null} - * @throws {Error} - */ - function getAssociativity (_node, parenthesis) { - var node = _node; - if (parenthesis !== 'keep') { - //ParenthesisNodes are only ignored when not in 'keep' mode - node = _node.getContent(); - } - var identifier = node.getIdentifier(); - var index = getPrecedence(node, parenthesis); - if (index === null) { - //node isn't in the list - return null; - } - var property = properties[index][identifier]; - - if (property.hasOwnProperty('associativity')) { - if (property.associativity === 'left') { - return 'left'; - } - if (property.associativity === 'right') { - return 'right'; - } - //associativity is invalid - throw Error('\'' + identifier + '\' has the invalid associativity \'' - + property.associativity + '\'.'); - } - - //associativity is undefined - return null; - } - - /** - * Check if an operator is associative with another operator. - * Returns either true or false or null if not defined. - * - * @param {Node} nodeA - * @param {Node} nodeB - * @param {string} parenthesis - * @return {bool|null} - */ - function isAssociativeWith (nodeA, nodeB, parenthesis) { - var a = nodeA; - var b = nodeB; - if (parenthesis !== 'keep') { - //ParenthesisNodes are only ignored when not in 'keep' mode - var a = nodeA.getContent(); - var b = nodeB.getContent(); - } - var identifierA = a.getIdentifier(); - var identifierB = b.getIdentifier(); - var index = getPrecedence(a, parenthesis); - if (index === null) { - //node isn't in the list - return null; - } - var property = properties[index][identifierA]; - - if (property.hasOwnProperty('associativeWith') - && (property.associativeWith instanceof Array)) { - for (var i = 0; i < property.associativeWith.length; i++) { - if (property.associativeWith[i] === identifierB) { - return true; - } - } - return false; - } - - //associativeWith is not defined - return null; - } - - module.exports.properties = properties; - module.exports.getPrecedence = getPrecedence; - module.exports.getAssociativity = getAssociativity; - module.exports.isAssociativeWith = isAssociativeWith; - - -/***/ }, -/* 281 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - var ResultSet = load(__webpack_require__(72)); - - /** - * @constructor BlockNode - * @extends {Node} - * Holds a set with blocks - * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks - * An array with blocks, where a block is constructed as an Object - * with properties block, which is a Node, and visible, which is - * a boolean. The property visible is optional and is true by default - */ - function BlockNode(blocks) { - if (!(this instanceof BlockNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input, copy blocks - if (!Array.isArray(blocks)) throw new Error('Array expected'); - this.blocks = blocks.map(function (block) { - var node = block && block.node; - var visible = block && block.visible !== undefined ? block.visible : true; - - if (!(node && node.isNode)) throw new TypeError('Property "node" must be a Node'); - if (typeof visible !== 'boolean') throw new TypeError('Property "visible" must be a boolean'); - - return { - node: node, - visible: visible - } - }); - } - - BlockNode.prototype = new Node(); - - BlockNode.prototype.type = 'BlockNode'; - - BlockNode.prototype.isBlockNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - BlockNode.prototype._compile = function (defs, args) { - defs.ResultSet = ResultSet; - var blocks = this.blocks.map(function (param) { - var js = param.node._compile(defs, args); - if (param.visible) { - return 'results.push(' + js + ');'; - } - else { - return js + ';'; - } - }); - - return '(function () {' + - 'var results = [];' + - blocks.join('') + - 'return new ResultSet(results);' + - '})()'; - }; - - /** - * Execute a callback for each of the child blocks of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - BlockNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.blocks.length; i++) { - callback(this.blocks[i].node, 'blocks[' + i + '].node', this); - } - }; - - /** - * Create a new BlockNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {BlockNode} Returns a transformed copy of the node - */ - BlockNode.prototype.map = function (callback) { - var blocks = []; - for (var i = 0; i < this.blocks.length; i++) { - var block = this.blocks[i]; - var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this)); - blocks[i] = { - node: node, - visible: block.visible - }; - } - return new BlockNode(blocks); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {BlockNode} - */ - BlockNode.prototype.clone = function () { - var blocks = this.blocks.map(function (block) { - return { - node: block.node, - visible: block.visible - }; - }); - - return new BlockNode(blocks); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - * @override - */ - BlockNode.prototype._toString = function (options) { - return this.blocks.map(function (param) { - return param.node.toString(options) + (param.visible ? '' : ';'); - }).join('\n'); - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - BlockNode.prototype._toTex = function (options) { - return this.blocks.map(function (param) { - return param.node.toTex(options) + (param.visible ? '' : ';'); - }).join('\\;\\;\n'); - }; - - return BlockNode; - } - - exports.name = 'BlockNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 282 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var latex = __webpack_require__(32); - var operators = __webpack_require__(280); - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr' - * - * @param {Node} condition Condition, must result in a boolean - * @param {Node} trueExpr Expression evaluated when condition is true - * @param {Node} falseExpr Expression evaluated when condition is true - * - * @constructor ConditionalNode - * @extends {Node} - */ - function ConditionalNode(condition, trueExpr, falseExpr) { - if (!(this instanceof ConditionalNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - if (!(condition && condition.isNode)) throw new TypeError('Parameter condition must be a Node'); - if (!(trueExpr && trueExpr.isNode)) throw new TypeError('Parameter trueExpr must be a Node'); - if (!(falseExpr && falseExpr.isNode)) throw new TypeError('Parameter falseExpr must be a Node'); - - this.condition = condition; - this.trueExpr = trueExpr; - this.falseExpr = falseExpr; - } - - ConditionalNode.prototype = new Node(); - - ConditionalNode.prototype.type = 'ConditionalNode'; - - ConditionalNode.prototype.isConditionalNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - ConditionalNode.prototype._compile = function (defs, args) { - /** - * Test whether a condition is met - * @param {*} condition - * @returns {boolean} true if condition is true or non-zero, else false - */ - defs.testCondition = function (condition) { - if (typeof condition === 'number' - || typeof condition === 'boolean' - || typeof condition === 'string') { - return condition ? true : false; - } - - if (condition) { - if (condition.isBigNumber === true) { - return condition.isZero() ? false : true; - } - - if (condition.isComplex === true) { - return (condition.re || condition.im) ? true : false; - } - - if (condition.isUnit === true) { - return condition.value ? true : false; - } - } - - if (condition === null || condition === undefined) { - return false; - } - - throw new TypeError('Unsupported type of condition "' + defs.math['typeof'](condition) + '"'); - }; - - return ( - 'testCondition(' + this.condition._compile(defs, args) + ') ? ' + - '( ' + this.trueExpr._compile(defs, args) + ') : ' + - '( ' + this.falseExpr._compile(defs, args) + ')' - ); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ConditionalNode.prototype.forEach = function (callback) { - callback(this.condition, 'condition', this); - callback(this.trueExpr, 'trueExpr', this); - callback(this.falseExpr, 'falseExpr', this); - }; - - /** - * Create a new ConditionalNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {ConditionalNode} Returns a transformed copy of the node - */ - ConditionalNode.prototype.map = function (callback) { - return new ConditionalNode( - this._ifNode(callback(this.condition, 'condition', this)), - this._ifNode(callback(this.trueExpr, 'trueExpr', this)), - this._ifNode(callback(this.falseExpr, 'falseExpr', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ConditionalNode} - */ - ConditionalNode.prototype.clone = function () { - return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - */ - ConditionalNode.prototype._toString = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var precedence = operators.getPrecedence(this, parenthesis); - - //Enclose Arguments in parentheses if they are an OperatorNode - //or have lower or equal precedence - //NOTE: enclosing all OperatorNodes in parentheses is a decision - //purely based on aesthetics and readability - var condition = this.condition.toString(options); - var conditionPrecedence = operators.getPrecedence(this.condition, parenthesis); - if ((parenthesis === 'all') - || (this.condition.type === 'OperatorNode') - || ((conditionPrecedence !== null) && (conditionPrecedence <= precedence))) { - condition = '(' + condition + ')'; - } - - var trueExpr = this.trueExpr.toString(options); - var truePrecedence = operators.getPrecedence(this.trueExpr, parenthesis); - if ((parenthesis === 'all') - || (this.trueExpr.type === 'OperatorNode') - || ((truePrecedence !== null) && (truePrecedence <= precedence))) { - trueExpr = '(' + trueExpr + ')'; - } - - var falseExpr = this.falseExpr.toString(options); - var falsePrecedence = operators.getPrecedence(this.falseExpr, parenthesis); - if ((parenthesis === 'all') - || (this.falseExpr.type === 'OperatorNode') - || ((falsePrecedence !== null) && (falsePrecedence <= precedence))) { - falseExpr = '(' + falseExpr + ')'; - } - return condition + ' ? ' + trueExpr + ' : ' + falseExpr; - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - ConditionalNode.prototype._toTex = function (options) { - return '\\begin{cases} {' - + this.trueExpr.toTex(options) + '}, &\\quad{\\text{if }\\;' - + this.condition.toTex(options) - + '}\\\\{' + this.falseExpr.toTex(options) - + '}, &\\quad{\\text{otherwise}}\\end{cases}'; - }; - - return ConditionalNode; - } - - exports.name = 'ConditionalNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 283 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var getType = __webpack_require__(41).type; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * A ConstantNode holds a constant value like a number or string. A ConstantNode - * stores a stringified version of the value and uses this to compile to - * JavaScript. - * - * In case of a stringified number as input, this may be compiled to a BigNumber - * when the math instance is configured for BigNumbers. - * - * Usage: - * - * // stringified values with type - * new ConstantNode('2.3', 'number'); - * new ConstantNode('true', 'boolean'); - * new ConstantNode('hello', 'string'); - * - * // non-stringified values, type will be automatically detected - * new ConstantNode(2.3); - * new ConstantNode('hello'); - * - * @param {string | number | boolean | null | undefined} value - * When valueType is provided, value must contain - * an uninterpreted string representing the value. - * When valueType is undefined, value can be a - * number, string, boolean, null, or undefined, and - * the type will be determined automatically. - * @param {string} [valueType] The type of value. Choose from 'number', 'string', - * 'boolean', 'undefined', 'null' - * @constructor ConstantNode - * @extends {Node} - */ - function ConstantNode(value, valueType) { - if (!(this instanceof ConstantNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (valueType) { - if (typeof valueType !== 'string') { - throw new TypeError('String expected for parameter "valueType"'); - } - if (typeof value !== 'string') { - throw new TypeError('String expected for parameter "value"'); - } - - this.value = value; - this.valueType = valueType; - } - else { - // stringify the value and determine the type - this.value = value + ''; - this.valueType = getType(value); - } - - if (!SUPPORTED_TYPES[this.valueType]) { - throw new TypeError('Unsupported type of value "' + this.valueType + '"'); - } - } - - var SUPPORTED_TYPES = { - 'number': true, - 'string': true, - 'boolean': true, - 'undefined': true, - 'null': true - }; - - ConstantNode.prototype = new Node(); - - ConstantNode.prototype.type = 'ConstantNode'; - - ConstantNode.prototype.isConstantNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - ConstantNode.prototype._compile = function (defs, args) { - switch (this.valueType) { - case 'number': - // TODO: replace this with using config.number - var numConfig = defs.math.config().number; - if (numConfig === 'BigNumber') { - return 'math.bignumber("' + this.value + '")'; - } - else if (numConfig === 'Fraction') { - return 'math.fraction("' + this.value + '")'; - } - else { - // remove leading zeros like '003.2' which are not allowed by JavaScript - return this.value.replace(/^(0*)[0-9]/, function (match, zeros) { - return match.substring(zeros.length); - }); - } - - case 'string': - return '"' + this.value + '"'; - - case 'boolean': - return this.value; - - case 'undefined': - return this.value; - - case 'null': - return this.value; - - default: - // TODO: move this error to the constructor? - throw new TypeError('Unsupported type of constant "' + this.valueType + '"'); - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ConstantNode.prototype.forEach = function (callback) { - // nothing to do, we don't have childs - }; - - - /** - * Create a new ConstantNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node) : Node} callback - * @returns {ConstantNode} Returns a clone of the node - */ - ConstantNode.prototype.map = function (callback) { - return this.clone(); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ConstantNode} - */ - ConstantNode.prototype.clone = function () { - return new ConstantNode(this.value, this.valueType); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - */ - ConstantNode.prototype._toString = function (options) { - switch (this.valueType) { - case 'string': - return '"' + this.value + '"'; - - default: - return this.value; - } - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - ConstantNode.prototype._toTex = function (options) { - var value = this.value, - index; - switch (this.valueType) { - case 'string': - return '\\mathtt{"' + value + '"}'; - - case 'number': - index = value.toLowerCase().indexOf('e'); - if (index !== -1) { - return value.substring(0, index) + '\\cdot10^{' + - value.substring(index + 1) + '}'; - } - return value; - - default: - return value; - } - }; - - return ConstantNode; - } - - exports.name = 'ConstantNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 284 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var keywords = __webpack_require__(273); - var latex = __webpack_require__(32); - var operators = __webpack_require__(280); - - function isString (x) { - return typeof x === 'string'; - } - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * @constructor FunctionAssignmentNode - * @extends {Node} - * Function assignment - * - * @param {string} name Function name - * @param {string[]} params Function parameter names - * @param {Node} expr The function expression - */ - function FunctionAssignmentNode(name, params, expr) { - if (!(this instanceof FunctionAssignmentNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); - if (!Array.isArray(params) || !params.every(isString)) throw new TypeError('Array containing strings expected for parameter "params"'); - if (!(expr && expr.isNode)) throw new TypeError('Node expected for parameter "expr"'); - if (name in keywords) throw new Error('Illegal function name, "' + name + '" is a reserved keyword'); - - this.name = name; - this.params = params; - this.expr = expr; - } - - FunctionAssignmentNode.prototype = new Node(); - - FunctionAssignmentNode.prototype.type = 'FunctionAssignmentNode'; - - FunctionAssignmentNode.prototype.isFunctionAssignmentNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - FunctionAssignmentNode.prototype._compile = function (defs, args) { - // we extend the original args and add the args to the child object - var childArgs = Object.create(args); - this.params.forEach(function (variable) { - childArgs[variable] = true; - }); - - // compile the function expression with the child args - var jsExpr = this.expr._compile(defs, childArgs); - - return 'scope["' + this.name + '"] = ' + - ' (function () {' + - ' var fn = function ' + this.name + '(' + this.params.join(',') + ') {' + - ' if (arguments.length != ' + this.params.length + ') {' + - // TODO: use util.error.ArgumentsError here? - // TODO: test arguments error - ' throw new SyntaxError("Wrong number of arguments in function ' + this.name + ' (" + arguments.length + " provided, ' + this.params.length + ' expected)");' + - ' }' + - ' return ' + jsExpr + '' + - ' };' + - ' fn.syntax = "' + this.name + '(' + this.params.join(', ') + ')";' + - ' return fn;' + - ' })()'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - FunctionAssignmentNode.prototype.forEach = function (callback) { - callback(this.expr, 'expr', this); - }; - - /** - * Create a new FunctionAssignmentNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {FunctionAssignmentNode} Returns a transformed copy of the node - */ - FunctionAssignmentNode.prototype.map = function (callback) { - var expr = this._ifNode(callback(this.expr, 'expr', this)); - - return new FunctionAssignmentNode(this.name, this.params.slice(0), expr); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {FunctionAssignmentNode} - */ - FunctionAssignmentNode.prototype.clone = function () { - return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr); - }; - - /** - * Is parenthesis needed? - * @param {Node} node - * @param {Object} parenthesis - * @private - */ - function needParenthesis(node, parenthesis) { - var precedence = operators.getPrecedence(node, parenthesis); - var exprPrecedence = operators.getPrecedence(node.expr, parenthesis); - - return (parenthesis === 'all') - || ((exprPrecedence !== null) && (exprPrecedence <= precedence)); - } - - /** - * get string representation - * @param {Object} options - * @return {string} str - */ - FunctionAssignmentNode.prototype._toString = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var expr = this.expr.toString(options); - if (needParenthesis(this, parenthesis)) { - expr = '(' + expr + ')'; - } - return 'function ' + this.name + - '(' + this.params.join(', ') + ') = ' + expr; - }; - - /** - * get LaTeX representation - * @param {Object} options - * @return {string} str - */ - FunctionAssignmentNode.prototype._toTex = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var expr = this.expr.toTex(options); - if (needParenthesis(this, parenthesis)) { - expr = '\\left(' + expr + '\\right)'; - } - - return '\\mathrm{' + this.name - + '}\\left(' + this.params.map(latex.toSymbol).join(',') + '\\right):=' + expr; - }; - - return FunctionAssignmentNode; - } - exports.name = 'FunctionAssignmentNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 285 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - var RangeNode = load(__webpack_require__(286)); - var SymbolNode = load(__webpack_require__(287)); - - var Range = load(__webpack_require__(67)); - - var isArray = Array.isArray; - - /** - * @constructor IndexNode - * @extends Node - * - * Describes a subset of a matrix or an object property. - * Cannot be used on its own, needs to be used within an AccessorNode or - * AssignmentNode. - * - * @param {Node[]} dimensions - * @param {boolean} [dotNotation=false] Optional property describing whether - * this index was written using dot - * notation like `a.b`, or using bracket - * notation like `a["b"]` (default). - * Used to stringify an IndexNode. - */ - function IndexNode(dimensions, dotNotation) { - if (!(this instanceof IndexNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.dimensions = dimensions; - this.dotNotation = dotNotation || false; - - // validate input - if (!isArray(dimensions) - || !dimensions.every(function (range) {return range && range.isNode;})) { - throw new TypeError('Array containing Nodes expected for parameter "dimensions"'); - } - if (this.dotNotation && !this.isObjectProperty()) { - throw new Error('dotNotation only applicable for object properties'); - } - - // TODO: deprecated since v3, remove some day - var deprecated = function () { - throw new Error('Property `IndexNode.object` is deprecated, use `IndexNode.fn` instead'); - }; - Object.defineProperty(this, 'object', { get: deprecated, set: deprecated }); - } - - IndexNode.prototype = new Node(); - - IndexNode.prototype.type = 'IndexNode'; - - IndexNode.prototype.isIndexNode = true; - - /** - * Compile all range nodes - * - * When some of the dimensions has `end` defined, the IndexNode requires - * a variable `size` to be defined in the current closure, and must contain - * the size of the matrix that's being handled. To check whether the `size` - * variable is needed, call IndexNode.needsSize(). - * - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the - * compiled expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} code - */ - IndexNode.prototype._compile = function (defs, args) { - // args can be mutated by IndexNode, when dimensions use `end` - var childArgs = Object.create(args); - - // helper function to create a Range from start, step and end - defs.range = function (start, end, step) { - return new Range( - (start && start.isBigNumber === true) ? start.toNumber() : start, - (end && end.isBigNumber === true) ? end.toNumber() : end, - (step && step.isBigNumber === true) ? step.toNumber() : step - ); - }; - - // TODO: implement support for bignumber (currently bignumbers are silently - // reduced to numbers when changing the value to zero-based) - - // TODO: Optimization: when the range values are ConstantNodes, - // we can beforehand resolve the zero-based value - - // optimization for a simple object property - var dimensions = this.dimensions.map(function (range, i) { - if (range && range.isRangeNode) { - if (range.needsEnd()) { - childArgs.end = true; - - // resolve end and create range - return '(function () {' + - 'var end = size[' + i + ']; ' + - 'return range(' + - range.start._compile(defs, childArgs) + ', ' + - range.end._compile(defs, childArgs) + ', ' + - (range.step ? range.step._compile(defs, childArgs) : '1') + - '); ' + - '})()'; - } - else { - // create range - return 'range(' + - range.start._compile(defs, childArgs) + ', ' + - range.end._compile(defs, childArgs) + ', ' + - (range.step ? range.step._compile(defs, childArgs) : '1') + - ')'; - } - } - if (range.isSymbolNode && range.name === 'end') { - childArgs.end = true; - - // resolve the parameter 'end' - return '(function () {' + - 'var end = size[' + i + ']; ' + - 'return ' + range._compile(defs, childArgs) + '; ' + - '})()' - } - else { // ConstantNode - return range._compile(defs, childArgs); - } - }); - - return 'math.index(' + dimensions.join(', ') + ')'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - IndexNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.dimensions.length; i++) { - callback(this.dimensions[i], 'dimensions[' + i + ']', this); - } - }; - - /** - * Create a new IndexNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {IndexNode} Returns a transformed copy of the node - */ - IndexNode.prototype.map = function (callback) { - var dimensions = []; - for (var i = 0; i < this.dimensions.length; i++) { - dimensions[i] = this._ifNode(callback(this.dimensions[i], 'dimensions[' + i + ']', this)); - } - - return new IndexNode(dimensions); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {IndexNode} - */ - IndexNode.prototype.clone = function () { - return new IndexNode(this.dimensions.slice(0)); - }; - - /** - * Test whether this IndexNode contains a single property name - * @return {boolean} - */ - IndexNode.prototype.isObjectProperty = function () { - return this.dimensions.length === 1 && - this.dimensions[0].isConstantNode && - this.dimensions[0].valueType === 'string'; - }; - - /** - * Returns the property name if IndexNode contains a property. - * If not, returns null. - * @return {string | null} - */ - IndexNode.prototype.getObjectProperty = function () { - return this.isObjectProperty() ? this.dimensions[0].value : null; - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - */ - IndexNode.prototype._toString = function (options) { - // format the parameters like "[1, 0:5]" - return this.dotNotation - ? ('.' + this.getObjectProperty()) - : ('[' + this.dimensions.join(', ') + ']'); - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - IndexNode.prototype._toTex = function (options) { - var dimensions = this.dimensions.map(function (range) { - return range.toTex(options); - }); - - return this.dotNotation - ? ('.' + this.getObjectProperty() + '') - : ('_{' + dimensions.join(',') + '}'); - }; - - /** - * Test whether this IndexNode needs the object size, size of the Matrix - * @return {boolean} - */ - IndexNode.prototype.needsSize = function () { - return this.dimensions.some(function (range) { - return (range.isRangeNode && range.needsEnd()) || - (range.isSymbolNode && range.name === 'end'); - }); - }; - - return IndexNode; - } - - exports.name = 'IndexNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 286 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var operators = __webpack_require__(280); - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * @constructor RangeNode - * @extends {Node} - * create a range - * @param {Node} start included lower-bound - * @param {Node} end included upper-bound - * @param {Node} [step] optional step - */ - function RangeNode(start, end, step) { - if (!(this instanceof RangeNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate inputs - if (!(start && start.isNode)) throw new TypeError('Node expected'); - if (!(end && end.isNode)) throw new TypeError('Node expected'); - if (step && !(step && step.isNode)) throw new TypeError('Node expected'); - if (arguments.length > 3) throw new Error('Too many arguments'); - - this.start = start; // included lower-bound - this.end = end; // included upper-bound - this.step = step || null; // optional step - } - - RangeNode.prototype = new Node(); - - RangeNode.prototype.type = 'RangeNode'; - - RangeNode.prototype.isRangeNode = true; - - /** - * Check whether the RangeNode needs the `end` symbol to be defined. - * This end is the size of the Matrix in current dimension. - * @return {boolean} - */ - RangeNode.prototype.needsEnd = function () { - // find all `end` symbols in this RangeNode - var endSymbols = this.filter(function (node) { - return (node && node.isSymbolNode) && (node.name == 'end'); - }); - - return endSymbols.length > 0; - }; - - /** - * Compile the node to javascript code - * - * When the range has a symbol `end` defined, the RangeNode requires - * a variable `end` to be defined in the current closure, which must contain - * the length of the of the matrix that's being handled in the range's - * dimension. To check whether the `end` variable is needed, call - * RangeNode.needsEnd(). - * - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - RangeNode.prototype._compile = function (defs, args) { - return 'math.range(' + - this.start._compile(defs, args) + ', ' + - this.end._compile(defs, args) + - (this.step ? (', ' + this.step._compile(defs, args)) : '') + - ')'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - RangeNode.prototype.forEach = function (callback) { - callback(this.start, 'start', this); - callback(this.end, 'end', this); - if (this.step) { - callback(this.step, 'step', this); - } - }; - - /** - * Create a new RangeNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {RangeNode} Returns a transformed copy of the node - */ - RangeNode.prototype.map = function (callback) { - return new RangeNode( - this._ifNode(callback(this.start, 'start', this)), - this._ifNode(callback(this.end, 'end', this)), - this.step && this._ifNode(callback(this.step, 'step', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {RangeNode} - */ - RangeNode.prototype.clone = function () { - return new RangeNode(this.start, this.end, this.step && this.step); - }; - - /** - * Calculate the necessary parentheses - * @param {Node} node - * @param {string} parenthesis - * @return {Object} parentheses - * @private - */ - function calculateNecessaryParentheses(node, parenthesis) { - var precedence = operators.getPrecedence(node, parenthesis); - var parens = {}; - - var startPrecedence = operators.getPrecedence(node.start, parenthesis); - parens.start = ((startPrecedence !== null) && (startPrecedence <= precedence)) - || (parenthesis === 'all'); - - if (node.step) { - var stepPrecedence = operators.getPrecedence(node.step, parenthesis); - parens.step = ((stepPrecedence !== null) && (stepPrecedence <= precedence)) - || (parenthesis === 'all'); - } - - var endPrecedence = operators.getPrecedence(node.end, parenthesis); - parens.end = ((endPrecedence !== null) && (endPrecedence <= precedence)) - || (parenthesis === 'all'); - - return parens; - } - - /** - * Get string representation - * @param {Object} options - * @return {string} str - */ - RangeNode.prototype._toString = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var parens = calculateNecessaryParentheses(this, parenthesis); - - //format string as start:step:stop - var str; - - var start = this.start.toString(options); - if (parens.start) { - start = '(' + start + ')'; - } - str = start; - - if (this.step) { - var step = this.step.toString(options); - if (parens.step) { - step = '(' + step + ')'; - } - str += ':' + step; - } - - var end = this.end.toString(options); - if (parens.end) { - end = '(' + end + ')'; - } - str += ':' + end; - - return str; - }; - - /** - * Get LaTeX representation - * @params {Object} options - * @return {string} str - */ - RangeNode.prototype._toTex = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var parens = calculateNecessaryParentheses(this, parenthesis); - - var str = this.start.toTex(options); - if (parens.start) { - str = '\\left(' + str + '\\right)'; - } - - if (this.step) { - var step = this.step.toTex(options); - if (parens.step) { - step = '\\left(' + step + '\\right)'; - } - str += ':' + step; - } - - var end = this.end.toTex(options); - if (parens.end) { - end = '\\left(' + end + '\\right)'; - } - str += ':' + end; - - return str; - }; - - return RangeNode; - } - - exports.name = 'RangeNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 287 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var latex = __webpack_require__(32); - - function factory (type, config, load, typed, math) { - var Node = load(__webpack_require__(272)); - - var Unit = load(__webpack_require__(75)); - - /** - * @constructor SymbolNode - * @extends {Node} - * A symbol node can hold and resolve a symbol - * @param {string} name - * @extends {Node} - */ - function SymbolNode(name) { - if (!(this instanceof SymbolNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); - - this.name = name; - } - - SymbolNode.prototype = new Node(); - - SymbolNode.prototype.type = 'SymbolNode'; - - SymbolNode.prototype.isSymbolNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - SymbolNode.prototype._compile = function (defs, args) { - // add a function to the definitions - defs['undef'] = undef; - defs['Unit'] = Unit; - - if (args[this.name]) { - // this is a FunctionAssignment argument - // (like an x when inside the expression of a function assignment `f(x) = ...`) - return this.name; - } - else if (this.name in defs.math) { - return '("' + this.name + '" in scope ? scope["' + this.name + '"] : math["' + this.name + '"])'; - } - else { - return '(' + - '"' + this.name + '" in scope ? scope["' + this.name + '"] : ' + - (Unit.isValuelessUnit(this.name) ? - 'new Unit(null, "' + this.name + '")' : - 'undef("' + this.name + '")') + - ')'; - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - SymbolNode.prototype.forEach = function (callback) { - // nothing to do, we don't have childs - }; - - /** - * Create a new SymbolNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node) : Node} callback - * @returns {SymbolNode} Returns a clone of the node - */ - SymbolNode.prototype.map = function (callback) { - return this.clone(); - }; - - /** - * Throws an error 'Undefined symbol {name}' - * @param {string} name - */ - function undef (name) { - throw new Error('Undefined symbol ' + name); - } - - /** - * Create a clone of this node, a shallow copy - * @return {SymbolNode} - */ - SymbolNode.prototype.clone = function() { - return new SymbolNode(this.name); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - * @override - */ - SymbolNode.prototype._toString = function(options) { - return this.name; - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - * @override - */ - SymbolNode.prototype._toTex = function(options) { - var isUnit = false; - if ((typeof math[this.name] === 'undefined') && Unit.isValuelessUnit(this.name)) { - isUnit = true; - } - var symbol = latex.toSymbol(this.name, isUnit); - if (symbol[0] === '\\') { - //no space needed if the symbol starts with '\' - return symbol; - } - //the space prevents symbols from breaking stuff like '\cdot' if it's written right before the symbol - return ' ' + symbol; - }; - - return SymbolNode; - } - - exports.name = 'SymbolNode'; - exports.path = 'expression.node'; - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.factory = factory; - - -/***/ }, -/* 288 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var string = __webpack_require__(23); - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * @constructor ObjectNode - * @extends {Node} - * Holds an object with keys/values - * @param {Object.} [properties] array with key/value pairs - */ - function ObjectNode(properties) { - if (!(this instanceof ObjectNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.properties = properties || {}; - - // validate input - if (properties) { - if (!(typeof properties === 'object') || Object.keys(properties).some(function (key) { - return !properties[key] || !properties[key].isNode; - })) { - throw new TypeError('Object containing Nodes expected'); - } - } - } - - ObjectNode.prototype = new Node(); - - ObjectNode.prototype.type = 'ObjectNode'; - - ObjectNode.prototype.isObjectNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} code - * @private - */ - ObjectNode.prototype._compile = function (defs, args) { - var entries = []; - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - entries.push('"' + key + '": ' + this.properties[key]._compile(defs, args)); - } - } - return '{' + entries.join(', ') + '}'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ObjectNode.prototype.forEach = function (callback) { - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - callback(this.properties[key], 'properties["' + key + '"]', this); - } - } - }; - - /** - * Create a new ObjectNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {ObjectNode} Returns a transformed copy of the node - */ - ObjectNode.prototype.map = function (callback) { - var properties = {}; - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - properties[key] = this._ifNode(callback(this.properties[key], 'properties["' + key + '"]', this)); - } - } - return new ObjectNode(properties); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ObjectNode} - */ - ObjectNode.prototype.clone = function() { - var properties = {}; - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - properties[key] = this.properties[key]; - } - } - return new ObjectNode(properties); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - * @override - */ - ObjectNode.prototype._toString = function(options) { - var entries = []; - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - entries.push('"' + key + '": ' + this.properties[key].toString(options)); - } - } - return '{' + entries.join(', ') + '}'; - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - ObjectNode.prototype._toTex = function(options) { - var entries = []; - for (var key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - entries.push("\\mathbf{" + key + ':} & ' + this.properties[key].toTex(options) + "\\\\"); - } - } - return '\\left\\{\\begin{array}{ll}' + entries.join('\n') + '\\end{array}\\right\\}'; - }; - - return ObjectNode; - } - - exports.name = 'ObjectNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 289 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var latex = __webpack_require__(32); - var operators = __webpack_require__(280); - - function factory (type, config, load, typed, math) { - var Node = load(__webpack_require__(272)); - var ConstantNode = load(__webpack_require__(283)); - var SymbolNode = load(__webpack_require__(287)); - var FunctionNode = load(__webpack_require__(290)); - - /** - * @constructor OperatorNode - * @extends {Node} - * An operator with two arguments, like 2+3 - * - * @param {string} op Operator name, for example '+' - * @param {string} fn Function name, for example 'add' - * @param {Node[]} args Operator arguments - * @param {boolean} [implicit] Is this an implicit multiplication? - */ - function OperatorNode(op, fn, args, implicit) { - if (!(this instanceof OperatorNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - //validate input - if (typeof op !== 'string') { - throw new TypeError('string expected for parameter "op"'); - } - if (typeof fn !== 'string') { - throw new TypeError('string expected for parameter "fn"'); - } - if (!Array.isArray(args) - || !args.every(function (node) {return node && node.isNode;})) { - throw new TypeError('Array containing Nodes expected for parameter "args"'); - } - - this.implicit = (implicit === true); - this.op = op; - this.fn = fn; - this.args = args || []; - } - - OperatorNode.prototype = new Node(); - - OperatorNode.prototype.type = 'OperatorNode'; - - OperatorNode.prototype.isOperatorNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - OperatorNode.prototype._compile = function (defs, args) { - if (!defs.math[this.fn]) { - throw new Error('Function ' + this.fn + ' missing in provided namespace "math"'); - } - - var jsArgs = this.args.map(function (arg) { - return arg._compile(defs, args); - }); - - return 'math.' + this.fn + '(' + jsArgs.join(', ') + ')'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - OperatorNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.args.length; i++) { - callback(this.args[i], 'args[' + i + ']', this); - } - }; - - /** - * Create a new OperatorNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {OperatorNode} Returns a transformed copy of the node - */ - OperatorNode.prototype.map = function (callback) { - var args = []; - for (var i = 0; i < this.args.length; i++) { - args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); - } - return new OperatorNode(this.op, this.fn, args); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {OperatorNode} - */ - OperatorNode.prototype.clone = function () { - return new OperatorNode(this.op, this.fn, this.args.slice(0)); - }; - - /** - * Calculate which parentheses are necessary. Gets an OperatorNode - * (which is the root of the tree) and an Array of Nodes - * (this.args) and returns an array where 'true' means that an argument - * has to be enclosed in parentheses whereas 'false' means the opposite. - * - * @param {OperatorNode} root - * @param {string} parenthesis - * @param {Node[]} args - * @param {boolean} latex - * @return {boolean[]} - * @private - */ - function calculateNecessaryParentheses(root, parenthesis, args, latex) { - //precedence of the root OperatorNode - var precedence = operators.getPrecedence(root, parenthesis); - var associativity = operators.getAssociativity(root, parenthesis); - - if ((parenthesis === 'all') || (args.length > 2)) { - var parens = []; - args.forEach(function (arg) { - switch (arg.getContent().type) { //Nodes that don't need extra parentheses - case 'ArrayNode': - case 'ConstantNode': - case 'SymbolNode': - case 'ParenthesisNode': - parens.push(false); - break; - default: - parens.push(true); - } - }); - return parens; - } - - switch (args.length) { - case 0: - return []; - case 1: //unary operators - //precedence of the operand - var operandPrecedence = operators.getPrecedence(args[0], parenthesis); - - //handle special cases for LaTeX, where some of the parentheses aren't needed - if (latex && (operandPrecedence !== null)) { - var operandIdentifier; - var rootIdentifier; - if (parenthesis === 'keep') { - operandIdentifier = args[0].getIdentifier(); - rootIdentifier = root.getIdentifier(); - } - else { - //Ignore Parenthesis Nodes when not in 'keep' mode - operandIdentifier = args[0].getContent().getIdentifier(); - rootIdentifier = root.getContent().getIdentifier(); - } - if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { - return [false]; - } - - if (operators.properties[operandPrecedence][operandIdentifier].latexParens === false) { - return [false]; - } - } - - if (operandPrecedence === null) { - //if the operand has no defined precedence, no parens are needed - return [false]; - } - - if (operandPrecedence <= precedence) { - //if the operands precedence is lower, parens are needed - return [true]; - } - - //otherwise, no parens needed - return [false]; - - case 2: //binary operators - var lhsParens; //left hand side needs parenthesis? - //precedence of the left hand side - var lhsPrecedence = operators.getPrecedence(args[0], parenthesis); - //is the root node associative with the left hand side - var assocWithLhs = operators.isAssociativeWith(root, args[0], parenthesis); - - if (lhsPrecedence === null) { - //if the left hand side has no defined precedence, no parens are needed - //FunctionNode for example - lhsParens = false; - } - else if ((lhsPrecedence === precedence) && (associativity === 'right') && !assocWithLhs) { - //In case of equal precedence, if the root node is left associative - // parens are **never** necessary for the left hand side. - //If it is right associative however, parens are necessary - //if the root node isn't associative with the left hand side - lhsParens = true; - } - else if (lhsPrecedence < precedence) { - lhsParens = true; - } - else { - lhsParens = false; - } - - var rhsParens; //right hand side needs parenthesis? - //precedence of the right hand side - var rhsPrecedence = operators.getPrecedence(args[1], parenthesis); - //is the root node associative with the right hand side? - var assocWithRhs = operators.isAssociativeWith(root, args[1], parenthesis); - - if (rhsPrecedence === null) { - //if the right hand side has no defined precedence, no parens are needed - //FunctionNode for example - rhsParens = false; - } - else if ((rhsPrecedence === precedence) && (associativity === 'left') && !assocWithRhs) { - //In case of equal precedence, if the root node is right associative - // parens are **never** necessary for the right hand side. - //If it is left associative however, parens are necessary - //if the root node isn't associative with the right hand side - rhsParens = true; - } - else if (rhsPrecedence < precedence) { - rhsParens = true; - } - else { - rhsParens = false; - } - - //handle special cases for LaTeX, where some of the parentheses aren't needed - if (latex) { - var rootIdentifier; - var lhsIdentifier; - var rhsIdentifier; - if (parenthesis === 'keep') { - rootIdentifier = root.getIdentifier(); - lhsIdentifier = root.args[0].getIdentifier(); - rhsIdentifier = root.args[1].getIdentifier(); - } - else { - //Ignore ParenthesisNodes when not in 'keep' mode - rootIdentifier = root.getContent().getIdentifier(); - lhsIdentifier = root.args[0].getContent().getIdentifier(); - rhsIdentifier = root.args[1].getContent().getIdentifier(); - } - - if (lhsPrecedence !== null) { - if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { - lhsParens = false; - } - - if (operators.properties[lhsPrecedence][lhsIdentifier].latexParens === false) { - lhsParens = false; - } - } - - if (rhsPrecedence !== null) { - if (operators.properties[precedence][rootIdentifier].latexRightParens === false) { - rhsParens = false; - } - - if (operators.properties[rhsPrecedence][rhsIdentifier].latexParens === false) { - rhsParens = false; - } - } - } - - return [lhsParens, rhsParens]; - } - } - - /** - * Get string representation. - * @param {Object} options - * @return {string} str - */ - OperatorNode.prototype._toString = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var implicit = (options && options.implicit) ? options.implicit : 'hide'; - var args = this.args; - var parens = calculateNecessaryParentheses(this, parenthesis, args, false); - - switch (args.length) { - case 1: //unary operators - var assoc = operators.getAssociativity(this, parenthesis); - - var operand = args[0].toString(options); - if (parens[0]) { - operand = '(' + operand + ')'; - } - - if (assoc === 'right') { //prefix operator - return this.op + operand; - } - else if (assoc === 'left') { //postfix - return operand + this.op; - } - - //fall back to postfix - return operand + this.op; - - case 2: - var lhs = args[0].toString(options); //left hand side - var rhs = args[1].toString(options); //right hand side - if (parens[0]) { //left hand side in parenthesis? - lhs = '(' + lhs + ')'; - } - if (parens[1]) { //right hand side in parenthesis? - rhs = '(' + rhs + ')'; - } - - if (this.implicit && (this.getIdentifier() === 'OperatorNode:multiply') && (implicit == 'hide')) { - return lhs + ' ' + rhs; - } - - return lhs + ' ' + this.op + ' ' + rhs; - - default: - //fallback to formatting as a function call - return this.fn + '(' + this.args.join(', ') + ')'; - } - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - OperatorNode.prototype._toTex = function (options) { - var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; - var implicit = (options && options.implicit) ? options.implicit : 'hide'; - var args = this.args; - var parens = calculateNecessaryParentheses(this, parenthesis, args, true); - var op = latex.operators[this.fn]; - op = typeof op === 'undefined' ? this.op : op; //fall back to using this.op - - switch (args.length) { - case 1: //unary operators - var assoc = operators.getAssociativity(this, parenthesis); - - var operand = args[0].toTex(options); - if (parens[0]) { - operand = '\\left(' + operand + '\\right)'; - } - - if (assoc === 'right') { //prefix operator - return op + operand; - } - else if (assoc === 'left') { //postfix operator - return operand + op; - } - - //fall back to postfix - return operand + op; - - case 2: //binary operators - var lhs = args[0]; //left hand side - var lhsTex = lhs.toTex(options); - if (parens[0]) { - lhsTex = '\\left(' + lhsTex + '\\right)'; - } - - var rhs = args[1]; //right hand side - var rhsTex = rhs.toTex(options); - if (parens[1]) { - rhsTex = '\\left(' + rhsTex + '\\right)'; - } - - //handle some exceptions (due to the way LaTeX works) - var lhsIdentifier; - if (parenthesis === 'keep') { - lhsIdentifier = lhs.getIdentifier(); - } - else { - //Ignore ParenthesisNodes if in 'keep' mode - lhsIdentifier = lhs.getContent().getIdentifier(); - } - switch (this.getIdentifier()) { - case 'OperatorNode:divide': - //op contains '\\frac' at this point - return op + '{' + lhsTex + '}' + '{' + rhsTex + '}'; - case 'OperatorNode:pow': - lhsTex = '{' + lhsTex + '}'; - rhsTex = '{' + rhsTex + '}'; - switch (lhsIdentifier) { - case 'ConditionalNode': // - case 'OperatorNode:divide': - lhsTex = '\\left(' + lhsTex + '\\right)'; - } - case 'OperatorNode:multiply': - if (this.implicit && (implicit === 'hide')) { - return lhsTex + '~' + rhsTex; - } - } - return lhsTex + op + rhsTex; - - default: - //fall back to formatting as a function call - //as this is a fallback, it doesn't use - //fancy function names - return '\\mathrm{' + this.fn + '}\\left(' - + args.map(function (arg) { - return arg.toTex(options); - }).join(',') + '\\right)'; - } - }; - - /** - * Get identifier. - * @return {string} - */ - OperatorNode.prototype.getIdentifier = function () { - return this.type + ':' + this.fn; - }; - - return OperatorNode; - } - - exports.name = 'OperatorNode'; - exports.path = 'expression.node'; - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.factory = factory; - - -/***/ }, -/* 290 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var latex = __webpack_require__(32); - - function factory (type, config, load, typed, math) { - var Node = load(__webpack_require__(272)); - var SymbolNode = load(__webpack_require__(287)); - - /** - * @constructor FunctionNode - * @extends {./Node} - * invoke a list with arguments on a node - * @param {./Node} fn Node resolving with a function on which to invoke - * the arguments, typically a SymboNode or AccessorNode - * @param {./Node[]} args - */ - function FunctionNode(fn, args) { - if (!(this instanceof FunctionNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // TODO deprecated since v3.0, cleanup some day - if (typeof fn === 'string') { - console.warn('WARNING: passing a string to FunctionNode is deprecated, pass a SymbolNode instead.'); - fn = new SymbolNode(fn); - } - - // validate input - if (!fn || !fn.isNode) throw new TypeError('Node expected as parameter "fn"'); - if (!Array.isArray(args) - || !args.every(function (arg) {return arg && arg.isNode;})) { - throw new TypeError('Array containing Nodes expected for parameter "args"'); - } - - this.fn = fn; - this.args = args || []; - - // readonly property name - Object.defineProperty(this, 'name', { - get: function () { - return this.fn.name || ''; - }.bind(this), - set: function () { - throw new Error('Cannot assign a new name, name is read-only'); - } - }); - - // TODO: deprecated since v3, remove some day - var deprecated = function () { - throw new Error('Property `FunctionNode.object` is deprecated, use `FunctionNode.fn` instead'); - }; - Object.defineProperty(this, 'object', { get: deprecated, set: deprecated }); - } - - FunctionNode.prototype = new Node(); - - FunctionNode.prototype.type = 'FunctionNode'; - - FunctionNode.prototype.isFunctionNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - FunctionNode.prototype._compile = function (defs, args) { - // compile fn and arguments - var jsFn = this.fn._compile(defs, args); - var jsArgs = this.args.map(function (arg) { - return arg._compile(defs, args); - }); - var argsName; - - if (this.fn.isSymbolNode) { - // we can statically determine whether the function has an rawArgs property - var name = this.fn.name; - var fn = defs.math[name]; - var isRaw = (typeof fn === 'function') && (fn.rawArgs == true); - - if (isRaw) { - // pass unevaluated parameters (nodes) to the function - argsName = this._getUniqueArgumentsName(defs); - defs[argsName] = this.args; - - return jsFn + '(' + argsName + ', math, scope)'; - } - else { - // "regular" evaluation - return jsFn + '(' + jsArgs.join(', ') + ')'; - } - } - else if (this.fn.isAccessorNode && this.fn.index.isObjectProperty()) { - // execute the function with the right context: the object of the AccessorNode - argsName = this._getUniqueArgumentsName(defs); - defs[argsName] = this.args; - - var jsObject = this.fn.object._compile(defs, args); - var prop = this.fn.index.getObjectProperty(); - - return '(function () {' + - 'var object = ' + jsObject + ';' + - 'return (object["' + prop + '"] && object["' + prop + '"].rawArgs) ' + - ' ? object["' + prop + '"](' + argsName + ', math, scope)' + - ' : object["' + prop + '"](' + jsArgs.join(', ') + ')' + - '})()'; - } - else { // this.fn.isAccessorNode && !this.fn.index.isObjectProperty() - // we have to dynamically determine whether the function has a rawArgs property - argsName = this._getUniqueArgumentsName(defs); - defs[argsName] = this.args; - - return '(function () {' + - 'var fn = ' + jsFn + ';' + - 'return (fn && fn.rawArgs) ' + - ' ? fn(' + argsName + ', math, scope)' + - ' : fn(' + jsArgs.join(', ') + ')' + - '})()'; - } - }; - - /** - * Get a unique name for a arguments to store in defs - * @param {Object} defs - * @return {string} A string like 'args1', 'args2', ... - * @private - */ - FunctionNode.prototype._getUniqueArgumentsName = function (defs) { - var argsName; - var i = 0; - - do { - argsName = 'args' + i; - i++; - } - while (argsName in defs); - - return argsName; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - FunctionNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.args.length; i++) { - callback(this.args[i], 'args[' + i + ']', this); - } - }; - - /** - * Create a new FunctionNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {FunctionNode} Returns a transformed copy of the node - */ - FunctionNode.prototype.map = function (callback) { - var fn = this.fn.map(callback); - var args = []; - for (var i = 0; i < this.args.length; i++) { - args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); - } - return new FunctionNode(fn, args); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {FunctionNode} - */ - FunctionNode.prototype.clone = function () { - return new FunctionNode(this.fn, this.args.slice(0)); - }; - - //backup Node's toString function - //@private - var nodeToString = FunctionNode.prototype.toString; - - /** - * Get string representation. (wrapper function) - * This overrides parts of Node's toString function. - * If callback is an object containing callbacks, it - * calls the correct callback for the current node, - * otherwise it falls back to calling Node's toString - * function. - * - * @param {Object} options - * @return {string} str - * @override - */ - FunctionNode.prototype.toString = function (options) { - var customString; - var name = this.fn.toString(options); - if (options && (typeof options.handler === 'object') && options.handler.hasOwnProperty(name)) { - //callback is a map of callback functions - customString = options.handler[name](this, options); - } - - if (typeof customString !== 'undefined') { - return customString; - } - - //fall back to Node's toString - return nodeToString.call(this, options); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - */ - FunctionNode.prototype._toString = function (options) { - var args = this.args.map(function (arg) { - return arg.toString(options); - }); - - // format the arguments like "add(2, 4.2)" - return this.fn.toString(options) + '(' + args.join(', ') + ')'; - }; - - /* - * Expand a LaTeX template - * - * @param {string} template - * @param {Node} node - * @param {Object} options - * @private - **/ - function expandTemplate(template, node, options) { - var latex = ''; - - // Match everything of the form ${identifier} or ${identifier[2]} or $$ - // while submatching identifier and 2 (in the second case) - var regex = new RegExp('\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)', 'ig'); - - var inputPos = 0; //position in the input string - var match; - while ((match = regex.exec(template)) !== null) { //go through all matches - // add everything in front of the match to the LaTeX string - latex += template.substring(inputPos, match.index); - inputPos = match.index; - - if (match[0] === '$$') { // escaped dollar sign - latex += '$'; - inputPos++; - } - else { // template parameter - inputPos += match[0].length; - var property = node[match[1]]; - if (!property) { - throw new ReferenceError('Template: Property ' + match[1] + ' does not exist.'); - } - if (match[2] === undefined) { //no square brackets - switch (typeof property) { - case 'string': - latex += property; - break; - case 'object': - if (property.isNode) { - latex += property.toTex(options); - } - else if (Array.isArray(property)) { - //make array of Nodes into comma separated list - latex += property.map(function (arg, index) { - if (arg && arg.isNode) { - return arg.toTex(options); - } - throw new TypeError('Template: ' + match[1] + '[' + index + '] is not a Node.'); - }).join(','); - } - else { - throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes'); - } - break; - default: - throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes'); - } - } - else { //with square brackets - if (property[match[2]] && property[match[2]].isNode) { - latex += property[match[2]].toTex(options); - } - else { - throw new TypeError('Template: ' + match[1] + '[' + match[2] + '] is not a Node.'); - } - } - } - } - latex += template.slice(inputPos); //append rest of the template - - return latex; - } - - //backup Node's toTex function - //@private - var nodeToTex = FunctionNode.prototype.toTex; - - /** - * Get LaTeX representation. (wrapper function) - * This overrides parts of Node's toTex function. - * If callback is an object containing callbacks, it - * calls the correct callback for the current node, - * otherwise it falls back to calling Node's toTex - * function. - * - * @param {Object} options - * @return {string} - */ - FunctionNode.prototype.toTex = function (options) { - var customTex; - if (options && (typeof options.handler === 'object') && options.handler.hasOwnProperty(this.name)) { - //callback is a map of callback functions - customTex = options.handler[this.name](this, options); - } - - if (typeof customTex !== 'undefined') { - return customTex; - } - - //fall back to Node's toTex - return nodeToTex.call(this, options); - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - */ - FunctionNode.prototype._toTex = function (options) { - var args = this.args.map(function (arg) { //get LaTeX of the arguments - return arg.toTex(options); - }); - - var latexConverter; - - if (math[this.name] && ((typeof math[this.name].toTex === 'function') || (typeof math[this.name].toTex === 'object') || (typeof math[this.name].toTex === 'string'))) { - //.toTex is a callback function - latexConverter = math[this.name].toTex; - } - - var customToTex; - switch (typeof latexConverter) { - case 'function': //a callback function - customToTex = latexConverter(this, options); - break; - case 'string': //a template string - customToTex = expandTemplate(latexConverter, this, options); - break; - case 'object': //an object with different "converters" for different numbers of arguments - switch (typeof latexConverter[args.length]) { - case 'function': - customToTex = latexConverter[args.length](this, options); - break; - case 'string': - customToTex = expandTemplate(latexConverter[args.length], this, options); - break; - } - } - - if (typeof customToTex !== 'undefined') { - return customToTex; - } - - return expandTemplate(latex.defaultTemplate, this, options); - }; - - /** - * Get identifier. - * @return {string} - */ - FunctionNode.prototype.getIdentifier = function () { - return this.type + ':' + this.name; - }; - - return FunctionNode; - } - - exports.name = 'FunctionNode'; - exports.path = 'expression.node'; - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.factory = factory; - - -/***/ }, -/* 291 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var Node = load(__webpack_require__(272)); - - /** - * @constructor ParenthesisNode - * @extends {Node} - * A parenthesis node describes manual parenthesis from the user input - * @param {Node} content - * @extends {Node} - */ - function ParenthesisNode(content) { - if (!(this instanceof ParenthesisNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (!(content && content.isNode)) { - throw new TypeError('Node expected for parameter "content"'); - } - - this.content = content; - } - - ParenthesisNode.prototype = new Node(); - - ParenthesisNode.prototype.type = 'ParenthesisNode'; - - ParenthesisNode.prototype.isParenthesisNode = true; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @param {Object} args Object with local function arguments, the key is - * the name of the argument, and the value is `true`. - * The object may not be mutated, but must be - * extended instead. - * @return {string} js - * @private - */ - ParenthesisNode.prototype._compile = function (defs, args) { - return this.content._compile(defs, args); - }; - - /** - * Get the content of the current Node. - * @return {Node} content - * @override - **/ - ParenthesisNode.prototype.getContent = function () { - return this.content.getContent(); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ParenthesisNode.prototype.forEach = function (callback) { - callback(this.content, 'content', this); - }; - - /** - * Create a new ParenthesisNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node) : Node} callback - * @returns {ParenthesisNode} Returns a clone of the node - */ - ParenthesisNode.prototype.map = function (callback) { - var content = callback(this.content, 'content', this); - return new ParenthesisNode(content); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ParenthesisNode} - */ - ParenthesisNode.prototype.clone = function() { - return new ParenthesisNode(this.content); - }; - - /** - * Get string representation - * @param {Object} options - * @return {string} str - * @override - */ - ParenthesisNode.prototype._toString = function(options) { - if ((!options) || (options && !options.parenthesis) || (options && options.parenthesis === 'keep')) { - return '(' + this.content.toString(options) + ')'; - } - return this.content.toString(options); - }; - - /** - * Get LaTeX representation - * @param {Object} options - * @return {string} str - * @override - */ - ParenthesisNode.prototype._toTex = function(options) { - if ((!options) || (options && !options.parenthesis) || (options && options.parenthesis === 'keep')) { - return '\\left(' + this.content.toTex(options) + '\\right)'; - } - return this.content.toTex(options); - }; - - return ParenthesisNode; - } - - exports.name = 'ParenthesisNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 292 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var parse = load(__webpack_require__(270)); - - /** - * Evaluate an expression. - * - * Syntax: - * - * math.eval(expr) - * math.eval(expr, scope) - * math.eval([expr1, expr2, expr3, ...]) - * math.eval([expr1, expr2, expr3, ...], scope) - * - * Example: - * - * math.eval('(2+3)/4'); // 1.25 - * math.eval('sqrt(3^2 + 4^2)'); // 5 - * math.eval('sqrt(-4)'); // 2i - * math.eval(['a=3', 'b=4', 'a*b']);, // [3, 4, 12] - * - * var scope = {a:3, b:4}; - * math.eval('a * b', scope); // 12 - * - * See also: - * - * parse, compile - * - * @param {string | string[] | Matrix} expr The expression to be evaluated - * @param {Object} [scope] Scope to read/write variables - * @return {*} The result of the expression - * @throws {Error} - */ - return typed('compile', { - 'string': function (expr) { - var scope = {}; - return parse(expr).compile().eval(scope); - }, - - 'string, Object': function (expr, scope) { - return parse(expr).compile().eval(scope); - }, - - 'Array | Matrix': function (expr) { - var scope = {}; - return deepMap(expr, function (entry) { - return parse(entry).compile().eval(scope); - }); - }, - - 'Array | Matrix, Object': function (expr, scope) { - return deepMap(expr, function (entry) { - return parse(entry).compile().eval(scope); - }); - } - }); - } - - exports.name = 'eval'; - exports.factory = factory; - -/***/ }, -/* 293 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var docs = load(__webpack_require__(96)); - - /** - * Retrieve help on a function or data type. - * Help files are retrieved from the documentation in math.expression.docs. - * - * Syntax: - * - * math.help(search) - * - * Examples: - * - * console.log(math.help('sin').toString()); - * console.log(math.help(math.add).toString()); - * console.log(math.help(math.add).toJSON()); - * - * @param {Function | string | Object} search A function or function name - * for which to get help - * @return {Help} A help object - */ - return typed('help', { - 'any': function (search) { - var prop; - var name = search; - - if (typeof search !== 'string') { - for (prop in math) { - // search in functions and constants - if (math.hasOwnProperty(prop) && (search === math[prop])) { - name = prop; - break; - } - } - - /* TODO: implement help for data types - if (!text) { - // search data type - for (prop in math.type) { - if (math.type.hasOwnProperty(prop)) { - if (search === math.type[prop]) { - text = prop; - break; - } - } - } - } - */ - } - - var doc = docs[name]; - if (!doc) { - throw new Error('No documentation found on "' + name + '"'); - } - return new type.Help(doc); - } - }); - } - - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.name = 'help'; - exports.factory = factory; - - -/***/ }, -/* 294 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var parse = load(__webpack_require__(270)); - - /** - * Parse an expression. Returns a node tree, which can be evaluated by - * invoking node.eval(); - * - * Syntax: - * - * math.parse(expr) - * math.parse(expr, options) - * math.parse([expr1, expr2, expr3, ...]) - * math.parse([expr1, expr2, expr3, ...], options) - * - * Example: - * - * var node = math.parse('sqrt(3^2 + 4^2)'); - * node.compile().eval(); // 5 - * - * var scope = {a:3, b:4} - * var node = math.parse('a * b'); // 12 - * var code = node.compile(); - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); - * nodes[2].compile().eval(); // 12 - * - * See also: - * - * eval, compile - * - * @param {string | string[] | Matrix} expr Expression to be parsed - * @param {{nodes: Object}} [options] Available options: - * - `nodes` a set of custom nodes - * @return {Node | Node[]} node - * @throws {Error} - */ - return typed('parse', { - 'string | Array | Matrix': parse, - 'string | Array | Matrix, Object': parse - }); - } - - exports.name = 'parse'; - exports.factory = factory; - - -/***/ }, -/* 295 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var Parser = load(__webpack_require__(296)); - - /** - * Create a parser. The function creates a new `math.expression.Parser` object. - * - * Syntax: - * - * math.parser() - * - * Examples: - * - * var parser = new math.parser(); - * - * // evaluate expressions - * var a = parser.eval('sqrt(3^2 + 4^2)'); // 5 - * var b = parser.eval('sqrt(-4)'); // 2i - * var c = parser.eval('2 inch in cm'); // 5.08 cm - * var d = parser.eval('cos(45 deg)'); // 0.7071067811865476 - * - * // define variables and functions - * parser.eval('x = 7 / 2'); // 3.5 - * parser.eval('x + 3'); // 6.5 - * parser.eval('function f(x, y) = x^y'); // f(x, y) - * parser.eval('f(2, 3)'); // 8 - * - * // get and set variables and functions - * var x = parser.get('x'); // 7 - * var f = parser.get('f'); // function - * var g = f(3, 2); // 9 - * parser.set('h', 500); - * var i = parser.eval('h / 2'); // 250 - * parser.set('hello', function (name) { - * return 'hello, ' + name + '!'; - * }); - * parser.eval('hello("user")'); // "hello, user!" - * - * // clear defined functions and variables - * parser.clear(); - * - * See also: - * - * eval, compile, parse - * - * @return {Parser} Parser - */ - return typed('parser', { - '': function () { - return new Parser(math); - } - }); - } - - exports.name = 'parser'; - exports.factory = factory; - exports.math = true; // requires the math namespace as 5th argument - - -/***/ }, -/* 296 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var extend = __webpack_require__(3).extend; - - function factory (type, config, load, typed, math) { - var _parse = load(__webpack_require__(270)); - - /** - * @constructor Parser - * Parser contains methods to evaluate or parse expressions, and has a number - * of convenience methods to get, set, and remove variables from memory. Parser - * keeps a scope containing variables in memory, which is used for all - * evaluations. - * - * Methods: - * var result = parser.eval(expr); // evaluate an expression - * var value = parser.get(name); // retrieve a variable from the parser - * var values = parser.getAll(); // retrieve all defined variables - * parser.set(name, value); // set a variable in the parser - * parser.remove(name); // clear a variable from the - * // parsers scope - * parser.clear(); // clear the parsers scope - * - * Example usage: - * var parser = new Parser(); - * // Note: there is a convenience method which can be used instead: - * // var parser = new math.parser(); - * - * // evaluate expressions - * parser.eval('sqrt(3^2 + 4^2)'); // 5 - * parser.eval('sqrt(-4)'); // 2i - * parser.eval('2 inch in cm'); // 5.08 cm - * parser.eval('cos(45 deg)'); // 0.7071067811865476 - * - * // define variables and functions - * parser.eval('x = 7 / 2'); // 3.5 - * parser.eval('x + 3'); // 6.5 - * parser.eval('function f(x, y) = x^y'); // f(x, y) - * parser.eval('f(2, 3)'); // 8 - * - * // get and set variables and functions - * var x = parser.get('x'); // 7 - * var f = parser.get('f'); // function - * var g = f(3, 2); // 9 - * parser.set('h', 500); - * var i = parser.eval('h / 2'); // 250 - * parser.set('hello', function (name) { - * return 'hello, ' + name + '!'; - * }); - * parser.eval('hello("user")'); // "hello, user!" - * - * // clear defined functions and variables - * parser.clear(); - * - */ - function Parser() { - if (!(this instanceof Parser)) { - throw new SyntaxError( - 'Constructor must be called with the new operator'); - } - this.scope = {}; - } - - /** - * Attach type information - */ - Parser.prototype.type = 'Parser'; - Parser.prototype.isParser = true; - - /** - * Parse an expression and return the parsed function node. - * The node tree can be compiled via `code = node.compile(math)`, - * and the compiled code can be executed as `code.eval([scope])` - * @param {string} expr - * @return {Node} node - * @throws {Error} - */ - Parser.prototype.parse = function (expr) { - throw new Error('Parser.parse is deprecated. Use math.parse instead.'); - }; - - /** - * Parse and compile an expression, return the compiled javascript code. - * The node can be evaluated via code.eval([scope]) - * @param {string} expr - * @return {{eval: function}} code - * @throws {Error} - */ - Parser.prototype.compile = function (expr) { - throw new Error('Parser.compile is deprecated. Use math.compile instead.'); - }; - - /** - * Parse and evaluate the given expression - * @param {string} expr A string containing an expression, for example "2+3" - * @return {*} result The result, or undefined when the expression was empty - * @throws {Error} - */ - Parser.prototype.eval = function (expr) { - // TODO: validate arguments - return _parse(expr) - .compile() - .eval(this.scope); - }; - - /** - * Get a variable (a function or variable) by name from the parsers scope. - * Returns undefined when not found - * @param {string} name - * @return {* | undefined} value - */ - Parser.prototype.get = function (name) { - // TODO: validate arguments - return this.scope[name]; - }; - - /** - * Get a map with all defined variables - * @return {Object} values - */ - Parser.prototype.getAll = function () { - return extend({}, this.scope); - }; - - /** - * Set a symbol (a function or variable) by name from the parsers scope. - * @param {string} name - * @param {* | undefined} value - */ - Parser.prototype.set = function (name, value) { - // TODO: validate arguments - return this.scope[name] = value; - }; - - /** - * Remove a variable from the parsers scope - * @param {string} name - */ - Parser.prototype.remove = function (name) { - // TODO: validate arguments - delete this.scope[name]; - }; - - /** - * Clear the scope with variables and functions - */ - Parser.prototype.clear = function () { - for (var name in this.scope) { - if (this.scope.hasOwnProperty(name)) { - delete this.scope[name]; - } - } - }; - - return Parser; - } - - exports.name = 'Parser'; - exports.path = 'expression'; - exports.factory = factory; - exports.math = true; // requires the math namespace as 5th argument - - -/***/ }, -/* 297 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(271), - __webpack_require__(277), - __webpack_require__(278), - __webpack_require__(281), - __webpack_require__(282), - __webpack_require__(283), - __webpack_require__(285), - __webpack_require__(284), - __webpack_require__(290), - __webpack_require__(272), - __webpack_require__(288), - __webpack_require__(289), - __webpack_require__(291), - __webpack_require__(286), - __webpack_require__(287), - __webpack_require__(298) - ]; - - -/***/ }, -/* 298 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * @constructor UpdateNode - */ - function UpdateNode() { - // TODO: deprecated since v3. Cleanup some day - throw new Error('UpdateNode is deprecated. Use AssignmentNode instead.'); - } - - return UpdateNode; - } - - exports.name = 'UpdateNode'; - exports.path = 'expression.node'; - exports.factory = factory; - - -/***/ }, -/* 299 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(300), - __webpack_require__(302), - __webpack_require__(304), - __webpack_require__(306), - __webpack_require__(307), - __webpack_require__(309), - __webpack_require__(315), - __webpack_require__(320), - __webpack_require__(322), - __webpack_require__(324) - ]; - - -/***/ }, -/* 300 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var errorTransform = __webpack_require__(275).transform; - - /** - * Attach a transform function to math.range - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function concat - * from one-based to zero based - */ - function factory (type, config, load, typed) { - var concat = load(__webpack_require__(301)); - - // @see: comment of concat itself - return typed('concat', { - '...any': function (args) { - // change last argument from one-based to zero-based - var lastIndex = args.length - 1; - var last = args[lastIndex]; - if (typeof last === 'number') { - args[lastIndex] = last - 1; - } - else if (last && last.isBigNumber === true) { - args[lastIndex] = last.minus(1); - } - - try { - return concat.apply(null, args); - } - catch (err) { - throw errorTransform(err); - } - } - }); - } - - exports.name = 'concat'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 301 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var isInteger = __webpack_require__(6).isInteger; - var array = __webpack_require__(40); - var IndexError = __webpack_require__(43); - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Concatenate two or more matrices. - * - * Syntax: - * - * math.concat(A, B, C, ...) - * math.concat(A, B, C, ..., dim) - * - * Where: - * - * - `dim: number` is a zero-based dimension over which to concatenate the matrices. - * By default the last dimension of the matrices. - * - * Examples: - * - * var A = [[1, 2], [5, 6]]; - * var B = [[3, 4], [7, 8]]; - * - * math.concat(A, B); // returns [[1, 2, 3, 4], [5, 6, 7, 8]] - * math.concat(A, B, 0); // returns [[1, 2], [5, 6], [3, 4], [7, 8]] - * math.concat('hello', ' ', 'world'); // returns 'hello world' - * - * See also: - * - * size, squeeze, subset, transpose - * - * @param {... Array | Matrix} args Two or more matrices - * @return {Array | Matrix} Concatenated matrix - */ - var concat = typed('concat', { - // TODO: change signature to '...Array | Matrix, dim?' when supported - '...Array | Matrix | number | BigNumber': function (args) { - var i; - var len = args.length; - var dim = -1; // zero-based dimension - var prevDim; - var asMatrix = false; - var matrices = []; // contains multi dimensional arrays - - for (i = 0; i < len; i++) { - var arg = args[i]; - - // test whether we need to return a Matrix (if not we return an Array) - if (arg && arg.isMatrix === true) { - asMatrix = true; - } - - if (typeof arg === 'number' || (arg && arg.isBigNumber === true)) { - if (i !== len - 1) { - throw new Error('Dimension must be specified as last argument'); - } - - // last argument contains the dimension on which to concatenate - prevDim = dim; - dim = arg.valueOf(); // change BigNumber to number - - if (!isInteger(dim)) { - throw new TypeError('Integer number expected for dimension'); - } - - if (dim < 0 || (i > 0 && dim > prevDim)) { - // TODO: would be more clear when throwing a DimensionError here - throw new IndexError(dim, prevDim + 1); - } - } - else { - // this is a matrix or array - var m = clone(arg).valueOf(); - var size = array.size(m); - matrices[i] = m; - prevDim = dim; - dim = size.length - 1; - - // verify whether each of the matrices has the same number of dimensions - if (i > 0 && dim != prevDim) { - throw new DimensionError(prevDim + 1, dim + 1); - } - } - } - - if (matrices.length == 0) { - throw new SyntaxError('At least one matrix expected'); - } - - var res = matrices.shift(); - while (matrices.length) { - res = _concat(res, matrices.shift(), dim, 0); - } - - return asMatrix ? matrix(res) : res; - }, - - '...string': function (args) { - return args.join(''); - } - }); - - concat.toTex = undefined; // use default template - - return concat; - } - - /** - * Recursively concatenate two matrices. - * The contents of the matrices is not cloned. - * @param {Array} a Multi dimensional array - * @param {Array} b Multi dimensional array - * @param {number} concatDim The dimension on which to concatenate (zero-based) - * @param {number} dim The current dim (zero-based) - * @return {Array} c The concatenated matrix - * @private - */ - function _concat(a, b, concatDim, dim) { - if (dim < concatDim) { - // recurse into next dimension - if (a.length != b.length) { - throw new DimensionError(a.length, b.length); - } - - var c = []; - for (var i = 0; i < a.length; i++) { - c[i] = _concat(a[i], b[i], concatDim, dim + 1); - } - return c; - } - else { - // concatenate this dimension - return a.concat(b); - } - } - - exports.name = 'concat'; - exports.factory = factory; - - -/***/ }, -/* 302 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /** - * Attach a transform function to math.filter - * Adds a property transform containing the transform function. - * - * This transform adds support for equations as test function for math.filter, - * so you can do something like 'filter([3, -2, 5], x > 0)'. - */ - function factory (type, config, load, typed) { - var filter = load(__webpack_require__(303)); - var SymbolNode = load(__webpack_require__(287)); - - function filterTransform(args, math, scope) { - var x, test; - - if (args[0]) { - x = args[0].compile().eval(scope); - } - - if (args[1]) { - if (args[1] && args[1].isSymbolNode) { - // a function pointer, like filter([3, -2, 5], myTestFunction); - test = args[1].compile().eval(scope); - } - else { - // an equation like filter([3, -2, 5], x > 0) - - // find an undefined symbol - var _scope = scope || {}; - var symbol = args[1] - .filter(function (node) { - return (node && node.isSymbolNode) && - !(node.name in math) && - !(node.name in _scope); - })[0]; - - // create a test function for this equation - var sub = Object.create(_scope); - var eq = args[1].compile(); - if (symbol) { - var name = symbol.name; - test = function (x) { - sub[name] = x; - return eq.eval(sub); - } - } - else { - throw new Error('No undefined variable found in filter equation'); - } - } - } - - return filter(x, test); - } - - filterTransform.rawArgs = true; - - return filterTransform; - } - - exports.name = 'filter'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 303 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(40).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Filter the items in an array or one dimensional matrix. - * - * Syntax: - * - * math.filter(x, test) - * - * Examples: - * - * function isPositive (x) { - * return x > 0; - * } - * math.filter([6, -2, -1, 4, 3], isPositive); // returns [6, 4, 3] - * - * math.filter(["23", "foo", "100", "55", "bar"], /[0-9]+/); // returns ["23", "100", "55"] - * - * See also: - * - * forEach, map, sort - * - * @param {Matrix | Array} x A one dimensional matrix or array to filter - * @param {Function | RegExp} test - * A function or regular expression to test items. - * When `test` is a function, it must return a boolean. - * All entries for which `test` returns true are returned. - * @return {Matrix | Array} Returns the filtered matrix. - */ - var filter = typed('filter', { - 'Array, function': _filterCallback, - - 'Array, RegExp': _filterRegExp, - - 'Matrix, function': function (x, test) { - return matrix(_filterCallback(x.toArray(), test)); - }, - - 'Matrix, RegExp': function (x, test) { - return matrix(_filterRegExp(x.toArray(), test)); - } - }); - - filter.toTex = undefined; // use default template - - return filter; - } - - /** - * Filter values in a callback given a callback function - * @param {Array} x - * @param {Function} callback - * @return {Array} Returns the filtered array - * @private - */ - function _filterCallback (x, callback) { - if (size(x).length !== 1) { - throw new Error('Only one dimensional matrices supported'); - } - - return x.filter(function (entry) { - return callback(entry); - }); - } - - /** - * Filter values in a callback given a regular expression - * @param {Array} x - * @param {Function} regexp - * @return {Array} Returns the filtered array - * @private - */ - function _filterRegExp (x, regexp) { - if (size(x).length !== 1) { - throw new Error('Only one dimensional matrices supported'); - } - - return x.filter(function (entry) { - return regexp.test(entry); - }); - } - - exports.name = 'filter'; - exports.factory = factory; - - -/***/ }, -/* 304 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /** - * Attach a transform function to math.forEach - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - */ - function factory (type, config, load, typed) { - var forEach = load(__webpack_require__(305)); - - return typed('forEach', { - 'Array | Matrix, function': function (array, callback) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - value.forEach(function (child, i) { - // we create a copy of the index array and append the new index value - recurse(child, index.concat(i + 1)); // one based index, hence i+1 - }); - } - else { - callback(value, index, array); - } - }; - recurse(array.valueOf(), []); // pass Array - } - }); - } - - exports.name = 'forEach'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 305 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Iterate over all elements of a matrix/array, and executes the given callback function. - * - * Syntax: - * - * math.forEach(x, callback) - * - * Examples: - * - * math.forEach([1, 2, 3], function(value) { - * console.log(value); - * }); - * // outputs 1, 2, 3 - * - * See also: - * - * filter, map, sort - * - * @param {Matrix | Array} x The matrix to iterate on. - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix/array being traversed. - */ - var forEach = typed('forEach', { - 'Array, function': _forEach, - - 'Matrix, function': function (x, callback) { - return x.forEach(callback); - } - }); - - forEach.toTex = undefined; // use default template - - return forEach; - } - - /** - * forEach for a multi dimensional array - * @param {Array} array - * @param {Function} callback - * @private - */ - function _forEach (array, callback) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - value.forEach(function (child, i) { - // we create a copy of the index array and append the new index value - recurse(child, index.concat(i)); - }); - } - else { - callback(value, index, array); - } - }; - recurse(array, []); - } - - exports.name = 'forEach'; - exports.factory = factory; - - -/***/ }, -/* 306 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isArray = Array.isArray; - - /** - * Attach a transform function to math.index - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - */ - function factory (type, config, load) { - var indexFactory = load(__webpack_require__(68)); - - return function indexTransform() { - var args = []; - for (var i = 0, ii = arguments.length; i < ii; i++) { - var arg = arguments[i]; - - // change from one-based to zero based, and convert BigNumber to number - if (arg && arg.isRange === true) { - arg.start--; - arg.end -= (arg.step > 0 ? 0 : 2); - } - else if (arg && arg.isSet === true) { - arg = arg.map(function (v) { return v - 1; }); - } - else if (arg && (arg.isArray === true || arg.isMatrix)) { - arg = arg.map(function (v) { return v - 1; }); - } - else if (typeof arg === 'number') { - arg--; - } - else if (arg && arg.isBigNumber === true) { - arg = arg.toNumber() - 1; - } - else if (typeof arg === 'string') { - // leave as is - } - else { - throw new TypeError('Dimension must be an Array, Matrix, number, string, or Range'); - } - - args[i] = arg; - } - - var res = new type.Index(); - type.Index.apply(res, args); - return res; - }; - } - - exports.name = 'index'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 307 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /** - * Attach a transform function to math.map - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - */ - function factory (type, config, load, typed) { - var map = load(__webpack_require__(308)); - var matrix = load(__webpack_require__(52)); - - return typed('max', { - 'Array, function': function (x, callback) { - return _map(x, callback, x); - }, - - 'Matrix, function': function (x, callback) { - return matrix(_map(x.valueOf(), callback, x)); - } - }); - } - - /** - * Map for a multi dimensional array. One-based indexes - * @param {Array} array - * @param {function} callback - * @param {Array} orig - * @return {Array} - * @private - */ - function _map (array, callback, orig) { - function recurse(value, index) { - if (Array.isArray(value)) { - return value.map(function (child, i) { - // we create a copy of the index array and append the new index value - return recurse(child, index.concat(i + 1)); // one based index, hence i + 1 - }); - } - else { - return callback(value, index, orig); - } - } - - return recurse(array, []); - } - - exports.name = 'map'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 308 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create a new matrix or array with the results of the callback function executed on - * each entry of the matrix/array. - * - * Syntax: - * - * math.map(x, callback) - * - * Examples: - * - * math.map([1, 2, 3], function(value) { - * return value * value; - * }); // returns [1, 4, 9] - * - * See also: - * - * filter, forEach, sort - * - * @param {Matrix | Array} x The matrix to iterate on. - * @param {Function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the matrix being traversed. - * @return {Matrix | array} Transformed map of x - */ - var map = typed('map', { - 'Array, function': _map, - - 'Matrix, function': function (x, callback) { - return x.map(callback); - } - }); - - map.toTex = undefined; // use default template - - return map; - } - - /** - * Map for a multi dimensional array - * @param {Array} array - * @param {Function} callback - * @return {Array} - * @private - */ - function _map (array, callback) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - return value.map(function (child, i) { - // we create a copy of the index array and append the new index value - return recurse(child, index.concat(i)); - }); - } - else { - return callback(value, index, array); - } - }; - - return recurse(array, []); - } - - exports.name = 'map'; - exports.factory = factory; - - -/***/ }, -/* 309 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var errorTransform = __webpack_require__(275).transform; - var isCollection = __webpack_require__(310); - - /** - * Attach a transform function to math.max - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function max - * from one-based to zero based - */ - function factory (type, config, load, typed) { - var max = load(__webpack_require__(311)); - - return typed('max', { - '...any': function (args) { - // change last argument dim from one-based to zero-based - if (args.length == 2 && isCollection(args[0])) { - var dim = args[1]; - if (typeof dim === 'number') { - args[1] = dim - 1; - } - else if (dim && dim.isBigNumber === true) { - args[1] = dim.minus(1); - } - } - - try { - return max.apply(null, args); - } - catch (err) { - throw errorTransform(err); - } - } - }); - } - - exports.name = 'max'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 310 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Test whether a value is a collection: an Array or Matrix - * @param {*} x - * @returns {boolean} isCollection - */ - module.exports = function isCollection (x) { - return (Array.isArray(x) || (x && x.isMatrix === true)); - }; - - -/***/ }, -/* 311 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepForEach = __webpack_require__(312); - var reduce = __webpack_require__(313); - var containsCollections = __webpack_require__(314); - - function factory (type, config, load, typed) { - var larger = load(__webpack_require__(64)); - - /** - * Compute the maximum value of a matrix or a list with values. - * In case of a multi dimensional array, the maximum of the flattened array - * will be calculated. When `dim` is provided, the maximum over the selected - * dimension will be calculated. Parameter `dim` is zero-based. - * - * Syntax: - * - * math.max(a, b, c, ...) - * math.max(A) - * math.max(A, dim) - * - * Examples: - * - * math.max(2, 1, 4, 3); // returns 4 - * math.max([2, 1, 4, 3]); // returns 4 - * - * // maximum over a specified dimension (zero-based) - * math.max([[2, 5], [4, 3], [1, 7]], 0); // returns [4, 7] - * math.max([[2, 5], [4, 3]], [1, 7], 1); // returns [5, 4, 7] - * - * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 - * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 - * - * See also: - * - * mean, median, min, prod, std, sum, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The maximum value - */ - var max = typed('max', { - // max([a, b, c, d, ...]) - 'Array | Matrix': _max, - - // max([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - return reduce(array, dim.valueOf(), _largest); - }, - - // max(a, b, c, d, ...) - '...': function (args) { - if (containsCollections(args)) { - throw new TypeError('Scalar values expected in function max'); - } - - return _max(args); - } - }); - - max.toTex = '\\max\\left(${args}\\right)'; - - return max; - - /** - * Return the largest of two values - * @param {*} x - * @param {*} y - * @returns {*} Returns x when x is largest, or y when y is largest - * @private - */ - function _largest(x, y){ - return larger(x, y) ? x : y; - } - - /** - * Recursively calculate the maximum value in an n-dimensional array - * @param {Array} array - * @return {number} max - * @private - */ - function _max(array) { - var max = undefined; - - deepForEach(array, function (value) { - if (max === undefined || larger(value, max)) { - max = value; - } - }); - - if (max === undefined) { - throw new Error('Cannot calculate max of an empty array'); - } - - return max; - } - } - - exports.name = 'max'; - exports.factory = factory; - - -/***/ }, -/* 312 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Recursively loop over all elements in a given multi dimensional array - * and invoke the callback on each of the elements. - * @param {Array | Matrix} array - * @param {Function} callback The callback method is invoked with one - * parameter: the current element in the array - */ - module.exports = function deepForEach (array, callback) { - if (array && array.isMatrix === true) { - array = array.valueOf(); - } - - for (var i = 0, ii = array.length; i < ii; i++) { - var value = array[i]; - - if (Array.isArray(value)) { - deepForEach(value, callback); - } - else { - callback(value); - } - } - }; - - -/***/ }, -/* 313 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var arraySize = __webpack_require__(40).size; - var IndexError = __webpack_require__(43); - - /** - * Reduce a given matrix or array to a new matrix or - * array with one less dimension, applying the given - * callback in the selected dimension. - * @param {Array | Matrix} mat - * @param {number} dim - * @param {Function} callback - * @return {Array | Matrix} res - */ - module.exports = function(mat, dim, callback) { - var size = Array.isArray(mat) ? arraySize(mat) : mat.size(); - if (dim < 0 || (dim >= size.length)) { - // TODO: would be more clear when throwing a DimensionError here - throw new IndexError(dim, size.length); - } - - if (mat && mat.isMatrix === true) { - return mat.create(_reduce(mat.valueOf(), dim, callback)); - }else { - return _reduce(mat, dim, callback); - } - }; - - /** - * Recursively reduce a matrix - * @param {Array} mat - * @param {number} dim - * @param {Function} callback - * @returns {Array} ret - * @private - */ - function _reduce(mat, dim, callback){ - var i, ret, val, tran; - - if(dim<=0){ - if( !Array.isArray(mat[0]) ){ - val = mat[0]; - for(i=1; i 0) { - while (x < end) { - array.push(x); - x += step; - } - } - else if (step < 0) { - while (x > end) { - array.push(x); - x += step; - } - } - - return array; - } - - /** - * Create a range with numbers. End is included - * @param {number} start - * @param {number} end - * @param {number} step - * @returns {Array} range - * @private - */ - function _rangeInc (start, end, step) { - var array = [], - x = start; - if (step > 0) { - while (x <= end) { - array.push(x); - x += step; - } - } - else if (step < 0) { - while (x >= end) { - array.push(x); - x += step; - } - } - - return array; - } - - /** - * Create a range with big numbers. End is excluded - * @param {BigNumber} start - * @param {BigNumber} end - * @param {BigNumber} step - * @returns {Array} range - * @private - */ - function _bigRangeEx (start, end, step) { - var array = [], - x = start; - if (step.gt(ZERO)) { - while (x.lt(end)) { - array.push(x); - x = x.plus(step); - } - } - else if (step.lt(ZERO)) { - while (x.gt(end)) { - array.push(x); - x = x.plus(step); - } - } - - return array; - } - - /** - * Create a range with big numbers. End is included - * @param {BigNumber} start - * @param {BigNumber} end - * @param {BigNumber} step - * @returns {Array} range - * @private - */ - function _bigRangeInc (start, end, step) { - var array = [], - x = start; - if (step.gt(ZERO)) { - while (x.lte(end)) { - array.push(x); - x = x.plus(step); - } - } - else if (step.lt(ZERO)) { - while (x.gte(end)) { - array.push(x); - x = x.plus(step); - } - } - - return array; - } - - /** - * Parse a string into a range, - * The string contains the start, optional step, and end, separated by a colon. - * If the string does not contain a valid range, null is returned. - * For example str='0:2:11'. - * @param {string} str - * @return {{start: number, end: number, step: number} | null} range Object containing properties start, end, step - * @private - */ - function _parse (str) { - var args = str.split(':'); - - // number - var nums = args.map(function (arg) { - // use Number and not parseFloat as Number returns NaN on invalid garbage in the string - return Number(arg); - }); - - var invalid = nums.some(function (num) { - return isNaN(num); - }); - if(invalid) { - return null; - } - - switch (nums.length) { - case 2: - return { - start: nums[0], - end: nums[1], - step: 1 - }; - - case 3: - return { - start: nums[0], - end: nums[2], - step: nums[1] - }; - - default: - return null; - } - } - - } - - exports.name = 'range'; - exports.factory = factory; - - -/***/ }, -/* 324 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var errorTransform = __webpack_require__(275).transform; - - /** - * Attach a transform function to math.subset - * Adds a property transform containing the transform function. - * - * This transform creates a range which includes the end value - */ - function factory (type, config, load, typed) { - var subset = load(__webpack_require__(276)); - - return typed('subset', { - '...any': function (args) { - try { - return subset.apply(null, args); - } - catch (err) { - throw errorTransform(err); - } - } - }); - } - - exports.name = 'subset'; - exports.path = 'expression.transform'; - exports.factory = factory; - - -/***/ }, -/* 325 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(3); - var string = __webpack_require__(23); - - function factory (type, config, load, typed) { - var parser = load(__webpack_require__(295))(); - - /** - * Documentation object - * @param {Object} doc Object containing properties: - * {string} name - * {string} category - * {string} description - * {string[]} syntax - * {string[]} examples - * {string[]} seealso - * @constructor - */ - function Help(doc) { - if (!(this instanceof Help)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (!doc) throw new Error('Argument "doc" missing'); - - this.doc = doc; - } - - /** - * Attach type information - */ - Help.prototype.type = 'Help'; - Help.prototype.isHelp = true; - - /** - * Generate a string representation of the Help object - * @return {string} Returns a string - * @private - */ - Help.prototype.toString = function () { - var doc = this.doc || {}; - var desc = '\n'; - - if (doc.name) { - desc += 'Name: ' + doc.name + '\n\n'; - } - if (doc.category) { - desc += 'Category: ' + doc.category + '\n\n'; - } - if (doc.description) { - desc += 'Description:\n ' + doc.description + '\n\n'; - } - if (doc.syntax) { - desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n'; - } - if (doc.examples) { - desc += 'Examples:\n'; - for (var i = 0; i < doc.examples.length; i++) { - var expr = doc.examples[i]; - desc += ' ' + expr + '\n'; - - var res; - try { - res = parser.eval(expr); - } - catch (e) { - res = e; - } - if (res && !res.isHelp) { - desc += ' ' + string.format(res, {precision: 14}) + '\n'; - } - } - desc += '\n'; - } - if (doc.seealso) { - desc += 'See also: ' + doc.seealso.join(', ') + '\n'; - } - - return desc; - }; - - /** - * Export the help object to JSON - */ - Help.prototype.toJSON = function () { - var obj = object.clone(this.doc); - obj.mathjs = 'Help'; - return obj; - }; - - /** - * Instantiate a Help object from a JSON object - * @param {Object} json - * @returns {Help} Returns a new Help object - */ - Help.fromJSON = function (json) { - var doc = {}; - for (var prop in json) { - if (prop !== 'mathjs') { // ignore mathjs field - doc[prop] = json[prop]; - } - } - return new Help(doc); - }; - - /** - * Returns a string representation of the Help object - */ - Help.prototype.valueOf = Help.prototype.toString; - - return Help; - } - - exports.name = 'Help'; - exports.path = 'type'; - exports.factory = factory; - - -/***/ }, -/* 326 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(327), - __webpack_require__(354), - __webpack_require__(386), - __webpack_require__(402), - __webpack_require__(411), - __webpack_require__(416), - __webpack_require__(419), - __webpack_require__(425), - __webpack_require__(437), - __webpack_require__(446), - __webpack_require__(450), - __webpack_require__(457), - __webpack_require__(459), - __webpack_require__(485), - __webpack_require__(487) - ]; - - -/***/ }, -/* 327 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - // decomposition - __webpack_require__(328), - __webpack_require__(329), - - // solver - __webpack_require__(349), - __webpack_require__(351), - __webpack_require__(353) - ]; - - -/***/ }, -/* 328 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - - var object = util.object; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var abs = load(__webpack_require__(86)); - var addScalar = load(__webpack_require__(53)); - var divideScalar = load(__webpack_require__(81)); - var multiplyScalar = load(__webpack_require__(80)); - var subtract = load(__webpack_require__(77)); - var larger = load(__webpack_require__(64)); - var equalScalar = load(__webpack_require__(48)); - var unaryMinus = load(__webpack_require__(78)); - - var SparseMatrix = type.SparseMatrix; - var DenseMatrix = type.DenseMatrix; - var Spa = type.Spa; - - /** - * Calculate the Matrix LU decomposition with partial pivoting. Matrix `A` is decomposed in two matrices (`L`, `U`) and a - * row permutation vector `p` where `A[p,:] = L * U` - * - * Syntax: - * - * math.lup(A); - * - * Example: - * - * var m = [[2, 1], [1, 4]]; - * var r = math.lup(); - * // r = { - * // L: [[1, 0], [0.5, 1]], - * // U: [[2, 1], [0, 3.5]], - * // P: [0, 1] - * // } - * - * See also: - * - * slu, lsolve, lusolve, usolve - * - * @param {Matrix | Array} A A two dimensional matrix or array for which to get the LUP decomposition. - * - * @return {Array} The lower triangular matrix, the upper triangular matrix and the permutation matrix. - */ - var lup = typed('lup', { - - 'DenseMatrix': function (m) { - return _denseLUP(m); - }, - - 'SparseMatrix': function (m) { - return _sparseLUP(m); - }, - - 'Array': function (a) { - // create dense matrix from array - var m = matrix(a); - // lup, use matrix implementation - var r = _denseLUP(m); - // result - return { - L: r.L.valueOf(), - U: r.U.valueOf(), - p: r.p - }; - } - }); - - var _denseLUP = function (m) { - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // minimum rows and columns - var n = Math.min(rows, columns); - // matrix array, clone original data - var data = object.clone(m._data); - // l matrix arrays - var ldata = []; - var lsize = [rows, n]; - // u matrix arrays - var udata = []; - var usize = [n, columns]; - // vars - var i, j, k; - // permutation vector - var p = []; - for (i = 0; i < rows; i++) - p[i] = i; - // loop columns - for (j = 0; j < columns; j++) { - // skip first column in upper triangular matrix - if (j > 0) { - // loop rows - for (i = 0; i < rows; i++) { - // min i,j - var min = Math.min(i, j); - // v[i, j] - var s = 0; - // loop up to min - for (k = 0; k < min; k++) { - // s = l[i, k] - data[k, j] - s = addScalar(s, multiplyScalar(data[i][k], data[k][j])); - } - data[i][j] = subtract(data[i][j], s); - } - } - // row with larger value in cvector, row >= j - var pi = j; - var pabsv = 0; - var vjj = 0; - // loop rows - for (i = j; i < rows; i++) { - // data @ i, j - var v = data[i][j]; - // absolute value - var absv = abs(v); - // value is greater than pivote value - if (larger(absv, pabsv)) { - // store row - pi = i; - // update max value - pabsv = absv; - // value @ [j, j] - vjj = v; - } - } - // swap rows (j <-> pi) - if (j !== pi) { - // swap values j <-> pi in p - p[j] = [p[pi], p[pi] = p[j]][0]; - // swap j <-> pi in data - DenseMatrix._swapRows(j, pi, data); - } - // check column is in lower triangular matrix - if (j < rows) { - // loop rows (lower triangular matrix) - for (i = j + 1; i < rows; i++) { - // value @ i, j - var vij = data[i][j]; - if (!equalScalar(vij, 0)) { - // update data - data[i][j] = divideScalar(data[i][j], vjj); - } - } - } - } - // loop columns - for (j = 0; j < columns; j++) { - // loop rows - for (i = 0; i < rows; i++) { - // initialize row in arrays - if (j === 0) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i] = []; - } - // L - ldata[i] = []; - } - // check we are in the upper triangular matrix - if (i < j) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = data[i][j]; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = 0; - } - continue; - } - // diagonal value - if (i === j) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = data[i][j]; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = 1; - } - continue; - } - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = 0; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = data[i][j]; - } - } - } - // l matrix - var l = new DenseMatrix({ - data: ldata, - size: lsize - }); - // u matrix - var u = new DenseMatrix({ - data: udata, - size: usize - }); - // p vector - var pv = []; - for (i = 0, n = p.length; i < n; i++) - pv[p[i]] = i; - // return matrices - return { - L: l, - U: u, - p: pv, - toString: function () { - return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.p; - } - }; - }; - - var _sparseLUP = function (m) { - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // minimum rows and columns - var n = Math.min(rows, columns); - // matrix arrays (will not be modified, thanks to permutation vector) - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // l matrix arrays - var lvalues = []; - var lindex = []; - var lptr = []; - var lsize = [rows, n]; - // u matrix arrays - var uvalues = []; - var uindex = []; - var uptr = []; - var usize = [n, columns]; - // vars - var i, j, k; - // permutation vectors, (current index -> original index) and (original index -> current index) - var pv_co = []; - var pv_oc = []; - for (i = 0; i < rows; i++) { - pv_co[i] = i; - pv_oc[i] = i; - } - // swap indices in permutation vectors (condition x < y)! - var swapIndeces = function (x, y) { - // find pv indeces getting data from x and y - var kx = pv_oc[x]; - var ky = pv_oc[y]; - // update permutation vector current -> original - pv_co[kx] = y; - pv_co[ky] = x; - // update permutation vector original -> current - pv_oc[x] = ky; - pv_oc[y] = kx; - }; - // loop columns - for (j = 0; j < columns; j++) { - // sparse accumulator - var spa = new Spa(); - // check lower triangular matrix has a value @ column j - if (j < rows) { - // update ptr - lptr.push(lvalues.length); - // first value in j column for lower triangular matrix - lvalues.push(1); - lindex.push(j); - } - // update ptr - uptr.push(uvalues.length); - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // copy column j into sparse accumulator - for (k = k0; k < k1; k++) { - // row - i = index[k]; - // copy column values into sparse accumulator (use permutation vector) - spa.set(pv_co[i], values[k]); - } - // skip first column in upper triangular matrix - if (j > 0) { - // loop rows in column j (above diagonal) - spa.forEach(0, j - 1, function (k, vkj) { - // loop rows in column k (L) - SparseMatrix._forEachRow(k, lvalues, lindex, lptr, function (i, vik) { - // check row is below k - if (i > k) { - // update spa value - spa.accumulate(i, unaryMinus(multiplyScalar(vik, vkj))); - } - }); - }); - } - // row with larger value in spa, row >= j - var pi = j; - var vjj = spa.get(j); - var pabsv = abs(vjj); - // loop values in spa (order by row, below diagonal) - spa.forEach(j + 1, rows - 1, function (x, v) { - // absolute value - var absv = abs(v); - // value is greater than pivote value - if (larger(absv, pabsv)) { - // store row - pi = x; - // update max value - pabsv = absv; - // value @ [j, j] - vjj = v; - } - }); - // swap rows (j <-> pi) - if (j !== pi) { - // swap values j <-> pi in L - SparseMatrix._swapRows(j, pi, lsize[1], lvalues, lindex, lptr); - // swap values j <-> pi in U - SparseMatrix._swapRows(j, pi, usize[1], uvalues, uindex, uptr); - // swap values in spa - spa.swap(j, pi); - // update permutation vector (swap values @ j, pi) - swapIndeces(j, pi); - } - // loop values in spa (order by row) - spa.forEach(0, rows - 1, function (x, v) { - // check we are above diagonal - if (x <= j) { - // update upper triangular matrix - uvalues.push(v); - uindex.push(x); - } - else { - // update value - v = divideScalar(v, vjj); - // check value is non zero - if (!equalScalar(v, 0)) { - // update lower triangular matrix - lvalues.push(v); - lindex.push(x); - } - } - }); - } - // update ptrs - uptr.push(uvalues.length); - lptr.push(lvalues.length); - - // return matrices - return { - L: new SparseMatrix({ - values: lvalues, - index: lindex, - ptr: lptr, - size: lsize - }), - U: new SparseMatrix({ - values: uvalues, - index: uindex, - ptr: uptr, - size: usize - }), - p: pv_co, - toString: function () { - return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.p; - } - }; - }; - - return lup; - } - - exports.name = 'lup'; - exports.factory = factory; - - -/***/ }, -/* 329 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - - var number = util.number, - - isInteger = number.isInteger; - - function factory (type, config, load, typed) { - - var cs_sqr = load(__webpack_require__(330)); - var cs_lu = load(__webpack_require__(341)); - - /** - * Calculate the Sparse Matrix LU decomposition with full pivoting. Sparse Matrix `A` is decomposed in two matrices (`L`, `U`) and two permutation vectors (`pinv`, `q`) where - * - * `P * A * Q = L * U` - * - * Syntax: - * - * math.slu(A, order, threshold); - * - * See also: - * - * lup, lsolve, usolve, lusolve - * - * @param {SparseMatrix} A A two dimensional sparse matrix for which to get the LU decomposition. - * @param {Number} order The Symbolic Ordering and Analysis order: - * 0 - Natural ordering, no permutation vector q is returned - * 1 - Matrix must be square, symbolic ordering and analisis is performed on M = A + A' - * 2 - Symbolic ordering and analisis is performed on M = A' * A. Dense columns from A' are dropped, A recreated from A'. - * This is appropriatefor LU factorization of unsymmetric matrices. - * 3 - Symbolic ordering and analisis is performed on M = A' * A. This is best used for LU factorization is matrix M has no dense rows. - * A dense row is a row with more than 10*sqr(columns) entries. - * @param {Number} threshold Partial pivoting threshold (1 for partial pivoting) - * - * @return {Object} The lower triangular matrix, the upper triangular matrix and the permutation vectors. - */ - var slu = typed('slu', { - - 'SparseMatrix, number, number': function (a, order, threshold) { - // verify order - if (!isInteger(order) || order < 0 || order > 3) - throw new Error('Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]'); - // verify threshold - if (threshold < 0 || threshold > 1) - throw new Error('Partial pivoting threshold must be a number from 0 to 1'); - - // perform symbolic ordering and analysis - var s = cs_sqr(order, a, false); - - // perform lu decomposition - var f = cs_lu(a, s, threshold); - - // return decomposition - return { - L: f.L, - U: f.U, - p: f.pinv, - q: s.q, - toString: function () { - return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\np: ' + this.p.toString() + (this.q ? '\nq: ' + this.q.toString() : '') + '\n'; - } - }; - } - }); - - return slu; - } - - exports.name = 'slu'; - exports.factory = factory; - - -/***/ }, -/* 330 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_amd = load(__webpack_require__(331)); - var cs_permute = load(__webpack_require__(336)); - var cs_etree = load(__webpack_require__(337)); - var cs_post = load(__webpack_require__(338)); - var cs_counts = load(__webpack_require__(339)); - - /** - * Symbolic ordering and analysis for QR and LU decompositions. - * - * @param {Number} order The ordering strategy (see cs_amd for more details) - * @param {Matrix} a The A matrix - * @param {boolean} qr Symbolic ordering and analysis for QR decomposition (true) or - * symbolic ordering and analysis for LU decomposition (false) - * - * @return {Object} The Symbolic ordering and analysis for matrix A - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_sqr = function (order, a, qr) { - // a arrays - var aptr = a._ptr; - var asize = a._size; - // columns - var n = asize[1]; - // vars - var k; - // symbolic analysis result - var s = {}; - // fill-reducing ordering - s.q = cs_amd(order, a); - // validate results - if (order && !s.q) - return null; - // QR symbolic analysis - if (qr) { - // apply permutations if needed - var c = order ? cs_permute(a, null, s.q, 0) : a; - // etree of C'*C, where C=A(:,q) - s.parent = cs_etree(c, 1); - // post order elimination tree - var post = cs_post (s.parent, n); - // col counts chol(C'*C) - s.cp = cs_counts(c, s.parent, post, 1); - // check we have everything needed to calculate number of nonzero elements - if (c && s.parent && s.cp && _vcount(c, s)) { - // calculate number of nonzero elements - for (s.unz = 0, k = 0; k < n; k++) - s.unz += s.cp[k]; - } - } - else { - // for LU factorization only, guess nnz(L) and nnz(U) - s.unz = 4 * (aptr[n]) + n; - s.lnz = s.unz; - } - // return result S - return s; - }; - - /** - * Compute nnz(V) = s.lnz, s.pinv, s.leftmost, s.m2 from A and s.parent - */ - var _vcount = function (a, s) { - // a arrays - var aptr = a._ptr; - var aindex = a._index; - var asize = a._size; - // rows & columns - var m = asize[0]; - var n = asize[1]; - // initialize s arrays - s.pinv = []; // (m + n); - s.leftmost = []; // (m); - // vars - var parent = s.parent; - var pinv = s.pinv; - var leftmost = s.leftmost; - // workspace, next: first m entries, head: next n entries, tail: next n entries, nque: next n entries - var w = []; // (m + 3 * n); - var next = 0; - var head = m; - var tail = m + n; - var nque = m + 2 * n; - // vars - var i, k, p, p0, p1; - // initialize w - for (k = 0; k < n; k++) { - // queue k is empty - w[head + k] = -1; - w[tail + k] = -1; - w[nque + k] = 0; - } - // initialize row arrays - for (i = 0; i < m; i++) - leftmost[i] = -1; - // loop columns backwards - for (k = n - 1; k >= 0; k--) { - // values & index for column k - for (p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) { - // leftmost[i] = min(find(A(i,:))) - leftmost[aindex[p]] = k; - } - } - // scan rows in reverse order - for (i = m - 1; i >= 0; i--) { - // row i is not yet ordered - pinv[i] = -1; - k = leftmost[i]; - // check row i is empty - if (k == -1) - continue; - // first row in queue k - if (w[nque + k]++ === 0) - w[tail + k] = i; - // put i at head of queue k - w[next + i] = w[head + k]; - w[head + k] = i; - } - s.lnz = 0; - s.m2 = m; - // find row permutation and nnz(V) - for (k = 0; k < n; k++) { - // remove row i from queue k - i = w[head + k]; - // count V(k,k) as nonzero - s.lnz++; - // add a fictitious row - if (i < 0) - i = s.m2++; - // associate row i with V(:,k) - pinv[i] = k; - // skip if V(k+1:m,k) is empty - if (--nque[k] <= 0) - continue; - // nque[k] is nnz (V(k+1:m,k)) - s.lnz += w[nque + k]; - // move all rows to parent of k - var pa = parent[k]; - if (pa != -1) { - if (w[nque + pa] === 0) - w[tail + pa] = w[tail + k]; - w[next + w[tail + k]] = w[head + pa]; - w[head + pa] = w[next + i]; - w[nque + pa] += w[nque + k]; - } - } - for (i = 0; i < m; i++) { - if (pinv[i] < 0) - pinv[i] = k++; - } - return true; - }; - - return cs_sqr; - } - - exports.name = 'cs_sqr'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 331 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_flip = load(__webpack_require__(332)); - var cs_fkeep = load(__webpack_require__(333)); - var cs_tdfs = load(__webpack_require__(334)); - - var add = load(__webpack_require__(51)); - var multiply = load(__webpack_require__(84)); - var transpose = load(__webpack_require__(335)); - - /** - * Approximate minimum degree ordering. The minimum degree algorithm is a widely used - * heuristic for finding a permutation P so that P*A*P' has fewer nonzeros in its factorization - * than A. It is a gready method that selects the sparsest pivot row and column during the course - * of a right looking sparse Cholesky factorization. - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - * - * @param {Number} order 0: Natural, 1: Cholesky, 2: LU, 3: QR - * @param {Matrix} m Sparse Matrix - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_amd = function (order, a) { - // check input parameters - if (!a || order <= 0 || order > 3) - return null; - // a matrix arrays - var asize = a._size; - // rows and columns - var m = asize[0]; - var n = asize[1]; - // initialize vars - var lemax = 0; - // dense threshold - var dense = Math.max(16, 10 * Math.sqrt(n)); - dense = Math.min(n - 2, dense); - // create target matrix C - var cm = _createTargetMatrix(order, a, m, n, dense); - // drop diagonal entries - cs_fkeep(cm, _diag, null); - // C matrix arrays - var cindex = cm._index; - var cptr = cm._ptr; - - // number of nonzero elements in C - var cnz = cptr[n]; - - // allocate result (n+1) - var P = []; - - // create workspace (8 * (n + 1)) - var W = []; - var len = 0; // first n + 1 entries - var nv = n + 1; // next n + 1 entries - var next = 2 * (n + 1); // next n + 1 entries - var head = 3 * (n + 1); // next n + 1 entries - var elen = 4 * (n + 1); // next n + 1 entries - var degree = 5 * (n + 1); // next n + 1 entries - var w = 6 * (n + 1); // next n + 1 entries - var hhead = 7 * (n + 1); // last n + 1 entries - - // use P as workspace for last - var last = P; - - // initialize quotient graph - var mark = _initializeQuotientGraph(n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree); - - // initialize degree lists - var nel = _initializeDegreeLists(n, cptr, W, degree, elen, w, dense, nv, head, last, next); - - // minimum degree node - var mindeg = 0; - - // vars - var i, j, k, k1, k2, e, pj, ln, nvi, pk, eln, p1, p2, pn, h, d; - - // while (selecting pivots) do - while (nel < n) { - // select node of minimum approximate degree. amd() is now ready to start eliminating the graph. It first - // finds a node k of minimum degree and removes it from its degree list. The variable nel keeps track of thow - // many nodes have been eliminated. - for (k = -1; mindeg < n && (k = W[head + mindeg]) == -1; mindeg++); - if (W[next + k] != -1) - last[W[next + k]] = -1; - // remove k from degree list - W[head + mindeg] = W[next + k]; - // elenk = |Ek| - var elenk = W[elen + k]; - // # of nodes k represents - var nvk = W[nv + k]; - // W[nv + k] nodes of A eliminated - nel += nvk; - - // Construct a new element. The new element Lk is constructed in place if |Ek| = 0. nv[i] is - // negated for all nodes i in Lk to flag them as members of this set. Each node i is removed from the - // degree lists. All elements e in Ek are absorved into element k. - var dk = 0; - // flag k as in Lk - W[nv + k] = -nvk; - var p = cptr[k]; - // do in place if W[elen + k] == 0 - var pk1 = (elenk === 0) ? p : cnz; - var pk2 = pk1; - for (k1 = 1; k1 <= elenk + 1; k1++) { - if (k1 > elenk) { - // search the nodes in k - e = k; - // list of nodes starts at cindex[pj] - pj = p; - // length of list of nodes in k - ln = W[len + k] - elenk; - } - else { - // search the nodes in e - e = cindex[p++]; - pj = cptr[e]; - // length of list of nodes in e - ln = W[len + e]; - } - for (k2 = 1; k2 <= ln; k2++) { - i = cindex[pj++]; - // check node i dead, or seen - if ((nvi = W[nv + i]) <= 0) - continue; - // W[degree + Lk] += size of node i - dk += nvi; - // negate W[nv + i] to denote i in Lk - W[nv + i] = -nvi; - // place i in Lk - cindex[pk2++] = i; - if (W[next + i] != -1) - last[W[next + i]] = last[i]; - // check we need to remove i from degree list - if (last[i] != -1) - W[next + last[i]] = W[next + i]; - else - W[head + W[degree + i]] = W[next + i]; - } - if (e != k) { - // absorb e into k - cptr[e] = cs_flip(k); - // e is now a dead element - W[w + e] = 0; - } - } - // cindex[cnz...nzmax] is free - if (elenk !== 0) - cnz = pk2; - // external degree of k - |Lk\i| - W[degree + k] = dk; - // element k is in cindex[pk1..pk2-1] - cptr[k] = pk1; - W[len + k] = pk2 - pk1; - // k is now an element - W[elen + k] = -2; - - // Find set differences. The scan1 function now computes the set differences |Le \ Lk| for all elements e. At the start of the - // scan, no entry in the w array is greater than or equal to mark. - - // clear w if necessary - mark = _wclear(mark, lemax, W, w, n); - // scan 1: find |Le\Lk| - for (pk = pk1; pk < pk2; pk++) { - i = cindex[pk]; - // check if W[elen + i] empty, skip it - if ((eln = W[elen + i]) <= 0) - continue; - // W[nv + i] was negated - nvi = -W[nv + i]; - var wnvi = mark - nvi; - // scan Ei - for (p = cptr[i], p1 = cptr[i] + eln - 1; p <= p1; p++) { - e = cindex[p]; - if (W[w + e] >= mark) { - // decrement |Le\Lk| - W[w + e] -= nvi; - } - else if (W[w + e] !== 0) { - // ensure e is a live element, 1st time e seen in scan 1 - W[w + e] = W[degree + e] + wnvi; - } - } - } - - // degree update - // The second pass computes the approximate degree di, prunes the sets Ei and Ai, and computes a hash - // function h(i) for all nodes in Lk. - - // scan2: degree update - for (pk = pk1; pk < pk2; pk++) { - // consider node i in Lk - i = cindex[pk]; - p1 = cptr[i]; - p2 = p1 + W[elen + i] - 1; - pn = p1; - // scan Ei - for (h = 0, d = 0, p = p1; p <= p2; p++) { - e = cindex[p]; - // check e is an unabsorbed element - if (W[w + e] !== 0) { - // dext = |Le\Lk| - var dext = W[w + e] - mark; - if (dext > 0) { - // sum up the set differences - d += dext; - // keep e in Ei - cindex[pn++] = e; - // compute the hash of node i - h += e; - } - else { - // aggressive absorb. e->k - cptr[e] = cs_flip(k); - // e is a dead element - W[w + e] = 0; - } - } - } - // W[elen + i] = |Ei| - W[elen + i] = pn - p1 + 1; - var p3 = pn; - var p4 = p1 + W[len + i]; - // prune edges in Ai - for (p = p2 + 1; p < p4; p++) { - j = cindex[p]; - // check node j dead or in Lk - var nvj = W[nv + j]; - if (nvj <= 0) - continue; - // degree(i) += |j| - d += nvj; - // place j in node list of i - cindex[pn++] = j; - // compute hash for node i - h += j; - } - // check for mass elimination - if (d === 0) { - // absorb i into k - cptr[i] = cs_flip(k); - nvi = -W[nv + i]; - // |Lk| -= |i| - dk -= nvi; - // |k| += W[nv + i] - nvk += nvi; - nel += nvi; - W[nv + i] = 0; - // node i is dead - W[elen + i] = -1; - } - else { - // update degree(i) - W[degree + i] = Math.min(W[degree + i], d); - // move first node to end - cindex[pn] = cindex[p3]; - // move 1st el. to end of Ei - cindex[p3] = cindex[p1]; - // add k as 1st element in of Ei - cindex[p1] = k; - // new len of adj. list of node i - W[len + i] = pn - p1 + 1; - // finalize hash of i - h = (h < 0 ? -h : h) % n; - // place i in hash bucket - W[next + i] = W[hhead + h]; - W[hhead + h] = i; - // save hash of i in last[i] - last[i] = h; - } - } - // finalize |Lk| - W[degree + k] = dk; - lemax = Math.max(lemax, dk); - // clear w - mark = _wclear(mark + lemax, lemax, W, w, n); - - // Supernode detection. Supernode detection relies on the hash function h(i) computed for each node i. - // If two nodes have identical adjacency lists, their hash functions wil be identical. - for (pk = pk1; pk < pk2; pk++) { - i = cindex[pk]; - // check i is dead, skip it - if (W[nv + i] >= 0) - continue; - // scan hash bucket of node i - h = last[i]; - i = W[hhead + h]; - // hash bucket will be empty - W[hhead + h] = -1; - for (; i != -1 && W[next + i] != -1; i = W[next + i], mark++) { - ln = W[len + i]; - eln = W[elen + i]; - for (p = cptr[i] + 1; p <= cptr[i] + ln - 1; p++) - W[w + cindex[p]] = mark; - var jlast = i; - // compare i with all j - for (j = W[next + i]; j != -1; ) { - var ok = W[len + j] === ln && W[elen + j] === eln; - for (p = cptr[j] + 1; ok && p <= cptr[j] + ln - 1; p++) { - // compare i and j - if (W[w + cindex[p]] != mark) - ok = 0; - } - // check i and j are identical - if (ok) { - // absorb j into i - cptr[j] = cs_flip(i); - W[nv + i] += W[nv + j]; - W[nv + j] = 0; - // node j is dead - W[elen + j] = -1; - // delete j from hash bucket - j = W[next + j]; - W[next + jlast] = j; - } - else { - // j and i are different - jlast = j; - j = W[next + j]; - } - } - } - } - - // Finalize new element. The elimination of node k is nearly complete. All nodes i in Lk are scanned one last time. - // Node i is removed from Lk if it is dead. The flagged status of nv[i] is cleared. - for (p = pk1, pk = pk1; pk < pk2; pk++) { - i = cindex[pk]; - // check i is dead, skip it - if ((nvi = -W[nv + i]) <= 0) - continue; - // restore W[nv + i] - W[nv + i] = nvi; - // compute external degree(i) - d = W[degree + i] + dk - nvi; - d = Math.min(d, n - nel - nvi); - if (W[head + d] != -1) - last[W[head + d]] = i; - // put i back in degree list - W[next + i] = W[head + d]; - last[i] = -1; - W[head + d] = i; - // find new minimum degree - mindeg = Math.min(mindeg, d); - W[degree + i] = d; - // place i in Lk - cindex[p++] = i; - } - // # nodes absorbed into k - W[nv + k] = nvk; - // length of adj list of element k - if ((W[len + k] = p - pk1) === 0) { - // k is a root of the tree - cptr[k] = -1; - // k is now a dead element - W[w + k] = 0; - } - if (elenk !== 0) { - // free unused space in Lk - cnz = p; - } - } - - // Postordering. The elimination is complete, but no permutation has been computed. All that is left - // of the graph is the assembly tree (ptr) and a set of dead nodes and elements (i is a dead node if - // nv[i] is zero and a dead element if nv[i] > 0). It is from this information only that the final permutation - // is computed. The tree is restored by unflipping all of ptr. - - // fix assembly tree - for (i = 0; i < n; i++) - cptr[i] = cs_flip(cptr[i]); - for (j = 0; j <= n; j++) - W[head + j] = -1; - // place unordered nodes in lists - for (j = n; j >= 0; j--) { - // skip if j is an element - if (W[nv + j] > 0) - continue; - // place j in list of its parent - W[next + j] = W[head + cptr[j]]; - W[head + cptr[j]] = j; - } - // place elements in lists - for (e = n; e >= 0; e--) { - // skip unless e is an element - if (W[nv + e] <= 0) - continue; - if (cptr[e] != -1) { - // place e in list of its parent - W[next + e] = W[head + cptr[e]]; - W[head + cptr[e]] = e; - } - } - // postorder the assembly tree - for (k = 0, i = 0; i <= n; i++) { - if (cptr[i] == -1) - k = cs_tdfs(i, k, W, head, next, P, w); - } - // remove last item in array - P.splice(P.length - 1, 1); - // return P - return P; - }; - - /** - * Creates the matrix that will be used by the approximate minimum degree ordering algorithm. The function accepts the matrix M as input and returns a permutation - * vector P. The amd algorithm operates on a symmetrix matrix, so one of three symmetric matrices is formed. - * - * Order: 0 - * A natural ordering P=null matrix is returned. - * - * Order: 1 - * Matrix must be square. This is appropriate for a Cholesky or LU factorization. - * P = M + M' - * - * Order: 2 - * Dense columns from M' are dropped, M recreated from M'. This is appropriatefor LU factorization of unsymmetric matrices. - * P = M' * M - * - * Order: 3 - * This is best used for QR factorization or LU factorization is matrix M has no dense rows. A dense row is a row with more than 10*sqr(columns) entries. - * P = M' * M - */ - var _createTargetMatrix = function (order, a, m, n, dense) { - // compute A' - var at = transpose(a); - - // check order = 1, matrix must be square - if (order === 1 && n === m) { - // C = A + A' - return add(a, at); - } - - // check order = 2, drop dense columns from M' - if (order == 2) { - // transpose arrays - var tindex = at._index; - var tptr = at._ptr; - // new column index - var p2 = 0; - // loop A' columns (rows) - for (var j = 0; j < m; j++) { - // column j of AT starts here - var p = tptr[j]; - // new column j starts here - tptr[j] = p2; - // skip dense col j - if (tptr[j + 1] - p > dense) - continue; - // map rows in column j of A - for (var p1 = tptr[j + 1]; p < p1; p++) - tindex[p2++] = tindex[p]; - } - // finalize AT - tptr[m] = p2; - // recreate A from new transpose matrix - a = transpose(at); - // use A' * A - return multiply(at, a); - } - - // use A' * A, square or rectangular matrix - return multiply(at, a); - }; - - /** - * Initialize quotient graph. There are four kind of nodes and elements that must be represented: - * - * - A live node is a node i (or a supernode) that has not been selected as a pivot nad has not been merged into another supernode. - * - A dead node i is one that has been removed from the graph, having been absorved into r = flip(ptr[i]). - * - A live element e is one that is in the graph, having been formed when node e was selected as the pivot. - * - A dead element e is one that has benn absorved into a subsequent element s = flip(ptr[e]). - */ - var _initializeQuotientGraph = function (n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree) { - // Initialize quotient graph - for (var k = 0; k < n; k++) - W[len + k] = cptr[k + 1] - cptr[k]; - W[len + n] = 0; - // initialize workspace - for (var i = 0; i <= n; i++) { - // degree list i is empty - W[head + i] = -1; - last[i] = -1; - W[next + i] = -1; - // hash list i is empty - W[hhead + i] = -1; - // node i is just one node - W[nv + i] = 1; - // node i is alive - W[w + i] = 1; - // Ek of node i is empty - W[elen + i] = 0; - // degree of node i - W[degree + i] = W[len + i]; - } - // clear w - var mark = _wclear(0, 0, W, w, n); - // n is a dead element - W[elen + n] = -2; - // n is a root of assembly tree - cptr[n] = -1; - // n is a dead element - W[w + n] = 0; - // return mark - return mark; - }; - - /** - * Initialize degree lists. Each node is placed in its degree lists. Nodes of zero degree are eliminated immediately. Nodes with - * degree >= dense are alsol eliminated and merged into a placeholder node n, a dead element. Thes nodes will appera last in the - * output permutation p. - */ - var _initializeDegreeLists = function (n, cptr, W, degree, elen, w, dense, nv, head, last, next) { - // result - var nel = 0; - // loop columns - for (var i = 0; i < n; i++) { - // degree @ i - var d = W[degree + i]; - // check node i is empty - if (d === 0) { - // element i is dead - W[elen + i] = -2; - nel++; - // i is a root of assembly tree - cptr[i] = -1; - W[w + i] = 0; - } - else if (d > dense) { - // absorb i into element n - W[nv + i] = 0; - // node i is dead - W[elen + i] = -1; - nel++; - cptr[i] = cs_flip(n); - W[nv + n]++; - } - else { - var h = W[head + d]; - if (h != -1) - last[h] = i; - // put node i in degree list d - W[next + i] = W[head + d]; - W[head + d] = i; - } - } - return nel; - }; - - var _wclear = function(mark, lemax, W, w, n) { - if (mark < 2 || (mark + lemax < 0)) { - for (var k = 0; k < n; k++) { - if (W[w + k] !== 0) - W[w + k] = 1; - } - mark = 2 ; - } - // at this point, W [0..n-1] < mark holds - return mark; - }; - - var _diag = function (i, j) { - return i != j; - }; - - return cs_amd; - } - - exports.name = 'cs_amd'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 332 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * This function "flips" its input about the integer -1. - * - * @param {Number} i The value to flip - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_flip = function (i) { - // flip the value - return -i - 2; - }; - - return cs_flip; - } - - exports.name = 'cs_flip'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 333 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * Keeps entries in the matrix when the callback function returns true, removes the entry otherwise - * - * @param {Matrix} a The sparse matrix - * @param {function} callback The callback function, function will be invoked with the following args: - * - The entry row - * - The entry column - * - The entry value - * - The state parameter - * @param {any} other The state - * - * @return The number of nonzero elements in the matrix - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_fkeep = function (a, callback, other) { - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - // columns - var n = asize[1]; - // nonzero items - var nz = 0; - // loop columns - for (var j = 0; j < n; j++) { - // get current location of col j - var p = aptr[j]; - // record new location of col j - aptr[j] = nz; - for (; p < aptr[j+1]; p++) { - // check we need to keep this item - if (callback(aindex[p], j, avalues ? avalues[p] : 1, other)) { - // keep A(i,j) - aindex[nz] = aindex[p]; - // check we need to process values (pattern only) - if (avalues) - avalues[nz] = avalues[p]; - // increment nonzero items - nz++; - } - } - } - // finalize A - aptr[n] = nz; - // trim arrays - aindex.splice(nz, aindex.length - nz); - // check we need to process values (pattern only) - if (avalues) - avalues.splice(nz, avalues.length - nz); - // return number of nonzero items - return (nz); - }; - - return cs_fkeep; - } - - exports.name = 'cs_fkeep'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 334 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * Depth-first search and postorder of a tree rooted at node j - * - * @param {Number} j The tree node - * @param {Number} k - * @param {Array} w The workspace array - * @param {Number} head The index offset within the workspace for the head array - * @param {Number} next The index offset within the workspace for the next array - * @param {Array} post The post ordering array - * @param {Number} stack The index offset within the workspace for the stack array - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_tdfs = function (j, k, w, head, next, post, stack) { - // variables - var top = 0; - // place j on the stack - w[stack] = j; - // while (stack is not empty) - while (top >= 0) { - // p = top of stack - var p = w[stack + top]; - // i = youngest child of p - var i = w[head + p]; - if (i == -1) { - // p has no unordered children left - top--; - // node p is the kth postordered node - post[k++] = p; - } - else { - // remove i from children of p - w[head + p] = w[next + i]; - // increment top - ++top; - // start dfs on child node i - w[stack + top] = i; - } - } - return k; - }; - - return cs_tdfs; - } - - exports.name = 'cs_tdfs'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 335 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var format = __webpack_require__(23).format; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var DenseMatrix = type.DenseMatrix, - SparseMatrix = type.SparseMatrix; - - /** - * Transpose a matrix. All values of the matrix are reflected over its - * main diagonal. Only two dimensional matrices are supported. - * - * Syntax: - * - * math.transpose(x) - * - * Examples: - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.transpose(A); // returns [[1, 4], [2, 5], [3, 6]] - * - * See also: - * - * diag, inv, subset, squeeze - * - * @param {Array | Matrix} x Matrix to be transposed - * @return {Array | Matrix} The transposed matrix - */ - var transpose = typed('transpose', { - - 'Array': function (x) { - // use dense matrix implementation - return transpose(matrix(x)).valueOf(); - }, - - 'Matrix': function (x) { - // matrix size - var size = x.size(); - - // result - var c; - - // process dimensions - switch (size.length) { - case 1: - // vector - c = x.clone(); - break; - - case 2: - // rows and columns - var rows = size[0]; - var columns = size[1]; - - // check columns - if (columns === 0) { - // throw exception - throw new RangeError('Cannot transpose a 2D matrix with no columns (size: ' + format(size) + ')'); - } - - // process storage format - switch (x.storage()) { - case 'dense': - c = _denseTranspose(x, rows, columns); - break; - case 'sparse': - c = _sparseTranspose(x, rows, columns); - break; - } - break; - - default: - // multi dimensional - throw new RangeError('Matrix must be a vector or two dimensional (size: ' + format(this._size) + ')'); - } - return c; - }, - - // scalars - 'any': function (x) { - return clone(x); - } - }); - - var _denseTranspose = function (m, rows, columns) { - // matrix array - var data = m._data; - // transposed matrix data - var transposed = []; - var transposedRow; - // loop columns - for (var j = 0; j < columns; j++) { - // initialize row - transposedRow = transposed[j] = []; - // loop rows - for (var i = 0; i < rows; i++) { - // set data - transposedRow[i] = clone(data[i][j]); - } - } - // return matrix - return new DenseMatrix({ - data: transposed, - size: [columns, rows], - datatype: m._datatype - }); - }; - - var _sparseTranspose = function (m, rows, columns) { - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // result matrices - var cvalues = values ? [] : undefined; - var cindex = []; - var cptr = []; - // row counts - var w = []; - for (var x = 0; x < rows; x++) - w[x] = 0; - // vars - var p, l, j; - // loop values in matrix - for (p = 0, l = index.length; p < l; p++) { - // number of values in row - w[index[p]]++; - } - // cumulative sum - var sum = 0; - // initialize cptr with the cummulative sum of row counts - for (var i = 0; i < rows; i++) { - // update cptr - cptr.push(sum); - // update sum - sum += w[i]; - // update w - w[i] = cptr[i]; - } - // update cptr - cptr.push(sum); - // loop columns - for (j = 0; j < columns; j++) { - // values & index in column - for (var k0 = ptr[j], k1 = ptr[j + 1], k = k0; k < k1; k++) { - // C values & index - var q = w[index[k]]++; - // C[j, i] = A[i, j] - cindex[q] = j; - // check we need to process values (pattern matrix) - if (values) - cvalues[q] = clone(values[k]); - } - } - // return matrix - return new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [columns, rows], - datatype: m._datatype - }); - }; - - transpose.toTex = {1: '\\left(${args[0]}\\right)' + latex.operators['transpose']}; - - return transpose; - } - - exports.name = 'transpose'; - exports.factory = factory; - - -/***/ }, -/* 336 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type) { - - var SparseMatrix = type.SparseMatrix; - - /** - * Permutes a sparse matrix C = P * A * Q - * - * @param {Matrix} a The Matrix A - * @param {Array} pinv The row permutation vector - * @param {Array} q The column permutation vector - * @param {boolean} values Create a pattern matrix (false), values and pattern otherwise - * - * @return {Matrix} C = P * A * Q, null on error - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_permute = function (a, pinv, q, values) { - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - var adt = a._datatype; - // rows & columns - var m = asize[0]; - var n = asize[1]; - // c arrays - var cvalues = values && a._values ? [] : null; - var cindex = []; // (aptr[n]); - var cptr = []; // (n + 1); - // initialize vars - var nz = 0; - // loop columns - for (var k = 0; k < n; k++) { - // column k of C is column q[k] of A - cptr[k] = nz; - // apply column permutation - var j = q ? (q[k]) : k; - // loop values in column j of A - for (var t0 = aptr[j], t1 = aptr[j + 1], t = t0; t < t1; t++) { - // row i of A is row pinv[i] of C - var r = pinv ? pinv[aindex[t]] : aindex[t]; - // index - cindex[nz] = r; - // check we need to populate values - if (cvalues) - cvalues[nz] = avalues[t]; - // increment number of nonzero elements - nz++; - } - } - // finalize the last column of C - cptr[n] = nz; - // return C matrix - return new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n], - datatype: adt - }); - }; - - return cs_permute; - } - - exports.name = 'cs_permute'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 337 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * Computes the elimination tree of Matrix A (using triu(A)) or the - * elimination tree of A'A without forming A'A. - * - * @param {Matrix} a The A Matrix - * @param {boolean} ata A value of true the function computes the etree of A'A - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_etree = function (a, ata) { - // check inputs - if (!a) - return null; - // a arrays - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - // rows & columns - var m = asize[0]; - var n = asize[1]; - - // allocate result - var parent = []; // (n) - - // allocate workspace - var w = []; // (n + (ata ? m : 0)) - var ancestor = 0; // first n entries in w - var prev = n; // last m entries (ata = true) - - var i, inext; - - // check we are calculating A'A - if (ata) { - // initialize workspace - for (i = 0; i < m; i++) - w[prev + i] = -1; - } - // loop columns - for (var k = 0; k < n; k++) { - // node k has no parent yet - parent[k] = -1; - // nor does k have an ancestor - w[ancestor + k] = -1; - // values in column k - for (var p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) { - // row - var r = aindex[p]; - // node - i = ata ? (w[prev + r]) : r; - // traverse from i to k - for (; i != -1 && i < k; i = inext) { - // inext = ancestor of i - inext = w[ancestor + i]; - // path compression - w[ancestor + i] = k; - // check no anc., parent is k - if (inext == -1) - parent[i] = k; - } - if (ata) - w[prev + r] = k; - } - } - return parent; - }; - - return cs_etree; - } - - exports.name = 'cs_etree'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 338 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_tdfs = load(__webpack_require__(334)); - - /** - * Post order a tree of forest - * - * @param {Array} parent The tree or forest - * @param {Number} n Number of columns - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_post = function (parent, n) { - // check inputs - if (!parent) - return null; - // vars - var k = 0; - var j; - // allocate result - var post = []; // (n); - // workspace, head: first n entries, next: next n entries, stack: last n entries - var w = []; // (3 * n); - var head = 0; - var next = n; - var stack = 2 * n; - // initialize workspace - for (j = 0; j < n; j++) { - // empty linked lists - w[head + j] = -1; - } - // traverse nodes in reverse order - for (j = n-1; j >= 0; j--) { - // check j is a root - if (parent[j] == -1) - continue; - // add j to list of its parent - w[next + j] = w[head + parent[j]]; - w[head + parent[j]] = j; - } - // loop nodes - for (j = 0; j < n; j++) { - // skip j if it is not a root - if (parent[j] != -1) - continue; - // depth-first search - k = cs_tdfs(j, k, w, head, next, post, stack); - } - return post; - }; - - return cs_post; - } - - exports.name = 'cs_post'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 339 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var transpose = load(__webpack_require__(335)); - - var cs_leaf = load(__webpack_require__(340)); - - /** - * Computes the column counts using the upper triangular part of A. - * It transposes A internally, none of the input parameters are modified. - * - * @param {Matrix} a The sparse matrix A - * - * @param {Matrix} ata Count the columns of A'A instead - * - * @return An array of size n of the column counts or null on error - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_counts = function (a, parent, post, ata) { - // check inputs - if (!a || !parent || !post) - return null; - // a matrix arrays - var asize = a._size; - // rows and columns - var m = asize[0]; - var n = asize[1]; - // variables - var i, j, k, J, p, p0, p1; - - // workspace size - var s = 4 * n + (ata ? (n + m + 1) : 0); - // allocate workspace - var w = []; // (s) - var ancestor = 0; // first n entries - var maxfirst = n; // next n entries - var prevleaf = 2 * n; // next n entries - var first = 3 * n; // next n entries - var head = 4 * n; // next n + 1 entries (used when ata is true) - var next = 5 * n + 1; // last entries in workspace - // clear workspace w[0..s-1] - for (k = 0; k < s; k++) - w[k] = -1; - - // allocate result - var colcount = []; // (n); - - // AT = A' - var at = transpose(a); - // at arrays - var tindex = at._index; - var tptr = at._ptr; - - // find w[first + j] - for (k = 0; k < n; k++) { - j = post[k]; - // colcount[j]=1 if j is a leaf - colcount[j] = (w[first + j] == -1) ? 1 : 0; - for (; j != -1 && w[first + j] == -1; j = parent[j]) - w[first + j] = k; - } - - // initialize ata if needed - if (ata) { - // invert post - for (k = 0; k < n; k++) - w[post[k]] = k; - // loop rows (columns in AT) - for (i = 0; i < m; i++) { - // values in column i of AT - for (k = n, p0 = tptr[i], p1 = tptr[i + 1], p = p0; p < p1; p++) - k = Math.min(k, w[tindex[p]]); - // place row i in linked list k - w[next + i] = w[head + k]; - w[head + k] = i; - } - } - - // each node in its own set - for (i = 0; i < n; i++) - w[ancestor + i] = i; - - for (k = 0; k < n; k++) { - // j is the kth node in postordered etree - j = post[k]; - // check j is not a root - if (parent[j] != -1) - colcount[parent[j]]--; - - // J=j for LL'=A case - for (J = (ata ? w[head + k] : j); J != -1; J = (ata ? w[next + J] : -1)) { - for (p = tptr[J]; p < tptr[J+1]; p++) { - i = tindex[p]; - var r = cs_leaf(i, j, w, first, maxfirst, prevleaf, ancestor); - // check A(i,j) is in skeleton - if (r.jleaf >= 1) - colcount[j]++; - // check account for overlap in q - if (r.jleaf == 2) - colcount[r.q]--; - } - } - if (parent[j] != -1) - w[ancestor + j] = parent[j]; - } - // sum up colcount's of each child - for (j = 0; j < n; j++) { - if (parent[j] != -1) - colcount[parent[j]] += colcount[j]; - } - return colcount; - }; - - return cs_counts; - } - - exports.name = 'cs_counts'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 340 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * This function determines if j is a leaf of the ith row subtree. - * Consider A(i,j), node j in ith row subtree and return lca(jprev,j) - * - * @param {Number} i The ith row subtree - * @param {Number} j The node to test - * @param {Array} w The workspace array - * @param {Number} first The index offset within the workspace for the first array - * @param {Number} maxfirst The index offset within the workspace for the maxfirst array - * @param {Number} prevleaf The index offset within the workspace for the prevleaf array - * @param {Number} ancestor The index offset within the workspace for the ancestor array - * - * @return {Object} - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_leaf = function (i, j, w, first, maxfirst, prevleaf, ancestor) { - - var s, sparent, jprev; - - // our result - var jleaf = 0; - var q; - - // check j is a leaf - if (i <= j || w[first + j] <= w[maxfirst + i]) - return (-1); - // update max first[j] seen so far - w[maxfirst + i] = w[first + j]; - // jprev = previous leaf of ith subtree - jprev = w[prevleaf + i]; - w[prevleaf + i] = j; - - // check j is first or subsequent leaf - if (jprev === -1) { - // 1st leaf, q = root of ith subtree - jleaf = 1; - q = i; - } - else { - // update jleaf - jleaf = 2; - // q = least common ancester (jprev,j) - for (q = jprev; q != w[ancestor + q]; q = w[ancestor + q]); - for (s = jprev; s != q; s = sparent) { - // path compression - sparent = w[ancestor + s]; - w[ancestor + s] = q; - } - } - return { - jleaf: jleaf, - q: q - }; - }; - - return cs_leaf; - } - - exports.name = 'cs_leaf'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 341 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var abs = load(__webpack_require__(86)); - var divideScalar = load(__webpack_require__(81)); - var multiply = load(__webpack_require__(84)); - - var larger = load(__webpack_require__(64)); - var largerEq = load(__webpack_require__(342)); - - var cs_spsolve = load(__webpack_require__(343)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Computes the numeric LU factorization of the sparse matrix A. Implements a Left-looking LU factorization - * algorithm that computes L and U one column at a tume. At the kth step, it access columns 1 to k-1 of L - * and column k of A. Given the fill-reducing column ordering q (see parameter s) computes L, U and pinv so - * L * U = A(p, q), where p is the inverse of pinv. - * - * @param {Matrix} m The A Matrix to factorize - * @param {Object} s The symbolic analysis from cs_sqr(). Provides the fill-reducing - * column ordering q - * @param {Number} tol Partial pivoting threshold (1 for partial pivoting) - * - * @return {Number} The numeric LU factorization of A or null - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_lu = function (m, s, tol) { - // validate input - if (!m) - return null; - // m arrays - var size = m._size; - // columns - var n = size[1]; - // symbolic analysis result - var q; - var lnz = 100; - var unz = 100; - // update symbolic analysis parameters - if (s) { - q = s.q; - lnz = s.lnz || lnz; - unz = s.unz || unz; - } - // L arrays - var lvalues = []; // (lnz) - var lindex = []; // (lnz); - var lptr = []; // (n + 1); - // L - var L = new SparseMatrix({ - values: lvalues, - index: lindex, - ptr: lptr, - size: [n, n] - }); - // U arrays - var uvalues = []; // (unz); - var uindex = []; // (unz); - var uptr = []; // (n + 1); - // U - var U = new SparseMatrix({ - values: uvalues, - index: uindex, - ptr: uptr, - size: [n, n] - }); - // inverse of permutation vector - var pinv = []; // (n); - // vars - var i, p; - // allocate arrays - var x = []; // (n); - var xi = []; // (2 * n); - // initialize variables - for (i = 0; i < n; i++) { - // clear workspace - x[i] = 0; - // no rows pivotal yet - pinv[i] = -1; - // no cols of L yet - lptr[i + 1] = 0; - } - // reset number of nonzero elements in L and U - lnz = 0; - unz = 0; - // compute L(:,k) and U(:,k) - for (var k = 0; k < n; k++) { - // update ptr - lptr[k] = lnz; - uptr[k] = unz; - // apply column permutations if needed - var col = q ? q[k] : k; - // solve triangular system, x = L\A(:,col) - var top = cs_spsolve(L, m, col, xi, x, pinv, 1); - // find pivot - var ipiv = -1; - var a = -1; - // loop xi[] from top -> n - for (p = top; p < n; p++) { - // x[i] is nonzero - i = xi[p]; - // check row i is not yet pivotal - if (pinv[i] < 0) { - // absolute value of x[i] - var xabs = abs(x[i]); - // check absoulte value is greater than pivot value - if (larger(xabs, a)) { - // largest pivot candidate so far - a = xabs; - ipiv = i; - } - } - else { - // x(i) is the entry U(pinv[i],k) - uindex[unz] = pinv[i]; - uvalues[unz++] = x[i]; - } - } - // validate we found a valid pivot - if (ipiv == -1 || a <= 0) - return null; - // update actual pivot column, give preference to diagonal value - if (pinv[col] < 0 && largerEq(abs(x[col]), multiply(a, tol))) - ipiv = col; - // the chosen pivot - var pivot = x[ipiv]; - // last entry in U(:,k) is U(k,k) - uindex[unz] = k; - uvalues[unz++] = pivot; - // ipiv is the kth pivot row - pinv[ipiv] = k; - // first entry in L(:,k) is L(k,k) = 1 - lindex[lnz] = ipiv; - lvalues[lnz++] = 1; - // L(k+1:n,k) = x / pivot - for (p = top; p < n; p++) { - // row - i = xi[p]; - // check x(i) is an entry in L(:,k) - if (pinv[i] < 0) { - // save unpermuted row in L - lindex[lnz] = i; - // scale pivot column - lvalues[lnz++] = divideScalar(x[i], pivot); - } - // x[0..n-1] = 0 for next k - x[i] = 0; - } - } - // update ptr - lptr[n] = lnz; - uptr[n] = unz; - // fix row indices of L for final pinv - for (p = 0; p < lnz; p++) - lindex[p] = pinv[lindex[p]]; - // trim arrays - lvalues.splice(lnz, lvalues.length - lnz); - lindex.splice(lnz, lindex.length - lnz); - uvalues.splice(unz, uvalues.length - unz); - uindex.splice(unz, uindex.length - unz); - // return LU factor - return { - L: L, - U: U, - pinv: pinv - }; - }; - - return cs_lu; - } - - exports.name = 'cs_lu'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 342 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether value x is larger or equal to y. - * - * The function returns true when x is larger than y or the relative - * difference between x and y is smaller than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.largerEq(x, y) - * - * Examples: - * - * math.larger(2, 1 + 1); // returns false - * math.largerEq(2, 1 + 1); // returns true - * - * See also: - * - * equal, unequal, smaller, smallerEq, larger, compare - * - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the x is larger or equal to y, else returns false - */ - var largerEq = typed('largerEq', { - - 'boolean, boolean': function (x, y) { - return x >= y; - }, - - 'number, number': function (x, y) { - return x >= y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.gte(y) || bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return x.compare(y) !== -1; - }, - - 'Complex, Complex': function () { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return largerEq(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x >= y; - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, largerEq); - break; - default: - // sparse + dense - c = algorithm03(y, x, largerEq, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, largerEq, false); - break; - default: - // dense + dense - c = algorithm13(x, y, largerEq); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return largerEq(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return largerEq(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return largerEq(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, largerEq, false); - break; - default: - c = algorithm14(x, y, largerEq, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, largerEq, true); - break; - default: - c = algorithm14(y, x, largerEq, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, largerEq, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, largerEq, true).valueOf(); - } - }); - - largerEq.toTex = { - 2: '\\left(${args[0]}' + latex.operators['largerEq'] + '${args[1]}\\right)' - }; - - return largerEq; - } - - exports.name = 'largerEq'; - exports.factory = factory; - - -/***/ }, -/* 343 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var divideScalar = load(__webpack_require__(81)); - var multiply = load(__webpack_require__(84)); - var subtract = load(__webpack_require__(77)); - - var cs_reach = load(__webpack_require__(344)); - - /** - * The function cs_spsolve() computes the solution to G * x = bk, where bk is the - * kth column of B. When lo is true, the function assumes G = L is lower triangular with the - * diagonal entry as the first entry in each column. When lo is true, the function assumes G = U - * is upper triangular with the diagonal entry as the last entry in each column. - * - * @param {Matrix} g The G matrix - * @param {Matrix} b The B matrix - * @param {Number} k The kth column in B - * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n - * The first n entries is the nonzero pattern, the last n entries is the stack - * @param {Array} x The soluton to the linear system G * x = b - * @param {Array} pinv The inverse row permutation vector, must be null for L * x = b - * @param {boolean} lo The lower (true) upper triangular (false) flag - * - * @return {Number} The index for the nonzero pattern - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_spsolve = function (g, b, k, xi, x, pinv, lo) { - // g arrays - var gvalues = g._values; - var gindex = g._index; - var gptr = g._ptr; - var gsize = g._size; - // columns - var n = gsize[1]; - // b arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - // vars - var p, p0, p1, q; - // xi[top..n-1] = cs_reach(B(:,k)) - var top = cs_reach(g, b, k, xi, pinv); - // clear x - for (p = top; p < n; p++) - x[xi[p]] = 0; - // scatter b - for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) - x[bindex[p]] = bvalues[p]; - // loop columns - for (var px = top; px < n; px++) { - // x array index for px - var j = xi[px]; - // apply permutation vector (U x = b), j maps to column J of G - var J = pinv ? pinv[j] : j; - // check column J is empty - if (J < 0) - continue; - // column value indeces in G, p0 <= p < p1 - p0 = gptr[J]; - p1 = gptr[J + 1]; - // x(j) /= G(j,j) - x[j] = divideScalar(x[j], gvalues[lo ? p0 : (p1 - 1)]); - // first entry L(j,j) - p = lo ? (p0 + 1) : p0; - q = lo ? (p1) : (p1 - 1); - // loop - for ( ; p < q ; p++) { - // row - var i = gindex[p]; - // x(i) -= G(i,j) * x(j) - x[i] = subtract(x[i], multiply(gvalues[p], x[j])); - } - } - // return top of stack - return top; - }; - - return cs_spsolve; - } - - exports.name = 'cs_spsolve'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 344 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_dfs = load(__webpack_require__(345)); - var cs_marked = load(__webpack_require__(346)); - var cs_mark = load(__webpack_require__(347)); - - /** - * The cs_reach function computes X = Reach(B), where B is the nonzero pattern of the n-by-1 - * sparse column of vector b. The function returns the set of nodes reachable from any node in B. The - * nonzero pattern xi of the solution x to the sparse linear system Lx=b is given by X=Reach(B). - * - * @param {Matrix} g The G matrix - * @param {Matrix} b The B matrix - * @param {Number} k The kth column in B - * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n - * The first n entries is the nonzero pattern, the last n entries is the stack - * @param {Array} pinv The inverse row permutation vector - * - * @return {Number} The index for the nonzero pattern - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_reach = function (g, b, k, xi, pinv) { - // g arrays - var gptr = g._ptr; - var gsize = g._size; - // b arrays - var bindex = b._index; - var bptr = b._ptr; - // columns - var n = gsize[1]; - // vars - var p, p0, p1; - // initialize top - var top = n; - // loop column indeces in B - for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) { - // node i - var i = bindex[p]; - // check node i is marked - if (!cs_marked(gptr, i)) { - // start a dfs at unmarked node i - top = cs_dfs(i, g, top, xi, pinv); - } - } - // loop columns from top -> n - 1 - for (p = top; p < n; p++) { - // restore G - cs_mark(gptr, xi[p]); - } - return top; - }; - - return cs_reach; - } - - exports.name = 'cs_reach'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 345 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_marked = load(__webpack_require__(346)); - var cs_mark = load(__webpack_require__(347)); - var cs_unflip = load(__webpack_require__(348)); - - /** - * Depth-first search computes the nonzero pattern xi of the directed graph G (Matrix) starting - * at nodes in B (see cs_reach()). - * - * @param {Number} j The starting node for the DFS algorithm - * @param {Matrix} g The G matrix to search, ptr array modified, then restored - * @param {Number} top Start index in stack xi[top..n-1] - * @param {Number} k The kth column in B - * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n - * The first n entries is the nonzero pattern, the last n entries is the stack - * @param {Array} pinv The inverse row permutation vector, must be null for L * x = b - * - * @return {Number} New value of top - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_dfs = function (j, g, top, xi, pinv) { - // g arrays - var index = g._index; - var ptr = g._ptr; - var size = g._size; - // columns - var n = size[1]; - // vars - var i, p, p2; - // initialize head - var head = 0; - // initialize the recursion stack - xi[0] = j; - // loop - while (head >= 0) { - // get j from the top of the recursion stack - j = xi[head]; - // apply permutation vector - var jnew = pinv ? pinv[j] : j; - // check node j is marked - if (!cs_marked(ptr, j)) { - // mark node j as visited - cs_mark(ptr, j); - // update stack (last n entries in xi) - xi[n + head] = jnew < 0 ? 0 : cs_unflip(ptr[jnew]); - } - // node j done if no unvisited neighbors - var done = 1; - // examine all neighbors of j, stack (last n entries in xi) - for (p = xi[n + head], p2 = jnew < 0 ? 0 : cs_unflip(ptr[jnew+1]); p < p2; p++) { - // consider neighbor node i - i = index[p]; - // check we have visited node i, skip it - if (cs_marked(ptr, i)) - continue; - // pause depth-first search of node j, update stack (last n entries in xi) - xi[n + head] = p; - // start dfs at node i - xi[++head] = i; - // node j is not done - done = 0; - // break, to start dfs(i) - break; - } - // check depth-first search at node j is done - if (done) { - // remove j from the recursion stack - head--; - // and place in the output stack - xi[--top] = j; - } - } - return top; - }; - - return cs_dfs; - } - - exports.name = 'cs_dfs'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 346 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * Checks if the node at w[j] is marked - * - * @param {Array} w The array - * @param {Number} j The array index - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_marked = function (w, j) { - // check node is marked - return w[j] < 0; - }; - - return cs_marked; - } - - exports.name = 'cs_marked'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 347 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_flip = load(__webpack_require__(332)); - - /** - * Marks the node at w[j] - * - * @param {Array} w The array - * @param {Number} j The array index - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_mark = function (w, j) { - // mark w[j] - w[j] = cs_flip(w [j]); - }; - - return cs_mark; - } - - exports.name = 'cs_mark'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 348 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load) { - - var cs_flip = load(__webpack_require__(332)); - - /** - * Flips the value if it is negative of returns the same value otherwise. - * - * @param {Number} i The value to flip - * - * Reference: http://faculty.cse.tamu.edu/davis/publications.html - */ - var cs_unflip = function (i) { - // flip the value if it is negative - return i < 0 ? cs_flip(i) : i; - }; - - return cs_unflip; - } - - exports.name = 'cs_unflip'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 349 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var divideScalar = load(__webpack_require__(81)); - var multiplyScalar = load(__webpack_require__(80)); - var subtract = load(__webpack_require__(77)); - var equalScalar = load(__webpack_require__(48)); - - var solveValidation = load(__webpack_require__(350)); - - var DenseMatrix = type.DenseMatrix; - - /** - * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. - * - * `L * x = b` - * - * Syntax: - * - * math.lsolve(L, b); - * - * Examples: - * - * var a = [[-2, 3], [2, 1]]; - * var b = [11, 9]; - * var x = lsolve(a, b); // [[-5.5], [20]] - * - * See also: - * - * lup, slu, usolve, lusolve - * - * @param {Matrix, Array} L A N x N matrix or array (L) - * @param {Matrix, Array} b A column vector with the b values - * - * @return {DenseMatrix | Array} A column vector with the linear system solution (x) - */ - var lsolve = typed('lsolve', { - - 'SparseMatrix, Array | Matrix': function (m, b) { - // process matrix - return _sparseForwardSubstitution(m, b); - }, - - 'DenseMatrix, Array | Matrix': function (m, b) { - // process matrix - return _denseForwardSubstitution(m, b); - }, - - 'Array, Array | Matrix': function (a, b) { - // create dense matrix from array - var m = matrix(a); - // use matrix implementation - var r = _denseForwardSubstitution(m, b); - // result - return r.valueOf(); - } - }); - - var _denseForwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = solveValidation(m, b, true); - // column vector data - var bdata = b._data; - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // result - var x = []; - // data - var data = m._data; - // forward solve m * x = b, loop columns - for (var j = 0; j < columns; j++) { - // b[j] - var bj = bdata[j][0] || 0; - // x[j] - var xj; - // forward substitution (outer product) avoids inner looping when bj == 0 - if (!equalScalar(bj, 0)) { - // value @ [j, j] - var vjj = data[j][j]; - // check vjj - if (equalScalar(vjj, 0)) { - // system cannot be solved - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - xj = divideScalar(bj, vjj); - // loop rows - for (var i = j + 1; i < rows; i++) { - // update copy of b - bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, data[i][j]))]; - } - } - else { - // zero @ j - xj = 0; - } - // update x - x[j] = [xj]; - } - // return vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - var _sparseForwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = solveValidation(m, b, true); - // column vector data - var bdata = b._data; - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // vars - var i, k; - // result - var x = []; - // forward solve m * x = b, loop columns - for (var j = 0; j < columns; j++) { - // b[j] - var bj = bdata[j][0] || 0; - // forward substitution (outer product) avoids inner looping when bj == 0 - if (!equalScalar(bj, 0)) { - // value @ [j, j] - var vjj = 0; - // lower triangular matrix values & index (column j) - var jvalues = []; - var jindex = []; - // last index in column - var l = ptr[j + 1]; - // values in column, find value @ [j, j] - for (k = ptr[j]; k < l; k++) { - // row - i = index[k]; - // check row (rows are not sorted!) - if (i === j) { - // update vjj - vjj = values[k]; - } - else if (i > j) { - // store lower triangular - jvalues.push(values[k]); - jindex.push(i); - } - } - // at this point we must have a value @ [j, j] - if (equalScalar(vjj, 0)) { - // system cannot be solved, there is no value @ [j, j] - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - var xj = divideScalar(bj, vjj); - // loop lower triangular - for (k = 0, l = jindex.length; k < l; k++) { - // row - i = jindex[k]; - // update copy of b - bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, jvalues[k]))]; - } - // update x - x[j] = [xj]; - } - else { - // update x - x[j] = [0]; - } - } - // return vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - return lsolve; - } - - exports.name = 'lsolve'; - exports.factory = factory; - - -/***/ }, -/* 350 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(39); - - var string = util.string; - var array = util.array; - - var isArray = Array.isArray; - - function factory (type) { - - var DenseMatrix = type.DenseMatrix; - - /** - * Validates matrix and column vector b for backward/forward substitution algorithms. - * - * @param {Matrix} m An N x N matrix - * @param {Array | Matrix} b A column vector - * @param {Boolean} copy Return a copy of vector b - * - * @return {DenseMatrix} Dense column vector b - */ - var solveValidation = function (m, b, copy) { - // matrix size - var size = m.size(); - // validate matrix dimensions - if (size.length !== 2) - throw new RangeError('Matrix must be two dimensional (size: ' + string.format(size) + ')'); - // rows & columns - var rows = size[0]; - var columns = size[1]; - // validate rows & columns - if (rows !== columns) - throw new RangeError('Matrix must be square (size: ' + string.format(size) + ')'); - // vars - var data, i, bdata; - // check b is matrix - if (b && b.isMatrix === true) { - // matrix size - var msize = b.size(); - // vector - if (msize.length === 1) { - // check vector length - if (msize[0] !== rows) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // create data array - data = []; - // matrix data (DenseMatrix) - bdata = b._data; - // loop b data - for (i = 0; i < rows; i++) { - // row array - data[i] = [bdata[i]]; - } - // return Dense Matrix - return new DenseMatrix({ - data: data, - size: [rows, 1], - datatype: b._datatype - }); - } - // two dimensions - if (msize.length === 2) { - // array must be a column vector - if (msize[0] !== rows || msize[1] !== 1) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // check matrix type - if (b.isDenseMatrix === true) { - // check a copy is needed - if (copy) { - // create data array - data = []; - // matrix data (DenseMatrix) - bdata = b._data; - // loop b data - for (i = 0; i < rows; i++) { - // row array - data[i] = [bdata[i][0]]; - } - // return Dense Matrix - return new DenseMatrix({ - data: data, - size: [rows, 1], - datatype: b._datatype - }); - } - // b is already a column vector - return b; - } - // create data array - data = []; - for (i = 0; i < rows; i++) - data[i] = [0]; - // sparse matrix arrays - var values = b._values; - var index = b._index; - var ptr = b._ptr; - // loop values in column 0 - for (var k1 = ptr[1], k = ptr[0]; k < k1; k++) { - // row - i = index[k]; - // add to data - data[i][0] = values[k]; - } - // return Dense Matrix - return new DenseMatrix({ - data: data, - size: [rows, 1], - datatype: b._datatype - }); - } - // throw error - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - // check b is array - if (isArray(b)) { - // size - var asize = array.size(b); - // check matrix dimensions, vector - if (asize.length === 1) { - // check vector length - if (asize[0] !== rows) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // create data array - data = []; - // loop b - for (i = 0; i < rows; i++) { - // row array - data[i] = [b[i]]; - } - // return Dense Matrix - return new DenseMatrix({ - data: data, - size: [rows, 1] - }); - } - if (asize.length === 2) { - // array must be a column vector - if (asize[0] !== rows || asize[1] !== 1) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // create data array - data = []; - // loop b data - for (i = 0; i < rows; i++) { - // row array - data[i] = [b[i][0]]; - } - // return Dense Matrix - return new DenseMatrix({ - data: data, - size: [rows, 1] - }); - } - // throw error - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - }; - - return solveValidation; - } - - exports.factory = factory; - -/***/ }, -/* 351 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isArray = Array.isArray; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var lup = load(__webpack_require__(328)); - var slu = load(__webpack_require__(329)); - var cs_ipvec = load(__webpack_require__(352)); - - var solveValidation = load(__webpack_require__(350)); - - var usolve = load(__webpack_require__(353)); - var lsolve = load(__webpack_require__(349)); - - /** - * Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector. - * - * Syntax: - * - * math.lusolve(A, b) // returns column vector with the solution to the linear system A * x = b - * math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A) - * - * Examples: - * - * var m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]; - * - * var x = math.lusolve(m, [-1, -1, -1, -1]); // x = [[-1], [-0.5], [-1/3], [-0.25]] - * - * var f = math.lup(m); - * var x1 = math.lusolve(f, [-1, -1, -1, -1]); // x1 = [[-1], [-0.5], [-1/3], [-0.25]] - * var x2 = math.lusolve(f, [1, 2, 1, -1]); // x2 = [[1], [1], [1/3], [-0.25]] - * - * var a = [[-2, 3], [2, 1]]; - * var b = [11, 9]; - * var x = lusolve(a, b); // [[-5.5], [20]] - * - * See also: - * - * lup, slu, lsolve, usolve - * - * @param {Matrix | Array | Object} A Invertible Matrix or the Matrix LU decomposition - * @param {Matrix | Array} b Column Vector - * @param {number} [order] The Symbolic Ordering and Analysis order, see slu for details. Matrix must be a SparseMatrix - * @param {Number} [threshold] Partial pivoting threshold (1 for partial pivoting), see slu for details. Matrix must be a SparseMatrix. - * - * @return {DenseMatrix | Array} Column vector with the solution to the linear system A * x = b - */ - var lusolve = typed('lusolve', { - - 'Array, Array | Matrix': function (a, b) { - // convert a to matrix - a = matrix(a); - // matrix lup decomposition - var d = lup(a); - // solve - var x = _lusolve(d.L, d.U, d.p, null, b); - // convert result to array - return x.valueOf(); - }, - - 'DenseMatrix, Array | Matrix': function (a, b) { - // matrix lup decomposition - var d = lup(a); - // solve - return _lusolve(d.L, d.U, d.p, null, b); - }, - - 'SparseMatrix, Array | Matrix': function (a, b) { - // matrix lup decomposition - var d = lup(a); - // solve - return _lusolve(d.L, d.U, d.p, null, b); - }, - - 'SparseMatrix, Array | Matrix, number, number': function (a, b, order, threshold) { - // matrix lu decomposition - var d = slu(a, order, threshold); - // solve - return _lusolve(d.L, d.U, d.p, d.q, b); - }, - - 'Object, Array | Matrix': function (d, b) { - // solve - return _lusolve(d.L, d.U, d.p, d.q, b); - } - }); - - var _toMatrix = function (a) { - // check it is a matrix - if (a && a.isMatrix === true) - return a; - // check array - if (isArray(a)) - return matrix(a); - // throw - throw new TypeError('Invalid Matrix LU decomposition'); - }; - - var _lusolve = function (l, u, p, q, b) { - // verify L, U, P - l = _toMatrix(l); - u = _toMatrix(u); - // validate matrix and vector - b = solveValidation(l, b, false); - // apply row permutations if needed (b is a DenseMatrix) - if (p) - b._data = cs_ipvec(p, b._data); - // use forward substitution to resolve L * y = b - var y = lsolve(l, b); - // use backward substitution to resolve U * x = y - var x = usolve(u, y); - // apply column permutations if needed (x is a DenseMatrix) - if (q) - x._data = cs_ipvec(q, x._data); - // return solution - return x; - }; - - return lusolve; - } - - exports.name = 'lusolve'; - exports.factory = factory; - - -/***/ }, -/* 352 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory () { - - /** - * Permutes a vector; x = P'b. In MATLAB notation, x(p)=b. - * - * @param {Array} p The permutation vector of length n. null value denotes identity - * @param {Array} b The input vector - * - * @return {Array} The output vector x = P'b - */ - var cs_ipvec = function (p, b, n) { - // vars - var k; - var n = b.length; - var x = []; - // check permutation vector was provided, p = null denotes identity - if (p) { - // loop vector - for (k = 0; k < n; k++) { - // apply permutation - x[p[k]] = b[k]; - } - } - else { - // loop vector - for (k = 0; k < n; k++) { - // x[i] = b[i] - x[k] = b[k]; - } - } - return x; - }; - - return cs_ipvec; - } - - exports.name = 'cs_ipvec'; - exports.path = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 353 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var divideScalar = load(__webpack_require__(81)); - var multiplyScalar = load(__webpack_require__(80)); - var subtract = load(__webpack_require__(77)); - var equalScalar = load(__webpack_require__(48)); - - var solveValidation = load(__webpack_require__(350)); - - var DenseMatrix = type.DenseMatrix; - - /** - * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. - * - * `U * x = b` - * - * Syntax: - * - * math.usolve(U, b); - * - * Examples: - * - * var a = [[-2, 3], [2, 1]]; - * var b = [11, 9]; - * var x = usolve(a, b); // [[8], [9]] - * - * See also: - * - * lup, slu, usolve, lusolve - * - * @param {Matrix, Array} U A N x N matrix or array (U) - * @param {Matrix, Array} b A column vector with the b values - * - * @return {DenseMatrix | Array} A column vector with the linear system solution (x) - */ - var usolve = typed('usolve', { - - 'SparseMatrix, Array | Matrix': function (m, b) { - // process matrix - return _sparseBackwardSubstitution(m, b); - }, - - 'DenseMatrix, Array | Matrix': function (m, b) { - // process matrix - return _denseBackwardSubstitution(m, b); - }, - - 'Array, Array | Matrix': function (a, b) { - // create dense matrix from array - var m = matrix(a); - // use matrix implementation - var r = _denseBackwardSubstitution(m, b); - // result - return r.valueOf(); - } - }); - - var _denseBackwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = solveValidation(m, b, true); - // column vector data - var bdata = b._data; - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // result - var x = []; - // arrays - var data = m._data; - // backward solve m * x = b, loop columns (backwards) - for (var j = columns - 1; j >= 0 ; j--) { - // b[j] - var bj = bdata[j][0] || 0; - // x[j] - var xj; - // backward substitution (outer product) avoids inner looping when bj == 0 - if (!equalScalar(bj, 0)) { - // value @ [j, j] - var vjj = data[j][j]; - // check vjj - if (equalScalar(vjj, 0)) { - // system cannot be solved - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - xj = divideScalar(bj, vjj); - // loop rows - for (var i = j - 1; i >= 0; i--) { - // update copy of b - bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, data[i][j]))]; - } - } - else { - // zero value @ j - xj = 0; - } - // update x - x[j] = [xj]; - } - // return column vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - var _sparseBackwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = solveValidation(m, b, true); - // column vector data - var bdata = b._data; - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // vars - var i, k; - // result - var x = []; - // backward solve m * x = b, loop columns (backwards) - for (var j = columns - 1; j >= 0 ; j--) { - // b[j] - var bj = bdata[j][0] || 0; - // backward substitution (outer product) avoids inner looping when bj == 0 - if (!equalScalar(bj, 0)) { - // value @ [j, j] - var vjj = 0; - // upper triangular matrix values & index (column j) - var jvalues = []; - var jindex = []; - // first & last indeces in column - var f = ptr[j]; - var l = ptr[j + 1]; - // values in column, find value @ [j, j], loop backwards - for (k = l - 1; k >= f; k--) { - // row - i = index[k]; - // check row - if (i === j) { - // update vjj - vjj = values[k]; - } - else if (i < j) { - // store upper triangular - jvalues.push(values[k]); - jindex.push(i); - } - } - // at this point we must have a value @ [j, j] - if (equalScalar(vjj, 0)) { - // system cannot be solved, there is no value @ [j, j] - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - var xj = divideScalar(bj, vjj); - // loop upper triangular - for (k = 0, l = jindex.length; k < l; k++) { - // row - i = jindex[k]; - // update copy of b - bdata[i] = [subtract(bdata[i][0], multiplyScalar(xj, jvalues[k]))]; - } - // update x - x[j] = [xj]; - } - else { - // update x - x[j] = [0]; - } - } - // return vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - return usolve; - } - - exports.name = 'usolve'; - exports.factory = factory; - - -/***/ }, -/* 354 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(86), - __webpack_require__(51), - __webpack_require__(53), - __webpack_require__(355), - __webpack_require__(357), - __webpack_require__(358), - __webpack_require__(317), - __webpack_require__(359), - __webpack_require__(361), - __webpack_require__(363), - __webpack_require__(364), - __webpack_require__(365), - __webpack_require__(366), - __webpack_require__(367), - __webpack_require__(368), - __webpack_require__(371), - __webpack_require__(374), - __webpack_require__(375), - __webpack_require__(376), - __webpack_require__(84), - __webpack_require__(377), - __webpack_require__(379), - __webpack_require__(82), - __webpack_require__(380), - __webpack_require__(382), - __webpack_require__(369), - __webpack_require__(383), - __webpack_require__(77), - __webpack_require__(78), - __webpack_require__(384), - __webpack_require__(385) - ]; - - -/***/ }, -/* 355 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var unaryMinus = load(__webpack_require__(78)); - var isNegative = load(__webpack_require__(356)); - var matrix = load(__webpack_require__(52)); - - /** - * Calculate the cubic root of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cbrt(x) - * math.cbrt(x, allRoots) - * - * Examples: - * - * math.cbrt(27); // returns 3 - * math.cube(3); // returns 27 - * math.cbrt(-64); // returns -4 - * math.cbrt(math.unit('27 m^3')); // returns Unit 3 m - * math.cbrt([27, 64, 125]); // returns [3, 4, 5] - * - * var x = math.complex('8i'); - * math.cbrt(x); // returns Complex 1.7320508075689 + i - * math.cbrt(x, true); // returns Matrix [ - * // 1.7320508075689 + i - * // -1.7320508075689 + i - * // -2i - * // ] - * - * See also: - * - * square, sqrt, cube - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x - * Value for which to calculate the cubic root. - * @param {boolean} [allRoots] Optional, false by default. Only applicable - * when `x` is a number or complex number. If true, all complex - * roots are returned, if false (default) the principal root is - * returned. - * @return {number | BigNumber | Complex | Unit | Array | Matrix} - * Returns the cubic root of `x` - */ - var cbrt = typed('cbrt', { - 'number': _cbrtNumber, - // note: signature 'number, boolean' is also supported, - // created by typed as it knows how to convert number to Complex - - 'Complex': _cbrtComplex, - - 'Complex, boolean': _cbrtComplex, - - 'BigNumber': function (x) { - return x.cbrt(); - }, - - 'Unit': _cbrtUnit, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since cbrt(0) = 0 - return deepMap(x, cbrt, true); - } - }); - - /** - * Calculate the cubic root for a complex number - * @param {Complex} x - * @param {boolean} [allRoots] If true, the function will return an array - * with all three roots. If false or undefined, - * the principal root is returned. - * @returns {Complex | Array. | Matrix.} Returns the cubic root(s) of x - * @private - */ - function _cbrtComplex(x, allRoots) { - // https://www.wikiwand.com/en/Cube_root#/Complex_numbers - - var arg_3 = x.arg() / 3; - var abs = x.abs(); - - // principal root: - var principal = new type.Complex(_cbrtNumber(abs), 0).mul( - new type.Complex(0, arg_3).exp()); - - if (allRoots) { - var all = [ - principal, - new type.Complex(_cbrtNumber(abs), 0).mul( - new type.Complex(0, arg_3 + Math.PI * 2 / 3).exp()), - new type.Complex(_cbrtNumber(abs), 0).mul( - new type.Complex(0, arg_3 - Math.PI * 2 / 3).exp()) - ]; - - return (config.matrix === 'Array') ? all : matrix(all); - } - else { - return principal; - } - } - - /** - * Calculate the cubic root for a Unit - * @param {Unit} x - * @return {Unit} Returns the cubic root of x - * @private - */ - function _cbrtUnit(x) { - if(x.value && x.value.isComplex) { - var result = x.clone(); - result.value = 1.0; - result = result.pow(1.0/3); // Compute the units - result.value = _cbrtComplex(x.value); // Compute the value - return result; - } - else { - var negate = isNegative(x.value); - if (negate) { - x.value = unaryMinus(x.value); - } - - // TODO: create a helper function for this - var third; - if (x.value && x.value.isBigNumber) { - third = new type.BigNumber(1).div(3); - } - else if (x.value && x.value.isFraction) { - third = new type.Fraction(1, 3); - } - else { - third = 1/3; - } - - var result = x.pow(third); - - if (negate) { - result.value = unaryMinus(result.value); - } - - return result; - } - } - - cbrt.toTex = {1: '\\sqrt[3]{${args[0]}}'}; - - return cbrt; - } - - /** - * Calculate cbrt for a number - * - * Code from es6-shim.js: - * https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1564-L1577 - * - * @param {number} x - * @returns {number | Complex} Returns the cubic root of x - * @private - */ - var _cbrtNumber = Math.cbrt || function (x) { - if (x === 0) { - return x; - } - - var negate = x < 0; - var result; - if (negate) { - x = -x; - } - - if (isFinite(x)) { - result = Math.exp(Math.log(x) / 3); - // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods - result = (x / (result * result) + (2 * result)) / 3; - } else { - result = x; - } - - return negate ? -result : result; - }; - - exports.name = 'cbrt'; - exports.factory = factory; - - -/***/ }, -/* 356 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Test whether a value is negative: smaller than zero. - * The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`. - * - * The function is evaluated element-wise in case of Array or Matrix input. - * - * Syntax: - * - * math.isNegative(x) - * - * Examples: - * - * math.isNegative(3); // returns false - * math.isNegative(-2); // returns true - * math.isNegative(0); // returns false - * math.isNegative(-0); // returns false - * math.isNegative(math.bignumber(2)); // returns false - * math.isNegative(math.fraction(-2, 5)); // returns true - * math.isNegative('-2'); // returns true - * math.isNegative([2, 0, -3]'); // returns [false, false, true] - * - * See also: - * - * isNumeric, isPositive, isZero, isInteger - * - * @param {number | BigNumber | Fraction | Unit | Array | Matrix} x Value to be tested - * @return {boolean} Returns true when `x` is larger than zero. - * Throws an error in case of an unknown data type. - */ - var isNegative = typed('isNegative', { - 'number': function (x) { - return x < 0; - }, - - 'BigNumber': function (x) { - return x.isNeg() && !x.isZero() && !x.isNaN(); - }, - - 'Fraction': function (x) { - return x.s < 0; // It's enough to decide on the sign - }, - - 'Unit': function (x) { - return isNegative(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, isNegative); - } - }); - - return isNegative; - } - - exports.name = 'isNegative'; - exports.factory = factory; - - -/***/ }, -/* 357 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Round a value towards plus infinity - * If `x` is complex, both real and imaginary part are rounded towards plus infinity. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.ceil(x) - * - * Examples: - * - * math.ceil(3.2); // returns number 4 - * math.ceil(3.8); // returns number 4 - * math.ceil(-4.2); // returns number -4 - * math.ceil(-4.7); // returns number -4 - * - * var c = math.complex(3.2, -2.7); - * math.ceil(c); // returns Complex 4 - 2i - * - * math.ceil([3.2, 3.8, -4.7]); // returns Array [4, 4, -4] - * - * See also: - * - * floor, fix, round - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded - * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value - */ - var ceil = typed('ceil', { - 'number': Math.ceil, - - 'Complex': function (x) { - return x.ceil(); - }, - - 'BigNumber': function (x) { - return x.ceil(); - }, - - 'Fraction': function (x) { - return x.ceil(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since ceil(0) = 0 - return deepMap(x, ceil, true); - } - }); - - ceil.toTex = {1: '\\left\\lceil${args[0]}\\right\\rceil'}; - - return ceil; - } - - exports.name = 'ceil'; - exports.factory = factory; - - -/***/ }, -/* 358 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Compute the cube of a value, `x * x * x`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cube(x) - * - * Examples: - * - * math.cube(2); // returns number 8 - * math.pow(2, 3); // returns number 8 - * math.cube(4); // returns number 64 - * 4 * 4 * 4; // returns number 64 - * - * math.cube([1, 2, 3, 4]); // returns Array [1, 8, 27, 64] - * - * See also: - * - * multiply, square, pow, cbrt - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x Number for which to calculate the cube - * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} Cube of x - */ - var cube = typed('cube', { - 'number': function (x) { - return x * x * x; - }, - - 'Complex': function (x) { - return x.mul(x).mul(x); // Is faster than pow(x, 3) - }, - - 'BigNumber': function (x) { - return x.times(x).times(x); - }, - - 'Fraction': function (x) { - return x.pow(3); // Is faster than mul()mul()mul() - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since cube(0) = 0 - return deepMap(x, cube, true); - }, - - 'Unit': function(x) { - return x.pow(3); - } - }); - - cube.toTex = {1: '\\left(${args[0]}\\right)^3'}; - - return cube; - } - - exports.name = 'cube'; - exports.factory = factory; - - -/***/ }, -/* 359 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var divideScalar = load(__webpack_require__(81)); - var latex = __webpack_require__(32); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Divide two matrices element wise. The function accepts both matrices and - * scalar values. - * - * Syntax: - * - * math.dotDivide(x, y) - * - * Examples: - * - * math.dotDivide(2, 4); // returns 0.5 - * - * a = [[9, 5], [6, 1]]; - * b = [[3, 2], [5, 2]]; - * - * math.dotDivide(a, b); // returns [[3, 2.5], [1.2, 0.5]] - * math.divide(a, b); // returns [[1.75, 0.75], [-1.75, 2.25]] - * - * See also: - * - * divide, multiply, dotMultiply - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Numerator - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Denominator - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Quotient, `x ./ y` - */ - var dotDivide = typed('dotDivide', { - - 'any, any': divideScalar, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse ./ sparse - c = algorithm07(x, y, divideScalar, false); - break; - default: - // sparse ./ dense - c = algorithm02(y, x, divideScalar, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense ./ sparse - c = algorithm03(x, y, divideScalar, false); - break; - default: - // dense ./ dense - c = algorithm13(x, y, divideScalar); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return dotDivide(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return dotDivide(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return dotDivide(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, divideScalar, false); - break; - default: - c = algorithm14(x, y, divideScalar, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, divideScalar, true); - break; - default: - c = algorithm14(y, x, divideScalar, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, divideScalar, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, divideScalar, true).valueOf(); - } - }); - - dotDivide.toTex = { - 2: '\\left(${args[0]}' + latex.operators['dotDivide'] + '${args[1]}\\right)' - }; - - return dotDivide; - } - - exports.name = 'dotDivide'; - exports.factory = factory; - - -/***/ }, -/* 360 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). - * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). - * - * - * ┌ f(Dij, Sij) ; S(i,j) !== 0 - * C(i,j) = ┤ - * └ 0 ; otherwise - * - * - * @param {Matrix} denseMatrix The DenseMatrix instance (D) - * @param {Matrix} sparseMatrix The SparseMatrix instance (S) - * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) - * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 - */ - var algorithm02 = function (denseMatrix, sparseMatrix, callback, inverse) { - // dense matrix arrays - var adata = denseMatrix._data; - var asize = denseMatrix._size; - var adt = denseMatrix._datatype; - // sparse matrix arrays - var bvalues = sparseMatrix._values; - var bindex = sparseMatrix._index; - var bptr = sparseMatrix._ptr; - var bsize = sparseMatrix._size; - var bdt = sparseMatrix._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // sparse matrix cannot be a Pattern matrix - if (!bvalues) - throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result (SparseMatrix) - var cvalues = []; - var cindex = []; - var cptr = []; - - // loop columns in b - for (var j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // values in column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - var i = bindex[k]; - // update C(i,j) - var cij = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); - // check for nonzero - if (!eq(cij, zero)) { - // push i & v - cindex.push(i); - cvalues.push(cij); - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - }; - - return algorithm02; - } - - exports.name = 'algorithm02'; - exports.factory = factory; - - -/***/ }, -/* 361 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var multiplyScalar = load(__webpack_require__(80)); - var latex = __webpack_require__(32); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm09 = load(__webpack_require__(362)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Multiply two matrices element wise. The function accepts both matrices and - * scalar values. - * - * Syntax: - * - * math.dotMultiply(x, y) - * - * Examples: - * - * math.dotMultiply(2, 4); // returns 8 - * - * a = [[9, 5], [6, 1]]; - * b = [[3, 2], [5, 2]]; - * - * math.dotMultiply(a, b); // returns [[27, 10], [30, 2]] - * math.multiply(a, b); // returns [[52, 28], [23, 14]] - * - * See also: - * - * multiply, divide, dotDivide - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Left hand value - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Right hand value - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` - */ - var dotMultiply = typed('dotMultiply', { - - 'any, any': multiplyScalar, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse .* sparse - c = algorithm09(x, y, multiplyScalar, false); - break; - default: - // sparse .* dense - c = algorithm02(y, x, multiplyScalar, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense .* sparse - c = algorithm02(x, y, multiplyScalar, false); - break; - default: - // dense .* dense - c = algorithm13(x, y, multiplyScalar); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return dotMultiply(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return dotMultiply(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return dotMultiply(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, multiplyScalar, false); - break; - default: - c = algorithm14(x, y, multiplyScalar, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm11(y, x, multiplyScalar, true); - break; - default: - c = algorithm14(y, x, multiplyScalar, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, multiplyScalar, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, multiplyScalar, true).valueOf(); - } - }); - - dotMultiply.toTex = { - 2: '\\left(${args[0]}' + latex.operators['dotMultiply'] + '${args[1]}\\right)' - }; - - return dotMultiply; - } - - exports.name = 'dotMultiply'; - exports.factory = factory; - - -/***/ }, -/* 362 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix A and invokes the callback function f(Aij, Bij). - * Callback function invoked NZA times, number of nonzero elements in A. - * - * - * ┌ f(Aij, Bij) ; A(i,j) !== 0 - * C(i,j) = ┤ - * └ 0 ; otherwise - * - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm09 = function (a, b, callback) { - // sparse matrix arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = avalues && bvalues ? [] : undefined; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var x = cvalues ? [] : undefined; - // marks indicating we have a value in x for a given column - var w = []; - - // vars - var i, j, k, k0, k1; - - // loop columns - for (j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // column mark - var mark = j + 1; - // check we need to process values - if (x) { - // loop B(:,j) - for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - i = bindex[k]; - // update workspace - w[i] = mark; - x[i] = bvalues[k]; - } - } - // loop A(:,j) - for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - i = aindex[k]; - // check we need to process values - if (x) { - // b value @ i,j - var vb = w[i] === mark ? x[i] : zero; - // invoke f - var vc = cf(avalues[k], vb); - // check zero value - if (!eq(vc, zero)) { - // push index - cindex.push(i); - // push value - cvalues.push(vc); - } - } - else { - // push index - cindex.push(i); - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm09; - } - - exports.name = 'algorithm09'; - exports.factory = factory; - - -/***/ }, -/* 363 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var pow = load(__webpack_require__(82)); - var latex = __webpack_require__(32); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculates the power of x to y element wise. - * - * Syntax: - * - * math.dotPow(x, y) - * - * Examples: - * - * math.dotPow(2, 3); // returns number 8 - * - * var a = [[1, 2], [4, 3]]; - * math.dotPow(a, 2); // returns Array [[1, 4], [16, 9]] - * math.pow(a, 2); // returns Array [[9, 8], [16, 17]] - * - * See also: - * - * pow, sqrt, multiply - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x The base - * @param {number | BigNumber | Complex | Unit | Array | Matrix} y The exponent - * @return {number | BigNumber | Complex | Unit | Array | Matrix} The value of `x` to the power `y` - */ - var dotPow = typed('dotPow', { - - 'any, any': pow, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse .^ sparse - c = algorithm07(x, y, pow, false); - break; - default: - // sparse .^ dense - c = algorithm03(y, x, pow, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense .^ sparse - c = algorithm03(x, y, pow, false); - break; - default: - // dense .^ dense - c = algorithm13(x, y, pow); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return dotPow(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return dotPow(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return dotPow(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, dotPow, false); - break; - default: - c = algorithm14(x, y, dotPow, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, dotPow, true); - break; - default: - c = algorithm14(y, x, dotPow, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, dotPow, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, dotPow, true).valueOf(); - } - }); - - dotPow.toTex = { - 2: '\\left(${args[0]}' + latex.operators['dotPow'] + '${args[1]}\\right)' - }; - - return dotPow; - } - - exports.name = 'dotPow'; - exports.factory = factory; - - -/***/ }, -/* 364 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the exponent of a value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.exp(x) - * - * Examples: - * - * math.exp(2); // returns number 7.3890560989306495 - * math.pow(math.e, 2); // returns number 7.3890560989306495 - * math.log(math.exp(2)); // returns number 2 - * - * math.exp([1, 2, 3]); - * // returns Array [ - * // 2.718281828459045, - * // 7.3890560989306495, - * // 20.085536923187668 - * // ] - * - * See also: - * - * log, pow - * - * @param {number | BigNumber | Complex | Array | Matrix} x A number or matrix to exponentiate - * @return {number | BigNumber | Complex | Array | Matrix} Exponent of `x` - */ - var exp = typed('exp', { - 'number': Math.exp, - - 'Complex': function (x) { - return x.exp(); - }, - - 'BigNumber': function (x) { - return x.exp(); - }, - - 'Array | Matrix': function (x) { - // TODO: exp(sparse) should return a dense matrix since exp(0)==1 - return deepMap(x, exp); - } - }); - - exp.toTex = {1: '\\exp\\left(${args[0]}\\right)'}; - - return exp; - } - - exports.name = 'exp'; - exports.factory = factory; - - -/***/ }, -/* 365 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Round a value towards zero. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.fix(x) - * - * Examples: - * - * math.fix(3.2); // returns number 3 - * math.fix(3.8); // returns number 3 - * math.fix(-4.2); // returns number -4 - * math.fix(-4.7); // returns number -4 - * - * var c = math.complex(3.2, -2.7); - * math.fix(c); // returns Complex 3 - 2i - * - * math.fix([3.2, 3.8, -4.7]); // returns Array [3, 3, -4] - * - * See also: - * - * ceil, floor, round - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded - * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value - */ - var fix = typed('fix', { - 'number': function (x) { - return (x > 0) ? Math.floor(x) : Math.ceil(x); - }, - - 'Complex': function (x) { - return new type.Complex( - (x.re > 0) ? Math.floor(x.re) : Math.ceil(x.re), - (x.im > 0) ? Math.floor(x.im) : Math.ceil(x.im) - ); - }, - - 'BigNumber': function (x) { - return x.isNegative() ? x.ceil() : x.floor(); - }, - - 'Fraction': function (x) { - return x.s < 0 ? x.ceil() : x.floor(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since fix(0) = 0 - return deepMap(x, fix, true); - } - }); - - fix.toTex = {1: '\\mathrm{${name}}\\left(${args[0]}\\right)'}; - - return fix; - } - - exports.name = 'fix'; - exports.factory = factory; - - -/***/ }, -/* 366 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Round a value towards minus infinity. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.floor(x) - * - * Examples: - * - * math.floor(3.2); // returns number 3 - * math.floor(3.8); // returns number 3 - * math.floor(-4.2); // returns number -5 - * math.floor(-4.7); // returns number -5 - * - * var c = math.complex(3.2, -2.7); - * math.floor(c); // returns Complex 3 - 3i - * - * math.floor([3.2, 3.8, -4.7]); // returns Array [3, 3, -5] - * - * See also: - * - * ceil, fix, round - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded - * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value - */ - var floor = typed('floor', { - 'number': Math.floor, - - 'Complex': function (x) { - return x.floor(); - }, - - 'BigNumber': function (x) { - return x.floor(); - }, - - 'Fraction': function (x) { - return x.floor(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since floor(0) = 0 - return deepMap(x, floor, true); - } - }); - - floor.toTex = {1: '\\left\\lfloor${args[0]}\\right\\rfloor'}; - - return floor; - } - - exports.name = 'floor'; - exports.factory = factory; - - -/***/ }, -/* 367 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm04 = load(__webpack_require__(55)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculate the greatest common divisor for two or more values or arrays. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.gcd(a, b) - * math.gcd(a, b, c, ...) - * - * Examples: - * - * math.gcd(8, 12); // returns 4 - * math.gcd(-4, 6); // returns 2 - * math.gcd(25, 15, -10); // returns 5 - * - * math.gcd([8, -4], [12, 6]); // returns [4, 2] - * - * See also: - * - * lcm, xgcd - * - * @param {... number | BigNumber | Fraction | Array | Matrix} args Two or more integer numbers - * @return {number | BigNumber | Fraction | Array | Matrix} The greatest common divisor - */ - var gcd = typed('gcd', { - - 'number, number': _gcd, - - 'BigNumber, BigNumber': _gcdBigNumber, - - 'Fraction, Fraction': function (x, y) { - return x.gcd(y); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm04(x, y, gcd); - break; - default: - // sparse + dense - c = algorithm01(y, x, gcd, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm01(x, y, gcd, false); - break; - default: - // dense + dense - c = algorithm13(x, y, gcd); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return gcd(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return gcd(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return gcd(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm10(x, y, gcd, false); - break; - default: - c = algorithm14(x, y, gcd, false); - break; - } - return c; - }, - - 'number | BigNumber, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, gcd, true); - break; - default: - c = algorithm14(y, x, gcd, true); - break; - } - return c; - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, gcd, false).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, gcd, true).valueOf(); - }, - - // TODO: need a smarter notation here - 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { - var res = gcd(a, b); - for (var i = 0; i < args.length; i++) { - res = gcd(res, args[i]); - } - return res; - } - }); - - gcd.toTex = '\\gcd\\left(${args}\\right)'; - - return gcd; - - /** - * Calculate gcd for BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @returns {BigNumber} Returns greatest common denominator of a and b - * @private - */ - function _gcdBigNumber(a, b) { - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function gcd must be integer numbers'); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - var zero = new type.BigNumber(0); - while (!b.isZero()) { - var r = a.mod(b); - a = b; - b = r; - } - return a.lt(zero) ? a.neg() : a; - } - } - - /** - * Calculate gcd for numbers - * @param {number} a - * @param {number} b - * @returns {number} Returns the greatest common denominator of a and b - * @private - */ - function _gcd(a, b) { - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function gcd must be integer numbers'); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - var r; - while (b != 0) { - r = a % b; - a = b; - b = r; - } - return (a < 0) ? -a : a; - } - - exports.name = 'gcd'; - exports.factory = factory; - - -/***/ }, -/* 368 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var flatten = __webpack_require__(40).flatten; - - function factory (type, config, load, typed) { - var abs = load(__webpack_require__(86)); - var add = load(__webpack_require__(53)); - var divide = load(__webpack_require__(81)); - var multiply = load(__webpack_require__(80)); - var sqrt = load(__webpack_require__(369)); - var smaller = load(__webpack_require__(60)); - var isPositive = load(__webpack_require__(370)); - - /** - * Calculate the hypotenusa of a list with values. The hypotenusa is defined as: - * - * hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) - * - * For matrix input, the hypotenusa is calculated for all values in the matrix. - * - * Syntax: - * - * math.hypot(a, b, ...) - * math.hypot([a, b, c, ...]) - * - * Examples: - * - * math.hypot(3, 4); // 5 - * math.hypot(3, 4, 5); // 7.0710678118654755 - * math.hypot([3, 4, 5]); // 7.0710678118654755 - * math.hypot(-2); // 2 - * - * See also: - * - * abs, norm - * - * @param {... number | BigNumber} args - * @return {number | BigNumber} Returns the hypothenusa of the input values. - */ - var hypot = typed('hypot', { - '... number | BigNumber': _hypot, - - 'Array': function (x) { - return hypot.apply(hypot, flatten(x)); - }, - - 'Matrix': function (x) { - return hypot.apply(hypot, flatten(x.toArray())); - } - }); - - /** - * Calculate the hypotenusa for an Array with values - * @param {Array.} args - * @return {number | BigNumber} Returns the result - * @private - */ - function _hypot (args) { - // code based on `hypot` from es6-shim: - // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1619-L1633 - var result = 0; - var largest = 0; - - for (var i = 0; i < args.length; i++) { - var value = abs(args[i]); - if (smaller(largest, value)) { - result = multiply(result, multiply(divide(largest, value), divide(largest, value))); - result = add(result, 1); - largest = value; - } else { - result = add(result, isPositive(value) ? multiply(divide(value, largest), divide(value, largest)) : value); - } - } - - return multiply(largest, sqrt(result)); - } - - hypot.toTex = '\\hypot\\left(${args}\\right)'; - - return hypot; - } - - exports.name = 'hypot'; - exports.factory = factory; - - -/***/ }, -/* 369 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the square root of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sqrt(x) - * - * Examples: - * - * math.sqrt(25); // returns 5 - * math.square(5); // returns 25 - * math.sqrt(-4); // returns Complex 2i - * - * See also: - * - * square, multiply, cube, cbrt - * - * @param {number | BigNumber | Complex | Array | Matrix | Unit} x - * Value for which to calculate the square root. - * @return {number | BigNumber | Complex | Array | Matrix | Unit} - * Returns the square root of `x` - */ - var sqrt = typed('sqrt', { - 'number': _sqrtNumber, - - 'Complex': function (x) { - return x.sqrt(); - }, - - 'BigNumber': function (x) { - if (!x.isNegative() || config.predictable) { - return x.sqrt(); - } - else { - // negative value -> downgrade to number to do complex value computation - return _sqrtNumber(x.toNumber()); - } - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sqrt(0) = 0 - return deepMap(x, sqrt, true); - }, - - 'Unit': function (x) { - // Someday will work for complex units when they are implemented - return x.pow(0.5); - } - - }); - - /** - * Calculate sqrt for a number - * @param {number} x - * @returns {number | Complex} Returns the square root of x - * @private - */ - function _sqrtNumber(x) { - if (x >= 0 || config.predictable) { - return Math.sqrt(x); - } - else { - return new type.Complex(x, 0).sqrt(); - } - } - - sqrt.toTex = {1: '\\sqrt{${args[0]}}'}; - - return sqrt; - } - - exports.name = 'sqrt'; - exports.factory = factory; - - -/***/ }, -/* 370 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Test whether a value is positive: larger than zero. - * The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`. - * - * The function is evaluated element-wise in case of Array or Matrix input. - * - * Syntax: - * - * math.isPositive(x) - * - * Examples: - * - * math.isPositive(3); // returns true - * math.isPositive(-2); // returns false - * math.isPositive(0); // returns false - * math.isPositive(-0); // returns false - * math.isPositive(0.5); // returns true - * math.isPositive(math.bignumber(2)); // returns true - * math.isPositive(math.fraction(-2, 5)); // returns false - * math.isPositive(math.fraction(1,3)); // returns false - * math.isPositive('2'); // returns true - * math.isPositive([2, 0, -3]'); // returns [true, false, false] - * - * See also: - * - * isNumeric, isZero, isNegative, isInteger - * - * @param {number | BigNumber | Fraction | Unit | Array | Matrix} x Value to be tested - * @return {boolean} Returns true when `x` is larger than zero. - * Throws an error in case of an unknown data type. - */ - var isPositive = typed('isPositive', { - 'number': function (x) { - return x > 0; - }, - - 'BigNumber': function (x) { - return !x.isNeg() && !x.isZero() && !x.isNaN(); - }, - - 'Fraction': function (x) { - return x.s > 0 && x.n > 0; - }, - - 'Unit': function (x) { - return isPositive(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, isPositive); - } - }); - - return isPositive; - } - - exports.name = 'isPositive'; - exports.factory = factory; - - -/***/ }, -/* 371 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm06 = load(__webpack_require__(372)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculate the least common multiple for two or more values or arrays. - * - * lcm is defined as: - * - * lcm(a, b) = abs(a * b) / gcd(a, b) - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.lcm(a, b) - * math.lcm(a, b, c, ...) - * - * Examples: - * - * math.lcm(4, 6); // returns 12 - * math.lcm(6, 21); // returns 42 - * math.lcm(6, 21, 5); // returns 210 - * - * math.lcm([4, 6], [6, 21]); // returns [12, 42] - * - * See also: - * - * gcd, xgcd - * - * @param {... number | BigNumber | Array | Matrix} args Two or more integer numbers - * @return {number | BigNumber | Array | Matrix} The least common multiple - */ - var lcm = typed('lcm', { - 'number, number': _lcm, - - 'BigNumber, BigNumber': _lcmBigNumber, - - 'Fraction, Fraction': function (x, y) { - - return x.lcm(y); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm06(x, y, lcm); - break; - default: - // sparse + dense - c = algorithm02(y, x, lcm, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm02(x, y, lcm, false); - break; - default: - // dense + dense - c = algorithm13(x, y, lcm); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return lcm(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return lcm(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return lcm(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, lcm, false); - break; - default: - c = algorithm14(x, y, lcm, false); - break; - } - return c; - }, - - 'number | BigNumber, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm11(y, x, lcm, true); - break; - default: - c = algorithm14(y, x, lcm, true); - break; - } - return c; - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, lcm, false).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, lcm, true).valueOf(); - }, - - // TODO: need a smarter notation here - 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { - var res = lcm(a, b); - for (var i = 0; i < args.length; i++) { - res = lcm(res, args[i]); - } - return res; - } - }); - - lcm.toTex = undefined; // use default template - - return lcm; - - /** - * Calculate lcm for two BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @returns {BigNumber} Returns the least common multiple of a and b - * @private - */ - function _lcmBigNumber(a, b) { - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function lcm must be integer numbers'); - } - - if (a.isZero() || b.isZero()) { - return new type.BigNumber(0); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - // evaluate lcm here inline to reduce overhead - var prod = a.times(b); - while (!b.isZero()) { - var t = b; - b = a.mod(t); - a = t; - } - return prod.div(a).abs(); - } - } - - /** - * Calculate lcm for two numbers - * @param {number} a - * @param {number} b - * @returns {number} Returns the least common multiple of a and b - * @private - */ - function _lcm (a, b) { - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function lcm must be integer numbers'); - } - - if (a == 0 || b == 0) { - return 0; - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - // evaluate lcm here inline to reduce overhead - var t; - var prod = a * b; - while (b != 0) { - t = b; - b = a % t; - a = t; - } - return Math.abs(prod / a); - } - - exports.name = 'lcm'; - exports.factory = factory; - - -/***/ }, -/* 372 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var scatter = __webpack_require__(373); - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). - * Callback function invoked (Anz U Bnz) times, where Anz and Bnz are the nonzero elements in both matrices. - * - * - * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 - * C(i,j) = ┤ - * └ 0 ; otherwise - * - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm06 = function (a, b, callback) { - // sparse matrix arrays - var avalues = a._values; - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bvalues = b._values; - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = avalues && bvalues ? [] : undefined; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // workspaces - var x = cvalues ? [] : undefined; - // marks indicating we have a value in x for a given column - var w = []; - // marks indicating value in a given row has been updated - var u = []; - - // loop columns - for (var j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // columns mark - var mark = j + 1; - // scatter the values of A(:,j) into workspace - scatter(a, j, w, x, u, mark, c, cf); - // scatter the values of B(:,j) into workspace - scatter(b, j, w, x, u, mark, c, cf); - // check we need to process values (non pattern matrix) - if (x) { - // initialize first index in j - var k = cptr[j]; - // loop index in j - while (k < cindex.length) { - // row - var i = cindex[k]; - // check function was invoked on current row (Aij !=0 && Bij != 0) - if (u[i] === mark) { - // value @ i - var v = x[i]; - // check for zero value - if (!eq(v, zero)) { - // push value - cvalues.push(v); - // increment pointer - k++; - } - else { - // remove value @ i, do not increment pointer - cindex.splice(k, 1); - } - } - else { - // remove value @ i, do not increment pointer - cindex.splice(k, 1); - } - } - } - else { - // initialize first index in j - var p = cptr[j]; - // loop index in j - while (p < cindex.length) { - // row - var r = cindex[p]; - // check function was invoked on current row (Aij !=0 && Bij != 0) - if (u[r] !== mark) { - // remove value @ i, do not increment pointer - cindex.splice(p, 1); - } - else { - // increment pointer - p++; - } - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm06; - } - - exports.name = 'algorithm06'; - exports.factory = factory; - - -/***/ }, -/* 373 */ -/***/ function(module, exports) { - - 'use strict'; - - module.exports = function scatter(a, j, w, x, u, mark, c, f, inverse, update, value) { - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - // c arrays - var cindex = c._index; - - // vars - var k, k0, k1, i; - - // check we need to process values (pattern matrix) - if (x) { - // values in j - for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - i = aindex[k]; - // check value exists in current j - if (w[i] !== mark) { - // i is new entry in j - w[i] = mark; - // add i to pattern of C - cindex.push(i); - // x(i) = A, check we need to call function this time - if (update) { - // copy value to workspace calling callback function - x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]); - // function was called on current row - u[i] = mark; - } - else { - // copy value to workspace - x[i] = avalues[k]; - } - } - else { - // i exists in C already - x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]); - // function was called on current row - u[i] = mark; - } - } - } - else { - // values in j - for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - i = aindex[k]; - // check value exists in current j - if (w[i] !== mark) { - // i is new entry in j - w[i] = mark; - // add i to pattern of C - cindex.push(i); - } - else { - // indicate function was called on current row - u[i] = mark; - } - } - } - }; - - -/***/ }, -/* 374 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var divideScalar = load(__webpack_require__(81)); - - /** - * Calculate the logarithm of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.log(x) - * math.log(x, base) - * - * Examples: - * - * math.log(3.5); // returns 1.252762968495368 - * math.exp(math.log(2.4)); // returns 2.4 - * - * math.pow(10, 4); // returns 10000 - * math.log(10000, 10); // returns 4 - * math.log(10000) / math.log(10); // returns 4 - * - * math.log(1024, 2); // returns 10 - * math.pow(2, 10); // returns 1024 - * - * See also: - * - * exp, log10 - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * Value for which to calculate the logarithm. - * @param {number | BigNumber | Complex} [base=e] - * Optional base for the logarithm. If not provided, the natural - * logarithm of `x` is calculated. - * @return {number | BigNumber | Complex | Array | Matrix} - * Returns the logarithm of `x` - */ - var log = typed('log', { - 'number': function (x) { - if (x >= 0 || config.predictable) { - return Math.log(x); - } - else { - // negative value -> complex value computation - return new type.Complex(x, 0).log(); - } - }, - - 'Complex': function (x) { - return x.log(); - }, - - 'BigNumber': function (x) { - if (!x.isNegative() || config.predictable) { - return x.ln(); - } - else { - // downgrade to number, return Complex valued result - return new type.Complex(x.toNumber(), 0).log(); - } - }, - - 'Array | Matrix': function (x) { - return deepMap(x, log); - }, - - 'any, any': function (x, base) { - // calculate logarithm for a specified base, log(x, base) - return divideScalar(log(x), log(base)); - } - }); - - log.toTex = { - 1: '\\ln\\left(${args[0]}\\right)', - 2: '\\log_{${args[1]}}\\left(${args[0]}\\right)' - }; - - return log; - } - - exports.name = 'log'; - exports.factory = factory; - - -/***/ }, -/* 375 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the 10-base logarithm of a value. This is the same as calculating `log(x, 10)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.log10(x) - * - * Examples: - * - * math.log10(0.00001); // returns -5 - * math.log10(10000); // returns 4 - * math.log(10000) / math.log(10); // returns 4 - * math.pow(10, 4); // returns 10000 - * - * See also: - * - * exp, log - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * Value for which to calculate the logarithm. - * @return {number | BigNumber | Complex | Array | Matrix} - * Returns the 10-base logarithm of `x` - */ - var log10 = typed('log10', { - 'number': function (x) { - if (x >= 0 || config.predictable) { - return _log10(x); - } - else { - // negative value -> complex value computation - return new type.Complex(x, 0).log().div(Math.LN10); - } - }, - - 'Complex': function (x) { - return new type.Complex(x).log().div(Math.LN10); - }, - - 'BigNumber': function (x) { - if (!x.isNegative() || config.predictable) { - return x.log(); - } - else { - // downgrade to number, return Complex valued result - return new type.Complex(x.toNumber(), 0).log().div(Math.LN10); - } - }, - - 'Array | Matrix': function (x) { - return deepMap(x, log10); - } - }); - - log10.toTex = {1: '\\log_{10}\\left(${args[0]}\\right)'}; - - return log10; - } - - /** - * Calculate the 10-base logarithm of a number - * @param {number} x - * @return {number} - * @private - */ - var _log10 = Math.log10 || function (x) { - return Math.log(x) / Math.LN10; - }; - - exports.name = 'log10'; - exports.factory = factory; - - - -/***/ }, -/* 376 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var latex = __webpack_require__(32); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm03 = load(__webpack_require__(61)); - var algorithm05 = load(__webpack_require__(79)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculates the modulus, the remainder of an integer division. - * - * For matrices, the function is evaluated element wise. - * - * The modulus is defined as: - * - * x - y * floor(x / y) - * - * See http://en.wikipedia.org/wiki/Modulo_operation. - * - * Syntax: - * - * math.mod(x, y) - * - * Examples: - * - * math.mod(8, 3); // returns 2 - * math.mod(11, 2); // returns 1 - * - * function isOdd(x) { - * return math.mod(x, 2) != 0; - * } - * - * isOdd(2); // returns false - * isOdd(3); // returns true - * - * See also: - * - * divide - * - * @param {number | BigNumber | Fraction | Array | Matrix} x Dividend - * @param {number | BigNumber | Fraction | Array | Matrix} y Divisor - * @return {number | BigNumber | Fraction | Array | Matrix} Returns the remainder of `x` divided by `y`. - */ - var mod = typed('mod', { - - 'number, number': _mod, - - 'BigNumber, BigNumber': function (x, y) { - return y.isZero() ? x : x.mod(y); - }, - - 'Fraction, Fraction': function (x, y) { - return x.mod(y); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // mod(sparse, sparse) - c = algorithm05(x, y, mod, false); - break; - default: - // mod(sparse, dense) - c = algorithm02(y, x, mod, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // mod(dense, sparse) - c = algorithm03(x, y, mod, false); - break; - default: - // mod(dense, dense) - c = algorithm13(x, y, mod); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return mod(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return mod(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return mod(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, mod, false); - break; - default: - c = algorithm14(x, y, mod, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, mod, true); - break; - default: - c = algorithm14(y, x, mod, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, mod, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, mod, true).valueOf(); - } - }); - - mod.toTex = { - 2: '\\left(${args[0]}' + latex.operators['mod'] + '${args[1]}\\right)' - }; - - return mod; - - /** - * Calculate the modulus of two numbers - * @param {number} x - * @param {number} y - * @returns {number} res - * @private - */ - function _mod(x, y) { - if (y > 0) { - // We don't use JavaScript's % operator here as this doesn't work - // correctly for x < 0 and x == 0 - // see http://en.wikipedia.org/wiki/Modulo_operation - return x - y * Math.floor(x / y); - } - else if (y === 0) { - return x; - } - else { // y < 0 - // TODO: implement mod for a negative divisor - throw new Error('Cannot calculate mod for a negative divisor'); - } - } - } - - exports.name = 'mod'; - exports.factory = factory; - - -/***/ }, -/* 377 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var abs = load(__webpack_require__(86)); - var add = load(__webpack_require__(51)); - var pow = load(__webpack_require__(82)); - var sqrt = load(__webpack_require__(369)); - var multiply = load(__webpack_require__(84)); - var equalScalar = load(__webpack_require__(48)); - var larger = load(__webpack_require__(64)); - var smaller = load(__webpack_require__(60)); - var matrix = load(__webpack_require__(52)); - var trace = load(__webpack_require__(378)); - var transpose = load(__webpack_require__(335)); - - - /** - * Calculate the norm of a number, vector or matrix. - * - * The second parameter p is optional. If not provided, it defaults to 2. - * - * Syntax: - * - * math.norm(x) - * math.norm(x, p) - * - * Examples: - * - * math.abs(-3.5); // returns 3.5 - * math.norm(-3.5); // returns 3.5 - * - * math.norm(math.complex(3, -4)); // returns 5 - * - * math.norm([1, 2, -3], Infinity); // returns 3 - * math.norm([1, 2, -3], -Infinity); // returns 1 - * - * math.norm([3, 4], 2); // returns 5 - * - * math.norm([[1, 2], [3, 4]], 1) // returns 6 - * math.norm([[1, 2], [3, 4]], 'inf'); // returns 7 - * math.norm([[1, 2], [3, 4]], 'fro'); // returns 5.477225575051661 - * - * See also: - * - * abs, hypot - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * Value for which to calculate the norm - * @param {number | BigNumber | string} [p=2] - * Vector space. - * Supported numbers include Infinity and -Infinity. - * Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) - * @return {number | BigNumber} the p-norm - */ - var norm = typed('norm', { - 'number': Math.abs, - - 'Complex': function (x) { - return x.abs(); - }, - - 'BigNumber': function (x) { - // norm(x) = abs(x) - return x.abs(); - }, - - 'boolean | null' : function (x) { - // norm(x) = abs(x) - return Math.abs(x); - }, - - 'Array': function (x) { - return _norm(matrix(x), 2); - }, - - 'Matrix': function (x) { - return _norm(x, 2); - }, - - 'number | Complex | BigNumber | boolean | null, number | BigNumber | string': function (x) { - // ignore second parameter, TODO: remove the option of second parameter for these types - return norm(x); - }, - - 'Array, number | BigNumber | string': function (x, p) { - return _norm(matrix(x), p); - }, - - 'Matrix, number | BigNumber | string': function (x, p) { - return _norm(x, p); - } - }); - - /** - * Calculate the norm for an array - * @param {Array} x - * @param {number | string} p - * @returns {number} Returns the norm - * @private - */ - function _norm (x, p) { - // size - var sizeX = x.size(); - - // check if it is a vector - if (sizeX.length == 1) { - // check p - if (p === Number.POSITIVE_INFINITY || p === 'inf') { - // norm(x, Infinity) = max(abs(x)) - var pinf = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - var v = abs(value); - if (larger(v, pinf)) - pinf = v; - }, - true); - return pinf; - } - if (p === Number.NEGATIVE_INFINITY || p === '-inf') { - // norm(x, -Infinity) = min(abs(x)) - var ninf; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - var v = abs(value); - if (!ninf || smaller(v, ninf)) - ninf = v; - }, - true); - return ninf || 0; - } - if (p === 'fro') { - return _norm(x, 2); - } - if (typeof p === 'number' && !isNaN(p)) { - // check p != 0 - if (!equalScalar(p, 0)) { - // norm(x, p) = sum(abs(xi) ^ p) ^ 1/p - var n = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - n = add(pow(abs(value), p), n); - }, - true); - return pow(n, 1 / p); - } - return Number.POSITIVE_INFINITY; - } - // invalid parameter value - throw new Error('Unsupported parameter value'); - } - // MxN matrix - if (sizeX.length == 2) { - // check p - if (p === 1) { - // norm(x) = the largest column sum - var c = []; - // result - var maxc = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value, index) { - var j = index[1]; - var cj = add(c[j] || 0, abs(value)); - if (larger(cj, maxc)) - maxc = cj; - c[j] = cj; - }, - true); - return maxc; - } - if (p === Number.POSITIVE_INFINITY || p === 'inf') { - // norm(x) = the largest row sum - var r = []; - // result - var maxr = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value, index) { - var i = index[0]; - var ri = add(r[i] || 0, abs(value)); - if (larger(ri, maxr)) - maxr = ri; - r[i] = ri; - }, - true); - return maxr; - } - if (p === 'fro') { - // norm(x) = sqrt(sum(diag(x'x))) - return sqrt(trace(multiply(transpose(x), x))); - } - if (p === 2) { - // not implemented - throw new Error('Unsupported parameter value, missing implementation of matrix singular value decomposition'); - } - // invalid parameter value - throw new Error('Unsupported parameter value'); - } - } - - norm.toTex = { - 1: '\\left\\|${args[0]}\\right\\|', - 2: undefined // use default template - }; - - return norm; - } - - exports.name = 'norm'; - exports.factory = factory; - - -/***/ }, -/* 378 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var format = __webpack_require__(23).format; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - var add = load(__webpack_require__(51)); - - /** - * Calculate the trace of a matrix: the sum of the elements on the main - * diagonal of a square matrix. - * - * Syntax: - * - * math.trace(x) - * - * Examples: - * - * math.trace([[1, 2], [3, 4]]); // returns 5 - * - * var A = [ - * [1, 2, 3], - * [-1, 2, 3], - * [2, 0, 3] - * ] - * math.trace(A); // returns 6 - * - * See also: - * - * diag - * - * @param {Array | Matrix} x A matrix - * - * @return {number} The trace of `x` - */ - var trace = typed('trace', { - - 'Array': function (x) { - // use dense matrix implementation - return trace(matrix(x)); - }, - - 'Matrix': function (x) { - // result - var c; - // process storage format - switch (x.storage()) { - case 'dense': - c = _denseTrace(x); - break; - case 'sparse': - c = _sparseTrace(x); - break; - } - return c; - }, - - 'any': clone - }); - - var _denseTrace = function (m) { - // matrix size & data - var size = m._size; - var data = m._data; - - // process dimensions - switch (size.length) { - case 1: - // vector - if (size[0] == 1) { - // return data[0] - return clone(data[0]); - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - case 2: - // two dimensional - var rows = size[0]; - var cols = size[1]; - if (rows === cols) { - // calulate sum - var sum = 0; - // loop diagonal - for (var i = 0; i < rows; i++) - sum = add(sum, data[i][i]); - // return trace - return sum; - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - default: - // multi dimensional - throw new RangeError('Matrix must be two dimensional (size: ' + format(size) + ')'); - } - }; - - var _sparseTrace = function (m) { - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - var size = m._size; - // check dimensions - var rows = size[0]; - var columns = size[1]; - // matrix must be square - if (rows === columns) { - // calulate sum - var sum = 0; - // check we have data (avoid looping columns) - if (values.length > 0) { - // loop columns - for (var j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - var i = index[k]; - // check row - if (i === j) { - // accumulate value - sum = add(sum, values[k]); - // exit loop - break; - } - if (i > j) { - // exit loop, no value on the diagonal for column j - break; - } - } - } - } - // return trace - return sum; - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - }; - - trace.toTex = {1: '\\mathrm{tr}\\left(${args[0]}\\right)'}; - - return trace; - } - - exports.name = 'trace'; - exports.factory = factory; - - -/***/ }, -/* 379 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm02 = load(__webpack_require__(360)); - var algorithm06 = load(__webpack_require__(372)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculate the nth root of a value. - * The principal nth root of a positive real number A, is the positive real - * solution of the equation - * - * x^root = A - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.nthRoot(a) - * math.nthRoot(a, root) - * - * Examples: - * - * math.nthRoot(9, 2); // returns 3, as 3^2 == 9 - * math.sqrt(9); // returns 3, as 3^2 == 9 - * math.nthRoot(64, 3); // returns 4, as 4^3 == 64 - * - * See also: - * - * sqrt, pow - * - * @param {number | BigNumber | Array | Matrix | Complex} a - * Value for which to calculate the nth root - * @param {number | BigNumber} [root=2] The root. - * @return {number | Complex | Array | Matrix} Returns the nth root of `a` - */ - var nthRoot = typed('nthRoot', { - - 'number': function (x) { - return _nthRoot(x, 2); - }, - 'number, number': _nthRoot, - - 'BigNumber': function (x) { - return _bigNthRoot(x, new type.BigNumber(2)); - }, - 'Complex' : function(x) { - return _nthComplexRoot(x, 2); - }, - 'Complex, number' : _nthComplexRoot, - 'BigNumber, BigNumber': _bigNthRoot, - - 'Array | Matrix': function (x) { - return nthRoot(x, 2); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // density must be one (no zeros in matrix) - if (y.density() === 1) { - // sparse + sparse - c = algorithm06(x, y, nthRoot); - } - else { - // throw exception - throw new Error('Root must be non-zero'); - } - break; - default: - // sparse + dense - c = algorithm02(y, x, nthRoot, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // density must be one (no zeros in matrix) - if (y.density() === 1) { - // dense + sparse - c = algorithm01(x, y, nthRoot, false); - } - else { - // throw exception - throw new Error('Root must be non-zero'); - } - break; - default: - // dense + dense - c = algorithm13(x, y, nthRoot); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return nthRoot(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return nthRoot(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return nthRoot(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, nthRoot, false); - break; - default: - c = algorithm14(x, y, nthRoot, false); - break; - } - return c; - }, - - 'number | BigNumber, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - // density must be one (no zeros in matrix) - if (y.density() === 1) { - // sparse - scalar - c = algorithm11(y, x, nthRoot, true); - } - else { - // throw exception - throw new Error('Root must be non-zero'); - } - break; - default: - c = algorithm14(y, x, nthRoot, true); - break; - } - return c; - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return nthRoot(matrix(x), y).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return nthRoot(x, matrix(y)).valueOf(); - } - }); - - nthRoot.toTex = {2: '\\sqrt[${args[1]}]{${args[0]}}'}; - - return nthRoot; - - /** - * Calculate the nth root of a for BigNumbers, solve x^root == a - * http://rosettacode.org/wiki/Nth_root#JavaScript - * @param {BigNumber} a - * @param {BigNumber} root - * @private - */ - function _bigNthRoot(a, root) { - var precision = type.BigNumber.precision; - var Big = type.BigNumber.clone({precision: precision + 2}); - var zero = new type.BigNumber(0); - - var one = new Big(1); - var inv = root.isNegative(); - if (inv) { - root = root.neg(); - } - - if (root.isZero()) { - throw new Error('Root must be non-zero'); - } - if (a.isNegative() && !root.abs().mod(2).equals(1)) { - throw new Error('Root must be odd when a is negative.'); - } - - // edge cases zero and infinity - if (a.isZero()) { - return inv ? new Big(Infinity) : 0; - } - if (!a.isFinite()) { - return inv ? zero : a; - } - - var x = a.abs().pow(one.div(root)); - // If a < 0, we require that root is an odd integer, - // so (-1) ^ (1/root) = -1 - x = a.isNeg() ? x.neg() : x; - return new type.BigNumber((inv ? one.div(x) : x).toPrecision(precision)); - } - } - - /** - * Calculate the nth root of a, solve x^root == a - * http://rosettacode.org/wiki/Nth_root#JavaScript - * @param {number} a - * @param {number} root - * @private - */ - function _nthRoot(a, root) { - var inv = root < 0; - if (inv) { - root = -root; - } - - if (root === 0) { - throw new Error('Root must be non-zero'); - } - if (a < 0 && (Math.abs(root) % 2 != 1)) { - throw new Error('Root must be odd when a is negative.'); - } - - // edge cases zero and infinity - if (a == 0) { - return inv ? Infinity : 0; - } - if (!isFinite(a)) { - return inv ? 0 : a; - } - - var x = Math.pow(Math.abs(a), 1/root); - // If a < 0, we require that root is an odd integer, - // so (-1) ^ (1/root) = -1 - x = a < 0 ? -x : x; - return inv ? 1 / x : x; - - // Very nice algorithm, but fails with nthRoot(-2, 3). - // Newton's method has some well-known problems at times: - // https://en.wikipedia.org/wiki/Newton%27s_method#Failure_analysis - /* - var x = 1; // Initial guess - var xPrev = 1; - var i = 0; - var iMax = 10000; - do { - var delta = (a / Math.pow(x, root - 1) - x) / root; - xPrev = x; - x = x + delta; - i++; - } - while (xPrev !== x && i < iMax); - - if (xPrev !== x) { - throw new Error('Function nthRoot failed to converge'); - } - - return inv ? 1 / x : x; - */ - } - - /** - * Calculate the nth root of a Complex Number a using De Moviers Theorem. - * @param {Complex} a - * @param {number} root - * @return {Array} array or n Complex Roots in Polar Form. - */ - function _nthComplexRoot(a, root) { - if (root < 0) throw new Error('Root must be greater than zero'); - if (root === 0) throw new Error('Root must be non-zero'); - if (root % 1 !== 0) throw new Error('Root must be an integer'); - var arg = a.arg(); - var abs = a.abs(); - var roots = []; - var r = Math.pow(abs, 1/root); - for(var k = 0; k < root; k++) { - roots.push({r: r, phi: (arg + 2 * Math.PI * k)/root}); - } - return roots; - } - - exports.name = 'nthRoot'; - exports.factory = factory; - - -/***/ }, -/* 380 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var toFixed = __webpack_require__(6).toFixed; - var deepMap = __webpack_require__(19); - - var NO_INT = 'Number of decimals in function round must be an integer'; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - var equalScalar = load(__webpack_require__(48)); - var zeros = load(__webpack_require__(381)); - - var algorithm11 = load(__webpack_require__(85)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Round a value towards the nearest integer. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.round(x) - * math.round(x, n) - * - * Examples: - * - * math.round(3.2); // returns number 3 - * math.round(3.8); // returns number 4 - * math.round(-4.2); // returns number -4 - * math.round(-4.7); // returns number -5 - * math.round(math.pi, 3); // returns number 3.142 - * math.round(123.45678, 2); // returns number 123.46 - * - * var c = math.complex(3.2, -2.7); - * math.round(c); // returns Complex 3 - 3i - * - * math.round([3.2, 3.8, -4.7]); // returns Array [3, 4, -5] - * - * See also: - * - * ceil, fix, floor - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded - * @param {number | BigNumber | Array} [n=0] Number of decimals - * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value - */ - var round = typed('round', { - - 'number': Math.round, - - 'number, number': function (x, n) { - if (!isInteger(n)) {throw new TypeError(NO_INT);} - if (n < 0 || n > 15) {throw new Error('Number of decimals in function round must be in te range of 0-15');} - - return _round(x, n); - }, - - 'Complex': function (x) { - return x.round(); - }, - - 'Complex, number': function (x, n) { - if (n % 1) {throw new TypeError(NO_INT);} - - return x.round(n); - }, - - 'Complex, BigNumber': function (x, n) { - if (!n.isInteger()) {throw new TypeError(NO_INT);} - - var _n = n.toNumber(); - return x.round(_n); - }, - - 'number, BigNumber': function (x, n) { - if (!n.isInteger()) {throw new TypeError(NO_INT);} - - return new type.BigNumber(x).toDecimalPlaces(n.toNumber()); - }, - - 'BigNumber': function (x) { - return x.toDecimalPlaces(0); - }, - - 'BigNumber, BigNumber': function (x, n) { - if (!n.isInteger()) {throw new TypeError(NO_INT);} - - return x.toDecimalPlaces(n.toNumber()); - }, - - 'Fraction': function (x) { - return x.round(); - }, - - 'Fraction, number': function (x, n) { - if (n % 1) {throw new TypeError(NO_INT);} - return x.round(n); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since round(0) = 0 - return deepMap(x, round, true); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, round, false); - break; - default: - c = algorithm14(x, y, round, false); - break; - } - return c; - }, - - 'number | Complex | BigNumber, Matrix': function (x, y) { - // check scalar is zero - if (!equalScalar(x, 0)) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, round, true); - break; - default: - c = algorithm14(y, x, round, true); - break; - } - return c; - } - // do not execute algorithm, result will be a zero matrix - return zeros(y.size(), y.storage()); - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, round, false).valueOf(); - }, - - 'number | Complex | BigNumber, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, round, true).valueOf(); - } - }); - - round.toTex = { - 1: '\\left\\lfloor${args[0]}\\right\\rceil', - 2: undefined // use default template - }; - - return round; - } - - /** - * round a number to the given number of decimals, or to zero if decimals is - * not provided - * @param {number} value - * @param {number} decimals number of decimals, between 0 and 15 (0 by default) - * @return {number} roundedValue - * @private - */ - function _round (value, decimals) { - return parseFloat(toFixed(value, decimals)); - } - - exports.name = 'round'; - exports.factory = factory; - - -/***/ }, -/* 381 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var resize = __webpack_require__(40).resize; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Create a matrix filled with zeros. The created matrix can have one or - * multiple dimensions. - * - * Syntax: - * - * math.zeros(m) - * math.zeros(m, format) - * math.zeros(m, n) - * math.zeros(m, n, format) - * math.zeros([m, n]) - * math.zeros([m, n], format) - * - * Examples: - * - * math.zeros(3); // returns [0, 0, 0] - * math.zeros(3, 2); // returns [[0, 0], [0, 0], [0, 0]] - * math.zeros(3, 'dense'); // returns [0, 0, 0] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.zeros(math.size(A)); // returns [[0, 0, 0], [0, 0, 0]] - * - * See also: - * - * ones, eye, size, range - * - * @param {...number | Array} size The size of each dimension of the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Array | Matrix} A matrix filled with zeros - */ - var zeros = typed('zeros', { - '': function () { - return (config.matrix === 'Array') - ? _zeros([]) - : _zeros([], 'default'); - }, - - // math.zeros(m, n, p, ..., format) - // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this - '...number | BigNumber | string': function (size) { - var last = size[size.length - 1]; - if (typeof last === 'string') { - var format = size.pop(); - return _zeros(size, format); - } - else if (config.matrix === 'Array') { - return _zeros(size); - } - else { - return _zeros(size, 'default'); - } - }, - - 'Array': _zeros, - - 'Matrix': function (size) { - var format = size.storage(); - return _zeros(size.valueOf(), format); - }, - - 'Array | Matrix, string': function (size, format) { - return _zeros (size.valueOf(), format); - } - }); - - zeros.toTex = undefined; // use default template - - return zeros; - - /** - * Create an Array or Matrix with zeros - * @param {Array} size - * @param {string} [format='default'] - * @return {Array | Matrix} - * @private - */ - function _zeros(size, format) { - var hasBigNumbers = _normalize(size); - var defaultValue = hasBigNumbers ? new type.BigNumber(0) : 0; - _validate(size); - - if (format) { - // return a matrix - var m = matrix(format); - if (size.length > 0) { - return m.resize(size, defaultValue); - } - return m; - } - else { - // return an Array - var arr = []; - if (size.length > 0) { - return resize(arr, size, defaultValue); - } - return arr; - } - } - - // replace BigNumbers with numbers, returns true if size contained BigNumbers - function _normalize(size) { - var hasBigNumbers = false; - size.forEach(function (value, index, arr) { - if (value && value.isBigNumber === true) { - hasBigNumbers = true; - arr[index] = value.toNumber(); - } - }); - return hasBigNumbers; - } - - // validate arguments - function _validate (size) { - size.forEach(function (value) { - if (typeof value !== 'number' || !isInteger(value) || value < 0) { - throw new Error('Parameters in function zeros must be positive integers'); - } - }); - } - } - - // TODO: zeros contains almost the same code as ones. Reuse this? - - exports.name = 'zeros'; - exports.factory = factory; - - -/***/ }, -/* 382 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(6); - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Compute the sign of a value. The sign of a value x is: - * - * - 1 when x > 1 - * - -1 when x < 0 - * - 0 when x == 0 - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sign(x) - * - * Examples: - * - * math.sign(3.5); // returns 1 - * math.sign(-4.2); // returns -1 - * math.sign(0); // returns 0 - * - * math.sign([3, 5, -2, 0, 2]); // returns [1, 1, -1, 0, 1] - * - * See also: - * - * abs - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x - * The number for which to determine the sign - * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}e - * The sign of `x` - */ - var sign = typed('sign', { - 'number': number.sign, - - 'Complex': function (x) { - return x.sign(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(x.cmp(0)); - }, - - 'Fraction': function (x) { - return new type.Fraction(x.s, 1); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sign(0) = 0 - return deepMap(x, sign, true); - }, - - 'Unit': function(x) { - return sign(x.value); - } - }); - - sign.toTex = {1: '\\mathrm{${name}}\\left(${args[0]}\\right)'}; - - return sign; - } - - exports.name = 'sign'; - exports.factory = factory; - - - -/***/ }, -/* 383 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Compute the square of a value, `x * x`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.square(x) - * - * Examples: - * - * math.square(2); // returns number 4 - * math.square(3); // returns number 9 - * math.pow(3, 2); // returns number 9 - * math.multiply(3, 3); // returns number 9 - * - * math.square([1, 2, 3, 4]); // returns Array [1, 4, 9, 16] - * - * See also: - * - * multiply, cube, sqrt, pow - * - * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x - * Number for which to calculate the square - * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} - * Squared value - */ - var square = typed('square', { - 'number': function (x) { - return x * x; - }, - - 'Complex': function (x) { - return x.mul(x); - }, - - 'BigNumber': function (x) { - return x.times(x); - }, - - 'Fraction': function (x) { - return x.mul(x); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since square(0) = 0 - return deepMap(x, square, true); - }, - - 'Unit': function(x) { - return x.pow(2); - } - }); - - square.toTex = {1: '\\left(${args[0]}\\right)^2'}; - - return square; - } - - exports.name = 'square'; - exports.factory = factory; - - -/***/ }, -/* 384 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - /** - * Unary plus operation. - * Boolean values and strings will be converted to a number, numeric values will be returned as is. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.unaryPlus(x) - * - * Examples: - * - * math.unaryPlus(3.5); // returns 3.5 - * math.unaryPlus(1); // returns 1 - * - * See also: - * - * unaryMinus, add, subtract - * - * @param {number | BigNumber | Fraction | string | Complex | Unit | Array | Matrix} x - * Input value - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} - * Returns the input value when numeric, converts to a number when input is non-numeric. - */ - var unaryPlus = typed('unaryPlus', { - 'number': function (x) { - return x; - }, - - 'Complex': function (x) { - return x; // complex numbers are immutable - }, - - 'BigNumber': function (x) { - return x; // bignumbers are immutable - }, - - 'Fraction': function (x) { - return x; // fractions are immutable - }, - - 'Unit': function (x) { - return x.clone(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since unaryPlus(0) = 0 - return deepMap(x, unaryPlus, true); - }, - - 'boolean | string | null': function (x) { - // convert to a number or bignumber - return (config.number == 'BigNumber') ? new type.BigNumber(+x): +x; - } - }); - - unaryPlus.toTex = { - 1: latex.operators['unaryPlus'] + '\\left(${args[0]}\\right)' - }; - - return unaryPlus; - } - - exports.name = 'unaryPlus'; - exports.factory = factory; - - -/***/ }, -/* 385 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Calculate the extended greatest common divisor for two values. - * See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm. - * - * Syntax: - * - * math.xgcd(a, b) - * - * Examples: - * - * math.xgcd(8, 12); // returns [4, -1, 1] - * math.gcd(8, 12); // returns 4 - * math.xgcd(36163, 21199); // returns [1247, -7, 12] - * - * See also: - * - * gcd, lcm - * - * @param {number | BigNumber} a An integer number - * @param {number | BigNumber} b An integer number - * @return {Array} Returns an array containing 3 integers `[div, m, n]` - * where `div = gcd(a, b)` and `a*m + b*n = div` - */ - var xgcd = typed('xgcd', { - 'number, number': _xgcd, - 'BigNumber, BigNumber': _xgcdBigNumber - // TODO: implement support for Fraction - }); - - xgcd.toTex = undefined; // use default template - - return xgcd; - - /** - * Calculate xgcd for two numbers - * @param {number} a - * @param {number} b - * @return {number} result - * @private - */ - function _xgcd (a, b) { - // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm - var t, // used to swap two variables - q, // quotient - r, // remainder - x = 0, lastx = 1, - y = 1, lasty = 0; - - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function xgcd must be integer numbers'); - } - - while (b) { - q = Math.floor(a / b); - r = a % b; - - t = x; - x = lastx - q * x; - lastx = t; - - t = y; - y = lasty - q * y; - lasty = t; - - a = b; - b = r; - } - - var res; - if (a < 0) { - res = [-a, -lastx, -lasty]; - } - else { - res = [a, a ? lastx : 0, lasty]; - } - return (config.matrix === 'Array') ? res : matrix(res); - } - - /** - * Calculate xgcd for two BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @return {BigNumber[]} result - * @private - */ - function _xgcdBigNumber(a, b) { - // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm - var t, // used to swap two variables - q, // quotient - r, // remainder - zero = new type.BigNumber(0), - one = new type.BigNumber(1), - x = zero, - lastx = one, - y = one, - lasty = zero; - - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function xgcd must be integer numbers'); - } - - //console.log('start', [a, b].toString()) - - while (!b.isZero()) { - //console.log('inner', [a, b, t, q, r, x, y, lastx, lasty].toString()); - q = a.div(b).floor(); - r = a.mod(b); - //console.log('MOD', [a, b, a.mod(b), r].toString()) - - t = x; - x = lastx.minus(q.times(x)); - lastx = t; - - t = y; - y = lasty.minus(q.times(y)); - lasty = t; - - a = b; - b = r; - - //console.log('inner end', [a, b, t, q, r, x, y, lastx, lasty].toString()); - } - - //console.log('end', [a, lastx, lasty].toString()) - - var res; - if (a.lt(zero)) { - res = [a.neg(), lastx.neg(), lasty.neg()]; - } - else { - res = [a, !a.isZero() ? lastx : 0, lasty]; - } - return (config.matrix === 'Array') ? res : matrix(res); - } - } - - exports.name = 'xgcd'; - exports.factory = factory; - - -/***/ }, -/* 386 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(387), - __webpack_require__(391), - __webpack_require__(392), - __webpack_require__(394), - __webpack_require__(396), - __webpack_require__(399), - __webpack_require__(401) - ]; - - -/***/ }, -/* 387 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var bigBitAnd = __webpack_require__(388); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm06 = load(__webpack_require__(372)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise AND two values, `x & y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.bitAnd(x, y) - * - * Examples: - * - * math.bitAnd(53, 131); // returns number 1 - * - * math.bitAnd([1, 12, 31], 42); // returns Array [0, 8, 10] - * - * See also: - * - * bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x First value to and - * @param {number | BigNumber | Array | Matrix} y Second value to and - * @return {number | BigNumber | Array | Matrix} AND of `x` and `y` - */ - var bitAnd = typed('bitAnd', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitAnd'); - } - - return x & y; - }, - - 'BigNumber, BigNumber': bigBitAnd, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse & sparse - c = algorithm06(x, y, bitAnd, false); - break; - default: - // sparse & dense - c = algorithm02(y, x, bitAnd, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense & sparse - c = algorithm02(x, y, bitAnd, false); - break; - default: - // dense & dense - c = algorithm13(x, y, bitAnd); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return bitAnd(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return bitAnd(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return bitAnd(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, bitAnd, false); - break; - default: - c = algorithm14(x, y, bitAnd, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm11(y, x, bitAnd, true); - break; - default: - c = algorithm14(y, x, bitAnd, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, bitAnd, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, bitAnd, true).valueOf(); - } - }); - - bitAnd.toTex = { - 2: '\\left(${args[0]}' + latex.operators['bitAnd'] + '${args[1]}\\right)' - }; - - return bitAnd; - } - - exports.name = 'bitAnd'; - exports.factory = factory; - - -/***/ }, -/* 388 */ -/***/ function(module, exports, __webpack_require__) { - - var bitwise = __webpack_require__(389); - - /** - * Bitwise and for Bignumbers - * - * Special Cases: - * N & n = N - * n & 0 = 0 - * n & -1 = n - * n & n = n - * I & I = I - * -I & -I = -I - * I & -I = 0 - * I & n = n - * I & -n = I - * -I & n = 0 - * -I & -n = -I - * - * @param {BigNumber} x - * @param {BigNumber} y - * @return {BigNumber} Result of `x` & `y`, is fully precise - * @private - */ - module.exports = function bitAnd(x, y) { - if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { - throw new Error('Integers expected in function bitAnd'); - } - - var BigNumber = x.constructor; - if (x.isNaN() || y.isNaN()) { - return new BigNumber(NaN); - } - - if (x.isZero() || y.eq(-1) || x.eq(y)) { - return x; - } - if (y.isZero() || x.eq(-1)) { - return y; - } - - if (!x.isFinite() || !y.isFinite()) { - if (!x.isFinite() && !y.isFinite()) { - if (x.isNegative() == y.isNegative()) { - return x; - } - return new BigNumber(0); - } - if (!x.isFinite()) { - if (y.isNegative()) { - return x; - } - if (x.isNegative()) { - return new BigNumber(0); - } - return y; - } - if (!y.isFinite()) { - if (x.isNegative()) { - return y; - } - if (y.isNegative()) { - return new BigNumber(0); - } - return x; - } - } - return bitwise(x, y, function (a, b) { return a & b }); - }; - - -/***/ }, -/* 389 */ -/***/ function(module, exports, __webpack_require__) { - - var bitNot = __webpack_require__(390); - - /** - * Applies bitwise function to numbers - * @param {BigNumber} x - * @param {BigNumber} y - * @param {function (a, b)} func - * @return {BigNumber} - */ - module.exports = function bitwise(x, y, func) { - var BigNumber = x.constructor; - - var xBits, yBits; - var xSign = +(x.s < 0); - var ySign = +(y.s < 0); - if (xSign) { - xBits = decCoefficientToBinaryString(bitNot(x)); - for (var i = 0; i < xBits.length; ++i) { - xBits[i] ^= 1; - } - } else { - xBits = decCoefficientToBinaryString(x); - } - if (ySign) { - yBits = decCoefficientToBinaryString(bitNot(y)); - for (var i = 0; i < yBits.length; ++i) { - yBits[i] ^= 1; - } - } else { - yBits = decCoefficientToBinaryString(y); - } - - var minBits, maxBits, minSign; - if (xBits.length <= yBits.length) { - minBits = xBits; - maxBits = yBits; - minSign = xSign; - } else { - minBits = yBits; - maxBits = xBits; - minSign = ySign; - } - - var shortLen = minBits.length; - var longLen = maxBits.length; - var expFuncVal = func(xSign, ySign) ^ 1; - var outVal = new BigNumber(expFuncVal ^ 1); - var twoPower = new BigNumber(1); - var two = new BigNumber(2); - - var prevPrec = BigNumber.precision; - BigNumber.config({precision: 1E9}); - - while (shortLen > 0) { - if (func(minBits[--shortLen], maxBits[--longLen]) == expFuncVal) { - outVal = outVal.plus(twoPower); - } - twoPower = twoPower.times(two); - } - while (longLen > 0) { - if (func(minSign, maxBits[--longLen]) == expFuncVal) { - outVal = outVal.plus(twoPower); - } - twoPower = twoPower.times(two); - } - - BigNumber.config({precision: prevPrec}); - - if (expFuncVal == 0) { - outVal.s = -outVal.s; - } - return outVal; - }; - - /* Extracted from decimal.js, and edited to specialize. */ - function decCoefficientToBinaryString (x) { - // Convert to string - var a = x.d; // array with digits - var r = a[0] + ''; - - for (var i = 1; i < a.length; ++i) { - var s = a[i] + ''; - for (var z = 7 - s.length; z--; ) { - s = '0' + s; - } - - r += s; - } - - var j; - for (j = r.length - 1; r.charAt(j) == '0'; --j); - - var xe = x.e; - var str = r.slice(0, j + 1 || 1); - var strL = str.length; - if (xe > 0) { - if (++xe > strL) { - // Append zeros. - for (xe -= strL; xe--; str += '0'); - } else if (xe < strL) { - str = str.slice(0, xe) + '.' + str.slice(xe); - } - } - - // Convert from base 10 (decimal) to base 2 - var arr = [0]; - for (var i = 0; i < str.length; ) { - for (var arrL = arr.length; arrL--; arr[arrL] *= 10); - - arr[0] += str.charAt(i++) << 0; // convert to int - for (var j = 0; j < arr.length; ++j) { - if (arr[j] > 1) { - if (arr[j + 1] == null) { - arr[j + 1] = 0; - } - - arr[j + 1] += arr[j] >> 1; - arr[j] &= 1; - } - } - } - - return arr.reverse(); - } - - -/***/ }, -/* 390 */ -/***/ function(module, exports) { - - /** - * Bitwise not - * @param {BigNumber} value - * @return {BigNumber} Result of ~`x`, fully precise - * - */ - module.exports = function bitNot (x) { - if (x.isFinite() && !x.isInteger()) { - throw new Error('Integer expected in function bitNot'); - } - - var BigNumber = x.constructor; - var prevPrec = BigNumber.precision; - BigNumber.config({precision: 1E9}); - - var x = x.plus(new BigNumber(1)); - x.s = -x.s || null; - - BigNumber.config({precision: prevPrec}); - return x; - }; - - -/***/ }, -/* 391 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var bigBitNot = __webpack_require__(390); - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - /** - * Bitwise NOT value, `~x`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.bitNot(x) - * - * Examples: - * - * math.bitNot(1); // returns number -2 - * - * math.bitNot([2, -3, 4]); // returns Array [-3, 2, 5] - * - * See also: - * - * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x Value to not - * @return {number | BigNumber | Array | Matrix} NOT of `x` - */ - var bitNot = typed('bitNot', { - 'number': function (x) { - if (!isInteger(x)) { - throw new Error('Integer expected in function bitNot'); - } - - return ~x; - }, - - 'BigNumber': bigBitNot, - - 'Array | Matrix': function (x) { - return deepMap(x, bitNot); - } - }); - - bitNot.toTex = { - 1: latex.operators['bitNot'] + '\\left(${args[0]}\\right)' - }; - - return bitNot; - } - - exports.name = 'bitNot'; - exports.factory = factory; - - -/***/ }, -/* 392 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var bigBitOr = __webpack_require__(393); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm04 = load(__webpack_require__(55)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise OR two values, `x | y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the lowest print base. - * - * Syntax: - * - * math.bitOr(x, y) - * - * Examples: - * - * math.bitOr(1, 2); // returns number 3 - * - * math.bitOr([1, 2, 3], 4); // returns Array [5, 6, 7] - * - * See also: - * - * bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x First value to or - * @param {number | BigNumber | Array | Matrix} y Second value to or - * @return {number | BigNumber | Array | Matrix} OR of `x` and `y` - */ - var bitOr = typed('bitOr', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitOr'); - } - - return x | y; - }, - - 'BigNumber, BigNumber': bigBitOr, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm04(x, y, bitOr); - break; - default: - // sparse + dense - c = algorithm01(y, x, bitOr, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm01(x, y, bitOr, false); - break; - default: - c = algorithm13(x, y, bitOr); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return bitOr(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return bitOr(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return bitOr(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm10(x, y, bitOr, false); - break; - default: - c = algorithm14(x, y, bitOr, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, bitOr, true); - break; - default: - c = algorithm14(y, x, bitOr, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, bitOr, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, bitOr, true).valueOf(); - } - }); - - bitOr.toTex = { - 2: '\\left(${args[0]}' + latex.operators['bitOr'] + '${args[1]}\\right)' - }; - - return bitOr; - } - - exports.name = 'bitOr'; - exports.factory = factory; - - -/***/ }, -/* 393 */ -/***/ function(module, exports, __webpack_require__) { - - var bitwise = __webpack_require__(389); - - /** - * Bitwise OR for BigNumbers - * - * Special Cases: - * N | n = N - * n | 0 = n - * n | -1 = -1 - * n | n = n - * I | I = I - * -I | -I = -I - * I | -n = -1 - * I | -I = -1 - * I | n = I - * -I | n = -I - * -I | -n = -n - * - * @param {BigNumber} x - * @param {BigNumber} y - * @return {BigNumber} Result of `x` | `y`, fully precise - */ - module.exports = function bitOr (x, y) { - if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { - throw new Error('Integers expected in function bitOr'); - } - - var BigNumber = x.constructor; - if (x.isNaN() || y.isNaN()) { - return new BigNumber(NaN); - } - - var negOne = new BigNumber(-1); - if (x.isZero() || y.eq(negOne) || x.eq(y)) { - return y; - } - if (y.isZero() || x.eq(negOne)) { - return x; - } - - if (!x.isFinite() || !y.isFinite()) { - if ((!x.isFinite() && !x.isNegative() && y.isNegative()) || - (x.isNegative() && !y.isNegative() && !y.isFinite())) { - return negOne; - } - if (x.isNegative() && y.isNegative()) { - return x.isFinite() ? x : y; - } - return x.isFinite() ? y : x; - } - - return bitwise(x, y, function (a, b) { return a | b }); - }; - - -/***/ }, -/* 394 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var bigBitXor = __webpack_require__(395); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise XOR two values, `x ^ y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.bitXor(x, y) - * - * Examples: - * - * math.bitXor(1, 2); // returns number 3 - * - * math.bitXor([2, 3, 4], 4); // returns Array [6, 7, 0] - * - * See also: - * - * bitAnd, bitNot, bitOr, leftShift, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x First value to xor - * @param {number | BigNumber | Array | Matrix} y Second value to xor - * @return {number | BigNumber | Array | Matrix} XOR of `x` and `y` - */ - var bitXor = typed('bitXor', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitXor'); - } - - return x ^ y; - }, - - 'BigNumber, BigNumber': bigBitXor, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, bitXor); - break; - default: - // sparse + dense - c = algorithm03(y, x, bitXor, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, bitXor, false); - break; - default: - // dense + dense - c = algorithm13(x, y, bitXor); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return bitXor(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return bitXor(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return bitXor(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, bitXor, false); - break; - default: - c = algorithm14(x, y, bitXor, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, bitXor, true); - break; - default: - c = algorithm14(y, x, bitXor, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, bitXor, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, bitXor, true).valueOf(); - } - }); - - bitXor.toTex = { - 2: '\\left(${args[0]}' + latex.operators['bitXor'] + '${args[1]}\\right)' - }; - - return bitXor; - } - - exports.name = 'bitXor'; - exports.factory = factory; - - -/***/ }, -/* 395 */ -/***/ function(module, exports, __webpack_require__) { - - var bitwise = __webpack_require__(389); - var bitNot = __webpack_require__(390); - - /** - * Bitwise XOR for BigNumbers - * - * Special Cases: - * N ^ n = N - * n ^ 0 = n - * n ^ n = 0 - * n ^ -1 = ~n - * I ^ n = I - * I ^ -n = -I - * I ^ -I = -1 - * -I ^ n = -I - * -I ^ -n = I - * - * @param {BigNumber} x - * @param {BigNumber} y - * @return {BigNumber} Result of `x` ^ `y`, fully precise - * - */ - module.exports = function bitXor(x, y) { - if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { - throw new Error('Integers expected in function bitXor'); - } - - var BigNumber = x.constructor; - if (x.isNaN() || y.isNaN()) { - return new BigNumber(NaN); - } - if (x.isZero()) { - return y; - } - if (y.isZero()) { - return x; - } - - if (x.eq(y)) { - return new BigNumber(0); - } - - var negOne = new BigNumber(-1); - if (x.eq(negOne)) { - return bitNot(y); - } - if (y.eq(negOne)) { - return bitNot(x); - } - - if (!x.isFinite() || !y.isFinite()) { - if (!x.isFinite() && !y.isFinite()) { - return negOne; - } - return new BigNumber(x.isNegative() == y.isNegative() - ? Infinity - : -Infinity); - } - return bitwise(x, y, function (a, b) { return a ^ b }); - }; - - -/***/ }, -/* 396 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var bigLeftShift = __webpack_require__(397); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var equalScalar = load(__webpack_require__(48)); - var zeros = load(__webpack_require__(381)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm02 = load(__webpack_require__(360)); - var algorithm08 = load(__webpack_require__(398)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise left logical shift of a value x by y number of bits, `x << y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.leftShift(x, y) - * - * Examples: - * - * math.leftShift(1, 2); // returns number 4 - * - * math.leftShift([1, 2, 3], 4); // returns Array [16, 32, 64] - * - * See also: - * - * leftShift, bitNot, bitOr, bitXor, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x Value to be shifted - * @param {number | BigNumber} y Amount of shifts - * @return {number | BigNumber | Array | Matrix} `x` shifted left `y` times - */ - var leftShift = typed('leftShift', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function leftShift'); - } - - return x << y; - }, - - 'BigNumber, BigNumber': bigLeftShift, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse & sparse - c = algorithm08(x, y, leftShift, false); - break; - default: - // sparse & dense - c = algorithm02(y, x, leftShift, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense & sparse - c = algorithm01(x, y, leftShift, false); - break; - default: - // dense & dense - c = algorithm13(x, y, leftShift); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return leftShift(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return leftShift(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return leftShift(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // check scalar - if (!equalScalar(y, 0)) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, leftShift, false); - break; - default: - c = algorithm14(x, y, leftShift, false); - break; - } - return c; - } - return x.clone(); - }, - - 'number | BigNumber, Matrix': function (x, y) { - // check scalar - if (!equalScalar(x, 0)) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, leftShift, true); - break; - default: - c = algorithm14(y, x, leftShift, true); - break; - } - return c; - } - return zeros(y.size(), y.storage()); - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return leftShift(matrix(x), y).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return leftShift(x, matrix(y)).valueOf(); - } - }); - - leftShift.toTex = { - 2: '\\left(${args[0]}' + latex.operators['leftShift'] + '${args[1]}\\right)' - }; - - return leftShift; - } - - exports.name = 'leftShift'; - exports.factory = factory; - - -/***/ }, -/* 397 */ -/***/ function(module, exports) { - - - /** - * Bitwise left shift - * - * Special Cases: - * n << -n = N - * n << N = N - * N << n = N - * n << 0 = n - * 0 << n = 0 - * I << I = N - * I << n = I - * n << I = I - * - * @param {BigNumber} x - * @param {BigNumber} y - * @return {BigNumber} Result of `x` << `y` - * - */ - module.exports = function leftShift (x, y) { - if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { - throw new Error('Integers expected in function leftShift'); - } - - var BigNumber = x.constructor; - if (x.isNaN() || y.isNaN() || (y.isNegative() && !y.isZero())) { - return new BigNumber(NaN); - } - if (x.isZero() || y.isZero()) { - return x; - } - if (!x.isFinite() && !y.isFinite()) { - return new BigNumber(NaN); - } - - // Math.pow(2, y) is fully precise for y < 55, and fast - if (y.lt(55)) { - return x.times(Math.pow(2, y.toNumber()) + ''); - } - return x.times(new BigNumber(2).pow(y)); - }; - - -/***/ }, -/* 398 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - - function factory (type, config, load, typed) { - - var equalScalar = load(__webpack_require__(48)); - - var SparseMatrix = type.SparseMatrix; - - /** - * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). - * Callback function invoked MAX(NNZA, NNZB) times - * - * - * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 - * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 - * └ 0 ; otherwise - * - * - * @param {Matrix} a The SparseMatrix instance (A) - * @param {Matrix} b The SparseMatrix instance (B) - * @param {Function} callback The f(Aij,Bij) operation to invoke - * - * @return {Matrix} SparseMatrix (C) - * - * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 - */ - var algorithm08 = function (a, b, callback) { - // sparse matrix arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var asize = a._size; - var adt = a._datatype; - // sparse matrix arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - - // validate dimensions - if (asize.length !== bsize.length) - throw new DimensionError(asize.length, bsize.length); - - // check rows & columns - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - - // sparse matrix cannot be a Pattern matrix - if (!avalues || !bvalues) - throw new Error('Cannot perform operation on Pattern Sparse Matrices'); - - // rows & columns - var rows = asize[0]; - var columns = asize[1]; - - // datatype - var dt; - // equal signature to use - var eq = equalScalar; - // zero value - var zero = 0; - // callback signature to use - var cf = callback; - - // process data types - if (typeof adt === 'string' && adt === bdt) { - // datatype - dt = adt; - // find signature that matches (dt, dt) - eq = typed.find(equalScalar, [dt, dt]); - // convert 0 to the same datatype - zero = typed.convert(0, dt); - // callback - cf = typed.find(callback, [dt, dt]); - } - - // result arrays - var cvalues = []; - var cindex = []; - var cptr = []; - // matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [rows, columns], - datatype: dt - }); - - // workspace - var x = []; - // marks indicating we have a value in x for a given column - var w = []; - - // vars - var k, k0, k1, i; - - // loop columns - for (var j = 0; j < columns; j++) { - // update cptr - cptr[j] = cindex.length; - // columns mark - var mark = j + 1; - // loop values in a - for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - i = aindex[k]; - // mark workspace - w[i] = mark; - // set value - x[i] = avalues[k]; - // add index - cindex.push(i); - } - // loop values in b - for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - i = bindex[k]; - // check value exists in workspace - if (w[i] === mark) { - // evaluate callback - x[i] = cf(x[i], bvalues[k]); - } - } - // initialize first index in j - k = cptr[j]; - // loop index in j - while (k < cindex.length) { - // row - i = cindex[k]; - // value @ i - var v = x[i]; - // check for zero value - if (!eq(v, zero)) { - // push value - cvalues.push(v); - // increment pointer - k++; - } - else { - // remove value @ i, do not increment pointer - cindex.splice(k, 1); - } - } - } - // update cptr - cptr[columns] = cindex.length; - - // return sparse matrix - return c; - }; - - return algorithm08; - } - - exports.name = 'algorithm08'; - exports.factory = factory; - - -/***/ }, -/* 399 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var bigRightArithShift = __webpack_require__(400); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var equalScalar = load(__webpack_require__(48)); - var zeros = load(__webpack_require__(381)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm02 = load(__webpack_require__(360)); - var algorithm08 = load(__webpack_require__(398)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.rightArithShift(x, y) - * - * Examples: - * - * math.rightArithShift(4, 2); // returns number 1 - * - * math.rightArithShift([16, -32, 64], 4); // returns Array [1, -2, 3] - * - * See also: - * - * bitAnd, bitNot, bitOr, bitXor, rightArithShift, rightLogShift - * - * @param {number | BigNumber | Array | Matrix} x Value to be shifted - * @param {number | BigNumber} y Amount of shifts - * @return {number | BigNumber | Array | Matrix} `x` sign-filled shifted right `y` times - */ - var rightArithShift = typed('rightArithShift', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function rightArithShift'); - } - - return x >> y; - }, - - 'BigNumber, BigNumber': bigRightArithShift, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse & sparse - c = algorithm08(x, y, rightArithShift, false); - break; - default: - // sparse & dense - c = algorithm02(y, x, rightArithShift, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense & sparse - c = algorithm01(x, y, rightArithShift, false); - break; - default: - // dense & dense - c = algorithm13(x, y, rightArithShift); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return rightArithShift(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return rightArithShift(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return rightArithShift(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // check scalar - if (!equalScalar(y, 0)) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, rightArithShift, false); - break; - default: - c = algorithm14(x, y, rightArithShift, false); - break; - } - return c; - } - return x.clone(); - }, - - 'number | BigNumber, Matrix': function (x, y) { - // check scalar - if (!equalScalar(x, 0)) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, rightArithShift, true); - break; - default: - c = algorithm14(y, x, rightArithShift, true); - break; - } - return c; - } - return zeros(y.size(), y.storage()); - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return rightArithShift(matrix(x), y).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return rightArithShift(x, matrix(y)).valueOf(); - } - }); - - rightArithShift.toTex = { - 2: '\\left(${args[0]}' + latex.operators['rightArithShift'] + '${args[1]}\\right)' - }; - - return rightArithShift; - } - - exports.name = 'rightArithShift'; - exports.factory = factory; - - -/***/ }, -/* 400 */ -/***/ function(module, exports) { - - /* - * Special Cases: - * n >> -n = N - * n >> N = N - * N >> n = N - * I >> I = N - * n >> 0 = n - * I >> n = I - * -I >> n = -I - * -I >> I = -I - * n >> I = I - * -n >> I = -1 - * 0 >> n = 0 - * - * @param {BigNumber} value - * @param {BigNumber} value - * @return {BigNumber} Result of `x` >> `y` - * - */ - module.exports = function rightArithShift (x, y) { - if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { - throw new Error('Integers expected in function rightArithShift'); - } - - var BigNumber = x.constructor; - if (x.isNaN() || y.isNaN() || (y.isNegative() && !y.isZero())) { - return new BigNumber(NaN); - } - if (x.isZero() || y.isZero()) { - return x; - } - if (!y.isFinite()) { - if (x.isNegative()) { - return new BigNumber(-1); - } - if (!x.isFinite()) { - return new BigNumber(NaN); - } - return new BigNumber(0); - } - - // Math.pow(2, y) is fully precise for y < 55, and fast - if (y.lt(55)) { - return x.div(Math.pow(2, y.toNumber()) + '').floor(); - } - return x.div(new BigNumber(2).pow(y)).floor(); - }; - - -/***/ }, -/* 401 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var equalScalar = load(__webpack_require__(48)); - var zeros = load(__webpack_require__(381)); - - var algorithm01 = load(__webpack_require__(54)); - var algorithm02 = load(__webpack_require__(360)); - var algorithm08 = load(__webpack_require__(398)); - var algorithm10 = load(__webpack_require__(56)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Bitwise right logical shift of value x by y number of bits, `x >>> y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.rightLogShift(x, y) - * - * Examples: - * - * math.rightLogShift(4, 2); // returns number 1 - * - * math.rightLogShift([16, -32, 64], 4); // returns Array [1, 2, 3] - * - * See also: - * - * bitAnd, bitNot, bitOr, bitXor, leftShift, rightLogShift - * - * @param {number | Array | Matrix} x Value to be shifted - * @param {number} y Amount of shifts - * @return {number | Array | Matrix} `x` zero-filled shifted right `y` times - */ - - var rightLogShift = typed('rightLogShift', { - - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function rightLogShift'); - } - - return x >>> y; - }, - - // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse & sparse - c = algorithm08(x, y, rightLogShift, false); - break; - default: - // sparse & dense - c = algorithm02(y, x, rightLogShift, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense & sparse - c = algorithm01(x, y, rightLogShift, false); - break; - default: - // dense & dense - c = algorithm13(x, y, rightLogShift); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return rightLogShift(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return rightLogShift(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return rightLogShift(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // check scalar - if (!equalScalar(y, 0)) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, rightLogShift, false); - break; - default: - c = algorithm14(x, y, rightLogShift, false); - break; - } - return c; - } - return x.clone(); - }, - - 'number | BigNumber, Matrix': function (x, y) { - // check scalar - if (!equalScalar(x, 0)) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm10(y, x, rightLogShift, true); - break; - default: - c = algorithm14(y, x, rightLogShift, true); - break; - } - return c; - } - return zeros(y.size(), y.storage()); - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return rightLogShift(matrix(x), y).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return rightLogShift(x, matrix(y)).valueOf(); - } - }); - - rightLogShift.toTex = { - 2: '\\left(${args[0]}' + latex.operators['rightLogShift'] + '${args[1]}\\right)' - }; - - return rightLogShift; - } - - exports.name = 'rightLogShift'; - exports.factory = factory; - - -/***/ }, -/* 402 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(403), - __webpack_require__(409), - __webpack_require__(404), - __webpack_require__(410) - ]; - - -/***/ }, -/* 403 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var stirlingS2 = load(__webpack_require__(404)); - var isNegative = load(__webpack_require__(356)); - var isInteger = load(__webpack_require__(408)); - - /** - * The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. - * bellNumbers only takes integer arguments. - * The following condition must be enforced: n >= 0 - * - * Syntax: - * - * math.bellNumbers(n) - * - * Examples: - * - * math.bellNumbers(3); // returns 5; - * math.bellNumbers(8); // returns 4140; - * - * See also: - * - * stirlingS2 - * - * @param {Number | BigNumber} n Total number of objects in the set - * @return {Number | BigNumber} B(n) - */ - var bellNumbers = typed('bellNumbers', { - 'number | BigNumber': function (n) { - - if (!isInteger(n) || isNegative(n)) { - throw new TypeError('Non-negative integer value expected in function bellNumbers'); - } - - // Sum (k=0, n) S(n,k). - var result = 0; - for(var i = 0; i <= n; i++) { - result = add(result, stirlingS2(n, i)); - } - - return result; - } - }); - - bellNumbers.toTex = {1: '\\mathrm{B}_{${args[0]}}'}; - - return bellNumbers; - } - - exports.name = 'bellNumbers'; - exports.factory = factory; - - -/***/ }, -/* 404 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var subtract = load(__webpack_require__(77)); - var multiply = load(__webpack_require__(84)); - var divide = load(__webpack_require__(317)); - var pow = load(__webpack_require__(82)); - var factorial = load(__webpack_require__(405)); - var combinations = load(__webpack_require__(407)); - var isNegative = load(__webpack_require__(356)); - var isInteger = load(__webpack_require__(408)); - var larger = load(__webpack_require__(64)); - - /** - * The Stirling numbers of the second kind, counts the number of ways to partition - * a set of n labelled objects into k nonempty unlabelled subsets. - * stirlingS2 only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * If n = k or k = 1, then s(n,k) = 1 - * - * Syntax: - * - * math.stirlingS2(n, k) - * - * Examples: - * - * math.stirlingS2(5, 3); //returns 25 - * - * See also: - * - * Bell numbers - * - * @param {Number | BigNumber} n Total number of objects in the set - * @param {Number | BigNumber} k Number of objects in the subset - * @return {Number | BigNumber} S(n,k) - */ - var stirlingS2 = typed('stirlingS2', { - 'number | BigNumber, number | BigNumber': function (n, k) { - if (!isInteger(n) || isNegative(n) || !isInteger(k) || isNegative(k)) { - throw new TypeError('Non-negative integer value expected in function stirlingS2'); - } - else if (larger(k, n)) { - throw new TypeError('k must be less than or equal to n in function stirlingS2'); - } - - // 1/k! Sum(i=0 -> k) [(-1)^(k-i)*C(k,j)* i^n] - var kFactorial = factorial(k); - var result = 0; - for(var i = 0; i <= k; i++) { - var negativeOne = pow(-1, subtract(k,i)); - var kChooseI = combinations(k,i); - var iPower = pow(i,n); - - result = add(result, multiply(multiply(kChooseI, iPower), negativeOne)); - } - - return divide(result, kFactorial); - } - }); - - stirlingS2.toTex = {2: '\\mathrm{S}\\left(${args}\\right)'}; - - return stirlingS2; - } - - exports.name = 'stirlingS2'; - exports.factory = factory; - - -/***/ }, -/* 405 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var gamma = load(__webpack_require__(406)); - var latex = __webpack_require__(32); - - /** - * Compute the factorial of a value - * - * Factorial only supports an integer value as argument. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.factorial(n) - * - * Examples: - * - * math.factorial(5); // returns 120 - * math.factorial(3); // returns 6 - * - * See also: - * - * combinations, gamma, permutations - * - * @param {number | BigNumber | Array | Matrix} n An integer number - * @return {number | BigNumber | Array | Matrix} The factorial of `n` - */ - var factorial = typed('factorial', { - 'number': function (n) { - if (n < 0) { - throw new Error('Value must be non-negative'); - } - - return gamma(n + 1); - }, - - 'BigNumber': function (n) { - if (n.isNegative()) { - throw new Error('Value must be non-negative'); - } - - return gamma(n.plus(1)); - }, - - 'Array | Matrix': function (n) { - return deepMap(n, factorial); - } - }); - - factorial.toTex = { - 1: '\\left(${args[0]}\\right)' + latex.operators['factorial'] - }; - - return factorial; - } - - exports.name = 'factorial'; - exports.factory = factory; - - -/***/ }, -/* 406 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var multiply = load(__webpack_require__(84)); - var pow = load(__webpack_require__(82)); - - /** - * Compute the gamma function of a value using Lanczos approximation for - * small values, and an extended Stirling approximation for large values. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.gamma(n) - * - * Examples: - * - * math.gamma(5); // returns 24 - * math.gamma(-0.5); // returns -3.5449077018110335 - * math.gamma(math.i); // returns -0.15494982830180973 - 0.49801566811835596i - * - * See also: - * - * combinations, factorial, permutations - * - * @param {number | Array | Matrix} n A real or complex number - * @return {number | Array | Matrix} The gamma of `n` - */ - var gamma = typed('gamma', { - 'number': function (n) { - var t, x; - - if (isInteger(n)) { - if (n <= 0) { - return isFinite(n) ? Infinity : NaN; - } - - if (n > 171) { - return Infinity; // Will overflow - } - - var value = n - 2; - var res = n - 1; - while (value > 1) { - res *= value; - value--; - } - - if (res == 0) { - res = 1; // 0! is per definition 1 - } - - return res; - } - - if (n < 0.5) { - return Math.PI / (Math.sin(Math.PI * n) * gamma(1-n)); - } - - if (n >= 171.35) { - return Infinity; // will overflow - } - - if (n > 85.0) { // Extended Stirling Approx - var twoN = n*n; - var threeN = twoN*n; - var fourN = threeN*n; - var fiveN = fourN*n; - return Math.sqrt(2*Math.PI/n) * Math.pow((n/Math.E), n) * - (1 + 1/(12*n) + 1/(288*twoN) - 139/(51840*threeN) - - 571/(2488320*fourN) + 163879/(209018880*fiveN) + - 5246819/(75246796800*fiveN*n)); - } - - --n; - x = p[0]; - for (var i = 1; i < p.length; ++i) { - x += p[i] / (n+i); - } - - t = n + g + 0.5; - return Math.sqrt(2*Math.PI) * Math.pow(t, n+0.5) * Math.exp(-t) * x; - }, - - 'Complex': function (n) { - var t, x; - - if (n.im == 0) { - return gamma(n.re); - } - - n = new type.Complex(n.re - 1, n.im); - x = new type.Complex(p[0], 0); - for (var i = 1; i < p.length; ++i) { - var real = n.re + i; // x += p[i]/(n+i) - var den = real*real + n.im*n.im; - if (den != 0) { - x.re += p[i] * real / den; - x.im += -(p[i] * n.im) / den; - } else { - x.re = p[i] < 0 - ? -Infinity - : Infinity; - } - } - - t = new type.Complex(n.re + g + 0.5, n.im); - var twoPiSqrt = Math.sqrt(2*Math.PI); - - n.re += 0.5; - var result = pow(t, n); - if (result.im == 0) { // sqrt(2*PI)*result - result.re *= twoPiSqrt; - } else if (result.re == 0) { - result.im *= twoPiSqrt; - } else { - result.re *= twoPiSqrt; - result.im *= twoPiSqrt; - } - - var r = Math.exp(-t.re); // exp(-t) - t.re = r * Math.cos(-t.im); - t.im = r * Math.sin(-t.im); - - return multiply(multiply(result, t), x); - }, - - 'BigNumber': function (n) { - if (n.isInteger()) { - return (n.isNegative() || n.isZero()) - ? new type.BigNumber(Infinity) - : bigFactorial(n.minus(1)); - } - - if (!n.isFinite()) { - return new type.BigNumber(n.isNegative() ? NaN : Infinity); - } - - throw new Error('Integer BigNumber expected'); - }, - - 'Array | Matrix': function (n) { - return deepMap(n, gamma); - } - }); - - /** - * Calculate factorial for a BigNumber - * @param {BigNumber} n - * @returns {BigNumber} Returns the factorial of n - */ - function bigFactorial(n) { - if (n.isZero()) { - return new type.BigNumber(1); // 0! is per definition 1 - } - - var precision = config.precision + (Math.log(n.toNumber()) | 0); - var Big = type.BigNumber.clone({precision: precision}); - - var res = new Big(n); - var value = n.toNumber() - 1; // number - while (value > 1) { - res = res.times(value); - value--; - } - - return new type.BigNumber(res.toPrecision(type.BigNumber.precision)); - } - - gamma.toTex = {1: '\\Gamma\\left(${args[0]}\\right)'}; - - return gamma; - } - - // TODO: comment on the variables g and p - - var g = 4.7421875; - - var p = [ - 0.99999999999999709182, - 57.156235665862923517, - -59.597960355475491248, - 14.136097974741747174, - -0.49191381609762019978, - 0.33994649984811888699e-4, - 0.46523628927048575665e-4, - -0.98374475304879564677e-4, - 0.15808870322491248884e-3, - -0.21026444172410488319e-3, - 0.21743961811521264320e-3, - -0.16431810653676389022e-3, - 0.84418223983852743293e-4, - -0.26190838401581408670e-4, - 0.36899182659531622704e-5 - ]; - - exports.name = 'gamma'; - exports.factory = factory; - - -/***/ }, -/* 407 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - /** - * Compute the number of ways of picking `k` unordered outcomes from `n` - * possibilities. - * - * Combinations only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * Syntax: - * - * math.combinations(n, k) - * - * Examples: - * - * math.combinations(7, 5); // returns 21 - * - * See also: - * - * permutations, factorial - * - * @param {number | BigNumber} n Total number of objects in the set - * @param {number | BigNumber} k Number of objects in the subset - * @return {number | BigNumber} Number of possible combinations. - */ - var combinations = typed('combinations', { - 'number, number': function (n, k) { - var max, result, i; - - if (!isInteger(n) || n < 0) { - throw new TypeError('Positive integer value expected in function combinations'); - } - if (!isInteger(k) || k < 0) { - throw new TypeError('Positive integer value expected in function combinations'); - } - if (k > n) { - throw new TypeError('k must be less than or equal to n'); - } - - max = Math.max(k, n - k); - result = 1; - for (i = 1; i <= n - max; i++) { - result = result * (max + i) / i; - } - - return result; - }, - - 'BigNumber, BigNumber': function (n, k) { - var max, result, i, ii; - var one = new type.BigNumber(1); - - if (!isPositiveInteger(n) || !isPositiveInteger(k)) { - throw new TypeError('Positive integer value expected in function combinations'); - } - if (k.gt(n)) { - throw new TypeError('k must be less than n in function combinations'); - } - - max = n.minus(k); - if (k.lt(max)) max = k; - result = one; - for (i = one, ii = n.minus(max); i.lte(ii); i = i.plus(1)) { - result = result.times(max.plus(i)).dividedBy(i); - } - - return result; - } - - // TODO: implement support for collection in combinations - }); - - combinations.toTex = {2: '\\binom{${args[0]}}{${args[1]}}'}; - - return combinations; - } - - /** - * Test whether BigNumber n is a positive integer - * @param {BigNumber} n - * @returns {boolean} isPositiveInteger - */ - function isPositiveInteger(n) { - return n.isInteger() && n.gte(0); - } - - exports.name = 'combinations'; - exports.factory = factory; - - -/***/ }, -/* 408 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Test whether a value is an integer number. - * The function supports `number`, `BigNumber`, and `Fraction`. - * - * The function is evaluated element-wise in case of Array or Matrix input. - * - * Syntax: - * - * math.isInteger(x) - * - * Examples: - * - * math.isInteger(2); // returns true - * math.isInteger(0); // returns true - * math.isInteger(0.5); // returns false - * math.isInteger(math.bignumber(500)); // returns true - * math.isInteger(math.fraction(4)); // returns true - * math.isInteger('3'); // returns true - * math.isInteger([3, 0.5, -2]); // returns [true, false, true] - * math.isInteger(math.complex('2-4i'); // throws an error - * - * See also: - * - * isNumeric, isPositive, isNegative, isZero - * - * @param {number | BigNumber | Fraction | Array | Matrix} x Value to be tested - * @return {boolean} Returns true when `x` contains a numeric, integer value. - * Throws an error in case of an unknown data type. - */ - var isInteger = typed('isInteger', { - 'number': number.isInteger, // TODO: what to do with isInteger(add(0.1, 0.2)) ? - - 'BigNumber': function (x) { - return x.isInt(); - }, - - 'Fraction': function (x) { - return x.d === 1 && isFinite(x.n); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, isInteger); - } - }); - - return isInteger; - } - - exports.name = 'isInteger'; - exports.factory = factory; - - -/***/ }, -/* 409 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var combinations = load(__webpack_require__(407)); - var add = load(__webpack_require__(53)); - var isPositive = load(__webpack_require__(370)); - var isInteger = load(__webpack_require__(408)); - var larger = load(__webpack_require__(64)); - - /** - * The composition counts of n into k parts. - * - * composition only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * Syntax: - * - * math.composition(n, k) - * - * Examples: - * - * math.composition(5, 3); // returns 6 - * - * See also: - * - * combinations - * - * @param {Number | BigNumber} n Total number of objects in the set - * @param {Number | BigNumber} k Number of objects in the subset - * @return {Number | BigNumber} Returns the composition counts of n into k parts. - */ - var composition = typed('composition', { - 'number | BigNumber, number | BigNumber': function (n, k) { - if (!isInteger(n) || !isPositive(n) || !isInteger(k) || !isPositive(k)) { - throw new TypeError('Positive integer value expected in function composition'); - } - else if (larger(k, n)) { - throw new TypeError('k must be less than or equal to n in function composition'); - } - - return combinations(add(n, -1), add(k, -1)); - } - }); - - composition.toTex = undefined; // use default template - - return composition; - } - - exports.name = 'composition'; - exports.factory = factory; - - -/***/ }, -/* 410 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var divide = load(__webpack_require__(317)); - var multiply = load(__webpack_require__(84)); - var combinations = load(__webpack_require__(407)); - var isNegative = load(__webpack_require__(356)); - var isInteger = load(__webpack_require__(408)); - - - /** - * The Catalan Numbers enumerate combinatorial structures of many different types. - * catalan only takes integer arguments. - * The following condition must be enforced: n >= 0 - * - * Syntax: - * - * math.catalan(n) - * - * Examples: - * - * math.catalan(3); // returns 5; - * math.catalan(8); // returns 1430; - * - * See also: - * - * bellNumbers - * - * @param {Number | BigNumber} n nth Catalan number - * @return {Number | BigNumber} Cn(n) - */ - var catalan = typed('catalan', { - 'number | BigNumber': function (n) { - - if (!isInteger(n) || isNegative(n)) { - throw new TypeError('Non-negative integer value expected in function catalan'); - } - - return divide(combinations(multiply(n,2), n), add(n,1)); - - } - }); - - catalan.toTex = {1: '\\mathrm{C}_{${args[0]}}'}; - - return catalan; - } - - exports.name = 'catalan'; - exports.factory = factory; - - -/***/ }, -/* 411 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(412), - __webpack_require__(413), - __webpack_require__(414), - __webpack_require__(415) - ]; - - -/***/ }, -/* 412 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Compute the argument of a complex value. - * For a complex number `a + bi`, the argument is computed as `atan2(b, a)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.arg(x) - * - * Examples: - * - * var a = math.complex(2, 2); - * math.arg(a) / math.pi; // returns number 0.25 - * - * var b = math.complex('2 + 3i'); - * math.arg(b); // returns number 0.982793723247329 - * math.atan2(3, 2); // returns number 0.982793723247329 - * - * See also: - * - * re, im, conj, abs - * - * @param {number | Complex | Array | Matrix} x - * A complex number or array with complex numbers - * @return {number | Array | Matrix} The argument of x - */ - var arg = typed('arg', { - 'number': function (x) { - return Math.atan2(0, x); - }, - - 'Complex': function (x) { - return x.arg(); - }, - - // TODO: implement BigNumber support for function arg - - 'Array | Matrix': function (x) { - return deepMap(x, arg); - } - }); - - arg.toTex = {1: '\\arg\\left(${args[0]}\\right)'}; - - return arg; - } - - exports.name = 'arg'; - exports.factory = factory; - - -/***/ }, -/* 413 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Compute the complex conjugate of a complex value. - * If `x = a+bi`, the complex conjugate of `x` is `a - bi`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.conj(x) - * - * Examples: - * - * math.conj(math.complex('2 + 3i')); // returns Complex 2 - 3i - * math.conj(math.complex('2 - 3i')); // returns Complex 2 + 3i - * math.conj(math.complex('-5.2i')); // returns Complex 5.2i - * - * See also: - * - * re, im, arg, abs - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * A complex number or array with complex numbers - * @return {number | BigNumber | Complex | Array | Matrix} - * The complex conjugate of x - */ - var conj = typed('conj', { - 'number': function (x) { - return x; - }, - - 'BigNumber': function (x) { - return x; - }, - - 'Complex': function (x) { - return x.conjugate(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, conj); - } - }); - - conj.toTex = {1: '\\left(${args[0]}\\right)^*'}; - - return conj; - } - - exports.name = 'conj'; - exports.factory = factory; - - -/***/ }, -/* 414 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Get the imaginary part of a complex number. - * For a complex number `a + bi`, the function returns `b`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.im(x) - * - * Examples: - * - * var a = math.complex(2, 3); - * math.re(a); // returns number 2 - * math.im(a); // returns number 3 - * - * math.re(math.complex('-5.2i')); // returns number -5.2 - * math.re(math.complex(2.4)); // returns number 0 - * - * See also: - * - * re, conj, abs, arg - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * A complex number or array with complex numbers - * @return {number | BigNumber | Array | Matrix} The imaginary part of x - */ - var im = typed('im', { - 'number': function (x) { - return 0; - }, - - 'BigNumber': function (x) { - return new type.BigNumber(0); - }, - - 'Complex': function (x) { - return x.im; - }, - - 'Array | Matrix': function (x) { - return deepMap(x, im); - } - }); - - im.toTex = {1: '\\Im\\left\\lbrace${args[0]}\\right\\rbrace'}; - - return im; - } - - exports.name = 'im'; - exports.factory = factory; - - -/***/ }, -/* 415 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Get the real part of a complex number. - * For a complex number `a + bi`, the function returns `a`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.re(x) - * - * Examples: - * - * var a = math.complex(2, 3); - * math.re(a); // returns number 2 - * math.im(a); // returns number 3 - * - * math.re(math.complex('-5.2i')); // returns number 0 - * math.re(math.complex(2.4)); // returns number 2.4 - * - * See also: - * - * im, conj, abs, arg - * - * @param {number | BigNumber | Complex | Array | Matrix} x - * A complex number or array with complex numbers - * @return {number | BigNumber | Array | Matrix} The real part of x - */ - var re = typed('re', { - 'number': function (x) { - return x; - }, - - 'BigNumber': function (x) { - return x; - }, - - 'Complex': function (x) { - return x.re; - }, - - 'Array | Matrix': function (x) { - return deepMap(x, re); - } - }); - - re.toTex = {1: '\\Re\\left\\lbrace${args[0]}\\right\\rbrace'}; - - return re; - } - - exports.name = 're'; - exports.factory = factory; - - -/***/ }, -/* 416 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(417), - __webpack_require__(418) - ]; - - -/***/ }, -/* 417 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var abs = load(__webpack_require__(86)); - var add = load(__webpack_require__(51)); - var matrix = load(__webpack_require__(52)); - var multiply = load(__webpack_require__(84)); - var subtract = load(__webpack_require__(77)); - - /** - * Calculates the point of intersection of two lines in two or three dimensions - * and of a line and a plane in three dimensions. The inputs are in the form of - * arrays or 1 dimensional matrices. The line intersection functions return null - * if the lines do not meet. - * - * Note: Fill the plane coefficients as `x + y + z = c` and not as `x + y + z + c = 0`. - * - * Syntax: - * - * math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2) - * math.intersect(endPoint1, endPoint2, planeCoefficients) - * - * Examples: - * - * math.intersect([0, 0], [10, 10], [10, 0], [0, 10]); // Returns [5, 5] - * math.intersect([0, 0, 0], [10, 10, 0], [10, 0, 0], [0, 10, 0]); // Returns [5, 5, 0] - * math.intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6]); // Returns [7, -4, 3] - * - * @param {Array | Matrix} w Co-ordinates of first end-point of first line - * @param {Array | Matrix} x Co-ordinates of second end-point of first line - * @param {Array | Matrix} y Co-ordinates of first end-point of second line - * OR Co-efficients of the plane's equation - * @param {Array | Matrix} z Co-ordinates of second end-point of second line - * OR null if the calculation is for line and plane - * @return {Array} Returns the point of intersection of lines/lines-planes - */ - var intersect = typed('intersect', { - 'Array, Array, Array': function (x, y, plane) { - if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } - if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } - if (!_4d(plane)) { throw new TypeError('Array with 4 numbers expected as third argument'); } - - return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]); - }, - - 'Array, Array, Array, Array': function (w, x, y, z) { - if (w.length === 2) { - if (!_2d(w)) { throw new TypeError('Array with 2 numbers expected for first argument'); } - if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for second argument'); } - if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for third argument'); } - if (!_2d(z)) { throw new TypeError('Array with 2 numbers expected for fourth argument'); } - - return _intersect2d(w, x, y, z); - } - else if (w.length === 3) { - if (!_3d(w)) { throw new TypeError('Array with 3 numbers expected for first argument'); } - if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for second argument'); } - if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for third argument'); } - if (!_3d(z)) { throw new TypeError('Array with 3 numbers expected for fourth argument'); } - - return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]); - } - else { - throw new TypeError('Arrays with two or thee dimensional points expected'); - } - }, - - 'Matrix, Matrix, Matrix': function (x, y, plane) { - return matrix(intersect(x.valueOf(), y.valueOf(), plane.valueOf())); - }, - - 'Matrix, Matrix, Matrix, Matrix': function (w, x, y, z) { - // TODO: output matrix type should match input matrix type - return matrix(intersect(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf())); - } - }); - - function _2d(x) { - return x.length === 2 && typeof x[0] === 'number' && typeof x[1] === 'number'; - } - - function _3d(x) { - return x.length === 3 && typeof x[0] === 'number' && typeof x[1] === 'number' && typeof x[2] === 'number'; - } - - function _4d(x) { - return x.length === 4 && typeof x[0] === 'number' && typeof x[1] === 'number' && typeof x[2] === 'number' && typeof x[3] === 'number'; - } - - function _intersect2d(p1a, p1b, p2a, p2b){ - var o1 = p1a; - var o2 = p2a; - var d1 = subtract(o1, p1b); - var d2 = subtract(o2, p2b); - var det = d1[0]*d2[1] - d2[0]*d1[1]; - if (abs(det) < config.epsilon) { - return null; - } - var t = (d2[0]*o1[1] - d2[1]*o1[0] - d2[0]*o2[1] + d2[1]*o2[0]) / det; - return add(multiply(d1, t), o1); - } - - function _intersect3d(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4){ - var d1343 = (x1 - x3)*(x4 - x3) + (y1 - y3)*(y4 - y3) + (z1 - z3)*(z4 - z3); - var d4321 = (x4 - x3)*(x2 - x1) + (y4 - y3)*(y2 - y1) + (z4 - z3)*(z2 - z1); - var d1321 = (x1 - x3)*(x2 - x1) + (y1 - y3)*(y2 - y1) + (z1 - z3)*(z2 - z1); - var d4343 = (x4 - x3)*(x4 - x3) + (y4 - y3)*(y4 - y3) + (z4 - z3)*(z4 - z3); - var d2121 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) + (z2 - z1)*(z2 - z1); - var ta = ( d1343*d4321 - d1321*d4343 ) / ( d2121*d4343 - d4321*d4321 ); - var tb = ( d1343 + ta * d4321 ) / (d4343); - - var pax = x1 + ta * (x2 - x1); - var pay = y1 + ta * (y2 - y1); - var paz = z1 + ta * (z2 - z1); - var pbx = x3 + tb * (x4 - x3); - var pby = y3 + tb * (y4 - y3); - var pbz = z3 + tb * (z4 - z3); - if (pax === pbx && pay === pby && paz === pbz){ - return [pax, pay, paz]; - } - else{ - return null; - } - } - - function _intersectLinePlane(x1, y1, z1, x2, y2, z2, x, y, z, c){ - var t = (c - x1*x - y1*y - z1*z)/(x2*x + y2*y + z2*z - x1 - y1 - z1); - var px = x1 + t * (x2 - x1); - var py = y1 + t * (y2 - y1); - var pz = z1 + t * (z2 - z1); - return [px, py, pz]; - // TODO: Add cases when line is parallel to the plane: - // (a) no intersection, - // (b) line contained in plane - } - - return intersect; - } - - exports.name = 'intersect'; - exports.factory = factory; - - -/***/ }, -/* 418 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Calculates: - * The eucledian distance between two points in 2 and 3 dimensional spaces. - * Distance between point and a line in 2 and 3 dimensional spaces. - * Pairwise distance between a set of 2D or 3D points - * NOTE: - * When substituting coefficients of a line(a, b and c), use ax + by + c = 0 instead of ax + by = c - * For parametric equation of a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b, c) - * - * Syntax: - * math.distance([x1, y1], [x2, y2]) - *- math.distance({pointOneX: 4, pointOneY: 5}, {pointTwoX: 2, pointTwoY: 7}) - * math.distance([x1, y1, z1], [x2, y2, z2]) - * math.distance({pointOneX: 4, pointOneY: 5, pointOneZ: 8}, {pointTwoX: 2, pointTwoY: 7, pointTwoZ: 9}) - * math.distance([[A], [B], [C]...]) - * math.distance([x1, y1], [LinePtX1, LinePtY1], [LinePtX2, LinePtY2]) - * math.distance({pointX: 1, pointY: 4}, {lineOnePtX: 6, lineOnePtY: 3}, {lineTwoPtX: 2, lineTwoPtY: 8}) - * math.distance([x1, y1, z1], [LinePtX1, LinePtY1, LinePtZ1], [LinePtX2, LinePtY2, LinePtZ2]) - * math.distance({pointX: 1, pointY: 4, pointZ: 7}, {lineOnePtX: 6, lineOnePtY: 3, lineOnePtZ: 4}, {lineTwoPtX: 2, lineTwoPtY: 8, lineTwoPtZ: 5}) - * math.distance([x1, y1], [xCoeffLine, yCoeffLine, constant]) - * math.distance({pointX: 10, pointY: 10}, {xCoeffLine: 8, yCoeffLine: 1, constant: 3}) - * math.distance([x1, y1, z1], [x0, y0, z0, a-tCoeff, b-tCoeff, c-tCoeff]) point and parametric equation of 3D line - * math.distance([x, y, z], [x0, y0, z0, a, b, c]) - * math.distance({pointX: 2, pointY: 5, pointZ: 9}, {x0: 4, y0: 6, z0: 3, a: 4, b: 2, c: 0}) - * - * Examples: - * math.distance([0,0], [4,4]) // Returns 5.6569 - * math.distance( - * {pointOneX: 0, pointOneY: 0}, - * {pointTwoX: 10, pointTwoY: 10}) // Returns 14.142135623730951 - * math.distance([1, 0, 1], [4, -2, 2]) // Returns 3.74166 - * math.distance( - * {pointOneX: 4, pointOneY: 5, pointOneZ: 8}, - * {pointTwoX: 2, pointTwoY: 7, pointTwoZ: 9}) // Returns 3 - * math.distance([[1, 2], [1, 2], [1, 3]]) // Returns [0, 1, 1] - * math.distance([[1,2,4], [1,2,6], [8,1,3]]) // Returns [2, 7.14142842854285, 7.681145747868608] - * math.distance([10, 10], [8, 1, 3]) // Returns 11.535230316796387 - * math.distance([10, 10], [2, 3], [-8, 0]) // Returns 8.759953130362847 - * math.distance( - * {pointX: 1, pointY: 4}, - * {lineOnePtX: 6, lineOnePtY: 3}, - * {lineTwoPtX: 2, lineTwoPtY: 8}) // Returns 2.720549372624744 - * math.distance([2, 3, 1], [1, 1, 2, 5, 0, 1]) // Returns 2.3204774044612857 - * math.distance( - * {pointX: 2, pointY: 3, pointZ: 1}, - * {x0: 1, y0: 1, z0: 2, a: 5, b: 0, c: 1} // Returns 2.3204774044612857 - * - * @param {Array | Matrix | Object} x Co-ordinates of first point - * @param {Array | Matrix | Object} y Co-ordinates of second point - * @return {Number | BigNumber} Returns the distance from two/three points - */ - - var distance = typed('distance', { - 'Array, Array, Array': function(x, y, z){ - // Point to Line 2D; (x=Point, y=LinePoint1, z=LinePoint2) - if (x.length == 2 && y.length == 2 && z.length == 2){ - if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } - if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for second argument'); } - if (!_2d(z)) { throw new TypeError('Array with 2 numbers expected for third argument'); } - var m = (z[1]-z[0])/(y[1]-y[0]); - var xCoeff = m*m*y[0]; - var yCoeff = -1*(m*y[0]); - var constant = x[1]; - - return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant); - } - else{ - throw new TypeError('Invalid Arguments: Try again'); - } - }, - 'Object, Object, Object': function(x, y, z){ - if (Object.keys(x).length == 2 && Object.keys(y).length == 2 && Object.keys(z).length == 2){ - if (!_2d(x)) { throw new TypeError('Values of pointX and pointY should be numbers'); } - if (!_2d(y)) { throw new TypeError('Values of lineOnePtX and lineOnePtY should be numbers'); } - if (!_2d(z)) { throw new TypeError('Values of lineTwoPtX and lineTwoPtY should be numbers'); } - if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('lineOnePtX') && - y.hasOwnProperty('lineOnePtY') && z.hasOwnProperty('lineTwoPtX') && z.hasOwnProperty('lineTwoPtY')){ - var m = (z.lineTwoPtY-z.lineTwoPtX)/(y.lineOnePtY-y.lineOnePtX); - var xCoeff = m*m*y.lineOnePtX; - var yCoeff = -1*(m*y.lineOnePtX); - var constant = x.pointX; - - return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant); - } - else{ - throw new TypeError('Key names do not match'); - } - } - else{ - throw new TypeError('Invalid Arguments: Try again'); - } - }, - 'Array, Array': function(x, y){ - // Point to Line 2D; (x=[pointX, pointY], y=[x-coeff, y-coeff, const]) - if (x.length == 2 && y.length == 3){ - if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } - if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } - - return _distancePointLine2D(x[0], x[1], y[0], y[1], y[2]); - } - // Point to Line 3D - else if (x.length == 3 && y.length == 6){ - if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } - if (!_parametricLine(y)) { throw new TypeError('Array with 6 numbers expected for second argument'); } - - return _distancePointLine3D(x[0], x[1], x[2], y[0], y[1], y[2], y[3], y[4], y[5]); - } - // Point to Point 2D - else if (x.length == 2 && y.length == 2){ - if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } - if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for second argument'); } - - return _distance2d(x[0], x[1], y[0], y[1]); - } - // Point to Point 3D - else if(x.length == 3 && y.length == 3){ - if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } - if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } - - return _distance3d(x[0], x[1], x[2], y[0], y[1], y[2]); - } - else{ - throw new TypeError('Invalid Arguments: Try again'); - } - }, - 'Object, Object': function(x, y){ - if (Object.keys(x).length == 2 && Object.keys(y).length == 3){ - if (!_2d(x)) { throw new TypeError('Values of pointX and pointY should be numbers'); } - if (!_3d(y)) { throw new TypeError('Values of xCoeffLine, yCoeffLine and constant should be numbers'); } - if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('xCoeffLine') && - y.hasOwnProperty('yCoeffLine') && y.hasOwnProperty('yCoeffLine')){ - - return _distancePointLine2D(x.pointX, x.pointY, y.xCoeffLine, y.yCoeffLine, y.constant); - } - else{ - throw new TypeError('Key names do not match'); - } - } - // Point to Line 3D - else if (Object.keys(x).length == 3 && Object.keys(y).length == 6){ - if (!_3d(x)) { throw new TypeError('Values of pointX, pointY and pointZ should be numbers'); } - if (!_parametricLine(y)) { throw new TypeError('Values of x0, y0, z0, a, b and c should be numbers'); } - if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('x0') && - y.hasOwnProperty('y0') && y.hasOwnProperty('z0') && y.hasOwnProperty('a') && - y.hasOwnProperty('b') && y.hasOwnProperty('c')){ - - return _distancePointLine3D(x.pointX, x.pointY, x.pointZ, y.x0, y.y0, y.z0, y.a, y.b, y.c); - } - else{ - throw new TypeError('Key names do not match'); - } - } - // Point to Point 2D - else if (Object.keys(x).length == 2 && Object.keys(y).length == 2){ - if (!_2d(x)) { throw new TypeError('Values of pointOneX and pointOneY should be numbers'); } - if (!_2d(y)) { throw new TypeError('Values of pointTwoX and pointTwoY should be numbers'); } - if (x.hasOwnProperty('pointOneX') && x.hasOwnProperty('pointOneY') && - y.hasOwnProperty('pointTwoX') && y.hasOwnProperty('pointTwoY')){ - - return _distance2d(x.pointOneX, x.pointOneY, y.pointTwoX, y.pointTwoY); - } - else{ - throw new TypeError('Key names do not match'); - } - } - // Point to Point 3D - else if(Object.keys(x).length == 3 && Object.keys(y).length == 3){ - if (!_3d(x)) { throw new TypeError('Values of pointOneX, pointOneY and pointOneZ should be numbers'); } - if (!_3d(y)) { throw new TypeError('Values of pointTwoX, pointTwoY and pointTwoZ should be numbers'); } - if (x.hasOwnProperty('pointOneX') && x.hasOwnProperty('pointOneY') && x.hasOwnProperty('pointOneZ') && - y.hasOwnProperty('pointTwoX') && y.hasOwnProperty('pointTwoY') && y.hasOwnProperty('pointTwoZ')){ - - return _distance3d(x.pointOneX, x.pointOneY, x.pointOneZ, y.pointTwoX, y.pointTwoY, y.pointTwoZ); - } - else { - throw new TypeError('Key names do not match'); - } - } - else{ - throw new TypeError('Invalid Arguments: Try again'); - } - }, - 'Array': function(arr){ - if (!_pairwise(arr)) { throw new TypeError('Incorrect array format entered for pairwise distance calculation'); } - - return _distancePairwise(arr); - } - }); - return distance; - } - - function _2d(a){ - // checks if the number of arguments are correct in count and are valid (should be numbers) - if (a.constructor !== Array){ - a = _objectToArray(a); - } - return typeof a[0] === 'number' && typeof a[1] === 'number'; - } - - function _3d(a){ - // checks if the number of arguments are correct in count and are valid (should be numbers) - if (a.constructor !== Array){ - a = _objectToArray(a); - } - return typeof a[0] === 'number' && typeof a[1] === 'number' && typeof a[2] === 'number'; - } - - function _parametricLine(a){ - if (a.constructor !== Array){ - a = _objectToArray(a); - } - return typeof a[0] === 'number' && typeof a[1] === 'number' && typeof a[2] === 'number' && - typeof a[3] === 'number' && typeof a[4] === 'number' && typeof a[5] === 'number'; - - } - - function _objectToArray(o){ - var keys = Object.keys(o); - var a = []; - for (var i = 0; i < keys.length; i++) { - a.push(o[keys[i]]); - } - return a; - } - - function _pairwise(a){ - //checks for valid arguments passed to _distancePairwise(Array) - if (a[0].length == 2 && typeof a[0][0] === 'number' && typeof a[0][1] === 'number'){ - for(var i in a){ - if (a[i].length != 2 || typeof a[i][0] !== 'number' || typeof a[i][1] !== 'number'){ - return false; - } - } - } - else if (a[0].length == 3 && typeof a[0][0] === 'number' && typeof a[0][1] === 'number' && typeof a[0][2] === 'number'){ - for(var i in a){ - if (a[i].length != 3 || typeof a[i][0] !== 'number' || typeof a[i][1] !== 'number' || typeof a[i][2] !== 'number'){ - return false; - } - } - } - else{ - return false; - } - return true; - } - - function _distancePointLine2D(x, y, a, b, c){ - var num = Math.abs(a*x + b*y + c); - var den = Math.pow((a*a + b*b), 0.5); - var result = (num/den); - return result; - } - - function _distancePointLine3D(x, y, z, x0, y0, z0, a, b, c){ - var num = [((y0-y)*(c))-((z0-z)*(b)), ((z0-z)*(a))-((x0-x)*(c)), ((x0-x)*(b))-((y0-y)*(a))] - num = Math.pow(num[0]*num[0] + num[1]*num[1] + num[2]*num[2], 0.5); - var den = Math.pow(a*a + b*b + c*c, 0.5); - var result = num/den; - return result; - } - - function _distance2d(x1, y1, x2, y2){ - var yDiff = y2 - y1; - var xDiff = x2 - x1; - var radicant = yDiff * yDiff + xDiff * xDiff; - var result = Math.pow(radicant, 0.5); - return result; - } - - function _distance3d(x1, y1, z1, x2, y2, z2){ - var zDiff = z2 - z1; - var yDiff = y2 - y1; - var xDiff = x2 - x1; - var radicant = zDiff * zDiff + yDiff * yDiff + xDiff * xDiff; - var result = Math.pow(radicant, 0.5); - return result; - } - - function _distancePairwise(a){ - var result = []; - for(var i = 0; i < a.length-1; i++){ - for(var j = i+1; j < a.length; j++){ - if (a[0].length == 2){ - result.push(_distance2d(a[i][0], a[i][1], a[j][0], a[j][1])); - } - else if (a[0].length == 3){ - result.push(_distance3d(a[i][0], a[i][1], a[i][2], a[j][0], a[j][1], a[j][2])); - } - } - } - return result; - } - - exports.name = 'distance'; - exports.factory = factory; - - -/***/ }, -/* 419 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(420), - __webpack_require__(421), - __webpack_require__(423), - __webpack_require__(424) - ]; - - -/***/ }, -/* 420 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - var zeros = load(__webpack_require__(381)); - var not = load(__webpack_require__(421)); - var isZero = load(__webpack_require__(422)); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm06 = load(__webpack_require__(372)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Logical `and`. Test whether two values are both defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.and(x, y) - * - * Examples: - * - * math.and(2, 4); // returns true - * - * a = [2, 0, 0]; - * b = [3, 7, 0]; - * c = 0; - * - * math.and(a, b); // returns [true, false, false] - * math.and(a, c); // returns [false, false, false] - * - * See also: - * - * not, or, xor - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check - * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check - * @return {boolean | Array | Matrix} - * Returns true when both inputs are defined with a nonzero/nonempty value. - */ - var and = typed('and', { - - 'number, number': function (x, y) { - return !!(x && y); - }, - - 'Complex, Complex': function (x, y) { - return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0); - }, - - 'BigNumber, BigNumber': function (x, y) { - return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN(); - }, - - 'Unit, Unit': function (x, y) { - return and(x.value, y.value); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse & sparse - c = algorithm06(x, y, and, false); - break; - default: - // sparse & dense - c = algorithm02(y, x, and, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense & sparse - c = algorithm02(x, y, and, false); - break; - default: - // dense & dense - c = algorithm13(x, y, and); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return and(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return and(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return and(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // check scalar - if (not(y)) { - // return zero matrix - return zeros(x.size(), x.storage()); - } - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, and, false); - break; - default: - c = algorithm14(x, y, and, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // check scalar - if (not(x)) { - // return zero matrix - return zeros(x.size(), x.storage()); - } - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm11(y, x, and, true); - break; - default: - c = algorithm14(y, x, and, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return and(matrix(x), y).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return and(x, matrix(y)).valueOf(); - } - }); - - and.toTex = { - 2: '\\left(${args[0]}' + latex.operators['and'] + '${args[1]}\\right)' - }; - - return and; - } - - exports.name = 'and'; - exports.factory = factory; - - -/***/ }, -/* 421 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - /** - * Logical `not`. Flips boolean value of a given parameter. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.not(x) - * - * Examples: - * - * math.not(2); // returns false - * math.not(0); // returns true - * math.not(true); // returns false - * - * a = [2, -7, 0]; - * math.not(a); // returns [false, false, true] - * - * See also: - * - * and, or, xor - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check - * @return {boolean | Array | Matrix} - * Returns true when input is a zero or empty value. - */ - var not = typed('not', { - 'number': function (x) { - return !x; - }, - - 'Complex': function (x) { - return x.re === 0 && x.im === 0; - }, - - 'BigNumber': function (x) { - return x.isZero() || x.isNaN(); - }, - - 'Unit': function (x) { - return not(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, not); - } - }); - - not.toTex = { - 1: latex.operators['not'] + '\\left(${args[0]}\\right)' - }; - - return not; - } - - exports.name = 'not'; - exports.factory = factory; - - -/***/ }, -/* 422 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var number = __webpack_require__(6); - - function factory (type, config, load, typed) { - /** - * Test whether a value is zero. - * The function can check for zero for types `number`, `BigNumber`, `Fraction`, - * `Complex`, and `Unit`. - * - * The function is evaluated element-wise in case of Array or Matrix input. - * - * Syntax: - * - * math.isZero(x) - * - * Examples: - * - * math.isZero(0); // returns true - * math.isZero(2); // returns false - * math.isZero(0.5); // returns false - * math.isZero(math.bignumber(0)); // returns true - * math.isZero(math.fraction(0)); // returns true - * math.isZero(math.fraction(1,3)); // returns false - * math.isZero(math.complex('2 - 4i'); // returns false - * math.isZero(math.complex('0i'); // returns true - * math.isZero('0'); // returns true - * math.isZero('2'); // returns false - * math.isZero([2, 0, -3]'); // returns [false, true, false] - * - * See also: - * - * isNumeric, isPositive, isNegative, isInteger - * - * @param {number | BigNumber | Complex | Fraction | Unit | Array | Matrix} x Value to be tested - * @return {boolean} Returns true when `x` is zero. - * Throws an error in case of an unknown data type. - */ - var isZero = typed('isZero', { - 'number': function (x) { - return x === 0; - }, - - 'BigNumber': function (x) { - return x.isZero(); - }, - - 'Complex': function (x) { - return x.re === 0 && x.im === 0; - }, - - 'Fraction': function (x) { - return x.d === 1 && x.n === 0; - }, - - 'Unit': function (x) { - return isZero(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, isZero); - } - }); - - return isZero; - } - - exports.name = 'isZero'; - exports.factory = factory; - - -/***/ }, -/* 423 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm05 = load(__webpack_require__(79)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Logical `or`. Test if at least one value is defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.or(x, y) - * - * Examples: - * - * math.or(2, 4); // returns true - * - * a = [2, 5, 0]; - * b = [0, 22, 0]; - * c = 0; - * - * math.or(a, b); // returns [true, true, false] - * math.or(b, c); // returns [false, true, false] - * - * See also: - * - * and, not, xor - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check - * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check - * @return {boolean | Array | Matrix} - * Returns true when one of the inputs is defined with a nonzero/nonempty value. - */ - var or = typed('or', { - - 'number, number': function (x, y) { - return !!(x || y); - }, - - 'Complex, Complex': function (x, y) { - return (x.re !== 0 || x.im !== 0) || (y.re !== 0 || y.im !== 0); - }, - - 'BigNumber, BigNumber': function (x, y) { - return (!x.isZero() && !x.isNaN()) || (!y.isZero() && !y.isNaN()); - }, - - 'Unit, Unit': function (x, y) { - return or(x.value, y.value); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm05(x, y, or); - break; - default: - // sparse + dense - c = algorithm03(y, x, or, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, or, false); - break; - default: - // dense + dense - c = algorithm13(x, y, or); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return or(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return or(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return or(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, or, false); - break; - default: - c = algorithm14(x, y, or, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, or, true); - break; - default: - c = algorithm14(y, x, or, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, or, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, or, true).valueOf(); - } - }); - - or.toTex = { - 2: '\\left(${args[0]}' + latex.operators['or'] + '${args[1]}\\right)' - }; - - return or; - } - - exports.name = 'or'; - exports.factory = factory; - - -/***/ }, -/* 424 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Logical `xor`. Test whether one and only one value is defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.xor(x, y) - * - * Examples: - * - * math.xor(2, 4); // returns false - * - * a = [2, 0, 0]; - * b = [2, 7, 0]; - * c = 0; - * - * math.xor(a, b); // returns [false, true, false] - * math.xor(a, c); // returns [true, false, false] - * - * See also: - * - * and, not, or - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check - * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check - * @return {boolean | Array | Matrix} - * Returns true when one and only one input is defined with a nonzero/nonempty value. - */ - var xor = typed('xor', { - - 'number, number': function (x, y) { - return !!(!!x ^ !!y); - }, - - 'Complex, Complex': function (x, y) { - return ((x.re !== 0 || x.im !== 0) !== (y.re !== 0 || y.im !== 0)); - }, - - 'BigNumber, BigNumber': function (x, y) { - return ((!x.isZero() && !x.isNaN()) !== (!y.isZero() && !y.isNaN())); - }, - - 'Unit, Unit': function (x, y) { - return xor(x.value, y.value); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, xor); - break; - default: - // sparse + dense - c = algorithm03(y, x, xor, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, xor, false); - break; - default: - // dense + dense - c = algorithm13(x, y, xor); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return xor(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return xor(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return xor(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, xor, false); - break; - default: - c = algorithm14(x, y, xor, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, xor, true); - break; - default: - c = algorithm14(y, x, xor, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, xor, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, xor, true).valueOf(); - } - }); - - xor.toTex = { - 2: '\\left(${args[0]}' + latex.operators['xor'] + '${args[1]}\\right)' - }; - - return xor; - } - - exports.name = 'xor'; - exports.factory = factory; - - -/***/ }, -/* 425 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(301), - __webpack_require__(426), - __webpack_require__(319), - __webpack_require__(427), - __webpack_require__(428), - __webpack_require__(83), - __webpack_require__(303), - __webpack_require__(429), - __webpack_require__(305), - __webpack_require__(318), - __webpack_require__(308), - __webpack_require__(430), - __webpack_require__(431), - __webpack_require__(323), - __webpack_require__(433), - __webpack_require__(434), - __webpack_require__(435), - __webpack_require__(436), - __webpack_require__(276), - __webpack_require__(378), - __webpack_require__(335), - __webpack_require__(381) - ]; - - -/***/ }, -/* 426 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(40).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - var subtract = load(__webpack_require__(77)); - var multiply = load(__webpack_require__(84)); - - /** - * Calculate the cross product for two vectors in three dimensional space. - * The cross product of `A = [a1, a2, a3]` and `B =[b1, b2, b3]` is defined - * as: - * - * cross(A, B) = [ - * a2 * b3 - a3 * b2, - * a3 * b1 - a1 * b3, - * a1 * b2 - a2 * b1 - * ] - * - * Syntax: - * - * math.cross(x, y) - * - * Examples: - * - * math.cross([1, 1, 0], [0, 1, 1]); // Returns [1, -1, 1] - * math.cross([3, -3, 1], [4, 9, 2]); // Returns [-15, -2, 39] - * math.cross([2, 3, 4], [5, 6, 7]); // Returns [-3, 6, -3] - * - * See also: - * - * dot, multiply - * - * @param {Array | Matrix} x First vector - * @param {Array | Matrix} y Second vector - * @return {Array | Matrix} Returns the cross product of `x` and `y` - */ - var cross = typed('cross', { - 'Matrix, Matrix': function (x, y) { - return matrix(_cross(x.toArray(), y.toArray())); - }, - - 'Matrix, Array': function (x, y) { - return matrix(_cross(x.toArray(), y)); - }, - - 'Array, Matrix': function (x, y) { - return matrix(_cross(x, y.toArray())); - }, - - 'Array, Array': _cross - }); - - cross.toTex = { - 2: '\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)' - }; - - return cross; - - /** - * Calculate the cross product for two arrays - * @param {Array} x First vector - * @param {Array} y Second vector - * @returns {Array} Returns the cross product of x and y - * @private - */ - function _cross(x, y) { - var xSize= size(x); - var ySize = size(y); - - if (xSize.length != 1 || ySize.length != 1 || xSize[0] != 3 || ySize[0] != 3) { - throw new RangeError('Vectors with length 3 expected ' + - '(Size A = [' + xSize.join(', ') + '], B = [' + ySize.join(', ') + '])'); - } - - return [ - subtract(multiply(x[1], y[2]), multiply(x[2], y[1])), - subtract(multiply(x[2], y[0]), multiply(x[0], y[2])), - subtract(multiply(x[0], y[1]), multiply(x[1], y[0])) - ]; - } - } - - exports.name = 'cross'; - exports.factory = factory; - - -/***/ }, -/* 427 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(40); - var clone = __webpack_require__(3).clone; - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - /** - * Create a diagonal matrix or retrieve the diagonal of a matrix - * - * When `x` is a vector, a matrix with vector `x` on the diagonal will be returned. - * When `x` is a two dimensional matrix, the matrixes `k`th diagonal will be returned as vector. - * When k is positive, the values are placed on the super diagonal. - * When k is negative, the values are placed on the sub diagonal. - * - * Syntax: - * - * math.diag(X) - * math.diag(X, format) - * math.diag(X, k) - * math.diag(X, k, format) - * - * Examples: - * - * // create a diagonal matrix - * math.diag([1, 2, 3]); // returns [[1, 0, 0], [0, 2, 0], [0, 0, 3]] - * math.diag([1, 2, 3], 1); // returns [[0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]] - * math.diag([1, 2, 3], -1); // returns [[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]] - * - * // retrieve the diagonal from a matrix - * var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; - * math.diag(a); // returns [1, 5, 9] - * - * See also: - * - * ones, zeros, eye - * - * @param {Matrix | Array} x A two dimensional matrix or a vector - * @param {number | BigNumber} [k=0] The diagonal where the vector will be filled - * in or retrieved. - * @param {string} [format='dense'] The matrix storage format. - * - * @returns {Matrix | Array} Diagonal matrix from input vector, or diagonal from input matrix. - */ - var diag = typed('diag', { - // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments - - 'Array': function (x) { - return _diag(x, 0, array.size(x), null); - }, - - 'Array, number': function (x, k) { - return _diag(x, k, array.size(x), null); - }, - - 'Array, BigNumber': function (x, k) { - return _diag(x, k.toNumber(), array.size(x), null); - }, - - 'Array, string': function (x, format) { - return _diag(x, 0, array.size(x), format); - }, - - 'Array, number, string': function (x, k, format) { - return _diag(x, k, array.size(x), format); - }, - - 'Array, BigNumber, string': function (x, k, format) { - return _diag(x, k.toNumber(), array.size(x), format); - }, - - 'Matrix': function (x) { - return _diag(x, 0, x.size(), x.storage()); - }, - - 'Matrix, number': function (x, k) { - return _diag(x, k, x.size(), x.storage()); - }, - - 'Matrix, BigNumber': function (x, k) { - return _diag(x, k.toNumber(), x.size(), x.storage()); - }, - - 'Matrix, string': function (x, format) { - return _diag(x, 0, x.size(), format); - }, - - 'Matrix, number, string': function (x, k, format) { - return _diag(x, k, x.size(), format); - }, - - 'Matrix, BigNumber, string': function (x, k, format) { - return _diag(x, k.toNumber(), x.size(), format); - } - }); - - diag.toTex = undefined; // use default template - - return diag; - - /** - * Creeate diagonal matrix from a vector or vice versa - * @param {Array | Matrix} x - * @param {number} k - * @param {string} format Storage format for matrix. If null, - * an Array is returned - * @returns {Array | Matrix} - * @private - */ - function _diag (x, k, size, format) { - if (!isInteger(k)) { - throw new TypeError ('Second parameter in function diag must be an integer'); - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // check dimensions - switch (size.length) { - case 1: - return _createDiagonalMatrix(x, k, format, size[0], kSub, kSuper); - case 2: - return _getDiagonal(x, k, format, size, kSub, kSuper); - } - throw new RangeError('Matrix for function diag must be 2 dimensional'); - } - - function _createDiagonalMatrix(x, k, format, l, kSub, kSuper) { - // matrix size - var ms = [l + kSub, l + kSuper]; - // get matrix constructor - var F = type.Matrix.storage(format || 'dense'); - // create diagonal matrix - var m = F.diagonal(ms, x, k); - // check we need to return a matrix - return format !== null ? m : m.valueOf(); - } - - function _getDiagonal(x, k, format, s, kSub, kSuper) { - // check x is a Matrix - if (x && x.isMatrix === true) { - // get diagonal matrix - var dm = x.diagonal(k); - // check we need to return a matrix - if (format !== null) { - // check we need to change matrix format - if (format !== dm.storage()) - return matrix(dm, format); - return dm; - } - return dm.valueOf(); - } - // vector size - var n = Math.min(s[0] - kSub, s[1] - kSuper); - // diagonal values - var vector = []; - // loop diagonal - for (var i = 0; i < n; i++) { - vector[i] = x[i + kSub][i + kSuper]; - } - // check we need to return a matrix - return format !== null ? matrix(vector) : vector; - } - } - - exports.name = 'diag'; - exports.factory = factory; - - -/***/ }, -/* 428 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(40).size; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var multiply = load(__webpack_require__(84)); - - /** - * Calculate the dot product of two vectors. The dot product of - * `A = [a1, a2, a3, ..., an]` and `B = [b1, b2, b3, ..., bn]` is defined as: - * - * dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn - * - * Syntax: - * - * math.dot(x, y) - * - * Examples: - * - * math.dot([2, 4, 1], [2, 2, 3]); // returns number 15 - * math.multiply([2, 4, 1], [2, 2, 3]); // returns number 15 - * - * See also: - * - * multiply, cross - * - * @param {Array | Matrix} x First vector - * @param {Array | Matrix} y Second vector - * @return {number} Returns the dot product of `x` and `y` - */ - var dot = typed('dot', { - 'Matrix, Matrix': function (x, y) { - return _dot(x.toArray(), y.toArray()); - }, - - 'Matrix, Array': function (x, y) { - return _dot(x.toArray(), y); - }, - - 'Array, Matrix': function (x, y) { - return _dot(x, y.toArray()); - }, - - 'Array, Array': _dot - }); - - dot.toTex = {2: '\\left(${args[0]}\\cdot${args[1]}\\right)'}; - - return dot; - - /** - * Calculate the dot product for two arrays - * @param {Array} x First vector - * @param {Array} y Second vector - * @returns {number} Returns the dot product of x and y - * @private - */ - // TODO: double code with math.multiply - function _dot(x, y) { - var xSize= size(x); - var ySize = size(y); - var len = xSize[0]; - - if (xSize.length !== 1 || ySize.length !== 1) throw new RangeError('Vector expected'); // TODO: better error message - if (xSize[0] != ySize[0]) throw new RangeError('Vectors must have equal length (' + xSize[0] + ' != ' + ySize[0] + ')'); - if (len == 0) throw new RangeError('Cannot calculate the dot product of empty vectors'); - - var prod = 0; - for (var i = 0; i < len; i++) { - prod = add(prod, multiply(x[i], y[i])); - } - - return prod; - } - } - - exports.name = 'dot'; - exports.factory = factory; - - -/***/ }, -/* 429 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(3).clone; - var _flatten = __webpack_require__(40).flatten; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Flatten a multi dimensional matrix into a single dimensional matrix. - * - * Syntax: - * - * math.flatten(x) - * - * Examples: - * - * math.flatten([[1,2], [3,4]]); // returns [1, 2, 3, 4] - * - * See also: - * - * concat, resize, size, squeeze - * - * @param {Matrix | Array} x Matrix to be flattened - * @return {Matrix | Array} Returns the flattened matrix - */ - var flatten = typed('flatten', { - 'Array': function (x) { - return _flatten(clone(x)); - }, - - 'Matrix': function (x) { - var flat = _flatten(clone(x.toArray())); - // TODO: return the same matrix type as x - return matrix(flat); - } - }); - - flatten.toTex = undefined; // use default template - - return flatten; - } - - exports.name = 'flatten'; - exports.factory = factory; - - -/***/ }, -/* 430 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var resize = __webpack_require__(40).resize; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Create a matrix filled with ones. The created matrix can have one or - * multiple dimensions. - * - * Syntax: - * - * math.ones(m) - * math.ones(m, format) - * math.ones(m, n) - * math.ones(m, n, format) - * math.ones([m, n]) - * math.ones([m, n], format) - * math.ones([m, n, p, ...]) - * math.ones([m, n, p, ...], format) - * - * Examples: - * - * math.ones(3); // returns [1, 1, 1] - * math.ones(3, 2); // returns [[1, 1], [1, 1], [1, 1]] - * math.ones(3, 2, 'dense'); // returns Dense Matrix [[1, 1], [1, 1], [1, 1]] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.ones(math.size(A)); // returns [[1, 1, 1], [1, 1, 1]] - * - * See also: - * - * zeros, eye, size, range - * - * @param {...number | Array} size The size of each dimension of the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Array | Matrix | number} A matrix filled with ones - */ - var ones = typed('ones', { - '': function () { - return (config.matrix === 'Array') - ? _ones([]) - : _ones([], 'default'); - }, - - // math.ones(m, n, p, ..., format) - // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this - '...number | BigNumber | string': function (size) { - var last = size[size.length - 1]; - if (typeof last === 'string') { - var format = size.pop(); - return _ones(size, format); - } - else if (config.matrix === 'Array') { - return _ones(size); - } - else { - return _ones(size, 'default'); - } - }, - - 'Array': _ones, - - 'Matrix': function (size) { - var format = size.storage(); - return _ones(size.valueOf(), format); - }, - - 'Array | Matrix, string': function (size, format) { - return _ones (size.valueOf(), format); - } - }); - - ones.toTex = undefined; // use default template - - return ones; - - /** - * Create an Array or Matrix with ones - * @param {Array} size - * @param {string} [format='default'] - * @return {Array | Matrix} - * @private - */ - function _ones(size, format) { - var hasBigNumbers = _normalize(size); - var defaultValue = hasBigNumbers ? new type.BigNumber(1) : 1; - _validate(size); - - if (format) { - // return a matrix - var m = matrix(format); - if (size.length > 0) { - return m.resize(size, defaultValue); - } - return m; - } - else { - // return an Array - var arr = []; - if (size.length > 0) { - return resize(arr, size, defaultValue); - } - return arr; - } - } - - // replace BigNumbers with numbers, returns true if size contained BigNumbers - function _normalize(size) { - var hasBigNumbers = false; - size.forEach(function (value, index, arr) { - if (value && value.isBigNumber === true) { - hasBigNumbers = true; - arr[index] = value.toNumber(); - } - }); - return hasBigNumbers; - } - - // validate arguments - function _validate (size) { - size.forEach(function (value) { - if (typeof value !== 'number' || !isInteger(value) || value < 0) { - throw new Error('Parameters in function ones must be positive integers'); - } - }); - } - } - - exports.name = 'ones'; - exports.factory = factory; - - -/***/ }, -/* 431 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var asc = load(__webpack_require__(432)); - function desc(a, b) { - return -asc(a, b); - } - - /** - * Partition-based selection of an array or 1D matrix. - * Will find the kth smallest value, and mutates the input array. - * Uses Quickselect. - * - * Syntax: - * - * math.partitionSelect(x, k) - * math.partitionSelect(x, k, compare) - * - * Examples: - * - * math.partitionSelect([5, 10, 1], 2); // returns 10 - * math.partitionSelect(['C', 'B', 'A', 'D'], 1); // returns 'B' - * - * function sortByLength (a, b) { - * return a.length - b.length; - * } - * math.partitionSelect(['Langdon', 'Tom', 'Sara'], 2, sortByLength); // returns 'Langdon' - * - * See also: - * - * sort - * - * @param {Matrix | Array} x A one dimensional matrix or array to sort - * @param {Number} k The kth smallest value to be retrieved; zero-based index - * @param {Function | 'asc' | 'desc'} [compare='asc'] - * An optional comparator function. The function is called as - * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, - * and 0 when a == b. - * @return {*} Returns the kth lowest value. - */ - return typed('partitionSelect', { - 'Array | Matrix, number': function (x, k) { - return _partitionSelect(x, k, asc); - }, - - 'Array | Matrix, number, string': function (x, k, compare) { - if (compare === 'asc') { - return _partitionSelect(x, k, asc); - } - else if (compare === 'desc') { - return _partitionSelect(x, k, desc); - } - else { - throw new Error('Compare string must be "asc" or "desc"'); - } - }, - - 'Array | Matrix, number, function': _partitionSelect - }); - - function _partitionSelect(x, k, compare) { - if (!isInteger(k) || k < 0) { - throw new Error('k must be a non-negative integer'); - } - - if (x && x.isMatrix) { - var size = x.size(); - if (size.length > 1) { - throw new Error('Only one dimensional matrices supported'); - } - return quickSelect(x.valueOf(), k, compare); - } - - if (Array.isArray(x)) { - return quickSelect(x, k, compare); - } - } - - /** - * Quickselect algorithm. - * Code adapted from: - * http://blog.teamleadnet.com/2012/07/quick-select-algorithm-find-kth-element.html - * - * @param {Array} arr - * @param {Number} k - * @param {Function} compare - * @private - */ - function quickSelect(arr, k, compare) { - if (k >= arr.length) { - throw new Error('k out of bounds'); - } - - var from = 0; - var to = arr.length - 1; - - // if from == to we reached the kth element - while (from < to) { - var r = from; - var w = to; - var pivot = arr[Math.floor(Math.random() * (to - from + 1)) + from]; - - // stop if the reader and writer meets - while (r < w) { - // arr[r] >= pivot - if (compare(arr[r], pivot) >= 0) { // put the large values at the end - var tmp = arr[w]; - arr[w] = arr[r]; - arr[r] = tmp; - --w; - } else { // the value is smaller than the pivot, skip - ++r; - } - } - - // if we stepped up (r++) we need to step one down (arr[r] > pivot) - if (compare(arr[r], pivot) > 0) { - --r; - } - - // the r pointer is on the end of the first k elements - if (k <= r) { - to = r; - } else { - from = r + 1; - } - } - - return arr[k]; - } - } - - exports.name = 'partitionSelect'; - exports.factory = factory; - - -/***/ }, -/* 432 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm05 = load(__webpack_require__(79)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y. - * - * x and y are considered equal when the relative difference between x and y - * is smaller than the configured epsilon. The function cannot be used to - * compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.compare(x, y) - * - * Examples: - * - * math.compare(6, 1); // returns 1 - * math.compare(2, 3); // returns -1 - * math.compare(7, 7); // returns 0 - * - * var a = math.unit('5 cm'); - * var b = math.unit('40 mm'); - * math.compare(a, b); // returns 1 - * - * math.compare(2, [1, 2, 3]); // returns [1, 0, -1] - * - * See also: - * - * equal, unequal, smaller, smallerEq, larger, largerEq - * - * @param {number | BigNumber | Fraction | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | Fraction | Unit | string | Array | Matrix} y Second value to compare - * @return {number | BigNumber | Fraction | Array | Matrix} Returns the result of the comparison: 1, 0 or -1. - */ - var compare = typed('compare', { - - 'boolean, boolean': function (x, y) { - return x === y ? 0 : (x > y ? 1 : -1); - }, - - 'number, number': function (x, y) { - return (x === y || nearlyEqual(x, y, config.epsilon)) - ? 0 - : (x > y ? 1 : -1); - }, - - 'BigNumber, BigNumber': function (x, y) { - return (x.eq(y) || bigNearlyEqual(x, y, config.epsilon)) - ? new type.BigNumber(0) - : new type.BigNumber(x.cmp(y)); - }, - - 'Fraction, Fraction': function (x, y) { - return new type.Fraction(x.compare(y)); - }, - - 'Complex, Complex': function () { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return compare(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x === y ? 0 : (x > y ? 1 : -1); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm05(x, y, compare); - break; - default: - // sparse + dense - c = algorithm03(y, x, compare, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, compare, false); - break; - default: - // dense + dense - c = algorithm13(x, y, compare); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return compare(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return compare(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return compare(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, compare, false); - break; - default: - c = algorithm14(x, y, compare, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, compare, true); - break; - default: - c = algorithm14(y, x, compare, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, compare, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, compare, true).valueOf(); - } - }); - - compare.toTex = undefined; // use default template - - return compare; - } - - exports.name = 'compare'; - exports.factory = factory; - - -/***/ }, -/* 433 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DimensionError = __webpack_require__(42); - var ArgumentsError = __webpack_require__(11); - - var isInteger = __webpack_require__(6).isInteger; - var format = __webpack_require__(23).format; - var clone = __webpack_require__(3).clone; - var array = __webpack_require__(40); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Resize a matrix - * - * Syntax: - * - * math.resize(x, size) - * math.resize(x, size, defaultValue) - * - * Examples: - * - * math.resize([1, 2, 3, 4, 5], [3]); // returns Array [1, 2, 3] - * math.resize([1, 2, 3], [5], 0); // returns Array [1, 2, 3, 0, 0] - * math.resize(2, [2, 3], 0); // returns Matrix [[2, 0, 0], [0, 0, 0]] - * math.resize("hello", [8], "!"); // returns string 'hello!!!' - * - * See also: - * - * size, squeeze, subset - * - * @param {Array | Matrix | *} x Matrix to be resized - * @param {Array | Matrix} size One dimensional array with numbers - * @param {number | string} [defaultValue=0] Zero by default, except in - * case of a string, in that case - * defaultValue = ' ' - * @return {* | Array | Matrix} A resized clone of matrix `x` - */ - // TODO: rework resize to a typed-function - var resize = function resize (x, size, defaultValue) { - if (arguments.length != 2 && arguments.length != 3) { - throw new ArgumentsError('resize', arguments.length, 2, 3); - } - - if (size && size.isMatrix === true) { - size = size.valueOf(); // get Array - } - - if (size.length && size[0] && size[0].isBigNumber === true) { - // convert bignumbers to numbers - size = size.map(function (value) { - return (value && value.isBigNumber === true) ? value.toNumber() : value; - }); - } - - // check x is a Matrix - if (x && x.isMatrix === true) { - // use optimized matrix implementation, return copy - return x.resize(size, defaultValue, true); - } - - if (typeof x === 'string') { - // resize string - return _resizeString(x, size, defaultValue); - } - - // check result should be a matrix - var asMatrix = Array.isArray(x) ? false : (config.matrix !== 'Array'); - - if (size.length == 0) { - // output a scalar - while (Array.isArray(x)) { - x = x[0]; - } - - return clone(x); - } - else { - // output an array/matrix - if (!Array.isArray(x)) { - x = [x]; - } - x = clone(x); - - var res = array.resize(x, size, defaultValue); - return asMatrix ? matrix(res) : res; - } - }; - - resize.toTex = undefined; // use default template - - return resize; - - /** - * Resize a string - * @param {string} str - * @param {number[]} size - * @param {string} [defaultChar=' '] - * @private - */ - function _resizeString(str, size, defaultChar) { - if (defaultChar !== undefined) { - if (typeof defaultChar !== 'string' || defaultChar.length !== 1) { - throw new TypeError('Single character expected as defaultValue'); - } - } - else { - defaultChar = ' '; - } - - if (size.length !== 1) { - throw new DimensionError(size.length, 1); - } - var len = size[0]; - if (typeof len !== 'number' || !isInteger(len)) { - throw new TypeError('Invalid size, must contain positive integers ' + - '(size: ' + format(size) + ')'); - } - - if (str.length > len) { - return str.substring(0, len); - } - else if (str.length < len) { - var res = str; - for (var i = 0, ii = len - str.length; i < ii; i++) { - res += defaultChar; - } - return res; - } - else { - return str; - } - } - } - - exports.name = 'resize'; - exports.factory = factory; - - -/***/ }, -/* 434 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(40); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Calculate the size of a matrix or scalar. - * - * Syntax: - * - * math.size(x) - * - * Examples: - * - * math.size(2.3); // returns [] - * math.size('hello world'); // returns [11] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.size(A); // returns [2, 3] - * math.size(math.range(1,6)); // returns [5] - * - * See also: - * - * resize, squeeze, subset - * - * @param {boolean | number | Complex | Unit | string | Array | Matrix} x A matrix - * @return {Array | Matrix} A vector with size of `x`. - */ - var size = typed('size', { - 'Matrix': function (x) { - // TODO: return the same matrix type as the input - return matrix(x.size()); - }, - - 'Array': array.size, - - 'string': function (x) { - return (config.matrix === 'Array') ? [x.length] : matrix([x.length]); - }, - - 'number | Complex | BigNumber | Unit | boolean | null': function (x) { - // scalar - return (config.matrix === 'Array') ? [] : matrix([]); - } - }); - - size.toTex = undefined; // use default template - - return size; - } - - exports.name = 'size'; - exports.factory = factory; - - -/***/ }, -/* 435 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(40).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - var asc = load(__webpack_require__(432)); - var desc = function (a, b) { - return -asc(a, b); - }; - - /** - * Sort the items in a matrix. - * - * Syntax: - * - * math.sort(x) - * math.sort(x, compare) - * - * Examples: - * - * math.sort([5, 10, 1]); // returns [1, 5, 10] - * math.sort(['C', 'B', 'A', 'D']); // returns ['A', 'B', 'C', 'D'] - * - * function sortByLength (a, b) { - * return a.length - b.length; - * } - * math.sort(['Langdon', 'Tom', 'Sara'], sortByLength); // returns ['Tom', 'Sara', 'Langdon'] - * - * See also: - * - * filter, forEach, map - * - * @param {Matrix | Array} x A one dimensional matrix or array to sort - * @param {Function | 'asc' | 'desc'} [compare='asc'] - * An optional _comparator function. The function is called as - * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, - * and 0 when a == b. - * @return {Matrix | Array} Returns the sorted matrix. - */ - var sort = typed('sort', { - 'Array': function (x) { - _arrayIsVector(x); - return x.sort(asc); - }, - - 'Matrix': function (x) { - _matrixIsVector(x); - return matrix(x.toArray().sort(asc), x.storage()); - }, - - 'Array, function': function (x, _comparator) { - _arrayIsVector(x); - return x.sort(_comparator); - }, - - 'Matrix, function': function (x, _comparator) { - _matrixIsVector(x); - return matrix(x.toArray().sort(_comparator), x.storage()); - }, - - 'Array, string': function (x, order) { - _arrayIsVector(x); - return x.sort(_comparator(order)); - }, - - 'Matrix, string': function (x, order) { - _matrixIsVector(x); - return matrix(x.toArray().sort(_comparator(order)), x.storage()); - } - }); - - sort.toTex = undefined; // use default template - - /** - * Get the comparator for given order ('asc' or 'desc') - * @param {'asc' | 'desc'} order - * @return {Function} Returns a _comparator function - */ - function _comparator (order) { - if (order === 'asc') { - return asc; - } - else if (order === 'desc') { - return desc; - } - else { - throw new Error('String "asc" or "desc" expected'); - } - } - - /** - * Validate whether an array is one dimensional - * Throws an error when this is not the case - * @param {Array} array - * @private - */ - function _arrayIsVector (array) { - if (size(array).length !== 1) { - throw new Error('One dimensional array expected'); - } - } - - /** - * Validate whether a matrix is one dimensional - * Throws an error when this is not the case - * @param {Matrix} matrix - * @private - */ - function _matrixIsVector (matrix) { - if (matrix.size().length !== 1) { - throw new Error('One dimensional matrix expected'); - } - } - - return sort; - } - - exports.name = 'sort'; - exports.factory = factory; - - -/***/ }, -/* 436 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(3); - var array = __webpack_require__(40); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - - /** - * Squeeze a matrix, remove inner and outer singleton dimensions from a matrix. - * - * Syntax: - * - * math.squeeze(x) - * - * Examples: - * - * math.squeeze([3]); // returns 3 - * math.squeeze([[3]]); // returns 3 - * - * var A = math.zeros(3, 1); // returns [[0], [0], [0]] (size 3x1) - * math.squeeze(A); // returns [0, 0, 0] (size 3) - * - * var B = math.zeros(1, 3); // returns [[0, 0, 0]] (size 1x3) - * math.squeeze(B); // returns [0, 0, 0] (size 3) - * - * // only inner and outer dimensions are removed - * var C = math.zeros(2, 1, 3); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) - * math.squeeze(C); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) - * - * See also: - * - * subset - * - * @param {Matrix | Array} x Matrix to be squeezed - * @return {Matrix | Array} Squeezed matrix - */ - var squeeze = typed('squeeze', { - 'Array': function (x) { - return array.squeeze(object.clone(x)); - }, - - 'Matrix': function (x) { - var res = array.squeeze(x.toArray()); - // FIXME: return the same type of matrix as the input - return Array.isArray(res) ? matrix(res) : res; - }, - - 'any': function (x) { - // scalar - return object.clone(x); - } - }); - - squeeze.toTex = undefined; // use default template - - return squeeze; - } - - exports.name = 'squeeze'; - exports.factory = factory; - - -/***/ }, -/* 437 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - //require('./distribution'), // TODO: rethink math.distribution - __webpack_require__(407), - __webpack_require__(405), - __webpack_require__(406), - __webpack_require__(438), - __webpack_require__(440), - __webpack_require__(441), - __webpack_require__(442), - __webpack_require__(444), - __webpack_require__(445) - ]; - - -/***/ }, -/* 438 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - - function factory(type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - var divide = load(__webpack_require__(317)); - var sum = load(__webpack_require__(439)); - var multiply = load(__webpack_require__(84)); - var dotDivide = load(__webpack_require__(359)); - var log = load(__webpack_require__(374)); - var isNumeric = load(__webpack_require__(88)); - - /** - * Calculate the Kullback-Leibler (KL) divergence between two distributions - * - * Syntax: - * - * math.kldivergence(x, y) - * - * Examples: - * - * math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5]); //returns 0.24376698773121153 - * - * - * @param {Array | Matrix} q First vector - * @param {Array | Matrix} p Second vector - * @return {number} Returns distance between q and p - */ - var kldivergence = typed('kldivergence', { - 'Array, Array': function(q, p) { - return _kldiv(matrix(q), matrix(p)); - }, - - 'Matrix, Array': function(q, p) { - return _kldiv(q, matrix(p)); - }, - - 'Array, Matrix': function(q, p){ - return _kldiv(matrix(q), p); - }, - - 'Matrix, Matrix': function(q, p){ - return _kldiv(q, p); - } - - }); - - function _kldiv(q, p) { - var plength = p.size().length; - var qlength = q.size().length; - if (plength > 1) { - throw new Error('first object must be one dimensional'); - } - - if (qlength > 1) { - throw new Error('second object must be one dimensional'); - } - - if(plength !== qlength){ - throw new Error("Length of two vectors must be equal"); - } - - //Before calculation, apply normalization - var sumq = sum(q); - if (sumq === 0) { - throw new Error("Sum of elements in first object must be non zero"); - } - - var sump = sum(p); - if (sump === 0) { - throw new Error("Sum of elements in second object must be non zero"); - } - var qnorm = divide(q, sum(q)); - var pnorm = divide(p, sum(p)); - - var result = sum(multiply(qnorm, log(dotDivide(qnorm, pnorm)))); - if (isNumeric(result)) { - return result; - } - else { - return Number.NaN; - } - } - - return kldivergence; - } - - - exports.name = 'kldivergence'; - exports.factory = factory; - - - -/***/ }, -/* 439 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepForEach = __webpack_require__(312); - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(53)); - - /** - * Compute the sum of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the sum of all - * elements will be calculated. - * - * Syntax: - * - * math.sum(a, b, c, ...) - * math.sum(A) - * - * Examples: - * - * math.sum(2, 1, 4, 3); // returns 10 - * math.sum([2, 1, 4, 3]); // returns 10 - * math.sum([[2, 5], [4, 3], [1, 7]]); // returns 22 - * - * See also: - * - * mean, median, min, max, prod, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The sum of all values - */ - var sum = typed('sum', { - 'Array | Matrix': function (args) { - // sum([a, b, c, d, ...]) - return _sum(args); - }, - - 'Array | Matrix, number | BigNumber': function () { - // sum([a, b, c, d, ...], dim) - // TODO: implement sum(A, dim) - throw new Error('sum(A, dim) is not yet supported'); - }, - - '...': function (args) { - // sum(a, b, c, d, ...) - return _sum(args); - } - }); - - sum.toTex = undefined; // use default template - - return sum; - - /** - * Recursively calculate the sum of an n-dimensional array - * @param {Array} array - * @return {number} sum - * @private - */ - function _sum(array) { - var sum = undefined; - - deepForEach(array, function (value) { - sum = (sum === undefined) ? value : add(sum, value); - }); - - if (sum === undefined) { - switch (config.number) { - case 'number': - return 0; - case 'BigNumber': - return new type.BigNumber(0); - case 'Fraction': - return new type.Fraction(0); - default: - return 0; - } - } - - return sum; - } - } - - exports.name = 'sum'; - exports.factory = factory; - - -/***/ }, -/* 440 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepForEach = __webpack_require__(312); - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var multiply = load(__webpack_require__(84)); - var divide = load(__webpack_require__(317)); - var factorial = load(__webpack_require__(405)); - var isInteger = load(__webpack_require__(408)); - var isPositive = load(__webpack_require__(370)); - - /** - * Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. - * - * multinomial takes one array of integers as an argument. - * The following condition must be enforced: every ai <= 0 - * - * Syntax: - * - * math.multinomial(a) // a is an array type - * - * Examples: - * - * math.multinomial([1,2,1]); // returns 12 - * - * See also: - * - * combinations, factorial - * - * @param {number[] | BigNumber[]} a Integer numbers of objects in the subset - * @return {Number | BigNumber} Multinomial coefficient. - */ - return typed('multinomial', { - 'Array | Matrix': function (a) { - var sum = 0; - var denom = 1; - - deepForEach(a, function(ai) { - if(!isInteger(ai) || !isPositive(ai)) { - throw new TypeError('Positive integer value expected in function multinomial'); - } - sum = add(sum, ai); - denom = multiply(denom, factorial(ai)); - }); - - return divide(factorial(sum), denom); - } - }); - } - - exports.name = 'multinomial'; - exports.factory = factory; - - -/***/ }, -/* 441 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - - function factory (type, config, load, typed) { - var factorial = load(__webpack_require__(405)); - - /** - * Compute the number of ways of obtaining an ordered subset of `k` elements - * from a set of `n` elements. - * - * Permutations only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * Syntax: - * - * math.permutations(n) - * math.permutations(n, k) - * - * Examples: - * - * math.permutations(5); // 120 - * math.permutations(5, 3); // 60 - * - * See also: - * - * combinations, factorial - * - * @param {number | BigNumber} n The number of objects in total - * @param {number | BigNumber} [k] The number of objects in the subset - * @return {number | BigNumber} The number of permutations - */ - var permutations = typed('permutations', { - 'number | BigNumber': factorial, - - 'number, number': function (n, k) { - var result, i; - - if (!isInteger(n) || n < 0) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (!isInteger(k) || k < 0) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (k > n) { - throw new TypeError('second argument k must be less than or equal to first argument n'); - } - - // Permute n objects, k at a time - result = 1; - for (i = n - k + 1; i <= n; i++) { - result = result * i; - } - - return result; - }, - - 'BigNumber, BigNumber': function (n, k) { - var result, i; - - if (!isPositiveInteger(n) || !isPositiveInteger(k)) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (k.gt(n)) { - throw new TypeError('second argument k must be less than or equal to first argument n'); - } - - result = new type.BigNumber(1); - for (i = n.minus(k).plus(1); i.lte(n); i = i.plus(1)) { - result = result.times(i); - } - - return result; - } - - // TODO: implement support for collection in permutations - }); - - permutations.toTex = undefined; // use default template - - return permutations; - } - - /** - * Test whether BigNumber n is a positive integer - * @param {BigNumber} n - * @returns {boolean} isPositiveInteger - */ - function isPositiveInteger(n) { - return n.isInteger() && n.gte(0); - } - - exports.name = 'permutations'; - exports.factory = factory; - - -/***/ }, -/* 442 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(443)); - - /** - * Random pick a value from a one dimensional array. - * Array element is picked using a random function with uniform distribution. - * - * Syntax: - * - * math.pickRandom(array) - * - * Examples: - * - * math.pickRandom([3, 6, 12, 2]); // returns one of the values in the array - * - * See also: - * - * random, randomInt - * - * @param {Array} array A one dimensional array - * @return {number} One of the elements of the provided input array - */ - // TODO: rework pickRandom to a typed-function - var pickRandom = distribution('uniform').pickRandom; - - pickRandom.toTex = undefined; // use default template - - return pickRandom; - } - - exports.name = 'pickRandom'; - exports.factory = factory; - - -/***/ }, -/* 443 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var ArgumentsError = __webpack_require__(11); - var isCollection = __webpack_require__(310); - - // TODO: rethink math.distribution - // TODO: rework to a typed function - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(52)); - var array = __webpack_require__(40); - - /** - * Create a distribution object with a set of random functions for given - * random distribution. - * - * Syntax: - * - * math.distribution(name) - * - * Examples: - * - * var normalDist = math.distribution('normal'); // create a normal distribution - * normalDist.random(0, 10); // get a random value between 0 and 10 - * - * See also: - * - * random, randomInt, pickRandom - * - * @param {string} name Name of a distribution. Choose from 'uniform', 'normal'. - * @return {Object} Returns a distribution object containing functions: - * `random([size] [, min] [, max])`, - * `randomInt([min] [, max])`, - * `pickRandom(array)` - */ - function distribution(name) { - if (!distributions.hasOwnProperty(name)) - throw new Error('Unknown distribution ' + name); - - var args = Array.prototype.slice.call(arguments, 1), - distribution = distributions[name].apply(this, args); - - return (function(distribution) { - - // This is the public API for all distributions - var randFunctions = { - - random: function(arg1, arg2, arg3) { - var size, min, max; - if (arguments.length > 3) { - throw new ArgumentsError('random', arguments.length, 0, 3); - - // `random(max)` or `random(size)` - } else if (arguments.length === 1) { - if (isCollection(arg1)) { - size = arg1; - } - else { - max = arg1; - } - // `random(min, max)` or `random(size, max)` - } else if (arguments.length === 2) { - if (isCollection(arg1)) { - size = arg1; - max = arg2; - } - else { - min = arg1; - max = arg2; - } - // `random(size, min, max)` - } else { - size = arg1; - min = arg2; - max = arg3; - } - - // TODO: validate type of min, max, and size - - if (max === undefined) max = 1; - if (min === undefined) min = 0; - if (size !== undefined) { - var res = _randomDataForMatrix(size.valueOf(), min, max, _random); - return (size && size.isMatrix === true) ? matrix(res) : res; - } - else return _random(min, max); - }, - - randomInt: function(arg1, arg2, arg3) { - var size, min, max; - if (arguments.length > 3 || arguments.length < 1) - throw new ArgumentsError('randomInt', arguments.length, 1, 3); - - // `random(max)` or `random(size)` - else if (arguments.length === 1) - if (isCollection(arg1)) { - size = arg1; - } - else { - max = arg1; - } - // `randomInt(min, max)` or `randomInt(size, max)` - else if (arguments.length === 2) { - if (isCollection(arg1)) { - size = arg1; - max = arg2; - } - else { - min = arg1; - max = arg2; - } - // `randomInt(size, min, max)` - } else { - size = arg1; - min = arg2; - max = arg3; - } - - // TODO: validate type of min, max, and size - - if (min === undefined) min = 0; - if (size !== undefined) { - var res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt); - return (size && size.isMatrix === true) ? matrix(res) : res; - } - else return _randomInt(min, max); - }, - - pickRandom: function(possibles) { - if (arguments.length !== 1) { - throw new ArgumentsError('pickRandom', arguments.length, 1); - } - if (possibles && possibles.isMatrix === true) { - possibles = possibles.valueOf(); // get Array - } - else if (!Array.isArray(possibles)) { - throw new TypeError('Unsupported type of value in function pickRandom'); - } - - if (array.size(possibles).length > 1) { - throw new Error('Only one dimensional vectors supported'); - } - - // TODO: add support for multi dimensional matrices - return possibles[Math.floor(Math.random() * possibles.length)]; - } - - }; - - var _random = function(min, max) { - return min + distribution() * (max - min); - }; - - var _randomInt = function(min, max) { - return Math.floor(min + distribution() * (max - min)); - }; - - // This is a function for generating a random matrix recursively. - var _randomDataForMatrix = function(size, min, max, randFunc) { - var data = [], length, i; - size = size.slice(0); - - if (size.length > 1) { - for (i = 0, length = size.shift(); i < length; i++) - data.push(_randomDataForMatrix(size, min, max, randFunc)); - } else { - for (i = 0, length = size.shift(); i < length; i++) - data.push(randFunc(min, max)); - } - - return data; - }; - - return randFunctions; - - })(distribution); - } - - // Each distribution is a function that takes no argument and when called returns - // a number between 0 and 1. - var distributions = { - - uniform: function() { - return Math.random; - }, - - // Implementation of normal distribution using Box-Muller transform - // ref : http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform - // We take : mean = 0.5, standard deviation = 1/6 - // so that 99.7% values are in [0, 1]. - normal: function() { - return function() { - var u1, u2, - picked = -1; - // We reject values outside of the interval [0, 1] - // TODO: check if it is ok to do that? - while (picked < 0 || picked > 1) { - u1 = Math.random(); - u2 = Math.random(); - picked = 1/6 * Math.pow(-2 * Math.log(u1), 0.5) * Math.cos(2 * Math.PI * u2) + 0.5; - } - return picked; - } - } - }; - - distribution.toTex = undefined; // use default template - - return distribution; - } - - exports.name = 'distribution'; - exports.factory = factory; - - -/***/ }, -/* 444 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(443)); - - /** - * Return a random number larger or equal to `min` and smaller than `max` - * using a uniform distribution. - * - * Syntax: - * - * math.random() // generate a random number between 0 and 1 - * math.random(max) // generate a random number between 0 and max - * math.random(min, max) // generate a random number between min and max - * math.random(size) // generate a matrix with random numbers between 0 and 1 - * math.random(size, max) // generate a matrix with random numbers between 0 and max - * math.random(size, min, max) // generate a matrix with random numbers between min and max - * - * Examples: - * - * math.random(); // returns a random number between 0 and 1 - * math.random(100); // returns a random number between 0 and 100 - * math.random(30, 40); // returns a random number between 30 and 40 - * math.random([2, 3]); // returns a 2x3 matrix with random numbers between 0 and 1 - * - * See also: - * - * randomInt, pickRandom - * - * @param {Array | Matrix} [size] If provided, an array or matrix with given - * size and filled with random values is returned - * @param {number} [min] Minimum boundary for the random value, included - * @param {number} [max] Maximum boundary for the random value, excluded - * @return {number | Array | Matrix} A random number - */ - // TODO: rework random to a typed-function - var random = distribution('uniform').random; - - random.toTex = undefined; // use default template - - return random; - } - - exports.name = 'random'; - exports.factory = factory; - - -/***/ }, -/* 445 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(443)); - - /** - * Return a random integer number larger or equal to `min` and smaller than `max` - * using a uniform distribution. - * - * Syntax: - * - * math.randomInt(max) // generate a random integer between 0 and max - * math.randomInt(min, max) // generate a random integer between min and max - * math.randomInt(size) // generate a matrix with random integer between 0 and 1 - * math.randomInt(size, max) // generate a matrix with random integer between 0 and max - * math.randomInt(size, min, max) // generate a matrix with random integer between min and max - * - * Examples: - * - * math.randomInt(100); // returns a random integer between 0 and 100 - * math.randomInt(30, 40); // returns a random integer between 30 and 40 - * math.randomInt([2, 3]); // returns a 2x3 matrix with random integers between 0 and 1 - * - * See also: - * - * random, pickRandom - * - * @param {Array | Matrix} [size] If provided, an array or matrix with given - * size and filled with random values is returned - * @param {number} [min] Minimum boundary for the random value, included - * @param {number} [max] Maximum boundary for the random value, excluded - * @return {number | Array | Matrix} A random integer value - */ - // TODO: rework randomInt to a typed-function - var randomInt = distribution('uniform').randomInt; - - randomInt.toTex = undefined; // use default template - - return randomInt; - } - - exports.name = 'randomInt'; - exports.factory = factory; - - -/***/ }, -/* 446 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(432), - __webpack_require__(447), - __webpack_require__(87), - __webpack_require__(64), - __webpack_require__(342), - __webpack_require__(60), - __webpack_require__(448), - __webpack_require__(449) - ]; - - -/***/ }, -/* 447 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var equal = load(__webpack_require__(87)); - - /** - * Test element wise whether two matrices are equal. - * The function accepts both matrices and scalar values. - * - * Syntax: - * - * math.deepEqual(x, y) - * - * Examples: - * - * math.deepEqual(2, 4); // returns false - * - * a = [2, 5, 1]; - * b = [2, 7, 1]; - * - * math.deepEqual(a, b); // returns false - * math.equal(a, b); // returns [true, false, true] - * - * See also: - * - * equal, unequal - * - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First matrix to compare - * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second matrix to compare - * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} - * Returns true when the input matrices have the same size and each of their elements is equal. - */ - var deepEqual = typed('deepEqual', { - 'any, any': function (x, y) { - return _deepEqual(x.valueOf(), y.valueOf()); - } - }); - - deepEqual.toTex = undefined; // use default template - - return deepEqual; - - /** - * Test whether two arrays have the same size and all elements are equal - * @param {Array | *} x - * @param {Array | *} y - * @return {boolean} Returns true if both arrays are deep equal - */ - function _deepEqual(x, y) { - if (Array.isArray(x)) { - if (Array.isArray(y)) { - var len = x.length; - if (len !== y.length) { - return false; - } - - for (var i = 0; i < len; i++) { - if (!_deepEqual(x[i], y[i])) { - return false; - } - } - - return true; - } - else { - return false; - } - } - else { - if (Array.isArray(y)) { - return false; - } - else { - return equal(x, y); - } - } - } - } - - exports.name = 'deepEqual'; - exports.factory = factory; - - -/***/ }, -/* 448 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether value x is smaller or equal to y. - * - * The function returns true when x is smaller than y or the relative - * difference between x and y is smaller than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.smallerEq(x, y) - * - * Examples: - * - * math.smaller(1 + 2, 3); // returns false - * math.smallerEq(1 + 2, 3); // returns true - * - * See also: - * - * equal, unequal, smaller, larger, largerEq, compare - * - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false - */ - var smallerEq = typed('smallerEq', { - - 'boolean, boolean': function (x, y) { - return x <= y; - }, - - 'number, number': function (x, y) { - return x <= y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.lte(y) || bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return x.compare(y) !== 1; - }, - - 'Complex, Complex': function () { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return smallerEq(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x <= y; - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, smallerEq); - break; - default: - // sparse + dense - c = algorithm03(y, x, smallerEq, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, smallerEq, false); - break; - default: - // dense + dense - c = algorithm13(x, y, smallerEq); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return smallerEq(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return smallerEq(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return smallerEq(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, smallerEq, false); - break; - default: - c = algorithm14(x, y, smallerEq, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, smallerEq, true); - break; - default: - c = algorithm14(y, x, smallerEq, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, smallerEq, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, smallerEq, true).valueOf(); - } - }); - - smallerEq.toTex = { - 2: '\\left(${args[0]}' + latex.operators['smallerEq'] + '${args[1]}\\right)' - }; - - return smallerEq; - } - - exports.name = 'smallerEq'; - exports.factory = factory; - - -/***/ }, -/* 449 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(6).nearlyEqual; - var bigNearlyEqual = __webpack_require__(49); - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm03 = load(__webpack_require__(61)); - var algorithm07 = load(__webpack_require__(62)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - var latex = __webpack_require__(32); - - /** - * Test whether two values are unequal. - * - * The function tests whether the relative difference between x and y is - * larger than the configured epsilon. The function cannot be used to compare - * values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im. - * - * Values `null` and `undefined` are compared strictly, thus `null` is unequal - * with everything except `null`, and `undefined` is unequal with everying - * except. `undefined`. - * - * Syntax: - * - * math.unequal(x, y) - * - * Examples: - * - * math.unequal(2 + 2, 3); // returns true - * math.unequal(2 + 2, 4); // returns false - * - * var a = math.unit('50 cm'); - * var b = math.unit('5 m'); - * math.unequal(a, b); // returns false - * - * var c = [2, 5, 1]; - * var d = [2, 7, 1]; - * - * math.unequal(c, d); // returns [false, true, false] - * math.deepEqual(c, d); // returns false - * - * math.unequal(0, null); // returns true - * See also: - * - * equal, deepEqual, smaller, smallerEq, larger, largerEq, compare - * - * @param {number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined} x First value to compare - * @param {number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined} y Second value to compare - * @return {boolean | Array | Matrix} Returns true when the compared values are unequal, else returns false - */ - var unequal = typed('unequal', { - - 'any, any': function (x, y) { - // strict equality for null and undefined? - if (x === null) { return y !== null; } - if (y === null) { return x !== null; } - if (x === undefined) { return y !== undefined; } - if (y === undefined) { return x !== undefined; } - - return _unequal(x, y); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = algorithm07(x, y, _unequal); - break; - default: - // sparse + dense - c = algorithm03(y, x, _unequal, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense + sparse - c = algorithm03(x, y, _unequal, false); - break; - default: - // dense + dense - c = algorithm13(x, y, _unequal); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return unequal(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return unequal(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return unequal(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm12(x, y, _unequal, false); - break; - default: - c = algorithm14(x, y, _unequal, false); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, _unequal, true); - break; - default: - c = algorithm14(y, x, _unequal, true); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, _unequal, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, _unequal, true).valueOf(); - } - }); - - var _unequal = typed('_unequal', { - - 'boolean, boolean': function (x, y) { - return x !== y; - }, - - 'number, number': function (x, y) { - return !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return !bigNearlyEqual(x, y, config.epsilon); - }, - - 'Fraction, Fraction': function (x, y) { - return !x.equals(y); - }, - - 'Complex, Complex': function (x, y) { - return !x.equals(y); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return unequal(x.value, y.value); - }, - - 'string, string': function (x, y) { - return x !== y; - } - }); - - unequal.toTex = { - 2: '\\left(${args[0]}' + latex.operators['unequal'] + '${args[1]}\\right)' - }; - - return unequal; - } - - exports.name = 'unequal'; - exports.factory = factory; - - -/***/ }, -/* 450 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(311), - __webpack_require__(316), - __webpack_require__(451), - __webpack_require__(321), - __webpack_require__(452), - __webpack_require__(453), - __webpack_require__(454), - __webpack_require__(455), - __webpack_require__(439), - __webpack_require__(456) - ]; - -/***/ }, -/* 451 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var flatten = __webpack_require__(40).flatten; - var reduce = __webpack_require__(313); - var containsCollections = __webpack_require__(314); - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(53)); - var divide = load(__webpack_require__(81)); - var compare = load(__webpack_require__(432)); - var partitionSelect = load(__webpack_require__(431)); - - /** - * Compute the median of a matrix or a list with values. The values are - * sorted and the middle value is returned. In case of an even number of - * values, the average of the two middle values is returned. - * Supported types of values are: Number, BigNumber, Unit - * - * In case of a (multi dimensional) array or matrix, the median of all - * elements will be calculated. - * - * Syntax: - * - * math.median(a, b, c, ...) - * math.median(A) - * - * Examples: - * - * math.median(5, 2, 7); // returns 5 - * math.median([3, -1, 5, 7]); // returns 4 - * - * See also: - * - * mean, min, max, sum, prod, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The median - */ - var median = typed('median', { - // median([a, b, c, d, ...]) - 'Array | Matrix': _median, - - // median([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - // TODO: implement median(A, dim) - throw new Error('median(A, dim) is not yet supported'); - //return reduce(arguments[0], arguments[1], ...); - }, - - // median(a, b, c, d, ...) - '...': function (args) { - if (containsCollections(args)) { - throw new TypeError('Scalar values expected in function median'); - } - - return _median(args); - } - }); - - - /** - * Recursively calculate the median of an n-dimensional array - * @param {Array} array - * @return {Number} median - * @private - */ - function _median(array) { - array = flatten(array.valueOf()); - - var num = array.length; - if (num == 0) { - throw new Error('Cannot calculate median of an empty array'); - } - - if (num % 2 == 0) { - // even: return the average of the two middle values - var mid = num / 2 - 1; - var right = partitionSelect(array, mid + 1); - - // array now partitioned at mid + 1, take max of left part - var left = array[mid]; - for (var i = 0; i < mid; ++i) { - if (compare(array[i], left) > 0) { - left = array[i]; - } - } - - return middle2(left, right); - } - else { - // odd: return the middle value - var m = partitionSelect(array, (num - 1) / 2); - - return middle(m); - } - } - - // helper function to type check the middle value of the array - var middle = typed({ - 'number | BigNumber | Unit': function (value) { - return value; - } - }); - - // helper function to type check the two middle value of the array - var middle2 = typed({ - 'number | BigNumber | Unit, number | BigNumber | Unit': function (left, right) { - return divide(add(left, right), 2); - } - }); - - median.toTex = undefined; // use default template - - return median; - } - - exports.name = 'median'; - exports.factory = factory; - - -/***/ }, -/* 452 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var flatten = __webpack_require__(40).flatten; - - function factory (type, config, load, typed) { - - /** - * Computes the mode of a set of numbers or a list with values(numbers or characters). - * If there are more than one modes, it returns a list of those values. - * - * Syntax: - * - * math.mode(a, b, c, ...) - * math.mode(A) - * - * Examples: - * - * math.mode(2, 1, 4, 3, 1); // returns [1] - * math.mode([1, 2.7, 3.2, 4, 2.7]); // returns [2.7] - * math.mode(1, 4, 6, 1, 6) // returns [1, 6] - * math.mode('a','a','b','c') // returns ["a"] - * math.mode(1, 1.5, 'abc') // returns [1, 1.5, "abc"] - * - * See also: - * - * median, - * mean - * - * @param {... *} args A single matrix - * @return {*} The mode of all values - */ - - var mode = typed('mode', { - 'Array | Matrix' : _mode, - - '...': function (args) { - return _mode(args); - } - }); - - return mode; - - /** - * Calculates the mode in an 1-dimensional array - * @param {Array} values - * @return {number} mode - * @private - */ - function _mode(values) { - values = flatten(values.valueOf()); - var num = values.length; - if (num == 0) { - throw new Error('Cannot calculate mode of an empty array'); - } - - var count = {}, - mode = [], - max = 0; - for (var i in values) { - if (!(values[i] in count)){ - count[values[i]] = 0; - } - count[values[i]]++; - if (count[values[i]] == max){ - mode.push(values[i]); - } - else if (count[values[i]] > max) { - max = count[values[i]]; - mode = [values[i]]; - } - } - return mode; - }; - } - - exports.name = 'mode'; - exports.factory = factory; - -/***/ }, -/* 453 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepForEach = __webpack_require__(312); - - function factory (type, config, load, typed) { - var multiply = load(__webpack_require__(80)); - - /** - * Compute the product of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the sum of all - * elements will be calculated. - * - * Syntax: - * - * math.prod(a, b, c, ...) - * math.prod(A) - * - * Examples: - * - * math.multiply(2, 3); // returns 6 - * math.prod(2, 3); // returns 6 - * math.prod(2, 3, 4); // returns 24 - * math.prod([2, 3, 4]); // returns 24 - * math.prod([[2, 5], [4, 3]]); // returns 120 - * - * See also: - * - * mean, median, min, max, sum, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The product of all values - */ - var prod = typed('prod', { - // prod([a, b, c, d, ...]) - 'Array | Matrix': _prod, - - // prod([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - // TODO: implement prod(A, dim) - throw new Error('prod(A, dim) is not yet supported'); - //return reduce(arguments[0], arguments[1], math.prod); - }, - - // prod(a, b, c, d, ...) - '...': function (args) { - return _prod(args); - } - }); - - prod.toTex = undefined; // use default template - - return prod; - - /** - * Recursively calculate the product of an n-dimensional array - * @param {Array} array - * @return {number} prod - * @private - */ - function _prod(array) { - var prod = undefined; - - deepForEach(array, function (value) { - prod = (prod === undefined) ? value : multiply(prod, value); - }); - - if (prod === undefined) { - throw new Error('Cannot calculate prod of an empty array'); - } - - return prod; - } - } - - exports.name = 'prod'; - exports.factory = factory; - - -/***/ }, -/* 454 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(6).isInteger; - var isNumber = __webpack_require__(6).isNumber; - var flatten = __webpack_require__(40).flatten; - var isCollection = __webpack_require__(310); - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(51)); - var multiply = load(__webpack_require__(84)); - var partitionSelect = load(__webpack_require__(431)); - var compare = load(__webpack_require__(432)); - - /** - * Compute the prob order quantile of a matrix or a list with values. - * The sequence is sorted and the middle value is returned. - * Supported types of sequence values are: Number, BigNumber, Unit - * Supported types of probability are: Number, BigNumber - * - * In case of a (multi dimensional) array or matrix, the prob order quantile - * of all elements will be calculated. - * - * Syntax: - * - * math.quantileSeq(A, prob[, sorted]) - * math.quantileSeq(A, [prob1, prob2, ...][, sorted]) - * math.quantileSeq(A, N[, sorted]) - * - * Examples: - * - * math.quantileSeq([3, -1, 5, 7], 0.5); // returns 4 - * math.quantileSeq([3, -1, 5, 7], [1/3, 2/3]); // returns [3, 5] - * math.quantileSeq([3, -1, 5, 7], 2); // returns [3, 5] - * math.quantileSeq([-1, 3, 5, 7], 0.5, true); // returns 4 - * - * See also: - * - * median, mean, min, max, sum, prod, std, var - * - * @param {Array, Matrix} data A single matrix or Array - * @param {Number, BigNumber, Array} probOrN prob is the order of the quantile, while N is - * the amount of evenly distributed steps of - * probabilities; only one of these options can - * be provided - * @param {Boolean} sorted=false is data sorted in ascending order - * @return {Number, BigNumber, Unit, Array} Quantile(s) - */ - function quantileSeq(data, probOrN, sorted) { - var probArr, dataArr, one; - - if (arguments.length < 2 || arguments.length > 3) { - throw new SyntaxError('Function quantileSeq requires two or three parameters'); - } - - if (isCollection(data)) { - sorted = sorted || false; - if (typeof sorted === 'boolean') { - dataArr = data.valueOf(); - if (isNumber(probOrN)) { - if (probOrN < 0) { - throw new Error('N/prob must be non-negative'); - } - - if (probOrN <= 1) { - // quantileSeq([a, b, c, d, ...], prob[,sorted]) - return _quantileSeq(dataArr, probOrN, sorted); - } - - if (probOrN > 1) { - // quantileSeq([a, b, c, d, ...], N[,sorted]) - if (!isInteger(probOrN)) { - throw new Error('N must be a positive integer'); - } - - var nPlusOne = probOrN + 1; - probArr = new Array(probOrN); - for (var i = 0; i < probOrN;) { - probArr[i] = _quantileSeq(dataArr, (++i) / nPlusOne, sorted); - } - return probArr; - } - } - - if (probOrN && probOrN.isBigNumber) { - if (probOrN.isNegative()) { - throw new Error('N/prob must be non-negative'); - } - - one = new probOrN.constructor(1); - - if (probOrN.lte(one)) { - // quantileSeq([a, b, c, d, ...], prob[,sorted]) - return _quantileSeq(dataArr, probOrN, sorted); - } - - if (probOrN.gt(one)) { - // quantileSeq([a, b, c, d, ...], N[,sorted]) - if (!probOrN.isInteger()) { - throw new Error('N must be a positive integer'); - } - - // largest possible Array length is 2^32-1; - // 2^32 < 10^15, thus safe conversion guaranteed - var intN = probOrN.toNumber(); - if (intN > 4294967295) { - throw new Error('N must be less than or equal to 2^32-1, as that is the maximum length of an Array'); - } - - var nPlusOne = new type.BigNumber(intN + 1); - probArr = new Array(intN); - for (var i = 0; i < intN;) { - probArr[i] = _quantileSeq(dataArr, new type.BigNumber(++i).div(nPlusOne), sorted); - } - return probArr; - } - } - - if (Array.isArray(probOrN)) { - // quantileSeq([a, b, c, d, ...], [prob1, prob2, ...][,sorted]) - probArr = new Array(probOrN.length); - for (var i = 0; i < probArr.length; ++i) { - var currProb = probOrN[i]; - if (isNumber(currProb)) { - if (currProb < 0 || currProb > 1) { - throw new Error('Probability must be between 0 and 1, inclusive'); - } - } else if (currProb && currProb.isBigNumber) { - one = new currProb.constructor(1); - if (currProb.isNegative() || currProb.gt(one)) { - throw new Error('Probability must be between 0 and 1, inclusive'); - } - } else { - throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function - } - - probArr[i] = _quantileSeq(dataArr, currProb, sorted); - } - return probArr; - } - - throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function - } - - throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function - } - - throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function - } - - /** - * Calculate the prob order quantile of an n-dimensional array. - * - * @param {Array} array - * @param {Number, BigNumber} prob - * @param {Boolean} sorted - * @return {Number, BigNumber, Unit} prob order quantile - * @private - */ - function _quantileSeq(array, prob, sorted) { - var flat = flatten(array); - var len = flat.length; - if (len === 0) { - throw new Error('Cannot calculate quantile of an empty sequence'); - } - - if (isNumber(prob)) { - var index = prob * (len-1); - var fracPart = index % 1; - if (fracPart === 0) { - var value = sorted ? flat[index] : partitionSelect(flat, index); - - validate(value); - - return value; - } - - var integerPart = Math.floor(index); - - var left, right; - if (sorted) { - left = flat[integerPart]; - right = flat[integerPart+1]; - } else { - right = partitionSelect(flat, integerPart+1); - - // max of partition is kth largest - left = flat[integerPart]; - for (var i = 0; i < integerPart; ++i) { - if (compare(flat[i], left) > 0) { - left = flat[i]; - } - } - } - - validate(left); - validate(right); - - // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1] - return add(multiply(left, 1 - fracPart), multiply(right, fracPart)); - } - - // If prob is a BigNumber - var index = prob.times(len-1); - if (index.isInteger()) { - index = index.toNumber(); - var value = sorted ? flat[index] : partitionSelect(flat, index); - - validate(value); - - return value; - } - - var integerPart = index.floor(); - var fracPart = index.minus(integerPart); - var integerPartNumber = integerPart.toNumber(); - - var left, right; - if (sorted) { - left = flat[integerPartNumber]; - right = flat[integerPartNumber+1]; - } else { - right = partitionSelect(flat, integerPartNumber+1); - - // max of partition is kth largest - left = flat[integerPartNumber]; - for (var i = 0; i < integerPartNumber; ++i) { - if (compare(flat[i], left) > 0) { - left = flat[i]; - } - } - } - - validate(left); - validate(right); - - // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1] - var one = new fracPart.constructor(1); - return add(multiply(left, one.minus(fracPart)), multiply(right, fracPart)); - } - - /** - * Check if array value types are valid, throw error otherwise. - * @param {number | BigNumber | Unit} x - * @param {number | BigNumber | Unit} x - * @private - */ - var validate = typed({ - 'number | BigNumber | Unit': function (x) { - return x; - } - }); - - return quantileSeq; - } - - exports.name = 'quantileSeq'; - exports.factory = factory; - - -/***/ }, -/* 455 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var sqrt = load(__webpack_require__(369)); - var variance = load(__webpack_require__(456)); - - /** - * Compute the standard deviation of a matrix or a list with values. - * The standard deviations is defined as the square root of the variance: - * `std(A) = sqrt(var(A))`. - * In case of a (multi dimensional) array or matrix, the standard deviation - * over all elements will be calculated. - * - * Optionally, the type of normalization can be specified as second - * parameter. The parameter `normalization` can be one of the following values: - * - * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - * - * Syntax: - * - * math.std(a, b, c, ...) - * math.std(A) - * math.std(A, normalization) - * - * Examples: - * - * math.std(2, 4, 6); // returns 2 - * math.std([2, 4, 6, 8]); // returns 2.581988897471611 - * math.std([2, 4, 6, 8], 'uncorrected'); // returns 2.23606797749979 - * math.std([2, 4, 6, 8], 'biased'); // returns 2 - * - * math.std([[1, 2, 3], [4, 5, 6]]); // returns 1.8708286933869707 - * - * See also: - * - * mean, median, max, min, prod, sum, var - * - * @param {Array | Matrix} array - * A single matrix or or multiple scalar values - * @param {string} [normalization='unbiased'] - * Determines how to normalize the variance. - * Choose 'unbiased' (default), 'uncorrected', or 'biased'. - * @return {*} The standard deviation - */ - var std = typed('std', { - // std([a, b, c, d, ...]) - 'Array | Matrix': _std, - - // std([a, b, c, d, ...], normalization) - 'Array | Matrix, string': _std, - - // std(a, b, c, d, ...) - '...': function (args) { - return _std(args); - } - }); - - std.toTex = undefined; // use default template - - return std; - - function _std(array, normalization) { - if (array.length == 0) { - throw new SyntaxError('Function std requires one or more parameters (0 provided)'); - } - - return sqrt(variance.apply(null, arguments)); - } - } - - exports.name = 'std'; - exports.factory = factory; - - -/***/ }, -/* 456 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DEFAULT_NORMALIZATION = 'unbiased'; - - var deepForEach = __webpack_require__(312); - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(53)); - var subtract = load(__webpack_require__(77)); - var multiply = load(__webpack_require__(80)); - var divide = load(__webpack_require__(81)); - - /** - * Compute the variance of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the variance over all - * elements will be calculated. - * - * Optionally, the type of normalization can be specified as second - * parameter. The parameter `normalization` can be one of the following values: - * - * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - * - * Note that older browser may not like the variable name `var`. In that - * case, the function can be called as `math['var'](...)` instead of - * `math.var(...)`. - * - * Syntax: - * - * math.var(a, b, c, ...) - * math.var(A) - * math.var(A, normalization) - * - * Examples: - * - * math.var(2, 4, 6); // returns 4 - * math.var([2, 4, 6, 8]); // returns 6.666666666666667 - * math.var([2, 4, 6, 8], 'uncorrected'); // returns 5 - * math.var([2, 4, 6, 8], 'biased'); // returns 4 - * - * math.var([[1, 2, 3], [4, 5, 6]]); // returns 3.5 - * - * See also: - * - * mean, median, max, min, prod, std, sum - * - * @param {Array | Matrix} array - * A single matrix or or multiple scalar values - * @param {string} [normalization='unbiased'] - * Determines how to normalize the variance. - * Choose 'unbiased' (default), 'uncorrected', or 'biased'. - * @return {*} The variance - */ - var variance = typed('variance', { - // var([a, b, c, d, ...]) - 'Array | Matrix': function (array) { - return _var(array, DEFAULT_NORMALIZATION); - }, - - // var([a, b, c, d, ...], normalization) - 'Array | Matrix, string': _var, - - // var(a, b, c, d, ...) - '...': function (args) { - return _var(args, DEFAULT_NORMALIZATION); - } - }); - - variance.toTex = '\\mathrm{Var}\\left(${args}\\right)'; - - return variance; - - /** - * Recursively calculate the variance of an n-dimensional array - * @param {Array} array - * @param {string} normalization - * Determines how to normalize the variance: - * - 'unbiased' The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - * @return {number | BigNumber} variance - * @private - */ - function _var(array, normalization) { - var sum = 0; - var num = 0; - - if (array.length == 0) { - throw new SyntaxError('Function var requires one or more parameters (0 provided)'); - } - - // calculate the mean and number of elements - deepForEach(array, function (value) { - sum = add(sum, value); - num++; - }); - if (num === 0) throw new Error('Cannot calculate var of an empty array'); - - var mean = divide(sum, num); - - // calculate the variance - sum = 0; - deepForEach(array, function (value) { - var diff = subtract(value, mean); - sum = add(sum, multiply(diff, diff)); - }); - - switch (normalization) { - case 'uncorrected': - return divide(sum, num); - - case 'biased': - return divide(sum, num + 1); - - case 'unbiased': - var zero = (sum && sum.isBigNumber === true) ? new type.BigNumber(0) : 0; - return (num == 1) ? zero : divide(sum, num - 1); - - default: - throw new Error('Unknown normalization "' + normalization + '". ' + - 'Choose "unbiased" (default), "uncorrected", or "biased".'); - } - } - } - - exports.name = 'var'; - exports.factory = factory; - - -/***/ }, -/* 457 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(89), - __webpack_require__(458) - ]; - - -/***/ }, -/* 458 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isString = __webpack_require__(23).isString; - var format = __webpack_require__(23).format; - - function factory (type, config, load, typed) { - /** - * Interpolate values into a string template. - * - * Syntax: - * - * math.print(template, values) - * math.print(template, values, precision) - * math.print(template, values, options) - * - * Example usage: - * - * // the following outputs: 'Lucy is 5 years old' - * math.print('Lucy is $age years old', {age: 5}); - * - * // the following outputs: 'The value of pi is 3.141592654' - * math.print('The value of pi is $pi', {pi: math.pi}, 10); - * - * // the following outputs: 'hello Mary! The date is 2013-03-23' - * math.print('Hello $user.name! The date is $date', { - * user: { - * name: 'Mary', - * }, - * date: new Date(2013, 2, 23).toISOString().substring(0, 10) - * }); - * - * See also: - * - * format - * - * @param {string} template A string containing variable placeholders. - * @param {Object} values An object containing variables which will - * be filled in in the template. - * @param {number | Object} [options] Formatting options, - * or the number of digits to format numbers. - * See function math.format for a description - * of all options. - * @return {string} Interpolated string - */ - var print = typed ('print', { - 'string, Object': _print, - 'string, Object, number': _print - }); - - print.toTex = undefined; // use default template - - return print; - } - - /** - * Interpolate values into a string template. - * @param {string} template - * @param {Object} values - * @param {number | Object} [options] - * @returns {string} Interpolated string - * @private - */ - function _print(template, values, options) { - return template.replace(/\$([\w\.]+)/g, function (original, key) { - var keys = key.split('.'); - var value = values[keys.shift()]; - while (keys.length && value !== undefined) { - var k = keys.shift(); - value = k ? value[k] : value + '.'; - } - - if (value !== undefined) { - if (!isString(value)) { - return format(value, options); - } - else { - return value; - } - } - - return original; - } - ); - } - - exports.name = 'print'; - exports.factory = factory; - - -/***/ }, -/* 459 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(460), - __webpack_require__(461), - __webpack_require__(462), - __webpack_require__(463), - __webpack_require__(464), - __webpack_require__(465), - __webpack_require__(466), - __webpack_require__(467), - __webpack_require__(468), - __webpack_require__(469), - __webpack_require__(470), - __webpack_require__(471), - __webpack_require__(472), - __webpack_require__(473), - __webpack_require__(474), - __webpack_require__(475), - __webpack_require__(476), - __webpack_require__(477), - __webpack_require__(478), - __webpack_require__(479), - __webpack_require__(480), - __webpack_require__(481), - __webpack_require__(482), - __webpack_require__(483), - __webpack_require__(484) - ]; - - -/***/ }, -/* 460 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse cosine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acos(x) - * - * Examples: - * - * math.acos(0.5); // returns number 1.0471975511965979 - * math.acos(math.cos(1.5)); // returns number 1.5 - * - * math.acos(2); // returns Complex 0 + 1.3169578969248166 i - * - * See also: - * - * cos, atan, asin - * - * @param {number | BigNumber | Complex | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} The arc cosine of x - */ - var acos = typed('acos', { - 'number': function (x) { - if ((x >= -1 && x <= 1) || config.predictable) { - return Math.acos(x); - } - else { - return new type.Complex(x, 0).acos(); - } - }, - - 'Complex': function (x) { - return x.acos(); - }, - - 'BigNumber': function (x) { - return x.acos(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acos); - } - }); - - acos.toTex = {1: '\\cos^{-1}\\left(${args[0]}\\right)'}; - - return acos; - } - - exports.name = 'acos'; - exports.factory = factory; - - -/***/ }, -/* 461 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the hyperbolic arccos of a value, - * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acosh(x) - * - * Examples: - * - * math.acosh(1.5); // returns 0.9624236501192069 - * - * See also: - * - * cosh, asinh, atanh - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arccosine of x - */ - var acosh = typed('acosh', { - 'number': function (x) { - if (x >= 1 || config.predictable) { - return _acosh(x); - } - if (x <= -1) { - return new type.Complex(Math.log(Math.sqrt(x*x - 1) - x), Math.PI); - } - return new type.Complex(x, 0).acosh(); - }, - - 'Complex': function (x) { - return x.acosh(); - }, - - 'BigNumber': function (x) { - return x.acosh(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acosh); - } - }); - - acosh.toTex = {1: '\\cosh^{-1}\\left(${args[0]}\\right)'}; - - return acosh; - } - - /** - * Calculate the hyperbolic arccos of a number - * @param {number} x - * @return {number} - * @private - */ - var _acosh = Math.acosh || function (x) { - return Math.log(Math.sqrt(x*x - 1) + x) - }; - - exports.name = 'acosh'; - exports.factory = factory; - - -/***/ }, -/* 462 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse cotangent of a value, defined as `acot(x) = atan(1/x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acot(x) - * - * Examples: - * - * math.acot(0.5); // returns number 0.4636476090008061 - * math.acot(math.cot(1.5)); // returns number 1.5 - * - * math.acot(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * cot, atan - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} The arc cotangent of x - */ - var acot = typed('acot', { - 'number': function (x) { - return Math.atan(1 / x); - }, - - 'Complex': function (x) { - return x.acot(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).atan(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acot); - } - }); - - acot.toTex = {1: '\\cot^{-1}\\left(${args[0]}\\right)'}; - - return acot; - } - - exports.name = 'acot'; - exports.factory = factory; - - -/***/ }, -/* 463 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the hyperbolic arccotangent of a value, - * defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acoth(x) - * - * Examples: - * - * math.acoth(0.5); // returns 0.8047189562170503 - * - * See also: - * - * acsch, asech - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arccotangent of x - */ - var acoth = typed('acoth', { - 'number': function (x) { - if (x >= 1 || x <= -1 || config.predictable) { - return isFinite(x) ? (Math.log((x+1)/x) + Math.log(x/(x-1))) / 2 : 0; - } - return new type.Complex(x, 0).acoth(); - }, - - 'Complex': function (x) { - return x.acoth(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).atanh(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acoth); - } - }); - - acoth.toTex = {1: '\\coth^{-1}\\left(${args[0]}\\right)'}; - - return acoth; - } - - exports.name = 'acoth'; - exports.factory = factory; - - -/***/ }, -/* 464 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acsc(x) - * - * Examples: - * - * math.acsc(0.5); // returns number 0.5235987755982989 - * math.acsc(math.csc(1.5)); // returns number ~1.5 - * - * math.acsc(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * csc, asin, asec - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} The arc cosecant of x - */ - var acsc = typed('acsc', { - 'number': function (x) { - if (x <= -1 || x >= 1 || config.predictable) { - return Math.asin(1 / x); - } - return new type.Complex(x, 0).acsc(); - }, - - 'Complex': function (x) { - return x.acsc(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).asin(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acsc); - } - }); - - acsc.toTex = {1: '\\csc^{-1}\\left(${args[0]}\\right)'}; - - return acsc; - } - - exports.name = 'acsc'; - exports.factory = factory; - - -/***/ }, -/* 465 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the hyperbolic arccosecant of a value, - * defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acsch(x) - * - * Examples: - * - * math.acsch(0.5); // returns 1.4436354751788103 - * - * See also: - * - * asech, acoth - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arccosecant of x - */ - var acsch = typed('acsch', { - 'number': function (x) { - x = 1 / x; - return Math.log(x + Math.sqrt(x*x + 1)); - }, - - 'Complex': function (x) { - return x.acsch(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).asinh(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, acsch); - } - }); - - acsch.toTex = {1: '\\mathrm{csch}^{-1}\\left(${args[0]}\\right)'}; - - return acsch; - } - - exports.name = 'acsch'; - exports.factory = factory; - - -/***/ }, -/* 466 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse secant of a value. Defined as `asec(x) = acos(1/x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asec(x) - * - * Examples: - * - * math.asec(0.5); // returns 1.0471975511965979 - * math.asec(math.sec(1.5)); // returns 1.5 - * - * math.asec(2); // returns 0 + 1.3169578969248166 i - * - * See also: - * - * acos, acot, acsc - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} The arc secant of x - */ - var asec = typed('asec', { - 'number': function (x) { - if (x <= -1 || x >= 1 || config.predictable) { - return Math.acos(1 / x); - } - return new type.Complex(x, 0).asec(); - }, - - 'Complex': function (x) { - return x.asec(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).acos(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, asec); - } - }); - - asec.toTex = {1: '\\sec^{-1}\\left(${args[0]}\\right)'}; - - return asec; - } - - exports.name = 'asec'; - exports.factory = factory; - - -/***/ }, -/* 467 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - var acosh = typed.find(load(__webpack_require__(461)), ['Complex']); - - /** - * Calculate the hyperbolic arcsecant of a value, - * defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asech(x) - * - * Examples: - * - * math.asech(0.5); // returns 1.3169578969248166 - * - * See also: - * - * acsch, acoth - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arcsecant of x - */ - var asech = typed('asech', { - 'number': function (x) { - if ((x <= 1 && x >= -1) || config.predictable) { - x = 1 / x; - - var ret = Math.sqrt(x*x - 1); - if (x > 0 || config.predictable) { - return Math.log(ret + x); - } - - return new type.Complex(Math.log(ret - x), Math.PI); - } - - return new type.Complex(x, 0).asech(); - }, - - 'Complex': function (x) { - return x.asech() - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x).acosh(); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, asech); - } - }); - - asech.toTex = {1: '\\mathrm{sech}^{-1}\\left(${args[0]}\\right)'}; - - return asech; - } - - exports.name = 'asech'; - exports.factory = factory; - - -/***/ }, -/* 468 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse sine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asin(x) - * - * Examples: - * - * math.asin(0.5); // returns number 0.5235987755982989 - * math.asin(math.sin(1.5)); // returns number ~1.5 - * - * math.asin(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * sin, atan, acos - * - * @param {number | BigNumber | Complex | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} The arc sine of x - */ - var asin = typed('asin', { - 'number': function (x) { - if ((x >= -1 && x <= 1) || config.predictable) { - return Math.asin(x); - } - else { - return new type.Complex(x, 0).asin(); - } - }, - - 'Complex': function (x) { - return x.asin(); - }, - - 'BigNumber': function (x) { - return x.asin(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since asin(0) = 0 - return deepMap(x, asin, true); - } - }); - - asin.toTex = {1: '\\sin^{-1}\\left(${args[0]}\\right)'}; - - return asin; - } - - exports.name = 'asin'; - exports.factory = factory; - - -/***/ }, -/* 469 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the hyperbolic arcsine of a value, - * defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asinh(x) - * - * Examples: - * - * math.asinh(0.5); // returns 0.48121182505960347 - * - * See also: - * - * acosh, atanh - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arcsine of x - */ - var asinh = typed('asinh', { - 'number': Math.asinh || function (x) { - return Math.log(Math.sqrt(x*x + 1) + x); - }, - - 'Complex': function (x) { - return x.asinh(); - }, - - 'BigNumber': function (x) { - return x.asinh(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since asinh(0) = 0 - return deepMap(x, asinh, true); - } - }); - - asinh.toTex = {1: '\\sinh^{-1}\\left(${args[0]}\\right)'}; - - return asinh; - } - - exports.name = 'asinh'; - exports.factory = factory; - - -/***/ }, -/* 470 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the inverse tangent of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atan(x) - * - * Examples: - * - * math.atan(0.5); // returns number 0.4636476090008061 - * math.atan(math.tan(1.5)); // returns number 1.5 - * - * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * tan, asin, acos - * - * @param {number | BigNumber | Complex | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} The arc tangent of x - */ - var atan = typed('atan', { - 'number': function (x) { - return Math.atan(x); - }, - - 'Complex': function (x) { - return x.atan(); - }, - - 'BigNumber': function (x) { - return x.atan(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since atan(0) = 0 - return deepMap(x, atan, true); - } - }); - - atan.toTex = {1: '\\tan^{-1}\\left(${args[0]}\\right)'}; - - return atan; - } - - exports.name = 'atan'; - exports.factory = factory; - - -/***/ }, -/* 471 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(52)); - - var algorithm02 = load(__webpack_require__(360)); - var algorithm03 = load(__webpack_require__(61)); - var algorithm09 = load(__webpack_require__(362)); - var algorithm11 = load(__webpack_require__(85)); - var algorithm12 = load(__webpack_require__(63)); - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Calculate the inverse tangent function with two arguments, y/x. - * By providing two arguments, the right quadrant of the computed angle can be - * determined. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atan2(y, x) - * - * Examples: - * - * math.atan2(2, 2) / math.pi; // returns number 0.25 - * - * var angle = math.unit(60, 'deg'); // returns Unit 60 deg - * var x = math.cos(angle); - * var y = math.sin(angle); - * - * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * tan, atan, sin, cos - * - * @param {number | Array | Matrix} y Second dimension - * @param {number | Array | Matrix} x First dimension - * @return {number | Array | Matrix} Four-quadrant inverse tangent - */ - var atan2 = typed('atan2', { - - 'number, number': Math.atan2, - - // Complex numbers doesn't seem to have a reasonable implementation of - // atan2(). Even Matlab removed the support, after they only calculated - // the atan only on base of the real part of the numbers and ignored the imaginary. - - 'BigNumber, BigNumber': function (y, x) { - return type.BigNumber.atan2(y, x); - }, - - 'Matrix, Matrix': function (x, y) { - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse .* sparse - c = algorithm09(x, y, atan2, false); - break; - default: - // sparse .* dense - c = algorithm02(y, x, atan2, true); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // dense .* sparse - c = algorithm03(x, y, atan2, false); - break; - default: - // dense .* dense - c = algorithm13(x, y, atan2); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return atan2(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return atan2(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return atan2(x, matrix(y)); - }, - - 'Matrix, number | BigNumber': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = algorithm11(x, y, atan2, false); - break; - default: - c = algorithm14(x, y, atan2, false); - break; - } - return c; - }, - - 'number | BigNumber, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = algorithm12(y, x, atan2, true); - break; - default: - c = algorithm14(y, x, atan2, true); - break; - } - return c; - }, - - 'Array, number | BigNumber': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, atan2, false).valueOf(); - }, - - 'number | BigNumber, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, atan2, true).valueOf(); - } - }); - - atan2.toTex = {2: '\\mathrm{atan2}\\left(${args}\\right)'}; - - return atan2; - } - - exports.name = 'atan2'; - exports.factory = factory; - - -/***/ }, -/* 472 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic arctangent of a value, - * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atanh(x) - * - * Examples: - * - * math.atanh(0.5); // returns 0.5493061443340549 - * - * See also: - * - * acosh, asinh - * - * @param {number | Complex | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic arctangent of x - */ - var atanh = typed('atanh', { - 'number': function (x) { - if ((x <= 1 && x >= -1) || config.predictable) { - return _atanh(x); - } - return new type.Complex(x, 0).atanh(); - }, - - 'Complex': function (x) { - return x.atanh(); - }, - - 'BigNumber': function (x) { - return x.atanh(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since atanh(0) = 0 - return deepMap(x, atanh, true); - } - }); - - atanh.toTex = {1: '\\tanh^{-1}\\left(${args[0]}\\right)'}; - - return atanh; - } - - /** - * Calculate the hyperbolic arctangent of a number - * @param {number} x - * @return {number} - * @private - */ - var _atanh = Math.atanh || function (x) { - return Math.log((1 + x)/(1 - x)) / 2 - }; - - exports.name = 'atanh'; - exports.factory = factory; - - -/***/ }, -/* 473 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the cosine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cos(x) - * - * Examples: - * - * math.cos(2); // returns number -0.4161468365471422 - * math.cos(math.pi / 4); // returns number 0.7071067811865475 - * math.cos(math.unit(180, 'deg')); // returns number -1 - * math.cos(math.unit(60, 'deg')); // returns number 0.5 - * - * var angle = 0.2; - * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns number ~1 - * - * See also: - * - * cos, tan - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Cosine of x - */ - var cos = typed('cos', { - 'number': Math.cos, - - 'Complex': function (x) { - return x.cos(); - }, - - 'BigNumber': function (x) { - return x.cos(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cos is no angle'); - } - return cos(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, cos); - } - }); - - cos.toTex = {1: '\\cos\\left(${args[0]}\\right)'}; - - return cos; - } - - exports.name = 'cos'; - exports.factory = factory; - - -/***/ }, -/* 474 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic cosine of a value, - * defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cosh(x) - * - * Examples: - * - * math.cosh(0.5); // returns number 1.1276259652063807 - * - * See also: - * - * sinh, tanh - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic cosine of x - */ - var cosh = typed('cosh', { - 'number': _cosh, - - 'Complex': function (x) { - return x.cosh(); - }, - - 'BigNumber': function (x) { - return x.cosh(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cosh is no angle'); - } - return cosh(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, cosh); - } - }); - - cosh.toTex = {1: '\\cosh\\left(${args[0]}\\right)'}; - - return cosh; - } - - /** - * Calculate the hyperbolic cosine of a number - * @param {number} x - * @returns {number} - * @private - */ - var _cosh = Math.cosh || function (x) { - return (Math.exp(x) + Math.exp(-x)) / 2; - }; - - exports.name = 'cosh'; - exports.factory = factory; - - -/***/ }, -/* 475 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the cotangent of a value. Defined as `cot(x) = 1 / tan(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cot(x) - * - * Examples: - * - * math.cot(2); // returns number -0.45765755436028577 - * 1 / math.tan(2); // returns number -0.45765755436028577 - * - * See also: - * - * tan, sec, csc - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Cotangent of x - */ - var cot = typed('cot', { - 'number': function (x) { - return 1 / Math.tan(x); - }, - - 'Complex': function (x) { - return x.cot(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.tan()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cot is no angle'); - } - return cot(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, cot); - } - }); - - cot.toTex = {1: '\\cot\\left(${args[0]}\\right)'}; - - return cot; - } - - exports.name = 'cot'; - exports.factory = factory; - - -/***/ }, -/* 476 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic cotangent of a value, - * defined as `coth(x) = 1 / tanh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.coth(x) - * - * Examples: - * - * // coth(x) = 1 / tanh(x) - * math.coth(2); // returns 1.0373147207275482 - * 1 / math.tanh(2); // returns 1.0373147207275482 - * - * See also: - * - * sinh, tanh, cosh - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic cotangent of x - */ - var coth = typed('coth', { - 'number': _coth, - - 'Complex': function (x) { - return x.coth(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.tanh()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function coth is no angle'); - } - return coth(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, coth); - } - }); - - coth.toTex = {1: '\\coth\\left(${args[0]}\\right)'}; - - return coth; - } - - /** - * Calculate the hyperbolic cosine of a number - * @param {number} x - * @returns {number} - * @private - */ - function _coth(x) { - var e = Math.exp(2 * x); - return (e + 1) / (e - 1); - } - - exports.name = 'coth'; - exports.factory = factory; - - -/***/ }, -/* 477 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.csc(x) - * - * Examples: - * - * math.csc(2); // returns number 1.099750170294617 - * 1 / math.sin(2); // returns number 1.099750170294617 - * - * See also: - * - * sin, sec, cot - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Cosecant of x - */ - var csc = typed('csc', { - 'number': function (x) { - return 1 / Math.sin(x); - }, - - 'Complex': function (x) { - return x.csc(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.sin()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function csc is no angle'); - } - return csc(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, csc); - } - }); - - csc.toTex = {1: '\\csc\\left(${args[0]}\\right)'}; - - return csc; - } - - exports.name = 'csc'; - exports.factory = factory; - - -/***/ }, -/* 478 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - var sign = __webpack_require__(6).sign; - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic cosecant of a value, - * defined as `csch(x) = 1 / sinh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.csch(x) - * - * Examples: - * - * // csch(x) = 1/ sinh(x) - * math.csch(0.5); // returns 1.9190347513349437 - * 1 / math.sinh(0.5); // returns 1.9190347513349437 - * - * See also: - * - * sinh, sech, coth - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic cosecant of x - */ - var csch = typed('csch', { - 'number': _csch, - - 'Complex': function (x) { - return x.csch(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.sinh()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function csch is no angle'); - } - return csch(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, csch); - } - }); - - csch.toTex = {1: '\\mathrm{csch}\\left(${args[0]}\\right)'}; - - return csch; - } - - /** - * Calculate the hyperbolic cosecant of a number - * @param {number} x - * @returns {number} - * @private - */ - function _csch(x) { - // consider values close to zero (+/-) - if (x == 0) { - return Number.POSITIVE_INFINITY; - } - else { - return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x); - } - } - - exports.name = 'csch'; - exports.factory = factory; - - -/***/ }, -/* 479 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sec(x) - * - * Examples: - * - * math.sec(2); // returns number -2.4029979617223822 - * 1 / math.cos(2); // returns number -2.4029979617223822 - * - * See also: - * - * cos, csc, cot - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Secant of x - */ - var sec = typed('sec', { - 'number': function (x) { - return 1 / Math.cos(x); - }, - - 'Complex': function (x) { - return x.sec(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.cos()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sec is no angle'); - } - return sec(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, sec); - } - }); - - sec.toTex = {1: '\\sec\\left(${args[0]}\\right)'}; - - return sec; - } - - exports.name = 'sec'; - exports.factory = factory; - - -/***/ }, -/* 480 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic secant of a value, - * defined as `sech(x) = 1 / cosh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sech(x) - * - * Examples: - * - * // sech(x) = 1/ cosh(x) - * math.sech(0.5); // returns 0.886818883970074 - * 1 / math.cosh(0.5); // returns 0.886818883970074 - * - * See also: - * - * cosh, csch, coth - * - * @param {number | Complex | Unit | Array | Matrix} x Function input - * @return {number | Complex | Array | Matrix} Hyperbolic secant of x - */ - var sech = typed('sech', { - 'number': _sech, - - 'Complex': function (x) { - return x.sech(); - }, - - 'BigNumber': function (x) { - return new type.BigNumber(1).div(x.cosh()); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sech is no angle'); - } - return sech(x.value); - }, - - 'Array | Matrix': function (x) { - return deepMap(x, sech); - } - }); - - sech.toTex = {1: '\\mathrm{sech}\\left(${args[0]}\\right)'}; - - return sech; - } - - /** - * Calculate the hyperbolic secant of a number - * @param {number} x - * @returns {number} - * @private - */ - function _sech(x) { - return 2 / (Math.exp(x) + Math.exp(-x)); - } - - exports.name = 'sech'; - exports.factory = factory; - - -/***/ }, -/* 481 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - - /** - * Calculate the sine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sin(x) - * - * Examples: - * - * math.sin(2); // returns number 0.9092974268256813 - * math.sin(math.pi / 4); // returns number 0.7071067811865475 - * math.sin(math.unit(90, 'deg')); // returns number 1 - * math.sin(math.unit(30, 'deg')); // returns number 0.5 - * - * var angle = 0.2; - * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns number ~1 - * - * See also: - * - * cos, tan - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Sine of x - */ - var sin = typed('sin', { - 'number': Math.sin, - - 'Complex': function (x) { - return x.sin(); - }, - - 'BigNumber': function (x) { - return x.sin(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sin is no angle'); - } - return sin(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sin(0) = 0 - return deepMap(x, sin, true); - } - }); - - sin.toTex = {1: '\\sin\\left(${args[0]}\\right)'}; - - return sin; - } - - exports.name = 'sin'; - exports.factory = factory; - - -/***/ }, -/* 482 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic sine of a value, - * defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sinh(x) - * - * Examples: - * - * math.sinh(0.5); // returns number 0.5210953054937474 - * - * See also: - * - * cosh, tanh - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic sine of x - */ - var sinh = typed('sinh', { - 'number': _sinh, - - 'Complex': function (x) { - return x.sinh(); - }, - - 'BigNumber': function (x) { - return x.sinh(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sinh is no angle'); - } - return sinh(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sinh(0) = 0 - return deepMap(x, sinh, true); - } - }); - - sinh.toTex = {1: '\\sinh\\left(${args[0]}\\right)'}; - - return sinh; - } - - /** - * Calculate the hyperbolic sine of a number - * @param {number} x - * @returns {number} - * @private - */ - var _sinh = Math.sinh || function (x) { - return (Math.exp(x) - Math.exp(-x)) / 2; - }; - - exports.name = 'sinh'; - exports.factory = factory; - - -/***/ }, -/* 483 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the tangent of a value. `tan(x)` is equal to `sin(x) / cos(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.tan(x) - * - * Examples: - * - * math.tan(0.5); // returns number 0.5463024898437905 - * math.sin(0.5) / math.cos(0.5); // returns number 0.5463024898437905 - * math.tan(math.pi / 4); // returns number 1 - * math.tan(math.unit(45, 'deg')); // returns number 1 - * - * See also: - * - * atan, sin, cos - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Tangent of x - */ - var tan = typed('tan', { - 'number': Math.tan, - - 'Complex': function (x) { - return x.tan(); - }, - - 'BigNumber': function (x) { - return x.tan(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function tan is no angle'); - } - return tan(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since tan(0) = 0 - return deepMap(x, tan, true); - } - }); - - tan.toTex = {1: '\\tan\\left(${args[0]}\\right)'}; - - return tan; - } - - exports.name = 'tan'; - exports.factory = factory; - - -/***/ }, -/* 484 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var deepMap = __webpack_require__(19); - - function factory (type, config, load, typed) { - /** - * Calculate the hyperbolic tangent of a value, - * defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.tanh(x) - * - * Examples: - * - * // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x) - * math.tanh(0.5); // returns 0.46211715726000974 - * math.sinh(0.5) / math.cosh(0.5); // returns 0.46211715726000974 - * 1 / math.coth(0.5); // returns 0.46211715726000974 - * - * See also: - * - * sinh, cosh, coth - * - * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input - * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic tangent of x - */ - var tanh = typed('tanh', { - 'number': _tanh, - - 'Complex': function (x) { - return x.tanh(); - }, - - 'BigNumber': function (x) { - return x.tanh(); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function tanh is no angle'); - } - return tanh(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since tanh(0) = 0 - return deepMap(x, tanh, true); - } - }); - - tanh.toTex = {1: '\\tanh\\left(${args[0]}\\right)'}; - - return tanh; - } - - /** - * Calculate the hyperbolic tangent of a number - * @param {number} x - * @returns {number} - * @private - */ - var _tanh = Math.tanh || function (x) { - var e = Math.exp(2 * x); - return (e - 1) / (e + 1); - }; - - exports.name = 'tanh'; - exports.factory = factory; - - -/***/ }, -/* 485 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(486) - ]; - -/***/ }, -/* 486 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var latex = __webpack_require__(32); - - var matrix = load(__webpack_require__(52)); - - var algorithm13 = load(__webpack_require__(57)); - var algorithm14 = load(__webpack_require__(58)); - - /** - * Change the unit of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.to(x, unit) - * - * Examples: - * - * math.to(math.unit('2 inch'), 'cm'); // returns Unit 5.08 cm - * math.to(math.unit('2 inch'), math.unit(null, 'cm')); // returns Unit 5.08 cm - * math.to(math.unit(16, 'bytes'), 'bits'); // returns Unit 128 bits - * - * See also: - * - * unit - * - * @param {Unit | Array | Matrix} x The unit to be converted. - * @param {Unit | Array | Matrix} unit New unit. Can be a string like "cm" - * or a unit without value. - * @return {Unit | Array | Matrix} value with changed, fixed unit. - */ - var to = typed('to', { - - 'Unit, Unit | string': function (x, unit) { - return x.to(unit); - }, - - 'Matrix, Matrix': function (x, y) { - // SparseMatrix does not support Units - return algorithm13(x, y, to); - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return to(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return to(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return to(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // SparseMatrix does not support Units - return algorithm14(x, y, to, false); - }, - - 'any, Matrix': function (x, y) { - // SparseMatrix does not support Units - return algorithm14(y, x, to, true); - }, - - 'Array, any': function (x, y) { - // use matrix implementation - return algorithm14(matrix(x), y, to, false).valueOf(); - }, - - 'any, Array': function (x, y) { - // use matrix implementation - return algorithm14(matrix(y), x, to, true).valueOf(); - } - }); - - to.toTex = { - 2: '\\left(${args[0]}' + latex.operators['to'] + '${args[1]}\\right)' - }; - - return to; - } - - exports.name = 'to'; - exports.factory = factory; - - -/***/ }, -/* 487 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(488), - __webpack_require__(408), - __webpack_require__(356), - __webpack_require__(88), - __webpack_require__(370), - __webpack_require__(422), - __webpack_require__(90) - ]; - - -/***/ }, -/* 488 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object= __webpack_require__(3); - - function factory (type, config, load, typed) { - /** - * Clone an object. - * - * Syntax: - * - * math.clone(x) - * - * Examples: - * - * math.clone(3.5); // returns number 3.5 - * math.clone(math.complex('2-4i'); // returns Complex 2 - 4i - * math.clone(math.unit(45, 'deg')); // returns Unit 45 deg - * math.clone([[1, 2], [3, 4]]); // returns Array [[1, 2], [3, 4]] - * math.clone("hello world"); // returns string "hello world" - * - * @param {*} x Object to be cloned - * @return {*} A clone of object x - */ - var clone = typed('clone', { - 'any': object.clone - }); - - clone.toTex = undefined; // use default template - - return clone; - } - - exports.name = 'clone'; - exports.factory = factory; - - -/***/ }, -/* 489 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = [ - __webpack_require__(490) - ]; - - -/***/ }, -/* 490 */ -/***/ function(module, exports) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Instantiate mathjs data types from their JSON representation - * @param {string} key - * @param {*} value - * @returns {*} Returns the revived object - */ - return function reviver(key, value) { - var constructor = type[value && value.mathjs]; - if (constructor && typeof constructor.fromJSON === 'function') { - return constructor.fromJSON(value); - } - - return value; - } - } - - exports.name = 'reviver'; - exports.path = 'json'; - exports.factory = factory; - - -/***/ }, -/* 491 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var ArgumentsError = __webpack_require__(11); - var DimensionError = __webpack_require__(42); - var IndexError = __webpack_require__(43); - - module.exports = [ - { - name: 'ArgumentsError', path: 'error', - factory: function () { - return ArgumentsError; - } - }, - { - name: 'DimensionError', - path: 'error', - factory: function () { - return DimensionError; - } - }, - { - name: 'IndexError', - path: 'error', - factory: function () { - return IndexError; - } - } - ]; - - // TODO: implement an InvalidValueError? - - -/***/ } -/******/ ]) -}); -; \ No newline at end of file diff --git a/mxClient.min.js b/mxClient.min.js deleted file mode 100644 index 80979cd..0000000 --- a/mxClient.min.js +++ /dev/null @@ -1,1564 +0,0 @@ -var mxClient={VERSION:"1.10.4.1",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE"),IS_OP:0<=navigator.userAgent.indexOf("Opera/"),IS_OT:0>navigator.userAgent.indexOf("Presto/2.4.")&&0>navigator.userAgent.indexOf("Presto/2.3.")&&0>navigator.userAgent.indexOf("Presto/2.2.")&& -0>navigator.userAgent.indexOf("Presto/2.1.")&&0>navigator.userAgent.indexOf("Presto/2.0.")&&0>navigator.userAgent.indexOf("Presto/1."),IS_SF:0<=navigator.userAgent.indexOf("AppleWebKit/")&&0>navigator.userAgent.indexOf("Chrome/"),IS_GC:0<=navigator.userAgent.indexOf("Chrome/"),IS_MT:0<=navigator.userAgent.indexOf("Firefox/")&&0>navigator.userAgent.indexOf("Firefox/1.")&&0>navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/")&&0>navigator.userAgent.indexOf("Iceweasel/1.")&& -0>navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/")&&0>navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/")&&0>navigator.userAgent.indexOf("Iceape/1."),IS_SVG:0<=navigator.userAgent.indexOf("Firefox/")||0<=navigator.userAgent.indexOf("Iceweasel/")||0<=navigator.userAgent.indexOf("Seamonkey/")||0<=navigator.userAgent.indexOf("Iceape/")||0<=navigator.userAgent.indexOf("Galeon/")||0<=navigator.userAgent.indexOf("Epiphany/")||0<= -navigator.userAgent.indexOf("AppleWebKit/")||0<=navigator.userAgent.indexOf("Gecko/")||0<=navigator.userAgent.indexOf("Opera/"),NO_FO:0<=navigator.userAgent.indexOf("Firefox/1.")||0<=navigator.userAgent.indexOf("Iceweasel/1.")||0<=navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/1.")||0<=navigator.userAgent.indexOf("Camino/1.")||0<=navigator.userAgent.indexOf("Epiphany/2.")|| -0<=navigator.userAgent.indexOf("Opera/")||0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Mozilla/2."),IS_VML:"MICROSOFT INTERNET EXPLORER"==navigator.appName.toUpperCase(),IS_MAC:0document.location.href.indexOf("http://")&& -0>document.location.href.indexOf("https://"),isBrowserSupported:function(){return mxClient.IS_VML||mxClient.IS_SVG},link:function(a,b,c){c=c||document;if(mxClient.IS_IE6)c.write('');else{var d=c.createElement("link");d.setAttribute("rel",a);d.setAttribute("href",b);d.setAttribute("charset","ISO-8859-1");d.setAttribute("type","text/css");c.getElementsByTagName("head")[0].appendChild(d)}},include:function(a){document.write(' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ FOSSEE +
+
+ + + + + + + + + \ No newline at end of file diff --git a/webapp/jquery/LICENSE.txt b/webapp/jquery/LICENSE.txt new file mode 100644 index 0000000..5a3cc20 --- /dev/null +++ b/webapp/jquery/LICENSE.txt @@ -0,0 +1,341 @@ + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/webapp/jquery/README.html b/webapp/jquery/README.html new file mode 100644 index 0000000..e527472 --- /dev/null +++ b/webapp/jquery/README.html @@ -0,0 +1,71 @@ + + +Farbtastic: jQuery color picker plug-in + +

Farbtastic: jQuery color picker plug-in

+

Farbtastic is a jQuery plug-in that can add one or more color picker widgets into a page. Each widget is then linked to an existing element (e.g. a text field) and will update the element's value when a color is selected.

+ +

Farbtastic uses layered transparent PNGs to render a saturation/luminance gradient inside of a hue circle. No Flash or pixel-sized divs are used.

+ +

Farbtastic was written by Steven Wittens and is licensed under the GPL.

+ +

Basic Usage

+
    +
  1. Include farbtastic.js and farbtastic.css in your HTML:
    +
    <script type="text/javascript" src="farbtastic.js"></script>
    <link rel="stylesheet" href="farbtastic.css" type="text/css" />
    +
  2. +
  3. Add a placeholder div and a text field to your HTML, and give each an ID:
    +
    <form><input type="text" id="color" name="color" value="#123456" /></form>
    <div id="colorpicker"></div>
    +
  4. +
  5. Add a ready() handler to the document which initializes the color picker and link it to the text field with the following syntax:
    +
    <script type="text/javascript">
      $(document).ready(function() {
        $('#colorpicker').farbtastic('#color');
      });
    </script>
    +
  6. +
+

See demo1.html and demo2.html for an example (jquery.js is not included!).

+

Styling

+

The color picker is a block-level element and is 195x195 pixels large. You can control the position by styling your placeholder (e.g. floating it).

+

Note that the black/white gradients inside wheel.png and mask.png were generated programmatically and cannot be recreated easily in an image editing program.

+

Advanced Usage

+

jQuery Method

+
+
$(...).farbtastic()
+$(...).farbtastic(callback)
+
This creates color pickers in the selected objects. callback is optional and can be a:

+
    +
  • DOM Node, jQuery object or jQuery selector: the color picker will be linked to the selected element(s) by syncing the value (for form elements) and color (all elements).
  • +
  • Function: this function will be called whenever the user chooses a different color.
+
+

Object

+
+
$.farbtastic(placeholder)
+$.farbtastic(placeholder, callback)
+
+
Invoking $.farbtastic(placeholder) is the same as using $(placeholder).farbtastic() except that the Farbtastic object is returned instead of the jQuery object. This allows you to use the Farbtastic methods and properties below.

+

Note that there is only one Farbtastic object per placeholder. If you call $.farbtastic(placeholder) twice with the same placeholder, you will get the same object back each time.

+

The optional callback argument behaves exactly as for the jQuery method.
+

+
+ + +

Methods

+
+
.linkTo(callback)
+
Allows you to set a new callback. Any existing callbacks are removed. See above for the meaning of callback.
+
.setColor(string)
+
Sets the picker color to the given color in hex representation.
+
.setColor([h, s, l])
+
Sets the picker color to the given color in normalized HSL (0..1 scale).
+
+

Properties

+
+
.linked
+
The elements (jQuery object) or callback function this picker is linked to.
+
.color
+
Current color in hex representation.
+
.hsl
+
Current color in normalized HSL.
+
+
+ + \ No newline at end of file diff --git a/webapp/jquery/farbtastic.css b/webapp/jquery/farbtastic.css new file mode 100644 index 0000000..48161fb --- /dev/null +++ b/webapp/jquery/farbtastic.css @@ -0,0 +1,51 @@ +/** + * Farbtastic Color Picker 1.2 + * © 2008 Steven Wittens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +.farbtastic { + position: relative; +} +.farbtastic * { + position: absolute; + cursor: crosshair; +} +.farbtastic, .farbtastic .wheel { + width: 195px; + height: 195px; +} +.farbtastic .color, .farbtastic .overlay { + top: 47px; + left: 47px; + width: 101px; + height: 101px; +} +.farbtastic .wheel { + background: url(wheel.png) no-repeat; + width: 195px; + height: 195px; +} +.farbtastic .overlay { + background: url(mask.png) no-repeat; +} +.farbtastic .marker { + width: 17px; + height: 17px; + margin: -8px 0 0 -8px; + overflow: hidden; + background: url(marker.png) no-repeat; +} + diff --git a/webapp/jquery/farbtastic.js b/webapp/jquery/farbtastic.js new file mode 100644 index 0000000..8463cb7 --- /dev/null +++ b/webapp/jquery/farbtastic.js @@ -0,0 +1,345 @@ +/** + * Farbtastic Color Picker 1.2 + * © 2008 Steven Wittens + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +jQuery.fn.farbtastic = function (callback) { + $.farbtastic(this, callback); + return this; +}; + +jQuery.farbtastic = function (container, callback) { + var container = $(container).get(0); + return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); +} + +jQuery._farbtastic = function (container, callback) { + // Store farbtastic object + var fb = this; + + // Insert markup + $(container).html('
'); + var e = $('.farbtastic', container); + fb.wheel = $('.wheel', container).get(0); + // Dimensions + fb.radius = 84; + fb.square = 100; + fb.width = 194; + + // Fix background PNGs in IE6 + if (navigator.appVersion.match(/MSIE [0-6]\./)) { + $('*', e).each(function () { + if (this.currentStyle.backgroundImage != 'none') { + var image = this.currentStyle.backgroundImage; + image = this.currentStyle.backgroundImage.substring(5, image.length - 2); + $(this).css({ + 'backgroundImage': 'none', + 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" + }); + } + }); + } + + /** + * Link to the given element(s) or callback. + */ + fb.linkTo = function (callback) { + // Unbind previous nodes + if (typeof fb.callback == 'object') { + $(fb.callback).unbind('keyup', fb.updateValue); + } + + // Reset color + fb.color = null; + + // Bind callback or elements + if (typeof callback == 'function') { + fb.callback = callback; + } + else if (typeof callback == 'object' || typeof callback == 'string') { + fb.callback = $(callback); + fb.callback.bind('keyup', fb.updateValue); + if (fb.callback.get(0).value) { + fb.setColor(fb.callback.get(0).value); + } + } + return this; + } + fb.updateValue = function (event) { + if (this.value && this.value != fb.color) { + fb.setColor(this.value); + } + } + + /** + * Change color with HTML syntax #123456 + */ + fb.setColor = function (color) { + var unpack = fb.unpack(color); + if (fb.color != color && unpack) { + fb.color = color; + fb.rgb = unpack; + fb.hsl = fb.RGBToHSL(fb.rgb); + fb.updateDisplay(); + } + return this; + } + + /** + * Change color with HSL triplet [0..1, 0..1, 0..1] + */ + fb.setHSL = function (hsl) { + fb.hsl = hsl; + fb.rgb = fb.HSLToRGB(hsl); + fb.color = fb.pack(fb.rgb); + fb.updateDisplay(); + return this; + } + + ///////////////////////////////////////////////////// + + /** + * Retrieve the coordinates of the given event relative to the center + * of the widget. + */ + fb.widgetCoords = function (event) { + var x, y; + var el = event.target || event.srcElement; + var reference = fb.wheel; + + if (typeof event.offsetX != 'undefined') { + // Use offset coordinates and find common offsetParent + var pos = { x: event.offsetX, y: event.offsetY }; + + // Send the coordinates upwards through the offsetParent chain. + var e = el; + while (e) { + e.mouseX = pos.x; + e.mouseY = pos.y; + pos.x += e.offsetLeft; + pos.y += e.offsetTop; + e = e.offsetParent; + } + + // Look for the coordinates starting from the wheel widget. + var e = reference; + var offset = { x: 0, y: 0 } + while (e) { + if (typeof e.mouseX != 'undefined') { + x = e.mouseX - offset.x; + y = e.mouseY - offset.y; + break; + } + offset.x += e.offsetLeft; + offset.y += e.offsetTop; + e = e.offsetParent; + } + + // Reset stored coordinates + e = el; + while (e) { + e.mouseX = undefined; + e.mouseY = undefined; + e = e.offsetParent; + } + } + else { + // Use absolute coordinates + var pos = fb.absolutePosition(reference); + x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x; + y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y; + } + // Subtract distance to middle + return { x: x - fb.width / 2, y: y - fb.width / 2 }; + } + + /** + * Mousedown handler + */ + fb.mousedown = function (event) { + // Capture mouse + if (!document.dragging) { + $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); + document.dragging = true; + } + + // Check which area is being dragged + var pos = fb.widgetCoords(event); + fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; + + // Process + fb.mousemove(event); + return false; + } + + /** + * Mousemove handler + */ + fb.mousemove = function (event) { + // Get coordinates relative to color picker center + var pos = fb.widgetCoords(event); + + // Set new HSL parameters + if (fb.circleDrag) { + var hue = Math.atan2(pos.x, -pos.y) / 6.28; + if (hue < 0) hue += 1; + fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); + } + else { + var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); + var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); + fb.setHSL([fb.hsl[0], sat, lum]); + } + return false; + } + + /** + * Mouseup handler + */ + fb.mouseup = function () { + // Uncapture mouse + $(document).unbind('mousemove', fb.mousemove); + $(document).unbind('mouseup', fb.mouseup); + document.dragging = false; + } + + /** + * Update the markers and styles + */ + fb.updateDisplay = function () { + // Markers + var angle = fb.hsl[0] * 6.28; + $('.h-marker', e).css({ + left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', + top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' + }); + + $('.sl-marker', e).css({ + left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', + top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' + }); + + // Saturation/Luminance gradient + $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); + + // Linked elements or callback + if (typeof fb.callback == 'object') { + // Set background/foreground color + $(fb.callback).css({ + backgroundColor: fb.color, + color: fb.hsl[2] > 0.5 ? '#000' : '#fff' + }); + + // Change linked value + $(fb.callback).each(function() { + if (this.value && this.value != fb.color) { + this.value = fb.color; + } + }); + } + else if (typeof fb.callback == 'function') { + fb.callback.call(fb, fb.color); + } + } + + /** + * Get absolute position of element + */ + fb.absolutePosition = function (el) { + var r = { x: el.offsetLeft, y: el.offsetTop }; + // Resolve relative to offsetParent + if (el.offsetParent) { + var tmp = fb.absolutePosition(el.offsetParent); + r.x += tmp.x; + r.y += tmp.y; + } + return r; + }; + + /* Various color utility functions */ + fb.pack = function (rgb) { + var r = Math.round(rgb[0] * 255); + var g = Math.round(rgb[1] * 255); + var b = Math.round(rgb[2] * 255); + return '#' + (r < 16 ? '0' : '') + r.toString(16) + + (g < 16 ? '0' : '') + g.toString(16) + + (b < 16 ? '0' : '') + b.toString(16); + } + + fb.unpack = function (color) { + if (color.length == 7) { + return [parseInt('0x' + color.substring(1, 3)) / 255, + parseInt('0x' + color.substring(3, 5)) / 255, + parseInt('0x' + color.substring(5, 7)) / 255]; + } + else if (color.length == 4) { + return [parseInt('0x' + color.substring(1, 2)) / 15, + parseInt('0x' + color.substring(2, 3)) / 15, + parseInt('0x' + color.substring(3, 4)) / 15]; + } + } + + fb.HSLToRGB = function (hsl) { + var m1, m2, r, g, b; + var h = hsl[0], s = hsl[1], l = hsl[2]; + m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; + m1 = l * 2 - m2; + return [this.hueToRGB(m1, m2, h+0.33333), + this.hueToRGB(m1, m2, h), + this.hueToRGB(m1, m2, h-0.33333)]; + } + + fb.hueToRGB = function (m1, m2, h) { + h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); + if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; + if (h * 2 < 1) return m2; + if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; + return m1; + } + + fb.RGBToHSL = function (rgb) { + var min, max, delta, h, s, l; + var r = rgb[0], g = rgb[1], b = rgb[2]; + min = Math.min(r, Math.min(g, b)); + max = Math.max(r, Math.max(g, b)); + delta = max - min; + l = (min + max) / 2; + s = 0; + if (l > 0 && l < 1) { + s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); + } + h = 0; + if (delta > 0) { + if (max == r && max != g) h += (g - b) / delta; + if (max == g && max != b) h += (2 + (b - r) / delta); + if (max == b && max != r) h += (4 + (r - g) / delta); + h /= 6; + } + return [h, s, l]; + } + + // Install mousedown handler (the others are set on the document on-demand) + $('*', e).mousedown(fb.mousedown); + + // Init color + fb.setColor('#c24747'); + + // Set linked elements/callback + if (callback) { + fb.linkTo(callback); + } +} \ No newline at end of file diff --git a/webapp/jquery/images/ui-bg_flat_75_ffffff_40x100.png b/webapp/jquery/images/ui-bg_flat_75_ffffff_40x100.png new file mode 100644 index 0000000..ac8b229 Binary files /dev/null and b/webapp/jquery/images/ui-bg_flat_75_ffffff_40x100.png differ diff --git a/webapp/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png b/webapp/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png new file mode 100644 index 0000000..86c2baa Binary files /dev/null and b/webapp/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png differ diff --git a/webapp/jquery/images/ui-icons_888888_256x240.png b/webapp/jquery/images/ui-icons_888888_256x240.png new file mode 100644 index 0000000..5ba708c Binary files /dev/null and b/webapp/jquery/images/ui-icons_888888_256x240.png differ diff --git a/webapp/jquery/jquery-1.8.2.js b/webapp/jquery/jquery-1.8.2.js new file mode 100644 index 0000000..12c7797 --- /dev/null +++ b/webapp/jquery/jquery-1.8.2.js @@ -0,0 +1,9440 @@ +/*! + * jQuery JavaScript Library v1.8.2 + * http://jquery.com/ + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time) + */ +(function( window, undefined ) { +var + // A central reference to the root jQuery(document) + rootjQuery, + + // The deferred used on DOM ready + readyList, + + // Use the correct document accordingly with window argument (sandbox) + document = window.document, + location = window.location, + navigator = window.navigator, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // Save a reference to some core methods + core_push = Array.prototype.push, + core_slice = Array.prototype.slice, + core_indexOf = Array.prototype.indexOf, + core_toString = Object.prototype.toString, + core_hasOwn = Object.prototype.hasOwnProperty, + core_trim = String.prototype.trim, + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Used for matching numbers + core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, + + // Used for detecting and trimming whitespace + core_rnotwhite = /\S/, + core_rspace = /\s+/, + + // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) + rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, + rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, + + // Matches dashed string for camelizing + rmsPrefix = /^-ms-/, + rdashAlpha = /-([\da-z])/gi, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // The ready event handler and self cleanup method + DOMContentLoaded = function() { + if ( document.addEventListener ) { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + } else if ( document.readyState === "complete" ) { + // we're here because readyState === "complete" in oldIE + // which is good enough for us to call the dom ready! + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context && context.nodeType ? context.ownerDocument || context : document ); + + // scripts is true for back-compat + selector = jQuery.parseHTML( match[1], doc, true ); + if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + this.attr.call( selector, context, true ); + } + + return jQuery.merge( this, selector ); + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.8.2", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return core_slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Add the callback + jQuery.ready.promise().done( fn ); + + return this; + }, + + eq: function( i ) { + i = +i; + return i === -1 ? + this.slice( i ) : + this.slice( i, i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( core_slice.apply( this, arguments ), + "slice", core_slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: core_push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger("ready").off("ready"); + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + isWindow: function( obj ) { + return obj != null && obj == obj.window; + }, + + isNumeric: function( obj ) { + return !isNaN( parseFloat(obj) ) && isFinite( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ core_toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !core_hasOwn.call(obj, "constructor") && + !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || core_hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + var name; + for ( name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw new Error( msg ); + }, + + // data: string of html + // context (optional): If specified, the fragment will be created in this context, defaults to document + // scripts (optional): If true, will include scripts passed in the html string + parseHTML: function( data, context, scripts ) { + var parsed; + if ( !data || typeof data !== "string" ) { + return null; + } + if ( typeof context === "boolean" ) { + scripts = context; + context = 0; + } + context = context || document; + + // Single tag + if ( (parsed = rsingleTag.exec( data )) ) { + return [ context.createElement( parsed[1] ) ]; + } + + parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); + return jQuery.merge( [], + (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); + }, + + parseJSON: function( data ) { + if ( !data || typeof data !== "string") { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + if ( !data || typeof data !== "string" ) { + return null; + } + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && core_rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + }, + + // args is for internal usage only + each: function( obj, callback, args ) { + var name, + i = 0, + length = obj.length, + isObj = length === undefined || jQuery.isFunction( obj ); + + if ( args ) { + if ( isObj ) { + for ( name in obj ) { + if ( callback.apply( obj[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( obj[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in obj ) { + if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { + break; + } + } + } + } + + return obj; + }, + + // Use native String.trim function wherever possible + trim: core_trim && !core_trim.call("\uFEFF\xA0") ? + function( text ) { + return text == null ? + "" : + core_trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + ( text + "" ).replace( rtrim, "" ); + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var type, + ret = results || []; + + if ( arr != null ) { + // The window, strings (and functions) also have 'length' + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + type = jQuery.type( arr ); + + if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { + core_push.call( ret, arr ); + } else { + jQuery.merge( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + var len; + + if ( arr ) { + if ( core_indexOf ) { + return core_indexOf.call( arr, elem, i ); + } + + len = arr.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in arr && arr[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var l = second.length, + i = first.length, + j = 0; + + if ( typeof l === "number" ) { + for ( ; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var retVal, + ret = [], + i = 0, + length = elems.length; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, + ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + var tmp, args, proxy; + + if ( typeof context === "string" ) { + tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + args = core_slice.call( arguments, 2 ); + proxy = function() { + return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || jQuery.guid++; + + return proxy; + }, + + // Multifunctional method to get and set values of a collection + // The value/s can optionally be executed if it's a function + access: function( elems, fn, key, value, chainable, emptyGet, pass ) { + var exec, + bulk = key == null, + i = 0, + length = elems.length; + + // Sets many values + if ( key && typeof key === "object" ) { + for ( i in key ) { + jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); + } + chainable = 1; + + // Sets one value + } else if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = pass === undefined && jQuery.isFunction( value ); + + if ( bulk ) { + // Bulk operations only iterate when executing function values + if ( exec ) { + exec = fn; + fn = function( elem, key, value ) { + return exec.call( jQuery( elem ), value ); + }; + + // Otherwise they run against the entire set + } else { + fn.call( elems, value ); + fn = null; + } + } + + if ( fn ) { + for (; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + } + + chainable = 1; + } + + return chainable ? + elems : + + // Gets + bulk ? + fn.call( elems ) : + length ? fn( elems[0], key ) : emptyGet; + }, + + now: function() { + return ( new Date() ).getTime(); + } +}); + +jQuery.ready.promise = function( obj ) { + if ( !readyList ) { + + readyList = jQuery.Deferred(); + + // Catch cases where $(document).ready() is called after the browser event has already occurred. + // we once tried to use readyState "interactive" here, but it caused issues like the one + // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + setTimeout( jQuery.ready, 1 ); + + // Standards-based browsers support DOMContentLoaded + } else if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else { + // Ensure firing before onload, maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var top = false; + + try { + top = window.frameElement == null && document.documentElement; + } catch(e) {} + + if ( top && top.doScroll ) { + (function doScrollCheck() { + if ( !jQuery.isReady ) { + + try { + // Use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + top.doScroll("left"); + } catch(e) { + return setTimeout( doScrollCheck, 50 ); + } + + // and execute any waiting functions + jQuery.ready(); + } + })(); + } + } + } + return readyList.promise( obj ); +}; + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); +// String to Object options format cache +var optionsCache = {}; + +// Convert String-formatted options into Object-formatted ones and store in cache +function createOptions( options ) { + var object = optionsCache[ options ] = {}; + jQuery.each( options.split( core_rspace ), function( _, flag ) { + object[ flag ] = true; + }); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + ( optionsCache[ options ] || createOptions( options ) ) : + jQuery.extend( {}, options ); + + var // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list was already fired + fired, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = !options.once && [], + // Fire callbacks + fire = function( data ) { + memory = options.memory && data; + fired = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + firing = true; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { + memory = false; // To prevent further calls using add + break; + } + } + firing = false; + if ( list ) { + if ( stack ) { + if ( stack.length ) { + fire( stack.shift() ); + } + } else if ( memory ) { + list = []; + } else { + self.disable(); + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + // First, we save the current length + var start = list.length; + (function add( args ) { + jQuery.each( args, function( _, arg ) { + var type = jQuery.type( arg ); + if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { + list.push( arg ); + } else if ( arg && arg.length && type !== "string" ) { + // Inspect recursively + add( arg ); + } + }); + })( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away + } else if ( memory ) { + firingStart = start; + fire( memory ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + jQuery.each( arguments, function( _, arg ) { + var index; + while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + // Handle firing indexes + if ( firing ) { + if ( index <= firingLength ) { + firingLength--; + } + if ( index <= firingIndex ) { + firingIndex--; + } + } + } + }); + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + return jQuery.inArray( fn, list ) > -1; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + if ( list && ( !fired || stack ) ) { + if ( firing ) { + stack.push( args ); + } else { + fire( args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; +jQuery.extend({ + + Deferred: function( func ) { + var tuples = [ + // action, add listener, listener list, final state + [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], + [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], + [ "notify", "progress", jQuery.Callbacks("memory") ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + then: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + return jQuery.Deferred(function( newDefer ) { + jQuery.each( tuples, function( i, tuple ) { + var action = tuple[ 0 ], + fn = fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer + deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? + function() { + var returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise() + .done( newDefer.resolve ) + .fail( newDefer.reject ) + .progress( newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + } : + newDefer[ action ] + ); + }); + fns = null; + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Keep pipe for back-compat + promise.pipe = promise.then; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 3 ]; + + // promise[ done | fail | progress ] = list.add + promise[ tuple[1] ] = list.add; + + // Handle state + if ( stateString ) { + list.add(function() { + // state = [ resolved | rejected ] + state = stateString; + + // [ reject_list | resolve_list ].disable; progress_list.lock + }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); + } + + // deferred[ resolve | reject | notify ] = list.fire + deferred[ tuple[0] ] = list.fire; + deferred[ tuple[0] + "With" ] = list.fireWith; + }); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( subordinate /* , ..., subordinateN */ ) { + var i = 0, + resolveValues = core_slice.call( arguments ), + length = resolveValues.length, + + // the count of uncompleted subordinates + remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, + + // the master Deferred. If resolveValues consist of only a single Deferred, just use that. + deferred = remaining === 1 ? subordinate : jQuery.Deferred(), + + // Update function for both resolve and progress values + updateFunc = function( i, contexts, values ) { + return function( value ) { + contexts[ i ] = this; + values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; + if( values === progressValues ) { + deferred.notifyWith( contexts, values ); + } else if ( !( --remaining ) ) { + deferred.resolveWith( contexts, values ); + } + }; + }, + + progressValues, progressContexts, resolveContexts; + + // add listeners to Deferred subordinates; treat others as resolved + if ( length > 1 ) { + progressValues = new Array( length ); + progressContexts = new Array( length ); + resolveContexts = new Array( length ); + for ( ; i < length; i++ ) { + if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { + resolveValues[ i ].promise() + .done( updateFunc( i, resolveContexts, resolveValues ) ) + .fail( deferred.reject ) + .progress( updateFunc( i, progressContexts, progressValues ) ); + } else { + --remaining; + } + } + } + + // if we're not waiting on anything, resolve the master + if ( !remaining ) { + deferred.resolveWith( resolveContexts, resolveValues ); + } + + return deferred.promise(); + } +}); +jQuery.support = (function() { + + var support, + all, + a, + select, + opt, + input, + fragment, + eventName, + i, + isSupported, + clickFn, + div = document.createElement("div"); + + // Preliminary tests + div.setAttribute( "className", "t" ); + div.innerHTML = "
a"; + + all = div.getElementsByTagName("*"); + a = div.getElementsByTagName("a")[ 0 ]; + a.style.cssText = "top:1px;float:left;opacity:.5"; + + // Can't get basic test support + if ( !all || !all.length ) { + return {}; + } + + // First batch of supports tests + select = document.createElement("select"); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName("input")[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute("href") === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.5/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Makes sure cloning an html5 element does not cause problems + // Where outerHTML is undefined, this still works + html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", + + // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode + boxModel: ( document.compatMode === "CSS1Compat" ), + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true, + boxSizingReliable: true, + pixelPosition: false + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", clickFn = function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent("onclick"); + div.detachEvent( "onclick", clickFn ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute( "type", "radio" ); + support.radioValue = input.value === "t"; + + input.setAttribute( "checked", "checked" ); + + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + fragment.removeChild( input ); + fragment.appendChild( div ); + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for ( i in { + submit: true, + change: true, + focusin: true + }) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + // Run tests that need a body at doc ready + jQuery(function() { + var container, div, tds, marginDiv, + divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", + body = document.getElementsByTagName("body")[0]; + + if ( !body ) { + // Return for frameset docs that don't have a body + return; + } + + container = document.createElement("div"); + container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; + body.insertBefore( container, body.firstChild ); + + // Construct the test element + div = document.createElement("div"); + container.appendChild( div ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + div.innerHTML = "
t
"; + tds = div.getElementsByTagName("td"); + tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE <= 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + + // Check box-sizing and margin behavior + div.innerHTML = ""; + div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; + support.boxSizing = ( div.offsetWidth === 4 ); + support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); + + // NOTE: To any future maintainer, we've window.getComputedStyle + // because jsdom on node.js will break without it. + if ( window.getComputedStyle ) { + support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; + support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + marginDiv = document.createElement("div"); + marginDiv.style.cssText = div.style.cssText = divReset; + marginDiv.style.marginRight = marginDiv.style.width = "0"; + div.style.width = "1px"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); + } + + if ( typeof div.style.zoom !== "undefined" ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.innerHTML = ""; + div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = "block"; + div.style.overflow = "visible"; + div.innerHTML = "
"; + div.firstChild.style.width = "5px"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); + + container.style.zoom = 1; + } + + // Null elements to avoid leaks in IE + body.removeChild( container ); + container = div = tds = marginDiv = null; + }); + + // Null elements to avoid leaks in IE + fragment.removeChild( div ); + all = a = select = opt = input = fragment = div = null; + + return support; +})(); +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + deletedIds: [], + + // Remove at next major release (1.9/2.0) + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++; + } else { + id = internalKey; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support array or space separated string names for data keys + if ( !jQuery.isArray( name ) ) { + + // try the string as a key before any manipulation + if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces unless a key with the spaces exists + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split(" "); + } + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject( cache[ id ] ) ) { + return; + } + } + + // Destroy the cache + if ( isNode ) { + jQuery.cleanData( [ elem ], true ); + + // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) + } else if ( jQuery.support.deleteExpando || cache != cache.window ) { + delete cache[ id ]; + + // When all else fails, null + } else { + cache[ id ] = null; + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; + + // nodes accept data unless otherwise specified; rejection can be conditional + return !noData || noData !== true && elem.getAttribute("classid") === noData; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var parts, part, attr, name, l, + elem = this[0], + i = 0, + data = null; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = jQuery.data( elem ); + + if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { + attr = elem.attributes; + for ( l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( !name.indexOf( "data-" ) ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( elem, name, data[ name ] ); + } + } + jQuery._data( elem, "parsedAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split( ".", 2 ); + parts[1] = parts[1] ? "." + parts[1] : ""; + part = parts[1] + "!"; + + return jQuery.access( this, function( value ) { + + if ( value === undefined ) { + data = this.triggerHandler( "getData" + part, [ parts[0] ] ); + + // Try to fetch any internally stored data first + if ( data === undefined && elem ) { + data = jQuery.data( elem, key ); + data = dataAttr( elem, key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + } + + parts[1] = value; + this.each(function() { + var self = jQuery( this ); + + self.triggerHandler( "setData" + part, parts ); + jQuery.data( this, key, value ); + self.triggerHandler( "changeData" + part, parts ); + }); + }, null, value, arguments.length > 1, null, false ); + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + // Only convert to a number if it doesn't change the string + +data + "" === data ? +data : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// checks a cache object for emptiness +function isEmptyDataObject( obj ) { + var name; + for ( name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} +jQuery.extend({ + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || jQuery.isArray(data) ) { + queue = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // not intended for public consumption - generates a queueHooks object, or returns the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return jQuery._data( elem, key ) || jQuery._data( elem, key, { + empty: jQuery.Callbacks("once memory").add(function() { + jQuery.removeData( elem, type + "queue", true ); + jQuery.removeData( elem, key, true ); + }) + }); + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[0], type ); + } + + return data === undefined ? + this : + this.each(function() { + var queue = jQuery.queue( this, type, data ); + + // ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while( i-- ) { + tmp = jQuery._data( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +}); +var nodeHook, boolHook, fixSpecified, + rclass = /[\t\r\n]/g, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea|)$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( core_rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var removes, className, elem, c, cl, i, l; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + if ( (value && typeof value === "string") || value === undefined ) { + removes = ( value || "" ).split( core_rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + if ( elem.nodeType === 1 && elem.className ) { + + className = (" " + elem.className + " ").replace( rclass, " " ); + + // loop over each item in the removal list + for ( c = 0, cl = removes.length; c < cl; c++ ) { + // Remove until there is nothing to remove, + while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) { + className = className.replace( " " + removes[ c ] + " " , " " ); + } + } + elem.className = value ? jQuery.trim( className ) : ""; + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( core_rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space separated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var val, + self = jQuery(this); + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 + attrFn: {}, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, value + "" ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, isBool, + i = 0; + + if ( value && elem.nodeType === 1 ) { + + attrNames = value.split( core_rspace ); + + for ( ; i < attrNames.length; i++ ) { + name = attrNames[ i ]; + + if ( name ) { + propName = jQuery.propFix[ name ] || name; + isBool = rboolean.test( name ); + + // See #9699 for explanation of this approach (setting first, then removal) + // Do not do this for boolean attributes (see #10870) + if ( !isBool ) { + jQuery.attr( elem, name, "" ); + } + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( isBool && propName in elem ) { + elem[ propName ] = false; + } + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true, + coords: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ? + ret.value : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.value = value + "" ); + } + }; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = value + "" ); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// IE6/7 call enctype encoding +if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); +}); +var rformElems = /^(?:textarea|input|select)$/i, + rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, + rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = jQuery.trim( hoverHack(types) ).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join(".") + }, handleObjIn ); + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var t, tns, type, origType, namespaces, origCount, + j, events, special, eventType, handleObj, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ); + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = jQuery.trim( hoverHack( types || "" ) ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = origType = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; + + // Remove matching events + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !namespaces || namespaces.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + delete elemData.handle; + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, "events", true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType, + type = event.type || event, + namespaces = []; + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; + for ( old = elem; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old === (elem.ownerDocument || document) ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + // Note that this is a bare JS function and not a jQuery handler + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { + event.preventDefault(); + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related, + handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = core_slice.call( arguments ), + run_all = !event.exclusive && !event.namespace, + special = jQuery.event.special[ event.type ] || {}, + handlerQueue = []; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers that should run if there are delegated events + // Avoid non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !(event.button && event.type === "click") ) { + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + + // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.disabled !== true || event.type !== "click" ) { + selMatch = {}; + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + + if ( selMatch[ sel ] === undefined ) { + selMatch[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) >= 0 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( selMatch[ sel ] ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) + .apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) + event.metaKey = !!event.metaKey; + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } +}; + +// Some plugins are using, but it's undocumented/deprecated and will be removed. +// The 1.7 special event interface should provide all the hooks needed now. +jQuery.event.handle = jQuery.event.dispatch; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + var name = "on" + type; + + if ( elem.detachEvent ) { + + // #8545, #7054, preventing memory leaks for custom events in IE6-8 – + // detachEvent needed property on element, by name of that event, to properly expose it to GC + if ( typeof elem[ name ] === "undefined" ) { + elem[ name ] = null; + } + + elem.detachEvent( name, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Create mouseenter/leave events using mouseover/out and event-time checks +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector; + + // For mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || (related !== target && !jQuery.contains( target, related )) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +}); + +// IE submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !jQuery._data( form, "_submit_attached" ) ) { + jQuery.event.add( form, "submit._submit", function( event ) { + event._submit_bubble = true; + }); + jQuery._data( form, "_submit_attached", true ); + } + }); + // return undefined since we don't need an event listener + }, + + postDispatch: function( event ) { + // If form was submitted by the user, bubble the event up the tree + if ( event._submit_bubble ) { + delete event._submit_bubble; + if ( this.parentNode && !event.isTrigger ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + } + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; +} + +// IE change delegation and checkbox/radio fix +if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed && !event.isTrigger ) { + this._just_changed = false; + } + // Allow triggered, simulated change events (#11500) + jQuery.event.simulate( "change", this, event, true ); + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + jQuery._data( elem, "_change_attached", true ); + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return !rformElems.test( this.nodeName ); + } + }; +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); +} + +jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { // && selector != null + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on( types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.on( name, null, data, fn ) : + this.trigger( name ); + }; + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } +}); +/*! + * Sizzle CSS Selector Engine + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license + * http://sizzlejs.com/ + */ +(function( window, undefined ) { + +var cachedruns, + assertGetIdNotName, + Expr, + getText, + isXML, + contains, + compile, + sortOrder, + hasDuplicate, + outermostContext, + + baseHasDuplicate = true, + strundefined = "undefined", + + expando = ( "sizcache" + Math.random() ).replace( ".", "" ), + + Token = String, + document = window.document, + docElem = document.documentElement, + dirruns = 0, + done = 0, + pop = [].pop, + push = [].push, + slice = [].slice, + // Use a stripped-down indexOf if a native one is unavailable + indexOf = [].indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, + + // Augment a function for special use by Sizzle + markFunction = function( fn, value ) { + fn[ expando ] = value == null || value; + return fn; + }, + + createCache = function() { + var cache = {}, + keys = []; + + return markFunction(function( key, value ) { + // Only keep the most recent entries + if ( keys.push( key ) > Expr.cacheLength ) { + delete cache[ keys.shift() ]; + } + + return (cache[ key ] = value); + }, cache ); + }, + + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + + // Regex + + // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + // http://www.w3.org/TR/css3-syntax/#characters + characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", + + // Loosely modeled on CSS identifier characters + // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors) + // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + identifier = characterEncoding.replace( "w", "w#" ), + + // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + operators = "([*^$|!~]?=)", + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", + + // Prefer arguments not in parens/brackets, + // then attribute selectors and non-pseudos (denoted by :), + // then anything else + // These preferences are here to reduce the number of selectors + // needing tokenize in the PSEUDO preFilter + pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)", + + // For matchExpr.POS and matchExpr.needsContext + pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), + rpseudo = new RegExp( pseudos ), + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, + + rnot = /^:not/, + rsibling = /[\x20\t\r\n\f]*[+~]/, + rendsWithNot = /:not\($/, + + rheader = /h\d/i, + rinputs = /input|select|textarea|button/i, + + rbackslash = /\\(?!\\)/g, + + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "POS": new RegExp( pos, "i" ), + "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + // For use in libraries implementing .is() + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" ) + }, + + // Support + + // Used for testing something on an element + assert = function( fn ) { + var div = document.createElement("div"); + + try { + return fn( div ); + } catch (e) { + return false; + } finally { + // release memory in IE + div = null; + } + }, + + // Check if getElementsByTagName("*") returns only elements + assertTagNameNoComments = assert(function( div ) { + div.appendChild( document.createComment("") ); + return !div.getElementsByTagName("*").length; + }), + + // Check if getAttribute returns normalized href attributes + assertHrefNotNormalized = assert(function( div ) { + div.innerHTML = ""; + return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && + div.firstChild.getAttribute("href") === "#"; + }), + + // Check if attributes should be retrieved by attribute nodes + assertAttributes = assert(function( div ) { + div.innerHTML = ""; + var type = typeof div.lastChild.getAttribute("multiple"); + // IE8 returns a string for some attributes even when not present + return type !== "boolean" && type !== "string"; + }), + + // Check if getElementsByClassName can be trusted + assertUsableClassName = assert(function( div ) { + // Opera can't find a second classname (in 9.6) + div.innerHTML = ""; + if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { + return false; + } + + // Safari 3.2 caches class attributes and doesn't catch changes + div.lastChild.className = "e"; + return div.getElementsByClassName("e").length === 2; + }), + + // Check if getElementById returns elements by name + // Check if getElementsByName privileges form controls or returns elements by ID + assertUsableName = assert(function( div ) { + // Inject content + div.id = expando + 0; + div.innerHTML = "
"; + docElem.insertBefore( div, docElem.firstChild ); + + // Test + var pass = document.getElementsByName && + // buggy browsers will return fewer than the correct 2 + document.getElementsByName( expando ).length === 2 + + // buggy browsers will return more than the correct 0 + document.getElementsByName( expando + 0 ).length; + assertGetIdNotName = !document.getElementById( expando ); + + // Cleanup + docElem.removeChild( div ); + + return pass; + }); + +// If slice is not available, provide a backup +try { + slice.call( docElem.childNodes, 0 )[0].nodeType; +} catch ( e ) { + slice = function( i ) { + var elem, + results = []; + for ( ; (elem = this[i]); i++ ) { + results.push( elem ); + } + return results; + }; +} + +function Sizzle( selector, context, results, seed ) { + results = results || []; + context = context || document; + var match, elem, xml, m, + nodeType = context.nodeType; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( nodeType !== 1 && nodeType !== 9 ) { + return []; + } + + xml = isXML( context ); + + if ( !xml && !seed ) { + if ( (match = rquickExpr.exec( selector )) ) { + // Speed-up: Sizzle("#ID") + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE, Opera, and Webkit return items + // by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + } else { + // Context is not a document + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } + } + + // Speed-up: Sizzle("TAG") + } else if ( match[2] ) { + push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); + return results; + + // Speed-up: Sizzle(".CLASS") + } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) { + push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); + return results; + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed, xml ); +} + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + return Sizzle( expr, null, null, [ elem ] ).length > 0; +}; + +// Returns a function to use in pseudos for input types +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +// Returns a function to use in pseudos for buttons +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} + +// Returns a function to use in pseudos for positionals +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( nodeType ) { + if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements + // innerText usage removed for consistency of new lines (see #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + // Do not include comment or processing instruction nodes + } else { + + // If no nodeType, this is expected to be an array + for ( ; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + ret += getText( node ); + } + } + return ret; +}; + +isXML = Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +// Element contains another +contains = Sizzle.contains = docElem.contains ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) ); + } : + docElem.compareDocumentPosition ? + function( a, b ) { + return b && !!( a.compareDocumentPosition( b ) & 16 ); + } : + function( a, b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; + } + } + return false; + }; + +Sizzle.attr = function( elem, name ) { + var val, + xml = isXML( elem ); + + if ( !xml ) { + name = name.toLowerCase(); + } + if ( (val = Expr.attrHandle[ name ]) ) { + return val( elem ); + } + if ( xml || assertAttributes ) { + return elem.getAttribute( name ); + } + val = elem.getAttributeNode( name ); + return val ? + typeof elem[ name ] === "boolean" ? + elem[ name ] ? name : null : + val.specified ? val.value : null : + null; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + // IE6/7 return a modified href + attrHandle: assertHrefNotNormalized ? + {} : + { + "href": function( elem ) { + return elem.getAttribute( "href", 2 ); + }, + "type": function( elem ) { + return elem.getAttribute("type"); + } + }, + + find: { + "ID": assertGetIdNotName ? + function( id, context, xml ) { + if ( typeof context.getElementById !== strundefined && !xml ) { + var m = context.getElementById( id ); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + } : + function( id, context, xml ) { + if ( typeof context.getElementById !== strundefined && !xml ) { + var m = context.getElementById( id ); + + return m ? + m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? + [m] : + undefined : + []; + } + }, + + "TAG": assertTagNameNoComments ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); + } + } : + function( tag, context ) { + var results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + var elem, + tmp = [], + i = 0; + + for ( ; (elem = results[i]); i++ ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }, + + "NAME": assertUsableName && function( tag, context ) { + if ( typeof context.getElementsByName !== strundefined ) { + return context.getElementsByName( name ); + } + }, + + "CLASS": assertUsableClassName && function( className, context, xml ) { + if ( typeof context.getElementsByClassName !== strundefined && !xml ) { + return context.getElementsByClassName( className ); + } + } + }, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( rbackslash, "" ); + + // Move the given value to match[3] whether quoted or unquoted + match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" ); + + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 3 xn-component of xn+y argument ([+-]?\d*n|) + 4 sign of xn-component + 5 x of xn-component + 6 sign of y-component + 7 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1] === "nth" ) { + // nth-child requires argument + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) ); + match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" ); + + // other types prohibit arguments + } else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var unquoted, excess; + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } + + if ( match[3] ) { + match[2] = match[3]; + } else if ( (unquoted = match[4]) ) { + // Only check arguments that contain a pseudo + if ( rpseudo.test(unquoted) && + // Get excess from tokenize (recursively) + (excess = tokenize( unquoted, true )) && + // advance to the next closing parenthesis + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + + // excess is a negative index + unquoted = unquoted.slice( 0, excess ); + match[0] = match[0].slice( 0, excess ); + } + match[2] = unquoted; + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + "ID": assertGetIdNotName ? + function( id ) { + id = id.replace( rbackslash, "" ); + return function( elem ) { + return elem.getAttribute("id") === id; + }; + } : + function( id ) { + id = id.replace( rbackslash, "" ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === id; + }; + }, + + "TAG": function( nodeName ) { + if ( nodeName === "*" ) { + return function() { return true; }; + } + nodeName = nodeName.replace( rbackslash, "" ).toLowerCase(); + + return function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ expando ][ className ]; + if ( !pattern ) { + pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") ); + } + return function( elem ) { + return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); + }; + }, + + "ATTR": function( name, operator, check ) { + return function( elem, context ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.substr( result.length - check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" : + false; + }; + }, + + "CHILD": function( type, argument, first, last ) { + + if ( type === "nth" ) { + return function( elem ) { + var node, diff, + parent = elem.parentNode; + + if ( first === 1 && last === 0 ) { + return true; + } + + if ( parent ) { + diff = 0; + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + diff++; + if ( elem === node ) { + break; + } + } + } + } + + // Incorporate the offset (or cast to NaN), then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + }; + } + + return function( elem ) { + var node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + /* falls through */ + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + "not": markFunction(function( selector ) { + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } + } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + "enabled": function( elem ) { + return elem.disabled === false; + }, + + "disabled": function( elem ) { + return elem.disabled === true; + }, + + "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, + + "selected": function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, + + "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), + // not comment, processing instructions, or others + // Thanks to Diego Perini for the nodeName shortcut + // Greater than "@" means alpha characters (specifically not starting with "#" or "?") + var nodeType; + elem = elem.firstChild; + while ( elem ) { + if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) { + return false; + } + elem = elem.nextSibling; + } + return true; + }, + + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "text": function( elem ) { + var type, attr; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && + (type = elem.type) === "text" && + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type ); + }, + + // Input types + "radio": createInputPseudo("radio"), + "checkbox": createInputPseudo("checkbox"), + "file": createInputPseudo("file"), + "password": createInputPseudo("password"), + "image": createInputPseudo("image"), + + "submit": createButtonPseudo("submit"), + "reset": createButtonPseudo("reset"), + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "focus": function( elem ) { + var doc = elem.ownerDocument; + return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href); + }, + + "active": function( elem ) { + return elem === elem.ownerDocument.activeElement; + }, + + // Positional types + "first": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ 0 ]; + }), + + "last": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ length - 1 ]; + }), + + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), + + "even": createPositionalPseudo(function( matchIndexes, length, argument ) { + for ( var i = 0; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "odd": createPositionalPseudo(function( matchIndexes, length, argument ) { + for ( var i = 1; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), + + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; + +function siblingCheck( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; +} + +sortOrder = docElem.compareDocumentPosition ? + function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + return ( !a.compareDocumentPosition || !b.compareDocumentPosition ? + a.compareDocumentPosition : + a.compareDocumentPosition(b) & 4 + ) ? -1 : 1; + } : + function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + +// Always assume the presence of duplicates if sort doesn't +// pass them to our comparison function (as in Google Chrome). +[0, 0].sort( sortOrder ); +baseHasDuplicate = !hasDuplicate; + +// Document sorting and removing duplicates +Sizzle.uniqueSort = function( results ) { + var elem, + i = 1; + + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( ; (elem = results[i]); i++ ) { + if ( elem === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + + return results; +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, soFar, groups, preFilters, + cached = tokenCache[ expando ][ selector ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + soFar = soFar.slice( match[0].length ); + } + groups.push( tokens = [] ); + } + + matched = false; + + // Combinators + if ( (match = rcombinators.exec( soFar )) ) { + tokens.push( matched = new Token( match.shift() ) ); + soFar = soFar.slice( matched.length ); + + // Cast descendant combinators to space + matched.type = match[0].replace( rtrim, " " ); + } + + // Filters + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + // The last two arguments here are (context, xml) for backCompat + (match = preFilters[ type ]( match, document, true ))) ) { + + tokens.push( matched = new Token( match.shift() ) ); + soFar = soFar.slice( matched.length ); + matched.type = type; + matched.matches = match; + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && combinator.dir === "parentNode", + doneName = done++; + + return combinator.first ? + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( checkNonElements || elem.nodeType === 1 ) { + return matcher( elem, context, xml ); + } + } + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching + if ( !xml ) { + var cache, + dirkey = dirruns + " " + doneName + " ", + cachedkey = dirkey + cachedruns; + while ( (elem = elem[ dir ]) ) { + if ( checkNonElements || elem.nodeType === 1 ) { + if ( (cache = elem[ expando ]) === cachedkey ) { + return elem.sizset; + } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) { + if ( elem.sizset ) { + return elem; + } + } else { + elem[ expando ] = cachedkey; + if ( matcher( elem, context, xml ) ) { + elem.sizset = true; + return elem; + } + elem.sizset = false; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( checkNonElements || elem.nodeType === 1 ) { + if ( matcher( elem, context, xml ) ) { + return elem; + } + } + } + } + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones + if ( seed && postFinder ) { + return; + } + + var i, elem, postFilterIn, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + postFilterIn = condense( matcherOut, postMap ); + postFilter( postFilterIn, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = postFilterIn.length; + while ( i-- ) { + if ( (elem = postFilterIn[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + } + } + } + + // Keep seed and results synchronized + if ( seed ) { + // Ignore postFinder because it can't coexist with seed + i = preFilter && matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + seed[ preMap[i] ] = !(results[ preMap[i] ] = elem); + } + } + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; + } else { + // The concatenated values are (context, xml) for backCompat + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && tokens.join("") + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, expandContext ) { + var elem, j, matcher, + setMatched = [], + matchedCount = 0, + i = "0", + unmatched = seed && [], + outermost = expandContext != null, + contextBackup = outermostContext, + // We must always have either seed elements or context + elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), + // Nested matchers should use non-integer dirruns + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E); + + if ( outermost ) { + outermostContext = context !== document && context; + cachedruns = superMatcher.el; + } + + // Add elements passing elementMatchers directly to results + for ( ; (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + for ( j = 0; (matcher = elementMatchers[j]); j++ ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + cachedruns = ++superMatcher.el; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + // They will have gone through all possible matchers + if ( (elem = !matcher && elem) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // Apply set filters to unmatched elements + matchedCount += i; + if ( bySet && i !== matchedCount ) { + for ( j = 0; (matcher = setMatchers[j]); j++ ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + superMatcher.el = 0; + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ expando ][ selector ]; + + if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element + if ( !group ) { + group = tokenize( selector ); + } + i = group.length; + while ( i-- ) { + cached = matcherFromTokens( group[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + } + return cached; +}; + +function multipleContexts( selector, contexts, results, seed ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results, seed ); + } + return results; +} + +function select( selector, context, results, seed, xml ) { + var i, tokens, token, type, find, + match = tokenize( selector ), + j = match.length; + + if ( !seed ) { + // Try to minimize operations if there is only one group + if ( match.length === 1 ) { + + // Take a shortcut and set the context if the root selector is an ID + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + context.nodeType === 9 && !xml && + Expr.relative[ tokens[1].type ] ) { + + context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0]; + if ( !context ) { + return results; + } + + selector = selector.slice( tokens.shift().length ); + } + + // Fetch a seed set for right-to-left matching + for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) { + token = tokens[i]; + + // Abort if we hit a combinator + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + // Search, expanding context for leading sibling combinators + if ( (seed = find( + token.matches[0].replace( rbackslash, "" ), + rsibling.test( tokens[0].type ) && context.parentNode || context, + xml + )) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && tokens.join(""); + if ( !selector ) { + push.apply( results, slice.call( seed, 0 ) ); + return results; + } + + break; + } + } + } + } + } + + // Compile and execute a filtering function + // Provide `match` to avoid retokenization if we modified the selector above + compile( selector, match )( + seed, + context, + xml, + results, + rsibling.test( selector ) + ); + return results; +} + +if ( document.querySelectorAll ) { + (function() { + var disconnectedMatch, + oldSelect = select, + rescape = /'|\\/g, + rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, + + // qSa(:focus) reports false when true (Chrome 21), + // A support test would require too much code (would include document ready) + rbuggyQSA = [":focus"], + + // matchesSelector(:focus) reports false when true (Chrome 21), + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + // A support test would require too much code (would include document ready) + // just skip matchesSelector for :active + rbuggyMatches = [ ":active", ":focus" ], + matches = docElem.matchesSelector || + docElem.mozMatchesSelector || + docElem.webkitMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector; + + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert(function( div ) { + // Select is set to empty string on purpose + // This is to test IE's treatment of not explictly + // setting a boolean content attribute, + // since its presence should be enough + // http://bugs.jquery.com/ticket/12359 + div.innerHTML = ""; + + // IE8 - Some boolean attributes are not treated correctly + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here (do not put tests after this one) + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); + } + }); + + assert(function( div ) { + + // Opera 10-12/IE9 - ^= $= *= and empty values + // Should not select anything + div.innerHTML = "

"; + if ( div.querySelectorAll("[test^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here (do not put tests after this one) + div.innerHTML = ""; + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push(":enabled", ":disabled"); + } + }); + + // rbuggyQSA always contains :focus, so no need for a length check + rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") ); + + select = function( selector, context, results, seed, xml ) { + // Only use querySelectorAll when not filtering, + // when this is not xml, + // and when no QSA bugs apply + if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + var groups, i, + old = true, + nid = expando, + newContext = context, + newSelector = context.nodeType === 9 && selector; + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); + + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; + + i = groups.length; + while ( i-- ) { + groups[i] = nid + groups[i].join(""); + } + newContext = rsibling.test( selector ) && context.parentNode || context; + newSelector = groups.join(","); + } + + if ( newSelector ) { + try { + push.apply( results, slice.call( newContext.querySelectorAll( + newSelector + ), 0 ) ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } + } + } + } + + return oldSelect( selector, context, results, seed, xml ); + }; + + if ( matches ) { + assert(function( div ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + disconnectedMatch = matches.call( div, "div" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + try { + matches.call( div, "[test!='']:sizzle" ); + rbuggyMatches.push( "!=", pseudos ); + } catch ( e ) {} + }); + + // rbuggyMatches always contains :active and :focus, so no need for a length check + rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") ); + + Sizzle.matchesSelector = function( elem, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace( rattributeQuotes, "='$1']" ); + + // rbuggyMatches always contains :active, so no need for an existence check + if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) { + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch(e) {} + } + + return Sizzle( expr, null, null, [ elem ] ).length > 0; + }; + } + })(); +} + +// Deprecated +Expr.pseudos["nth"] = Expr.pseudos["eq"]; + +// Back-compat +function setFilters() {} +Expr.filters = setFilters.prototype = Expr.pseudos; +Expr.setFilters = new setFilters(); + +// Override sizzle attribute retrieval +Sizzle.attr = jQuery.attr; +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.pseudos; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})( window ); +var runtil = /Until$/, + rparentsprev = /^(?:parents|prev(?:Until|All))/, + isSimple = /^.[^:#\[\.,]*$/, + rneedsContext = jQuery.expr.match.needsContext, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var i, l, length, n, r, ret, + self = this; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + ret = this.pushStack( "", "find", selector ); + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var i, + targets = jQuery( target, this ), + len = targets.length; + + return this.filter(function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + rneedsContext.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + ret = [], + pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( ; i < l; i++ ) { + cur = this[i]; + + while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + } + cur = cur.parentNode; + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter(selector) + ); + } +}); + +jQuery.fn.andSelf = jQuery.fn.addBack; + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +function sibling( cur, dir ) { + do { + cur = cur[ dir ]; + } while ( cur && cur.nodeType !== 1 ); + + return cur; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( this.length > 1 && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, core_slice.call( arguments ).join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); +} +function createSafeFragment( document ) { + var list = nodeNames.split( "|" ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; +} + +var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + rtagName = /<([\w:]+)/, + rtbody = /]", "i"), + rcheckableType = /^(?:checkbox|radio)$/, + // checked="checked" or checked + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, + rscriptType = /\/(java|ecma)script/i, + rcleanScript = /^\s*\s*$/g, + wrapMap = { + option: [ 1, "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ), + fragmentDiv = safeFragment.appendChild( document.createElement("div") ); + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, +// unless wrapped in a div with non-breaking characters in front of it. +if ( !jQuery.support.htmlSerialize ) { + wrapMap._default = [ 1, "X
", "
" ]; +} + +jQuery.fn.extend({ + text: function( value ) { + return jQuery.access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); + }, null, value, arguments.length ); + }, + + wrapAll: function( html ) { + if ( jQuery.isFunction( html ) ) { + return this.each(function(i) { + jQuery(this).wrapAll( html.call(this, i) ); + }); + } + + if ( this[0] ) { + // The elements to wrap the target around + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); + + if ( this[0].parentNode ) { + wrap.insertBefore( this[0] ); + } + + wrap.map(function() { + var elem = this; + + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { + elem = elem.firstChild; + } + + return elem; + }).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( jQuery.isFunction( html ) ) { + return this.each(function(i) { + jQuery(this).wrapInner( html.call(this, i) ); + }); + } + + return this.each(function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + }); + }, + + wrap: function( html ) { + var isFunction = jQuery.isFunction( html ); + + return this.each(function(i) { + jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); + }); + }, + + unwrap: function() { + return this.parent().each(function() { + if ( !jQuery.nodeName( this, "body" ) ) { + jQuery( this ).replaceWith( this.childNodes ); + } + }).end(); + }, + + append: function() { + return this.domManip(arguments, true, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 ) { + this.appendChild( elem ); + } + }); + }, + + prepend: function() { + return this.domManip(arguments, true, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 ) { + this.insertBefore( elem, this.firstChild ); + } + }); + }, + + before: function() { + if ( !isDisconnected( this[0] ) ) { + return this.domManip(arguments, false, function( elem ) { + this.parentNode.insertBefore( elem, this ); + }); + } + + if ( arguments.length ) { + var set = jQuery.clean( arguments ); + return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); + } + }, + + after: function() { + if ( !isDisconnected( this[0] ) ) { + return this.domManip(arguments, false, function( elem ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + }); + } + + if ( arguments.length ) { + var set = jQuery.clean( arguments ); + return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); + } + }, + + // keepData is for internal use only--do not document + remove: function( selector, keepData ) { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { + if ( !keepData && elem.nodeType === 1 ) { + jQuery.cleanData( elem.getElementsByTagName("*") ); + jQuery.cleanData( [ elem ] ); + } + + if ( elem.parentNode ) { + elem.parentNode.removeChild( elem ); + } + } + } + + return this; + }, + + empty: function() { + var elem, + i = 0; + + for ( ; (elem = this[i]) != null; i++ ) { + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( elem.getElementsByTagName("*") ); + } + + // Remove any remaining nodes + while ( elem.firstChild ) { + elem.removeChild( elem.firstChild ); + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function () { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + }); + }, + + html: function( value ) { + return jQuery.access( this, function( value ) { + var elem = this[0] || {}, + i = 0, + l = this.length; + + if ( value === undefined ) { + return elem.nodeType === 1 ? + elem.innerHTML.replace( rinlinejQuery, "" ) : + undefined; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && + ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && + !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { + + value = value.replace( rxhtmlTag, "<$1>" ); + + try { + for (; i < l; i++ ) { + // Remove element nodes and prevent memory leaks + elem = this[i] || {}; + if ( elem.nodeType === 1 ) { + jQuery.cleanData( elem.getElementsByTagName( "*" ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch(e) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function( value ) { + if ( !isDisconnected( this[0] ) ) { + // Make sure that the elements are removed from the DOM before they are inserted + // this can help fix replacing a parent with child elements + if ( jQuery.isFunction( value ) ) { + return this.each(function(i) { + var self = jQuery(this), old = self.html(); + self.replaceWith( value.call( this, i, old ) ); + }); + } + + if ( typeof value !== "string" ) { + value = jQuery( value ).detach(); + } + + return this.each(function() { + var next = this.nextSibling, + parent = this.parentNode; + + jQuery( this ).remove(); + + if ( next ) { + jQuery(next).before( value ); + } else { + jQuery(parent).append( value ); + } + }); + } + + return this.length ? + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : + this; + }, + + detach: function( selector ) { + return this.remove( selector, true ); + }, + + domManip: function( args, table, callback ) { + + // Flatten any nested arrays + args = [].concat.apply( [], args ); + + var results, first, fragment, iNoClone, + i = 0, + value = args[0], + scripts = [], + l = this.length; + + // We can't cloneNode fragments that contain checked, in WebKit + if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) { + return this.each(function() { + jQuery(this).domManip( args, table, callback ); + }); + } + + if ( jQuery.isFunction(value) ) { + return this.each(function(i) { + var self = jQuery(this); + args[0] = value.call( this, i, table ? self.html() : undefined ); + self.domManip( args, table, callback ); + }); + } + + if ( this[0] ) { + results = jQuery.buildFragment( args, this, scripts ); + fragment = results.fragment; + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + if ( first ) { + table = table && jQuery.nodeName( first, "tr" ); + + // Use the original fragment for the last item instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + // Fragments from the fragment cache must always be cloned and never used in place. + for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) { + callback.call( + table && jQuery.nodeName( this[i], "table" ) ? + findOrAppend( this[i], "tbody" ) : + this[i], + i === iNoClone ? + fragment : + jQuery.clone( fragment, true, true ) + ); + } + } + + // Fix #11809: Avoid leaking memory + fragment = first = null; + + if ( scripts.length ) { + jQuery.each( scripts, function( i, elem ) { + if ( elem.src ) { + if ( jQuery.ajax ) { + jQuery.ajax({ + url: elem.src, + type: "GET", + dataType: "script", + async: false, + global: false, + "throws": true + }); + } else { + jQuery.error("no ajax"); + } + } else { + jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) ); + } + + if ( elem.parentNode ) { + elem.parentNode.removeChild( elem ); + } + }); + } + } + + return this; + } +}); + +function findOrAppend( elem, tag ) { + return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); +} + +function cloneCopyEvent( src, dest ) { + + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { + return; + } + + var type, i, l, + oldData = jQuery._data( src ), + curData = jQuery._data( dest, oldData ), + events = oldData.events; + + if ( events ) { + delete curData.handle; + curData.events = {}; + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + + // make the cloned public data object a copy from the original + if ( curData.data ) { + curData.data = jQuery.extend( {}, curData.data ); + } +} + +function cloneFixAttributes( src, dest ) { + var nodeName; + + // We do not need to do anything for non-Elements + if ( dest.nodeType !== 1 ) { + return; + } + + // clearAttributes removes the attributes, which we don't want, + // but also removes the attachEvent events, which we *do* want + if ( dest.clearAttributes ) { + dest.clearAttributes(); + } + + // mergeAttributes, in contrast, only merges back on the + // original attributes, not the events + if ( dest.mergeAttributes ) { + dest.mergeAttributes( src ); + } + + nodeName = dest.nodeName.toLowerCase(); + + if ( nodeName === "object" ) { + // IE6-10 improperly clones children of object elements using classid. + // IE10 throws NoModificationAllowedError if parent is null, #12132. + if ( dest.parentNode ) { + dest.outerHTML = src.outerHTML; + } + + // This path appears unavoidable for IE9. When cloning an object + // element in IE9, the outerHTML strategy above is not sufficient. + // If the src has innerHTML and the destination does not, + // copy the src.innerHTML into the dest.innerHTML. #10324 + if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) { + dest.innerHTML = src.innerHTML; + } + + } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + // IE6-8 fails to persist the checked state of a cloned checkbox + // or radio button. Worse, IE6-7 fail to give the cloned element + // a checked appearance if the defaultChecked value isn't also set + + dest.defaultChecked = dest.checked = src.checked; + + // IE6-7 get confused and end up setting the value of a cloned + // checkbox/radio button to an empty string instead of "on" + if ( dest.value !== src.value ) { + dest.value = src.value; + } + + // IE6-8 fails to return the selected option to the default selected + // state when cloning options + } else if ( nodeName === "option" ) { + dest.selected = src.defaultSelected; + + // IE6-8 fails to set the defaultValue to the correct value when + // cloning other types of input fields + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + + // IE blanks contents when cloning scripts + } else if ( nodeName === "script" && dest.text !== src.text ) { + dest.text = src.text; + } + + // Event data gets referenced instead of copied if the expando + // gets copied too + dest.removeAttribute( jQuery.expando ); +} + +jQuery.buildFragment = function( args, context, scripts ) { + var fragment, cacheable, cachehit, + first = args[ 0 ]; + + // Set context from what may come in as undefined or a jQuery collection or a node + // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & + // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception + context = context || document; + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; + + // Only cache "small" (1/2 KB) HTML strings that are associated with the main document + // Cloning options loses the selected state, so don't cache them + // IE 6 doesn't like it when you put or elements in a fragment + // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache + // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 + if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document && + first.charAt(0) === "<" && !rnocache.test( first ) && + (jQuery.support.checkClone || !rchecked.test( first )) && + (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { + + // Mark cacheable and look for a hit + cacheable = true; + fragment = jQuery.fragments[ first ]; + cachehit = fragment !== undefined; + } + + if ( !fragment ) { + fragment = context.createDocumentFragment(); + jQuery.clean( args, context, fragment, scripts ); + + // Update the cache, but only store false + // unless this is a second parsing of the same content + if ( cacheable ) { + jQuery.fragments[ first ] = cachehit && fragment; + } + } + + return { fragment: fragment, cacheable: cacheable }; +}; + +jQuery.fragments = {}; + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + i = 0, + ret = [], + insert = jQuery( selector ), + l = insert.length, + parent = this.length === 1 && this[0].parentNode; + + if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) { + insert[ original ]( this[0] ); + return this; + } else { + for ( ; i < l; i++ ) { + elems = ( i > 0 ? this.clone(true) : this ).get(); + jQuery( insert[i] )[ original ]( elems ); + ret = ret.concat( elems ); + } + + return this.pushStack( ret, name, insert.selector ); + } + }; +}); + +function getAll( elem ) { + if ( typeof elem.getElementsByTagName !== "undefined" ) { + return elem.getElementsByTagName( "*" ); + + } else if ( typeof elem.querySelectorAll !== "undefined" ) { + return elem.querySelectorAll( "*" ); + + } else { + return []; + } +} + +// Used in clean, fixes the defaultChecked property +function fixDefaultChecked( elem ) { + if ( rcheckableType.test( elem.type ) ) { + elem.defaultChecked = elem.checked; + } +} + +jQuery.extend({ + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var srcElements, + destElements, + i, + clone; + + if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { + clone = elem.cloneNode( true ); + + // IE<=8 does not properly clone detached, unknown element nodes + } else { + fragmentDiv.innerHTML = elem.outerHTML; + fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); + } + + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { + // IE copies events bound via attachEvent when using cloneNode. + // Calling detachEvent on the clone will also remove the events + // from the original. In order to get around this, we use some + // proprietary methods to clear the events. Thanks to MooTools + // guys for this hotness. + + cloneFixAttributes( elem, clone ); + + // Using Sizzle here is crazy slow, so we use getElementsByTagName instead + srcElements = getAll( elem ); + destElements = getAll( clone ); + + // Weird iteration because IE will replace the length property + // with an element if you are cloning the body and one of the + // elements on the page has a name or id of "length" + for ( i = 0; srcElements[i]; ++i ) { + // Ensure that the destination node is not null; Fixes #9587 + if ( destElements[i] ) { + cloneFixAttributes( srcElements[i], destElements[i] ); + } + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + cloneCopyEvent( elem, clone ); + + if ( deepDataAndEvents ) { + srcElements = getAll( elem ); + destElements = getAll( clone ); + + for ( i = 0; srcElements[i]; ++i ) { + cloneCopyEvent( srcElements[i], destElements[i] ); + } + } + } + + srcElements = destElements = null; + + // Return the cloned set + return clone; + }, + + clean: function( elems, context, fragment, scripts ) { + var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags, + safe = context === document && safeFragment, + ret = []; + + // Ensure that context is a document + if ( !context || typeof context.createDocumentFragment === "undefined" ) { + context = document; + } + + // Use the already-created safe fragment if context permits + for ( i = 0; (elem = elems[i]) != null; i++ ) { + if ( typeof elem === "number" ) { + elem += ""; + } + + if ( !elem ) { + continue; + } + + // Convert html string into DOM nodes + if ( typeof elem === "string" ) { + if ( !rhtml.test( elem ) ) { + elem = context.createTextNode( elem ); + } else { + // Ensure a safe container in which to render the html + safe = safe || createSafeFragment( context ); + div = context.createElement("div"); + safe.appendChild( div ); + + // Fix "XHTML"-style tags in all browsers + elem = elem.replace(rxhtmlTag, "<$1>"); + + // Go to html and back, then peel off extra wrappers + tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + depth = wrap[0]; + div.innerHTML = wrap[1] + elem + wrap[2]; + + // Move to the right depth + while ( depth-- ) { + div = div.lastChild; + } + + // Remove IE's autoinserted from table fragments + if ( !jQuery.support.tbody ) { + + // String was a , *may* have spurious + hasBody = rtbody.test(elem); + tbody = tag === "table" && !hasBody ? + div.firstChild && div.firstChild.childNodes : + + // String was a bare or + wrap[1] === "
" && !hasBody ? + div.childNodes : + []; + + for ( j = tbody.length - 1; j >= 0 ; --j ) { + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { + tbody[ j ].parentNode.removeChild( tbody[ j ] ); + } + } + } + + // IE completely kills leading whitespace when innerHTML is used + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); + } + + elem = div.childNodes; + + // Take out of fragment container (we need a fresh div each time) + div.parentNode.removeChild( div ); + } + } + + if ( elem.nodeType ) { + ret.push( elem ); + } else { + jQuery.merge( ret, elem ); + } + } + + // Fix #11356: Clear elements from safeFragment + if ( div ) { + elem = div = safe = null; + } + + // Reset defaultChecked for any radios and checkboxes + // about to be appended to the DOM in IE 6/7 (#8060) + if ( !jQuery.support.appendChecked ) { + for ( i = 0; (elem = ret[i]) != null; i++ ) { + if ( jQuery.nodeName( elem, "input" ) ) { + fixDefaultChecked( elem ); + } else if ( typeof elem.getElementsByTagName !== "undefined" ) { + jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); + } + } + } + + // Append elements to a provided document fragment + if ( fragment ) { + // Special handling of each script element + handleScript = function( elem ) { + // Check if we consider it executable + if ( !elem.type || rscriptType.test( elem.type ) ) { + // Detach the script and store it in the scripts array (if provided) or the fragment + // Return truthy to indicate that it has been handled + return scripts ? + scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : + fragment.appendChild( elem ); + } + }; + + for ( i = 0; (elem = ret[i]) != null; i++ ) { + // Check if we're done after handling an executable script + if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { + // Append to fragment and handle embedded scripts + fragment.appendChild( elem ); + if ( typeof elem.getElementsByTagName !== "undefined" ) { + // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration + jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); + + // Splice the scripts into ret after their former ancestor and advance our index beyond them + ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); + i += jsTags.length; + } + } + } + } + + return ret; + }, + + cleanData: function( elems, /* internal */ acceptData ) { + var data, id, elem, type, + i = 0, + internalKey = jQuery.expando, + cache = jQuery.cache, + deleteExpando = jQuery.support.deleteExpando, + special = jQuery.event.special; + + for ( ; (elem = elems[i]) != null; i++ ) { + + if ( acceptData || jQuery.acceptData( elem ) ) { + + id = elem[ internalKey ]; + data = id && cache[ id ]; + + if ( data ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Remove cache only if it was not already removed by jQuery.event.remove + if ( cache[ id ] ) { + + delete cache[ id ]; + + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( deleteExpando ) { + delete elem[ internalKey ]; + + } else if ( elem.removeAttribute ) { + elem.removeAttribute( internalKey ); + + } else { + elem[ internalKey ] = null; + } + + jQuery.deletedIds.push( id ); + } + } + } + } + } +}); +// Limit scope pollution from any deprecated API +(function() { + +var matched, browser; + +// Use of jQuery.browser is frowned upon. +// More details: http://api.jquery.com/jQuery.browser +// jQuery.uaMatch maintained for back-compat +jQuery.uaMatch = function( ua ) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || + /(webkit)[ \/]([\w.]+)/.exec( ua ) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || + /(msie) ([\w.]+)/.exec( ua ) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || + []; + + return { + browser: match[ 1 ] || "", + version: match[ 2 ] || "0" + }; +}; + +matched = jQuery.uaMatch( navigator.userAgent ); +browser = {}; + +if ( matched.browser ) { + browser[ matched.browser ] = true; + browser.version = matched.version; +} + +// Chrome is Webkit, but Webkit is also Safari. +if ( browser.chrome ) { + browser.webkit = true; +} else if ( browser.webkit ) { + browser.safari = true; +} + +jQuery.browser = browser; + +jQuery.sub = function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; +}; + +})(); +var curCSS, iframe, iframeDoc, + ralpha = /alpha\([^)]*\)/i, + ropacity = /opacity=([^)]*)/, + rposition = /^(top|right|bottom|left)$/, + // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" + // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rmargin = /^margin/, + rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), + rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), + rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ), + elemdisplay = {}, + + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: 0, + fontWeight: 400 + }, + + cssExpand = [ "Top", "Right", "Bottom", "Left" ], + cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], + + eventsToggle = jQuery.fn.toggle; + +// return a css property mapped to a potentially vendor prefixed property +function vendorPropName( style, name ) { + + // shortcut for names that are not vendor prefixed + if ( name in style ) { + return name; + } + + // check for vendor prefixed names + var capName = name.charAt(0).toUpperCase() + name.slice(1), + origName = name, + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in style ) { + return name; + } + } + + return origName; +} + +function isHidden( elem, el ) { + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); +} + +function showHide( elements, show ) { + var elem, display, + values = [], + index = 0, + length = elements.length; + + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + values[ index ] = jQuery._data( elem, "olddisplay" ); + if ( show ) { + // Reset the inline display of this element to learn if it is + // being hidden by cascaded rules or not + if ( !values[ index ] && elem.style.display === "none" ) { + elem.style.display = ""; + } + + // Set elements which have been overridden with display: none + // in a stylesheet to whatever the default browser style is + // for such an element + if ( elem.style.display === "" && isHidden( elem ) ) { + values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); + } + } else { + display = curCSS( elem, "display" ); + + if ( !values[ index ] && display !== "none" ) { + jQuery._data( elem, "olddisplay", display ); + } + } + } + + // Set the display of most of the elements in a second loop + // to avoid the constant reflow + for ( index = 0; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + if ( !show || elem.style.display === "none" || elem.style.display === "" ) { + elem.style.display = show ? values[ index ] || "" : "none"; + } + } + + return elements; +} + +jQuery.fn.extend({ + css: function( name, value ) { + return jQuery.access( this, function( elem, name, value ) { + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + }, + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state, fn2 ) { + var bool = typeof state === "boolean"; + + if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { + return eventsToggle.apply( this, arguments ); + } + + return this.each(function() { + if ( bool ? state : isHidden( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + }); + } +}); + +jQuery.extend({ + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + + } + } + } + }, + + // Exclude the following css properties to add px + cssNumber: { + "fillOpacity": true, + "fontWeight": true, + "lineHeight": true, + "opacity": true, + "orphans": true, + "widows": true, + "zIndex": true, + "zoom": true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: { + // normalize float css property + "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" + }, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = jQuery.camelCase( name ), + style = elem.style; + + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // convert relative number strings (+= or -=) to relative numbers. #7345 + if ( type === "string" && (ret = rrelNum.exec( value )) ) { + value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); + // Fixes bug #9237 + type = "number"; + } + + // Make sure that NaN and null values aren't set. See: #7116 + if ( value == null || type === "number" && isNaN( value ) ) { + return; + } + + // If a number was passed in, add 'px' to the (except for certain CSS properties) + if ( type === "number" && !jQuery.cssNumber[ origName ] ) { + value += "px"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided + // Fixes bug #5509 + try { + style[ name ] = value; + } catch(e) {} + } + + } else { + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, numeric, extra ) { + var val, num, hooks, + origName = jQuery.camelCase( name ); + + // Make sure that we're working with the right name + name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); + + // gets hook for the prefixed version + // followed by the unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name ); + } + + //convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Return, converting to number if forced or a qualifier was provided and val looks numeric + if ( numeric || extra !== undefined ) { + num = parseFloat( val ); + return numeric || jQuery.isNumeric( num ) ? num || 0 : val; + } + return val; + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.call( elem ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; + } +}); + +// NOTE: To any future maintainer, we've window.getComputedStyle +// because jsdom on node.js will break without it. +if ( window.getComputedStyle ) { + curCSS = function( elem, name ) { + var ret, width, minWidth, maxWidth, + computed = window.getComputedStyle( elem, null ), + style = elem.style; + + if ( computed ) { + + ret = computed[ name ]; + if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right + // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels + // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret; + }; +} else if ( document.documentElement.currentStyle ) { + curCSS = function( elem, name ) { + var left, rsLeft, + ret = elem.currentStyle && elem.currentStyle[ name ], + style = elem.style; + + // Avoid setting ret to empty string here + // so we don't default to auto + if ( ret == null && style && style[ name ] ) { + ret = style[ name ]; + } + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + // but not position css attributes, as those are proportional to the parent element instead + // and we can't measure the parent instead because it might trigger a "stacking dolls" problem + if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { + + // Remember the original values + left = style.left; + rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; + + // Put in the new values to get a computed value out + if ( rsLeft ) { + elem.runtimeStyle.left = elem.currentStyle.left; + } + style.left = name === "fontSize" ? "1em" : ret; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + if ( rsLeft ) { + elem.runtimeStyle.left = rsLeft; + } + } + + return ret === "" ? "auto" : ret; + }; +} + +function setPositiveNumber( elem, value, subtract ) { + var matches = rnumsplit.exec( value ); + return matches ? + Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : + value; +} + +function augmentWidthOrHeight( elem, name, extra, isBorderBox ) { + var i = extra === ( isBorderBox ? "border" : "content" ) ? + // If we already have the right measurement, avoid augmentation + 4 : + // Otherwise initialize for horizontal or vertical properties + name === "width" ? 1 : 0, + + val = 0; + + for ( ; i < 4; i += 2 ) { + // both box models exclude margin, so add it if we want it + if ( extra === "margin" ) { + // we use jQuery.css instead of curCSS here + // because of the reliableMarginRight CSS hook! + val += jQuery.css( elem, extra + cssExpand[ i ], true ); + } + + // From this point on we use curCSS for maximum performance (relevant in animations) + if ( isBorderBox ) { + // border-box includes padding, so remove it if we want content + if ( extra === "content" ) { + val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; + } + + // at this point, extra isn't border nor margin, so remove border + if ( extra !== "margin" ) { + val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; + } + } else { + // at this point, extra isn't content, so add padding + val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; + + // at this point, extra isn't content nor padding, so add border + if ( extra !== "padding" ) { + val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; + } + } + } + + return val; +} + +function getWidthOrHeight( elem, name, extra ) { + + // Start with offset property, which is equivalent to the border-box value + var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, + valueIsBorderBox = true, + isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"; + + // some non-html elements return undefined for offsetWidth, so check for null/undefined + // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 + // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 + if ( val <= 0 || val == null ) { + // Fall back to computed then uncomputed css if necessary + val = curCSS( elem, name ); + if ( val < 0 || val == null ) { + val = elem.style[ name ]; + } + + // Computed unit is not pixels. Stop here and return. + if ( rnumnonpx.test(val) ) { + return val; + } + + // we need the check for style in case a browser which returns unreliable values + // for getComputedStyle silently falls back to the reliable elem.style + valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); + + // Normalize "", auto, and prepare for extra + val = parseFloat( val ) || 0; + } + + // use the active box-sizing model to add/subtract irrelevant styles + return ( val + + augmentWidthOrHeight( + elem, + name, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox + ) + ) + "px"; +} + + +// Try to determine the default display value of an element +function css_defaultDisplay( nodeName ) { + if ( elemdisplay[ nodeName ] ) { + return elemdisplay[ nodeName ]; + } + + var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ), + display = elem.css("display"); + elem.remove(); + + // If the simple way fails, + // get element's real default display by attaching it to a temp iframe + if ( display === "none" || display === "" ) { + // Use the already-created iframe if possible + iframe = document.body.appendChild( + iframe || jQuery.extend( document.createElement("iframe"), { + frameBorder: 0, + width: 0, + height: 0 + }) + ); + + // Create a cacheable copy of the iframe document on first call. + // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML + // document to it; WebKit & Firefox won't allow reusing the iframe document. + if ( !iframeDoc || !iframe.createElement ) { + iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; + iframeDoc.write(""); + iframeDoc.close(); + } + + elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) ); + + display = curCSS( elem, "display" ); + document.body.removeChild( iframe ); + } + + // Store the correct default display + elemdisplay[ nodeName ] = display; + + return display; +} + +jQuery.each([ "height", "width" ], function( i, name ) { + jQuery.cssHooks[ name ] = { + get: function( elem, computed, extra ) { + if ( computed ) { + // certain elements can have dimension info if we invisibly show them + // however, it must have a current display style that would benefit from this + if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { + return jQuery.swap( elem, cssShow, function() { + return getWidthOrHeight( elem, name, extra ); + }); + } else { + return getWidthOrHeight( elem, name, extra ); + } + } + }, + + set: function( elem, value, extra ) { + return setPositiveNumber( elem, value, extra ? + augmentWidthOrHeight( + elem, + name, + extra, + jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" + ) : 0 + ); + } + }; +}); + +if ( !jQuery.support.opacity ) { + jQuery.cssHooks.opacity = { + get: function( elem, computed ) { + // IE uses filters for opacity + return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? + ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : + computed ? "1" : ""; + }, + + set: function( elem, value ) { + var style = elem.style, + currentStyle = elem.currentStyle, + opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", + filter = currentStyle && currentStyle.filter || style.filter || ""; + + // IE has trouble with opacity if it does not have layout + // Force it by setting the zoom level + style.zoom = 1; + + // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 + if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && + style.removeAttribute ) { + + // Setting style.filter to null, "" & " " still leave "filter:" in the cssText + // if "filter:" is present at all, clearType is disabled, we want to avoid this + // style.removeAttribute is IE Only, but so apparently is this code path... + style.removeAttribute( "filter" ); + + // if there there is no filter style applied in a css rule, we are done + if ( currentStyle && !currentStyle.filter ) { + return; + } + } + + // otherwise, set new filter values + style.filter = ralpha.test( filter ) ? + filter.replace( ralpha, opacity ) : + filter + " " + opacity; + } + }; +} + +// These hooks cannot be added until DOM ready because the support test +// for it is not run until after DOM ready +jQuery(function() { + if ( !jQuery.support.reliableMarginRight ) { + jQuery.cssHooks.marginRight = { + get: function( elem, computed ) { + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + // Work around by temporarily setting element display to inline-block + return jQuery.swap( elem, { "display": "inline-block" }, function() { + if ( computed ) { + return curCSS( elem, "marginRight" ); + } + }); + } + }; + } + + // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 + // getComputedStyle returns percent when specified for top/left/bottom/right + // rather than make the css module depend on the offset module, we just check for it here + if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { + jQuery.each( [ "top", "left" ], function( i, prop ) { + jQuery.cssHooks[ prop ] = { + get: function( elem, computed ) { + if ( computed ) { + var ret = curCSS( elem, prop ); + // if curCSS returns percentage, fallback to offset + return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; + } + } + }; + }); + } + +}); + +if ( jQuery.expr && jQuery.expr.filters ) { + jQuery.expr.filters.hidden = function( elem ) { + return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none"); + }; + + jQuery.expr.filters.visible = function( elem ) { + return !jQuery.expr.filters.hidden( elem ); + }; +} + +// These hooks are used by animate to expand properties +jQuery.each({ + margin: "", + padding: "", + border: "Width" +}, function( prefix, suffix ) { + jQuery.cssHooks[ prefix + suffix ] = { + expand: function( value ) { + var i, + + // assumes a single number if not a string + parts = typeof value === "string" ? value.split(" ") : [ value ], + expanded = {}; + + for ( i = 0; i < 4; i++ ) { + expanded[ prefix + cssExpand[ i ] + suffix ] = + parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; + } + + return expanded; + } + }; + + if ( !rmargin.test( prefix ) ) { + jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; + } +}); +var r20 = /%20/g, + rbracket = /\[\]$/, + rCRLF = /\r?\n/g, + rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, + rselectTextarea = /^(?:select|textarea)/i; + +jQuery.fn.extend({ + serialize: function() { + return jQuery.param( this.serializeArray() ); + }, + serializeArray: function() { + return this.map(function(){ + return this.elements ? jQuery.makeArray( this.elements ) : this; + }) + .filter(function(){ + return this.name && !this.disabled && + ( this.checked || rselectTextarea.test( this.nodeName ) || + rinput.test( this.type ) ); + }) + .map(function( i, elem ){ + var val = jQuery( this ).val(); + + return val == null ? + null : + jQuery.isArray( val ) ? + jQuery.map( val, function( val, i ){ + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + }) : + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + }).get(); + } +}); + +//Serialize an array of form elements or a set of +//key/values into a query string +jQuery.param = function( a, traditional ) { + var prefix, + s = [], + add = function( key, value ) { + // If value is a function, invoke it and return its value + value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); + }; + + // Set traditional to true for jQuery <= 1.3.2 behavior. + if ( traditional === undefined ) { + traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; + } + + // If an array was passed in, assume that it is an array of form elements. + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + // Serialize the form elements + jQuery.each( a, function() { + add( this.name, this.value ); + }); + + } else { + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for ( prefix in a ) { + buildParams( prefix, a[ prefix ], traditional, add ); + } + } + + // Return the resulting serialization + return s.join( "&" ).replace( r20, "+" ); +}; + +function buildParams( prefix, obj, traditional, add ) { + var name; + + if ( jQuery.isArray( obj ) ) { + // Serialize array item. + jQuery.each( obj, function( i, v ) { + if ( traditional || rbracket.test( prefix ) ) { + // Treat each array item as a scalar. + add( prefix, v ); + + } else { + // If array item is non-scalar (array or object), encode its + // numeric index to resolve deserialization ambiguity issues. + // Note that rack (as of 1.0.0) can't currently deserialize + // nested arrays properly, and attempting to do so may cause + // a server error. Possible fixes are to modify rack's + // deserialization algorithm or to provide an option or flag + // to force array serialization to be shallow. + buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); + } + }); + + } else if ( !traditional && jQuery.type( obj ) === "object" ) { + // Serialize object item. + for ( name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } + + } else { + // Serialize scalar item. + add( prefix, obj ); + } +} +var + // Document location + ajaxLocParts, + ajaxLocation, + + rhash = /#.*$/, + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL + // #7653, #8125, #8152: local protocol detection + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, + rnoContent = /^(?:GET|HEAD)$/, + rprotocol = /^\/\//, + rquery = /\?/, + rscript = /)<[^<]*)*<\/script>/gi, + rts = /([?&])_=[^&]*/, + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, + + // Keep a copy of the old load method + _load = jQuery.fn.load, + + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression + allTypes = ["*/"] + ["*"]; + +// #8138, IE may throw an exception when accessing +// a field from window.location if document.domain has been set +try { + ajaxLocation = location.href; +} catch( e ) { + // Use the href attribute of an A element + // since IE will modify it given document.location + ajaxLocation = document.createElement( "a" ); + ajaxLocation.href = ""; + ajaxLocation = ajaxLocation.href; +} + +// Segment location into parts +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; + +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport +function addToPrefiltersOrTransports( structure ) { + + // dataTypeExpression is optional and defaults to "*" + return function( dataTypeExpression, func ) { + + if ( typeof dataTypeExpression !== "string" ) { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, list, placeBefore, + dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), + i = 0, + length = dataTypes.length; + + if ( jQuery.isFunction( func ) ) { + // For each dataType in the dataTypeExpression + for ( ; i < length; i++ ) { + dataType = dataTypes[ i ]; + // We control if we're asked to add before + // any existing element + placeBefore = /^\+/.test( dataType ); + if ( placeBefore ) { + dataType = dataType.substr( 1 ) || "*"; + } + list = structure[ dataType ] = structure[ dataType ] || []; + // then we add to the structure accordingly + list[ placeBefore ? "unshift" : "push" ]( func ); + } + } + }; +} + +// Base inspection function for prefilters and transports +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, + dataType /* internal */, inspected /* internal */ ) { + + dataType = dataType || options.dataTypes[ 0 ]; + inspected = inspected || {}; + + inspected[ dataType ] = true; + + var selection, + list = structure[ dataType ], + i = 0, + length = list ? list.length : 0, + executeOnly = ( structure === prefilters ); + + for ( ; i < length && ( executeOnly || !selection ); i++ ) { + selection = list[ i ]( options, originalOptions, jqXHR ); + // If we got redirected to another dataType + // we try there if executing only and not done already + if ( typeof selection === "string" ) { + if ( !executeOnly || inspected[ selection ] ) { + selection = undefined; + } else { + options.dataTypes.unshift( selection ); + selection = inspectPrefiltersOrTransports( + structure, options, originalOptions, jqXHR, selection, inspected ); + } + } + } + // If we're only executing or nothing was selected + // we try the catchall dataType if not done already + if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { + selection = inspectPrefiltersOrTransports( + structure, options, originalOptions, jqXHR, "*", inspected ); + } + // unnecessary when only executing (prefilters) + // but it'll be ignored by the caller in that case + return selection; +} + +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes #9887 +function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } +} + +jQuery.fn.load = function( url, params, callback ) { + if ( typeof url !== "string" && _load ) { + return _load.apply( this, arguments ); + } + + // Don't do a request if no elements are being requested + if ( !this.length ) { + return this; + } + + var selector, type, response, + self = this, + off = url.indexOf(" "); + + if ( off >= 0 ) { + selector = url.slice( off, url.length ); + url = url.slice( 0, off ); + } + + // If it's a function + if ( jQuery.isFunction( params ) ) { + + // We assume that it's the callback + callback = params; + params = undefined; + + // Otherwise, build a param string + } else if ( params && typeof params === "object" ) { + type = "POST"; + } + + // Request the remote document + jQuery.ajax({ + url: url, + + // if "type" variable is undefined, then "GET" method will be used + type: type, + dataType: "html", + data: params, + complete: function( jqXHR, status ) { + if ( callback ) { + self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); + } + } + }).done(function( responseText ) { + + // Save response for use in complete callback + response = arguments; + + // See if a selector was specified + self.html( selector ? + + // Create a dummy div to hold the results + jQuery("
") + + // inject the contents of the document in, removing the scripts + // to avoid any 'Permission Denied' errors in IE + .append( responseText.replace( rscript, "" ) ) + + // Locate the specified elements + .find( selector ) : + + // If not, just inject the full result + responseText ); + + }); + + return this; +}; + +// Attach a bunch of functions for handling common AJAX events +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ + jQuery.fn[ o ] = function( f ){ + return this.on( o, f ); + }; +}); + +jQuery.each( [ "get", "post" ], function( i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + // shift arguments if data argument was omitted + if ( jQuery.isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + return jQuery.ajax({ + type: method, + url: url, + data: data, + success: callback, + dataType: type + }); + }; +}); + +jQuery.extend({ + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + }, + + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + }, + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + if ( settings ) { + // Building a settings object + ajaxExtend( target, jQuery.ajaxSettings ); + } else { + // Extending ajaxSettings + settings = target; + target = jQuery.ajaxSettings; + } + ajaxExtend( target, settings ); + return target; + }, + + ajaxSettings: { + url: ajaxLocation, + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), + global: true, + type: "GET", + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + processData: true, + async: true, + /* + timeout: 0, + data: null, + dataType: null, + username: null, + password: null, + cache: null, + throws: false, + traditional: false, + headers: {}, + */ + + accepts: { + xml: "application/xml, text/xml", + html: "text/html", + text: "text/plain", + json: "application/json, text/javascript", + "*": allTypes + }, + + contents: { + xml: /xml/, + html: /html/, + json: /json/ + }, + + responseFields: { + xml: "responseXML", + text: "responseText" + }, + + // List of data converters + // 1) key format is "source_type destination_type" (a single space in-between) + // 2) the catchall symbol "*" can be used for source_type + converters: { + + // Convert anything to text + "* text": window.String, + + // Text to html (true = no transformation) + "text html": true, + + // Evaluate text as a json expression + "text json": jQuery.parseJSON, + + // Parse text as xml + "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + context: true, + url: true + } + }, + + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), + ajaxTransport: addToPrefiltersOrTransports( transports ), + + // Main method + ajax: function( url, options ) { + + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + var // ifModified key + ifModifiedKey, + // Response headers + responseHeadersString, + responseHeaders, + // transport + transport, + // timeout handle + timeoutTimer, + // Cross-domain detection vars + parts, + // To know if global events are to be dispatched + fireGlobals, + // Loop variable + i, + // Create the final options object + s = jQuery.ajaxSetup( {}, options ), + // Callbacks context + callbackContext = s.context || s, + // Context for global events + // It's the callbackContext if one was provided in the options + // and if it's a DOM node or a jQuery collection + globalEventContext = callbackContext !== s && + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? + jQuery( callbackContext ) : jQuery.event, + // Deferreds + deferred = jQuery.Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), + // Status-dependent callbacks + statusCode = s.statusCode || {}, + // Headers (they are sent all at once) + requestHeaders = {}, + requestHeadersNames = {}, + // The jqXHR state + state = 0, + // Default abort message + strAbort = "canceled", + // Fake xhr + jqXHR = { + + readyState: 0, + + // Caches the header + setRequestHeader: function( name, value ) { + if ( !state ) { + var lname = name.toLowerCase(); + name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; + requestHeaders[ name ] = value; + } + return this; + }, + + // Raw string + getAllResponseHeaders: function() { + return state === 2 ? responseHeadersString : null; + }, + + // Builds headers hashtable if needed + getResponseHeader: function( key ) { + var match; + if ( state === 2 ) { + if ( !responseHeaders ) { + responseHeaders = {}; + while( ( match = rheaders.exec( responseHeadersString ) ) ) { + responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; + } + } + match = responseHeaders[ key.toLowerCase() ]; + } + return match === undefined ? null : match; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( !state ) { + s.mimeType = type; + } + return this; + }, + + // Cancel the request + abort: function( statusText ) { + statusText = statusText || strAbort; + if ( transport ) { + transport.abort( statusText ); + } + done( 0, statusText ); + return this; + } + }; + + // Callback for when everything is done + // It is defined here because jslint complains if it is declared + // at the end of the function (which would be more logical and readable) + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; + + // Called once + if ( state === 2 ) { + return; + } + + // State is "done" now + state = 2; + + // Clear timeout if it exists + if ( timeoutTimer ) { + clearTimeout( timeoutTimer ); + } + + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); + } + + // If successful, handle type chaining + if ( status >= 200 && status < 300 || status === 304 ) { + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + + modified = jqXHR.getResponseHeader("Last-Modified"); + if ( modified ) { + jQuery.lastModified[ ifModifiedKey ] = modified; + } + modified = jqXHR.getResponseHeader("Etag"); + if ( modified ) { + jQuery.etag[ ifModifiedKey ] = modified; + } + } + + // If not modified + if ( status === 304 ) { + + statusText = "notmodified"; + isSuccess = true; + + // If we have data + } else { + + isSuccess = ajaxConvert( s, response ); + statusText = isSuccess.state; + success = isSuccess.data; + error = isSuccess.error; + isSuccess = !error; + } + } else { + // We extract error from statusText + // then normalize statusText and status for non-aborts + error = statusText; + if ( !statusText || status ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } + } + + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; + + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } + + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; + + if ( fireGlobals ) { + globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), + [ jqXHR, s, isSuccess ? success : error ] ); + } + + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger( "ajaxStop" ); + } + } + } + + // Attach deferreds + deferred.promise( jqXHR ); + jqXHR.success = jqXHR.done; + jqXHR.error = jqXHR.fail; + jqXHR.complete = completeDeferred.add; + + // Status-dependent callbacks + jqXHR.statusCode = function( map ) { + if ( map ) { + var tmp; + if ( state < 2 ) { + for ( tmp in map ) { + statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; + } + } else { + tmp = map[ jqXHR.status ]; + jqXHR.always( tmp ); + } + } + return this; + }; + + // Remove hash character (#7531: and string promotion) + // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) + // We also use the url parameter if available + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); + + // Extract dataTypes list + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); + + // A cross-domain request is in order when we have a protocol:host:port mismatch + if ( s.crossDomain == null ) { + parts = rurl.exec( s.url.toLowerCase() ) || false; + s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !== + ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ); + } + + // Convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) { + s.data = jQuery.param( s.data, s.traditional ); + } + + // Apply prefilters + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefilter, stop there + if ( state === 2 ) { + return jqXHR; + } + + // We can fire global events as of now if asked to + fireGlobals = s.global; + + // Uppercase the type + s.type = s.type.toUpperCase(); + + // Determine if request has content + s.hasContent = !rnoContent.test( s.type ); + + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger( "ajaxStart" ); + } + + // More options handling for requests with no content + if ( !s.hasContent ) { + + // If data is available, append data to url + if ( s.data ) { + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; + // #9682: remove data so that it's not used in an eventual retry + delete s.data; + } + + // Get ifModifiedKey before adding the anti-cache parameter + ifModifiedKey = s.url; + + // Add anti-cache in url if needed + if ( s.cache === false ) { + + var ts = jQuery.now(), + // try replacing _= if it is there + ret = s.url.replace( rts, "$1_=" + ts ); + + // if nothing was replaced, add timestamp to the end + s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); + } + } + + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + ifModifiedKey = ifModifiedKey || s.url; + if ( jQuery.lastModified[ ifModifiedKey ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); + } + if ( jQuery.etag[ ifModifiedKey ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); + } + } + + // Set the Accepts header for the server, depending on the dataType + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : + s.accepts[ "*" ] + ); + + // Check for headers option + for ( i in s.headers ) { + jqXHR.setRequestHeader( i, s.headers[ i ] ); + } + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { + // Abort if not done already and return + return jqXHR.abort(); + + } + + // aborting is no longer a cancellation + strAbort = "abort"; + + // Install callbacks on deferreds + for ( i in { success: 1, error: 1, complete: 1 } ) { + jqXHR[ i ]( s[ i ] ); + } + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); + } else { + jqXHR.readyState = 1; + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = setTimeout( function(){ + jqXHR.abort( "timeout" ); + }, s.timeout ); + } + + try { + state = 1; + transport.send( requestHeaders, done ); + } catch (e) { + // Propagate exception as error if not done + if ( state < 2 ) { + done( -1, e ); + // Simply rethrow otherwise + } else { + throw e; + } + } + } + + return jqXHR; + }, + + // Counter for holding the number of active queries + active: 0, + + // Last-Modified header cache for next request + lastModified: {}, + etag: {} + +}); + +/* Handles responses to an ajax request: + * - sets all responseXXX fields accordingly + * - finds the right dataType (mediates between content-type and expected dataType) + * - returns the corresponding response + */ +function ajaxHandleResponses( s, jqXHR, responses ) { + + var ct, type, finalDataType, firstDataType, + contents = s.contents, + dataTypes = s.dataTypes, + responseFields = s.responseFields; + + // Fill responseXXX fields + for ( type in responseFields ) { + if ( type in responses ) { + jqXHR[ responseFields[type] ] = responses[ type ]; + } + } + + // Remove auto dataType and get content-type in the process + while( dataTypes[ 0 ] === "*" ) { + dataTypes.shift(); + if ( ct === undefined ) { + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); + } + } + + // Check if we're dealing with a known content-type + if ( ct ) { + for ( type in contents ) { + if ( contents[ type ] && contents[ type ].test( ct ) ) { + dataTypes.unshift( type ); + break; + } + } + } + + // Check to see if we have a response for the expected dataType + if ( dataTypes[ 0 ] in responses ) { + finalDataType = dataTypes[ 0 ]; + } else { + // Try convertible dataTypes + for ( type in responses ) { + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { + finalDataType = type; + break; + } + if ( !firstDataType ) { + firstDataType = type; + } + } + // Or just use first one + finalDataType = finalDataType || firstDataType; + } + + // If we found a dataType + // We add the dataType to the list if needed + // and return the corresponding response + if ( finalDataType ) { + if ( finalDataType !== dataTypes[ 0 ] ) { + dataTypes.unshift( finalDataType ); + } + return responses[ finalDataType ]; + } +} + +// Chain conversions given the request and the original response +function ajaxConvert( s, response ) { + + var conv, conv2, current, tmp, + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(), + prev = dataTypes[ 0 ], + converters = {}, + i = 0; + + // Apply the dataFilter if provided + if ( s.dataFilter ) { + response = s.dataFilter( response, s.dataType ); + } + + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; + } + } + + // Convert to each sequential dataType, tolerating list modification + for ( ; (current = dataTypes[++i]); ) { + + // There's only work to do if current dataType is non-auto + if ( current !== "*" ) { + + // Convert response if prev dataType is non-auto and differs from current + if ( prev !== "*" && prev !== current ) { + + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; + + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { + + // If conv2 outputs current + tmp = conv2.split(" "); + if ( tmp[ 1 ] === current ) { + + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; + + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.splice( i--, 0, current ); + } + + break; + } + } + } + } + + // Apply converter (if not an equivalence) + if ( conv !== true ) { + + // Unless errors are allowed to bubble, catch and return them + if ( conv && s["throws"] ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; + } + } + } + } + + // Update prev for next iteration + prev = current; + } + } + + return { state: "success", data: response }; +} +var oldCallbacks = [], + rquestion = /\?/, + rjsonp = /(=)\?(?=&|$)|\?\?/, + nonce = jQuery.now(); + +// Default jsonp settings +jQuery.ajaxSetup({ + jsonp: "callback", + jsonpCallback: function() { + var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); + this[ callback ] = true; + return callback; + } +}); + +// Detect, normalize options and install callbacks for jsonp requests +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { + + var callbackName, overwritten, responseContainer, + data = s.data, + url = s.url, + hasCallback = s.jsonp !== false, + replaceInUrl = hasCallback && rjsonp.test( url ), + replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && + !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && + rjsonp.test( data ); + + // Handle iff the expected data type is "jsonp" or we have a parameter to set + if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { + + // Get callback name, remembering preexisting value associated with it + callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? + s.jsonpCallback() : + s.jsonpCallback; + overwritten = window[ callbackName ]; + + // Insert callback into url or form data + if ( replaceInUrl ) { + s.url = url.replace( rjsonp, "$1" + callbackName ); + } else if ( replaceInData ) { + s.data = data.replace( rjsonp, "$1" + callbackName ); + } else if ( hasCallback ) { + s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; + } + + // Use data converter to retrieve json after script execution + s.converters["script json"] = function() { + if ( !responseContainer ) { + jQuery.error( callbackName + " was not called" ); + } + return responseContainer[ 0 ]; + }; + + // force json dataType + s.dataTypes[ 0 ] = "json"; + + // Install callback + window[ callbackName ] = function() { + responseContainer = arguments; + }; + + // Clean-up function (fires after converters) + jqXHR.always(function() { + // Restore preexisting value + window[ callbackName ] = overwritten; + + // Save back as free + if ( s[ callbackName ] ) { + // make sure that re-using the options doesn't screw things around + s.jsonpCallback = originalSettings.jsonpCallback; + + // save the callback name for future use + oldCallbacks.push( callbackName ); + } + + // Call if it was a function and we have a response + if ( responseContainer && jQuery.isFunction( overwritten ) ) { + overwritten( responseContainer[ 0 ] ); + } + + responseContainer = overwritten = undefined; + }); + + // Delegate to script + return "script"; + } +}); +// Install script dataType +jQuery.ajaxSetup({ + accepts: { + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /javascript|ecmascript/ + }, + converters: { + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } + } +}); + +// Handle cache's special case and global +jQuery.ajaxPrefilter( "script", function( s ) { + if ( s.cache === undefined ) { + s.cache = false; + } + if ( s.crossDomain ) { + s.type = "GET"; + s.global = false; + } +}); + +// Bind script tag hack transport +jQuery.ajaxTransport( "script", function(s) { + + // This transport only deals with cross domain requests + if ( s.crossDomain ) { + + var script, + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; + + return { + + send: function( _, callback ) { + + script = document.createElement( "script" ); + + script.async = "async"; + + if ( s.scriptCharset ) { + script.charset = s.scriptCharset; + } + + script.src = s.url; + + // Attach handlers for all browsers + script.onload = script.onreadystatechange = function( _, isAbort ) { + + if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { + + // Handle memory leak in IE + script.onload = script.onreadystatechange = null; + + // Remove the script + if ( head && script.parentNode ) { + head.removeChild( script ); + } + + // Dereference the script + script = undefined; + + // Callback if not abort + if ( !isAbort ) { + callback( 200, "success" ); + } + } + }; + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709 and #4378). + head.insertBefore( script, head.firstChild ); + }, + + abort: function() { + if ( script ) { + script.onload( 0, 1 ); + } + } + }; + } +}); +var xhrCallbacks, + // #5280: Internet Explorer will keep connections alive if we don't abort on unload + xhrOnUnloadAbort = window.ActiveXObject ? function() { + // Abort all pending requests + for ( var key in xhrCallbacks ) { + xhrCallbacks[ key ]( 0, 1 ); + } + } : false, + xhrId = 0; + +// Functions to create xhrs +function createStandardXHR() { + try { + return new window.XMLHttpRequest(); + } catch( e ) {} +} + +function createActiveXHR() { + try { + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); + } catch( e ) {} +} + +// Create the request object +// (This is still attached to ajaxSettings for backward compatibility) +jQuery.ajaxSettings.xhr = window.ActiveXObject ? + /* Microsoft failed to properly + * implement the XMLHttpRequest in IE7 (can't request local files), + * so we use the ActiveXObject when it is available + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so + * we need a fallback. + */ + function() { + return !this.isLocal && createStandardXHR() || createActiveXHR(); + } : + // For all other browsers, use the standard XMLHttpRequest object + createStandardXHR; + +// Determine support properties +(function( xhr ) { + jQuery.extend( jQuery.support, { + ajax: !!xhr, + cors: !!xhr && ( "withCredentials" in xhr ) + }); +})( jQuery.ajaxSettings.xhr() ); + +// Create transport if the browser can provide an xhr +if ( jQuery.support.ajax ) { + + jQuery.ajaxTransport(function( s ) { + // Cross domain only allowed if supported through XMLHttpRequest + if ( !s.crossDomain || jQuery.support.cors ) { + + var callback; + + return { + send: function( headers, complete ) { + + // Get a new xhr + var handle, i, + xhr = s.xhr(); + + // Open the socket + // Passing null username, generates a login popup on Opera (#2865) + if ( s.username ) { + xhr.open( s.type, s.url, s.async, s.username, s.password ); + } else { + xhr.open( s.type, s.url, s.async ); + } + + // Apply custom fields if provided + if ( s.xhrFields ) { + for ( i in s.xhrFields ) { + xhr[ i ] = s.xhrFields[ i ]; + } + } + + // Override mime type if needed + if ( s.mimeType && xhr.overrideMimeType ) { + xhr.overrideMimeType( s.mimeType ); + } + + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !s.crossDomain && !headers["X-Requested-With"] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; + } + + // Need an extra try/catch for cross domain requests in Firefox 3 + try { + for ( i in headers ) { + xhr.setRequestHeader( i, headers[ i ] ); + } + } catch( _ ) {} + + // Do send the request + // This may raise an exception which is actually + // handled in jQuery.ajax (so no try/catch here) + xhr.send( ( s.hasContent && s.data ) || null ); + + // Listener + callback = function( _, isAbort ) { + + var status, + statusText, + responseHeaders, + responses, + xml; + + // Firefox throws exceptions when accessing properties + // of an xhr when a network error occurred + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) + try { + + // Was never called and is aborted or complete + if ( callback && ( isAbort || xhr.readyState === 4 ) ) { + + // Only called once + callback = undefined; + + // Do not keep as active anymore + if ( handle ) { + xhr.onreadystatechange = jQuery.noop; + if ( xhrOnUnloadAbort ) { + delete xhrCallbacks[ handle ]; + } + } + + // If it's an abort + if ( isAbort ) { + // Abort it manually if needed + if ( xhr.readyState !== 4 ) { + xhr.abort(); + } + } else { + status = xhr.status; + responseHeaders = xhr.getAllResponseHeaders(); + responses = {}; + xml = xhr.responseXML; + + // Construct response list + if ( xml && xml.documentElement /* #4958 */ ) { + responses.xml = xml; + } + + // When requesting binary data, IE6-9 will throw an exception + // on any attempt to access responseText (#11426) + try { + responses.text = xhr.responseText; + } catch( _ ) { + } + + // Firefox throws an exception when accessing + // statusText for faulty cross-domain requests + try { + statusText = xhr.statusText; + } catch( e ) { + // We normalize with Webkit giving an empty statusText + statusText = ""; + } + + // Filter status for non standard behaviors + + // If the request is local and we have data: assume a success + // (success with no data won't get notified, that's the best we + // can do given current implementations) + if ( !status && s.isLocal && !s.crossDomain ) { + status = responses.text ? 200 : 404; + // IE - #1450: sometimes returns 1223 when it should be 204 + } else if ( status === 1223 ) { + status = 204; + } + } + } + } catch( firefoxAccessException ) { + if ( !isAbort ) { + complete( -1, firefoxAccessException ); + } + } + + // Call complete if needed + if ( responses ) { + complete( status, statusText, responses, responseHeaders ); + } + }; + + if ( !s.async ) { + // if we're in sync mode we fire the callback + callback(); + } else if ( xhr.readyState === 4 ) { + // (IE6 & IE7) if it's in cache and has been + // retrieved directly we need to fire the callback + setTimeout( callback, 0 ); + } else { + handle = ++xhrId; + if ( xhrOnUnloadAbort ) { + // Create the active xhrs callbacks list if needed + // and attach the unload handler + if ( !xhrCallbacks ) { + xhrCallbacks = {}; + jQuery( window ).unload( xhrOnUnloadAbort ); + } + // Add to list of active xhrs callbacks + xhrCallbacks[ handle ] = callback; + } + xhr.onreadystatechange = callback; + } + }, + + abort: function() { + if ( callback ) { + callback(0,1); + } + } + }; + } + }); +} +var fxNow, timerId, + rfxtypes = /^(?:toggle|show|hide)$/, + rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), + rrun = /queueHooks$/, + animationPrefilters = [ defaultPrefilter ], + tweeners = { + "*": [function( prop, value ) { + var end, unit, + tween = this.createTween( prop, value ), + parts = rfxnum.exec( value ), + target = tween.cur(), + start = +target || 0, + scale = 1, + maxIterations = 20; + + if ( parts ) { + end = +parts[2]; + unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + + // We need to compute starting value + if ( unit !== "px" && start ) { + // Iteratively approximate from a nonzero starting point + // Prefer the current property, because this process will be trivial if it uses the same units + // Fallback to end or a simple constant + start = jQuery.css( tween.elem, prop, true ) || end || 1; + + do { + // If previous iteration zeroed out, double until we get *something* + // Use a string for doubling factor so we don't accidentally see scale as unchanged below + scale = scale || ".5"; + + // Adjust and apply + start = start / scale; + jQuery.style( tween.elem, prop, start + unit ); + + // Update scale, tolerating zero or NaN from tween.cur() + // And breaking the loop if scale is unchanged or perfect, or if we've just had enough + } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); + } + + tween.unit = unit; + tween.start = start; + // If a +=/-= token was provided, we're doing a relative animation + tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; + } + return tween; + }] + }; + +// Animations created synchronously will run synchronously +function createFxNow() { + setTimeout(function() { + fxNow = undefined; + }, 0 ); + return ( fxNow = jQuery.now() ); +} + +function createTweens( animation, props ) { + jQuery.each( props, function( prop, value ) { + var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), + index = 0, + length = collection.length; + for ( ; index < length; index++ ) { + if ( collection[ index ].call( animation, prop, value ) ) { + + // we're done with this property + return; + } + } + }); +} + +function Animation( elem, properties, options ) { + var result, + index = 0, + tweenerIndex = 0, + length = animationPrefilters.length, + deferred = jQuery.Deferred().always( function() { + // don't match elem in the :animated selector + delete tick.elem; + }), + tick = function() { + var currentTime = fxNow || createFxNow(), + remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + percent = 1 - ( remaining / animation.duration || 0 ), + index = 0, + length = animation.tweens.length; + + for ( ; index < length ; index++ ) { + animation.tweens[ index ].run( percent ); + } + + deferred.notifyWith( elem, [ animation, percent, remaining ]); + + if ( percent < 1 && length ) { + return remaining; + } else { + deferred.resolveWith( elem, [ animation ] ); + return false; + } + }, + animation = deferred.promise({ + elem: elem, + props: jQuery.extend( {}, properties ), + opts: jQuery.extend( true, { specialEasing: {} }, options ), + originalProperties: properties, + originalOptions: options, + startTime: fxNow || createFxNow(), + duration: options.duration, + tweens: [], + createTween: function( prop, end, easing ) { + var tween = jQuery.Tween( elem, animation.opts, prop, end, + animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.tweens.push( tween ); + return tween; + }, + stop: function( gotoEnd ) { + var index = 0, + // if we are going to the end, we want to run all the tweens + // otherwise we skip this part + length = gotoEnd ? animation.tweens.length : 0; + + for ( ; index < length ; index++ ) { + animation.tweens[ index ].run( 1 ); + } + + // resolve when we played the last frame + // otherwise, reject + if ( gotoEnd ) { + deferred.resolveWith( elem, [ animation, gotoEnd ] ); + } else { + deferred.rejectWith( elem, [ animation, gotoEnd ] ); + } + return this; + } + }), + props = animation.props; + + propFilter( props, animation.opts.specialEasing ); + + for ( ; index < length ; index++ ) { + result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); + if ( result ) { + return result; + } + } + + createTweens( animation, props ); + + if ( jQuery.isFunction( animation.opts.start ) ) { + animation.opts.start.call( elem, animation ); + } + + jQuery.fx.timer( + jQuery.extend( tick, { + anim: animation, + queue: animation.opts.queue, + elem: elem + }) + ); + + // attach callbacks from options + return animation.progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); +} + +function propFilter( props, specialEasing ) { + var index, name, easing, value, hooks; + + // camelCase, specialEasing and expand cssHook pass + for ( index in props ) { + name = jQuery.camelCase( index ); + easing = specialEasing[ name ]; + value = props[ index ]; + if ( jQuery.isArray( value ) ) { + easing = value[ 1 ]; + value = props[ index ] = value[ 0 ]; + } + + if ( index !== name ) { + props[ name ] = value; + delete props[ index ]; + } + + hooks = jQuery.cssHooks[ name ]; + if ( hooks && "expand" in hooks ) { + value = hooks.expand( value ); + delete props[ name ]; + + // not quite $.extend, this wont overwrite keys already present. + // also - reusing 'index' from above because we have the correct "name" + for ( index in value ) { + if ( !( index in props ) ) { + props[ index ] = value[ index ]; + specialEasing[ index ] = easing; + } + } + } else { + specialEasing[ name ] = easing; + } + } +} + +jQuery.Animation = jQuery.extend( Animation, { + + tweener: function( props, callback ) { + if ( jQuery.isFunction( props ) ) { + callback = props; + props = [ "*" ]; + } else { + props = props.split(" "); + } + + var prop, + index = 0, + length = props.length; + + for ( ; index < length ; index++ ) { + prop = props[ index ]; + tweeners[ prop ] = tweeners[ prop ] || []; + tweeners[ prop ].unshift( callback ); + } + }, + + prefilter: function( callback, prepend ) { + if ( prepend ) { + animationPrefilters.unshift( callback ); + } else { + animationPrefilters.push( callback ); + } + } +}); + +function defaultPrefilter( elem, props, opts ) { + var index, prop, value, length, dataShow, tween, hooks, oldfire, + anim = this, + style = elem.style, + orig = {}, + handled = [], + hidden = elem.nodeType && isHidden( elem ); + + // handle queue: false promises + if ( !opts.queue ) { + hooks = jQuery._queueHooks( elem, "fx" ); + if ( hooks.unqueued == null ) { + hooks.unqueued = 0; + oldfire = hooks.empty.fire; + hooks.empty.fire = function() { + if ( !hooks.unqueued ) { + oldfire(); + } + }; + } + hooks.unqueued++; + + anim.always(function() { + // doing this makes sure that the complete handler will be called + // before this completes + anim.always(function() { + hooks.unqueued--; + if ( !jQuery.queue( elem, "fx" ).length ) { + hooks.empty.fire(); + } + }); + }); + } + + // height/width overflow pass + if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { + // Make sure that nothing sneaks out + // Record all 3 overflow attributes because IE does not + // change the overflow attribute when overflowX and + // overflowY are set to the same value + opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; + + // Set display property to inline-block for height/width + // animations on inline elements that are having width/height animated + if ( jQuery.css( elem, "display" ) === "inline" && + jQuery.css( elem, "float" ) === "none" ) { + + // inline-level elements accept inline-block; + // block-level elements need to be inline with layout + if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { + style.display = "inline-block"; + + } else { + style.zoom = 1; + } + } + } + + if ( opts.overflow ) { + style.overflow = "hidden"; + if ( !jQuery.support.shrinkWrapBlocks ) { + anim.done(function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + }); + } + } + + + // show/hide pass + for ( index in props ) { + value = props[ index ]; + if ( rfxtypes.exec( value ) ) { + delete props[ index ]; + if ( value === ( hidden ? "hide" : "show" ) ) { + continue; + } + handled.push( index ); + } + } + + length = handled.length; + if ( length ) { + dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); + if ( hidden ) { + jQuery( elem ).show(); + } else { + anim.done(function() { + jQuery( elem ).hide(); + }); + } + anim.done(function() { + var prop; + jQuery.removeData( elem, "fxshow", true ); + for ( prop in orig ) { + jQuery.style( elem, prop, orig[ prop ] ); + } + }); + for ( index = 0 ; index < length ; index++ ) { + prop = handled[ index ]; + tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 ); + orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop ); + + if ( !( prop in dataShow ) ) { + dataShow[ prop ] = tween.start; + if ( hidden ) { + tween.end = tween.start; + tween.start = prop === "width" || prop === "height" ? 1 : 0; + } + } + } + } +} + +function Tween( elem, options, prop, end, easing ) { + return new Tween.prototype.init( elem, options, prop, end, easing ); +} +jQuery.Tween = Tween; + +Tween.prototype = { + constructor: Tween, + init: function( elem, options, prop, end, easing, unit ) { + this.elem = elem; + this.prop = prop; + this.easing = easing || "swing"; + this.options = options; + this.start = this.now = this.cur(); + this.end = end; + this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + }, + cur: function() { + var hooks = Tween.propHooks[ this.prop ]; + + return hooks && hooks.get ? + hooks.get( this ) : + Tween.propHooks._default.get( this ); + }, + run: function( percent ) { + var eased, + hooks = Tween.propHooks[ this.prop ]; + + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } + this.now = ( this.end - this.start ) * eased + this.start; + + if ( this.options.step ) { + this.options.step.call( this.elem, this.now, this ); + } + + if ( hooks && hooks.set ) { + hooks.set( this ); + } else { + Tween.propHooks._default.set( this ); + } + return this; + } +}; + +Tween.prototype.init.prototype = Tween.prototype; + +Tween.propHooks = { + _default: { + get: function( tween ) { + var result; + + if ( tween.elem[ tween.prop ] != null && + (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { + return tween.elem[ tween.prop ]; + } + + // passing any value as a 4th parameter to .css will automatically + // attempt a parseFloat and fallback to a string if the parse fails + // so, simple values such as "10px" are parsed to Float. + // complex values such as "rotate(1rad)" are returned as is. + result = jQuery.css( tween.elem, tween.prop, false, "" ); + // Empty strings, null, undefined and "auto" are converted to 0. + return !result || result === "auto" ? 0 : result; + }, + set: function( tween ) { + // use step hook for back compat - use cssHook if its there - use .style if its + // available and use plain properties where available + if ( jQuery.fx.step[ tween.prop ] ) { + jQuery.fx.step[ tween.prop ]( tween ); + } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { + jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); + } else { + tween.elem[ tween.prop ] = tween.now; + } + } + } +}; + +// Remove in 2.0 - this supports IE8's panic based approach +// to setting things on disconnected nodes + +Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { + set: function( tween ) { + if ( tween.elem.nodeType && tween.elem.parentNode ) { + tween.elem[ tween.prop ] = tween.now; + } + } +}; + +jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { + var cssFn = jQuery.fn[ name ]; + jQuery.fn[ name ] = function( speed, easing, callback ) { + return speed == null || typeof speed === "boolean" || + // special check for .toggle( handler, handler, ... ) + ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ? + cssFn.apply( this, arguments ) : + this.animate( genFx( name, true ), speed, easing, callback ); + }; +}); + +jQuery.fn.extend({ + fadeTo: function( speed, to, easing, callback ) { + + // show any hidden elements after setting opacity to 0 + return this.filter( isHidden ).css( "opacity", 0 ).show() + + // animate to the value specified + .end().animate({ opacity: to }, speed, easing, callback ); + }, + animate: function( prop, speed, easing, callback ) { + var empty = jQuery.isEmptyObject( prop ), + optall = jQuery.speed( speed, easing, callback ), + doAnimation = function() { + // Operate on a copy of prop so per-property easing won't be lost + var anim = Animation( this, jQuery.extend( {}, prop ), optall ); + + // Empty animations resolve immediately + if ( empty ) { + anim.stop( true ); + } + }; + + return empty || optall.queue === false ? + this.each( doAnimation ) : + this.queue( optall.queue, doAnimation ); + }, + stop: function( type, clearQueue, gotoEnd ) { + var stopQueue = function( hooks ) { + var stop = hooks.stop; + delete hooks.stop; + stop( gotoEnd ); + }; + + if ( typeof type !== "string" ) { + gotoEnd = clearQueue; + clearQueue = type; + type = undefined; + } + if ( clearQueue && type !== false ) { + this.queue( type || "fx", [] ); + } + + return this.each(function() { + var dequeue = true, + index = type != null && type + "queueHooks", + timers = jQuery.timers, + data = jQuery._data( this ); + + if ( index ) { + if ( data[ index ] && data[ index ].stop ) { + stopQueue( data[ index ] ); + } + } else { + for ( index in data ) { + if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { + stopQueue( data[ index ] ); + } + } + } + + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { + timers[ index ].anim.stop( gotoEnd ); + dequeue = false; + timers.splice( index, 1 ); + } + } + + // start the next in the queue if the last step wasn't forced + // timers currently will call their complete callbacks, which will dequeue + // but only if they were gotoEnd + if ( dequeue || !gotoEnd ) { + jQuery.dequeue( this, type ); + } + }); + } +}); + +// Generate parameters to create a standard animation +function genFx( type, includeWidth ) { + var which, + attrs = { height: type }, + i = 0; + + // if we include width, step value is 1 to do all cssExpand values, + // if we don't include width, step value is 2 to skip over Left and Right + includeWidth = includeWidth? 1 : 0; + for( ; i < 4 ; i += 2 - includeWidth ) { + which = cssExpand[ i ]; + attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; + } + + if ( includeWidth ) { + attrs.opacity = attrs.width = type; + } + + return attrs; +} + +// Generate shortcuts for custom animations +jQuery.each({ + slideDown: genFx("show"), + slideUp: genFx("hide"), + slideToggle: genFx("toggle"), + fadeIn: { opacity: "show" }, + fadeOut: { opacity: "hide" }, + fadeToggle: { opacity: "toggle" } +}, function( name, props ) { + jQuery.fn[ name ] = function( speed, easing, callback ) { + return this.animate( props, speed, easing, callback ); + }; +}); + +jQuery.speed = function( speed, easing, fn ) { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { + complete: fn || !fn && easing || + jQuery.isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing + }; + + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; + + // normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; + } + + // Queueing + opt.old = opt.complete; + + opt.complete = function() { + if ( jQuery.isFunction( opt.old ) ) { + opt.old.call( this ); + } + + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); + } + }; + + return opt; +}; + +jQuery.easing = { + linear: function( p ) { + return p; + }, + swing: function( p ) { + return 0.5 - Math.cos( p*Math.PI ) / 2; + } +}; + +jQuery.timers = []; +jQuery.fx = Tween.prototype.init; +jQuery.fx.tick = function() { + var timer, + timers = jQuery.timers, + i = 0; + + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + // Checks the timer has not already been removed + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); + } + } + + if ( !timers.length ) { + jQuery.fx.stop(); + } +}; + +jQuery.fx.timer = function( timer ) { + if ( timer() && jQuery.timers.push( timer ) && !timerId ) { + timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); + } +}; + +jQuery.fx.interval = 13; + +jQuery.fx.stop = function() { + clearInterval( timerId ); + timerId = null; +}; + +jQuery.fx.speeds = { + slow: 600, + fast: 200, + // Default speed + _default: 400 +}; + +// Back Compat <1.8 extension point +jQuery.fx.step = {}; + +if ( jQuery.expr && jQuery.expr.filters ) { + jQuery.expr.filters.animated = function( elem ) { + return jQuery.grep(jQuery.timers, function( fn ) { + return elem === fn.elem; + }).length; + }; +} +var rroot = /^(?:body|html)$/i; + +jQuery.fn.offset = function( options ) { + if ( arguments.length ) { + return options === undefined ? + this : + this.each(function( i ) { + jQuery.offset.setOffset( this, options, i ); + }); + } + + var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, + box = { top: 0, left: 0 }, + elem = this[ 0 ], + doc = elem && elem.ownerDocument; + + if ( !doc ) { + return; + } + + if ( (body = doc.body) === elem ) { + return jQuery.offset.bodyOffset( elem ); + } + + docElem = doc.documentElement; + + // Make sure it's not a disconnected DOM node + if ( !jQuery.contains( docElem, elem ) ) { + return box; + } + + // If we don't have gBCR, just use 0,0 rather than error + // BlackBerry 5, iOS 3 (original iPhone) + if ( typeof elem.getBoundingClientRect !== "undefined" ) { + box = elem.getBoundingClientRect(); + } + win = getWindow( doc ); + clientTop = docElem.clientTop || body.clientTop || 0; + clientLeft = docElem.clientLeft || body.clientLeft || 0; + scrollTop = win.pageYOffset || docElem.scrollTop; + scrollLeft = win.pageXOffset || docElem.scrollLeft; + return { + top: box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + }; +}; + +jQuery.offset = { + + bodyOffset: function( body ) { + var top = body.offsetTop, + left = body.offsetLeft; + + if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { + top += parseFloat( jQuery.css(body, "marginTop") ) || 0; + left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; + } + + return { top: top, left: left }; + }, + + setOffset: function( elem, options, i ) { + var position = jQuery.css( elem, "position" ); + + // set position first, in-case top/left are set even on static elem + if ( position === "static" ) { + elem.style.position = "relative"; + } + + var curElem = jQuery( elem ), + curOffset = curElem.offset(), + curCSSTop = jQuery.css( elem, "top" ), + curCSSLeft = jQuery.css( elem, "left" ), + calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, + props = {}, curPosition = {}, curTop, curLeft; + + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed + if ( calculatePosition ) { + curPosition = curElem.position(); + curTop = curPosition.top; + curLeft = curPosition.left; + } else { + curTop = parseFloat( curCSSTop ) || 0; + curLeft = parseFloat( curCSSLeft ) || 0; + } + + if ( jQuery.isFunction( options ) ) { + options = options.call( elem, i, curOffset ); + } + + if ( options.top != null ) { + props.top = ( options.top - curOffset.top ) + curTop; + } + if ( options.left != null ) { + props.left = ( options.left - curOffset.left ) + curLeft; + } + + if ( "using" in options ) { + options.using.call( elem, props ); + } else { + curElem.css( props ); + } + } +}; + + +jQuery.fn.extend({ + + position: function() { + if ( !this[0] ) { + return; + } + + var elem = this[0], + + // Get *real* offsetParent + offsetParent = this.offsetParent(), + + // Get correct offsets + offset = this.offset(), + parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); + + // Subtract element margins + // note: when an element has margin: auto the offsetLeft and marginLeft + // are the same in Safari causing offset.left to incorrectly be 0 + offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; + offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; + + // Add offsetParent borders + parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; + parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; + + // Subtract the two offsets + return { + top: offset.top - parentOffset.top, + left: offset.left - parentOffset.left + }; + }, + + offsetParent: function() { + return this.map(function() { + var offsetParent = this.offsetParent || document.body; + while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { + offsetParent = offsetParent.offsetParent; + } + return offsetParent || document.body; + }); + } +}); + + +// Create scrollLeft and scrollTop methods +jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { + var top = /Y/.test( prop ); + + jQuery.fn[ method ] = function( val ) { + return jQuery.access( this, function( elem, method, val ) { + var win = getWindow( elem ); + + if ( val === undefined ) { + return win ? (prop in win) ? win[ prop ] : + win.document.documentElement[ method ] : + elem[ method ]; + } + + if ( win ) { + win.scrollTo( + !top ? val : jQuery( win ).scrollLeft(), + top ? val : jQuery( win ).scrollTop() + ); + + } else { + elem[ method ] = val; + } + }, method, val, arguments.length, null ); + }; +}); + +function getWindow( elem ) { + return jQuery.isWindow( elem ) ? + elem : + elem.nodeType === 9 ? + elem.defaultView || elem.parentWindow : + false; +} +// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods +jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { + jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { + // margin is only for outerHeight, outerWidth + jQuery.fn[ funcName ] = function( margin, value ) { + var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), + extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); + + return jQuery.access( this, function( elem, type, value ) { + var doc; + + if ( jQuery.isWindow( elem ) ) { + // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there + // isn't a whole lot we can do. See pull request at this URL for discussion: + // https://github.com/jquery/jquery/pull/764 + return elem.document.documentElement[ "client" + name ]; + } + + // Get document width or height + if ( elem.nodeType === 9 ) { + doc = elem.documentElement; + + // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest + // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. + return Math.max( + elem.body[ "scroll" + name ], doc[ "scroll" + name ], + elem.body[ "offset" + name ], doc[ "offset" + name ], + doc[ "client" + name ] + ); + } + + return value === undefined ? + // Get width or height on the element, requesting but not forcing parseFloat + jQuery.css( elem, type, value, extra ) : + + // Set width or height on the element + jQuery.style( elem, type, value, extra ); + }, type, chainable ? margin : undefined, chainable, null ); + }; + }); +}); +// Expose jQuery to the global object +window.jQuery = window.$ = jQuery; + +// Expose jQuery as an AMD module, but only for AMD loaders that +// understand the issues with loading multiple versions of jQuery +// in a page that all might call define(). The loader will indicate +// they have special allowances for multiple jQuery versions by +// specifying define.amd.jQuery = true. Register as a named module, +// since jQuery can be concatenated with other files that may use define, +// but not use a proper concatenation script that understands anonymous +// AMD modules. A named AMD is safest and most robust way to register. +// Lowercase jquery is used because AMD module names are derived from +// file names, and jQuery is normally delivered in a lowercase file name. +// Do this after creating the global so that if an AMD module wants to call +// noConflict to hide this version of jQuery, it will work. +if ( typeof define === "function" && define.amd && define.amd.jQuery ) { + define( "jquery", [], function () { return jQuery; } ); +} + +})( window ); diff --git a/webapp/jquery/jquery-ui.css b/webapp/jquery/jquery-ui.css new file mode 100644 index 0000000..a76b9ab --- /dev/null +++ b/webapp/jquery/jquery-ui.css @@ -0,0 +1,470 @@ +/*! jQuery UI - v1.9.0 - 2012-10-05 +* http://jqueryui.com +* Includes: jquery.ui.core.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css +* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } +.ui-helper-clearfix:after { clear: both; } +.ui-helper-clearfix { zoom: 1; } +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } + +.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; } +.ui-accordion .ui-accordion-icons { padding-left: 2.2em; } +.ui-accordion .ui-accordion-noicons { padding-left: .7em; } +.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; } +.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } +.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; } + +.ui-autocomplete { position: absolute; cursor: default; } + +/* workarounds */ +* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ + +.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ +.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; } +.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ +button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ +.ui-button-icons-only { width: 3.4em; } +button.ui-button-icons-only { width: 3.7em; } + +/*button text element */ +.ui-button .ui-button-text { display: block; line-height: 1.4; } +.ui-button-text-only .ui-button-text { padding: .4em 1em; } +.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } +.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } +.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } +.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } +/* no icon support for input elements, provide padding by default */ +input.ui-button { padding: .4em 1em; } + +/*button icon element(s) */ +.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } +.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } +.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } +.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } +.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } + +/*button sets*/ +.ui-buttonset { margin-right: 7px; } +.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } + +/* workarounds */ +button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ + +.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } +.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } +.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } +.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } +.ui-datepicker .ui-datepicker-prev { left:2px; } +.ui-datepicker .ui-datepicker-next { right:2px; } +.ui-datepicker .ui-datepicker-prev-hover { left:1px; } +.ui-datepicker .ui-datepicker-next-hover { right:1px; } +.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } +.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } +.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } +.ui-datepicker select.ui-datepicker-month-year {width: 100%;} +.ui-datepicker select.ui-datepicker-month, +.ui-datepicker select.ui-datepicker-year { width: 49%;} +.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } +.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } +.ui-datepicker td { border: 0; padding: 1px; } +.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } +.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } +.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } +.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } + +/* with multiple calendars */ +.ui-datepicker.ui-datepicker-multi { width:auto; } +.ui-datepicker-multi .ui-datepicker-group { float:left; } +.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } +.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } +.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } +.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } +.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } + +/* RTL support */ +.ui-datepicker-rtl { direction: rtl; } +.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } +.ui-datepicker-rtl .ui-datepicker-group { float:right; } +.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } +.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } + +/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ +.ui-datepicker-cover { + position: absolute; /*must have*/ + z-index: -1; /*must have*/ + filter: mask(); /*must have*/ + top: -4px; /*must have*/ + left: -4px; /*must have*/ + width: 200px; /*must have*/ + height: 200px; /*must have*/ +} +.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } +.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } +.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } +.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } +.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } +.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } +.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } +.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } + +.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; } +.ui-menu .ui-menu { margin-top: -3px; position: absolute; } +.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; } +.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; } +.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; } +.ui-menu .ui-menu-item a.ui-state-focus, +.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; } + +.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; } +.ui-menu .ui-state-disabled a { cursor: default; } + +/* icon support */ +.ui-menu-icons { position: relative; } +.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; } + +/* left-aligned */ +.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; } + +/* right-aligned */ +.ui-menu .ui-menu-icon { position: static; float: right; } + +.ui-progressbar { height:2em; text-align: left; overflow: hidden; } +.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; } +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} +.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } + +.ui-slider { position: relative; text-align: left; } +.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } +.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } + +.ui-slider-horizontal { height: .8em; } +.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } +.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } +.ui-slider-horizontal .ui-slider-range-min { left: 0; } +.ui-slider-horizontal .ui-slider-range-max { right: 0; } + +.ui-slider-vertical { width: .8em; height: 100px; } +.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } +.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } +.ui-slider-vertical .ui-slider-range-min { bottom: 0; } +.ui-slider-vertical .ui-slider-range-max { top: 0; } +.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; } +.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; } +.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; z-index: 100; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; } +.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */ +.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */ +.ui-spinner-up { top: 0; } +.ui-spinner-down { bottom: 0; } + +/* TR overrides */ +span.ui-spinner { background: none; } +.ui-spinner .ui-icon-triangle-1-s { + /* need to fix icons sprite */ + background-position:-65px -16px; +} + +.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ +.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } +.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; } +.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } +.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; } +.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; } +.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ +.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } + +.ui-tooltip { + padding:8px; + position:absolute; + z-index:9999; + -o-box-shadow: 0 0 5px #aaa; + -moz-box-shadow: 0 0 5px #aaa; + -webkit-box-shadow: 0 0 5px #aaa; + box-shadow: 0 0 5px #aaa; +} +/* Fades and background-images don't work well together in IE6, drop the image */ +* html .ui-tooltip { + background-image: none; +} +body .ui-tooltip { border-width:2px; } + +/* Component containers +----------------------------------*/ +.ui-widget { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1.1em/*{fsDefault}*/; } +.ui-widget .ui-widget { font-size: 1em; } +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1em; } +.ui-widget-content { border: 1px solid #aaaaaa/*{borderColorContent}*/; background: #ffffff/*{bgColorContent}*/ url(images/ui-bg_flat_75_ffffff_40x100.png)/*{bgImgUrlContent}*/ 50%/*{bgContentXPos}*/ 50%/*{bgContentYPos}*/ repeat-x/*{bgContentRepeat}*/; color: #222222/*{fcContent}*/; } +.ui-widget-content a { color: #222222/*{fcContent}*/; } +.ui-widget-header { border: 1px solid #aaaaaa/*{borderColorHeader}*/; background: #cccccc/*{bgColorHeader}*/ url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)/*{bgImgUrlHeader}*/ 50%/*{bgHeaderXPos}*/ 50%/*{bgHeaderYPos}*/ repeat-x/*{bgHeaderRepeat}*/; color: #222222/*{fcHeader}*/; font-weight: bold; } +.ui-widget-header a { color: #222222/*{fcHeader}*/; } + +/* Interaction states +----------------------------------*/ +.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(images/ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; } +.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555/*{fcDefault}*/; text-decoration: none; } +.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999/*{borderColorHover}*/; background: #dadada/*{bgColorHover}*/ url(images/ui-bg_glass_75_dadada_1x400.png)/*{bgImgUrlHover}*/ 50%/*{bgHoverXPos}*/ 50%/*{bgHoverYPos}*/ repeat-x/*{bgHoverRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcHover}*/; } +.ui-state-hover a, .ui-state-hover a:hover { color: #212121/*{fcHover}*/; text-decoration: none; } +.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa/*{borderColorActive}*/; background: #ffffff/*{bgColorActive}*/ url(images/ui-bg_glass_65_ffffff_1x400.png)/*{bgImgUrlActive}*/ 50%/*{bgActiveXPos}*/ 50%/*{bgActiveYPos}*/ repeat-x/*{bgActiveRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcActive}*/; } +.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121/*{fcActive}*/; text-decoration: none; } + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1/*{borderColorHighlight}*/; background: #fbf9ee/*{bgColorHighlight}*/ url(images/ui-bg_glass_55_fbf9ee_1x400.png)/*{bgImgUrlHighlight}*/ 50%/*{bgHighlightXPos}*/ 50%/*{bgHighlightYPos}*/ repeat-x/*{bgHighlightRepeat}*/; color: #363636/*{fcHighlight}*/; } +.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636/*{fcHighlight}*/; } +.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a/*{borderColorError}*/; background: #fef1ec/*{bgColorError}*/ url(images/ui-bg_glass_95_fef1ec_1x400.png)/*{bgImgUrlError}*/ 50%/*{bgErrorXPos}*/ 50%/*{bgErrorYPos}*/ repeat-x/*{bgErrorRepeat}*/; color: #cd0a0a/*{fcError}*/; } +.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a/*{fcError}*/; } +.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a/*{fcError}*/; } +.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } +.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } +.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; } +.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; } +.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsHeader}*/; } +.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png)/*{iconsDefault}*/; } +.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsHover}*/; } +.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsActive}*/; } +.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png)/*{iconsHighlight}*/; } +.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png)/*{iconsError}*/; } + +/* positioning */ +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-on { background-position: -96px -144px; } +.ui-icon-radio-off { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-start { background-position: -80px -160px; } +/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px/*{cornerRadius}*/; -webkit-border-top-left-radius: 4px/*{cornerRadius}*/; -khtml-border-top-left-radius: 4px/*{cornerRadius}*/; border-top-left-radius: 4px/*{cornerRadius}*/; } +.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px/*{cornerRadius}*/; -webkit-border-top-right-radius: 4px/*{cornerRadius}*/; -khtml-border-top-right-radius: 4px/*{cornerRadius}*/; border-top-right-radius: 4px/*{cornerRadius}*/; } +.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px/*{cornerRadius}*/; -webkit-border-bottom-left-radius: 4px/*{cornerRadius}*/; -khtml-border-bottom-left-radius: 4px/*{cornerRadius}*/; border-bottom-left-radius: 4px/*{cornerRadius}*/; } +.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px/*{cornerRadius}*/; -webkit-border-bottom-right-radius: 4px/*{cornerRadius}*/; -khtml-border-bottom-right-radius: 4px/*{cornerRadius}*/; border-bottom-right-radius: 4px/*{cornerRadius}*/; } + +/* Overlays */ +.ui-widget-overlay { background: #aaaaaa/*{bgColorOverlay}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlOverlay}*/ 50%/*{bgOverlayXPos}*/ 50%/*{bgOverlayYPos}*/ repeat-x/*{bgOverlayRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityOverlay}*/; } +.ui-widget-shadow { margin: -8px/*{offsetTopShadow}*/ 0 0 -8px/*{offsetLeftShadow}*/; padding: 8px/*{thicknessShadow}*/; background: #aaaaaa/*{bgColorShadow}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlShadow}*/ 50%/*{bgShadowXPos}*/ 50%/*{bgShadowYPos}*/ repeat-x/*{bgShadowRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityShadow}*/; -moz-border-radius: 8px/*{cornerRadiusShadow}*/; -khtml-border-radius: 8px/*{cornerRadiusShadow}*/; -webkit-border-radius: 8px/*{cornerRadiusShadow}*/; border-radius: 8px/*{cornerRadiusShadow}*/; } \ No newline at end of file diff --git a/webapp/jquery/marker.png b/webapp/jquery/marker.png new file mode 100644 index 0000000..3929bbb Binary files /dev/null and b/webapp/jquery/marker.png differ diff --git a/webapp/jquery/mask.png b/webapp/jquery/mask.png new file mode 100644 index 0000000..b0a4d40 Binary files /dev/null and b/webapp/jquery/mask.png differ diff --git a/webapp/jquery/wheel.png b/webapp/jquery/wheel.png new file mode 100644 index 0000000..97b343d Binary files /dev/null and b/webapp/jquery/wheel.png differ diff --git a/webapp/math.js b/webapp/math.js new file mode 100644 index 0000000..26bb8a3 --- /dev/null +++ b/webapp/math.js @@ -0,0 +1,53091 @@ +/** + * math.js + * https://github.com/josdejong/mathjs + * + * Math.js is an extensive math library for JavaScript and Node.js, + * It features real and complex numbers, units, matrices, a large set of + * mathematical functions, and a flexible expression parser. + * + * @version 3.2.1 + * @date 2016-04-26 + * + * @license + * Copyright (C) 2013-2016 Jos de Jong + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["math"] = factory(); + else + root["math"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + var core = __webpack_require__(1); + + /** + * math.js factory function. Creates a new instance of math.js + * + * @param {Object} [config] Available configuration options: + * {number} epsilon + * Minimum relative difference between two + * compared values, used by all comparison functions. + * {string} matrix + * A string 'matrix' (default) or 'array'. + * {string} number + * A string 'number' (default), 'bignumber', or + * 'fraction' + * {number} precision + * The number of significant digits for BigNumbers. + * Not applicable for Numbers. + * {boolean} predictable + * Predictable output type of functions. When true, + * output type depends only on the input types. When + * false (default), output type can vary depending + * on input values. For example `math.sqrt(-2)` + * returns `NaN` when predictable is false, and + * returns `complex('2i')` when true. + */ + function create (config) { + // create a new math.js instance + var math = core.create(config); + math.create = create; + + // import data types, functions, constants, expression parser, etc. + math['import'](__webpack_require__(13)); + + return math; + } + + // return a new instance of math.js + module.exports = create(); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(2); + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + var isFactory = __webpack_require__(3).isFactory; + var deepExtend = __webpack_require__(3).deepExtend; + var typedFactory = __webpack_require__(4); + var emitter = __webpack_require__(8); + + var importFactory = __webpack_require__(10); + var configFactory = __webpack_require__(12); + + /** + * Math.js core. Creates a new, empty math.js instance + * @param {Object} [options] Available options: + * {number} epsilon + * Minimum relative difference between two + * compared values, used by all comparison functions. + * {string} matrix + * A string 'Matrix' (default) or 'Array'. + * {string} number + * A string 'number' (default), 'BigNumber', or 'Fraction' + * {number} precision + * The number of significant digits for BigNumbers. + * Not applicable for Numbers. + * {boolean} predictable + * Predictable output type of functions. When true, + * output type depends only on the input types. When + * false (default), output type can vary depending + * on input values. For example `math.sqrt(-2)` + * returns `NaN` when predictable is false, and + * returns `complex('2i')` when true. + * @returns {Object} Returns a bare-bone math.js instance containing + * functions: + * - `import` to add new functions + * - `config` to change configuration + * - `on`, `off`, `once`, `emit` for events + */ + exports.create = function create (options) { + // simple test for ES5 support + if (typeof Object.create !== 'function') { + throw new Error('ES5 not supported by this JavaScript engine. ' + + 'Please load the es5-shim and es5-sham library for compatibility.'); + } + + // cached factories and instances + var factories = []; + var instances = []; + + // create a namespace for the mathjs instance, and attach emitter functions + var math = emitter.mixin({}); + math.type = {}; + math.expression = { + transform: Object.create(math) + }; + + // create a new typed instance + math.typed = typedFactory.create(math.type); + + // create configuration options. These are private + var _config = { + // minimum relative difference between two compared values, + // used by all comparison functions + epsilon: 1e-12, + + // type of default matrix output. Choose 'matrix' (default) or 'array' + matrix: 'Matrix', + + // type of default number output. Choose 'number' (default) 'BigNumber', or 'Fraction + number: 'number', + + // number of significant digits in BigNumbers + precision: 64, + + // predictable output type of functions. When true, output type depends only + // on the input types. When false (default), output type can vary depending + // on input values. For example `math.sqrt(-2)` returns `NaN` when + // predictable is false, and returns `complex('2i')` when true. + predictable: false + }; + + /** + * Load a function or data type from a factory. + * If the function or data type already exists, the existing instance is + * returned. + * @param {{type: string, name: string, factory: Function}} factory + * @returns {*} + */ + function load (factory) { + if (!isFactory(factory)) { + throw new Error('Factory object with properties `type`, `name`, and `factory` expected'); + } + + var index = factories.indexOf(factory); + var instance; + if (index === -1) { + // doesn't yet exist + if (factory.math === true) { + // pass with math namespace + instance = factory.factory(math.type, _config, load, math.typed, math); + } + else { + instance = factory.factory(math.type, _config, load, math.typed); + } + + // append to the cache + factories.push(factory); + instances.push(instance); + } + else { + // already existing function, return the cached instance + instance = instances[index]; + } + + return instance; + } + + // load the import and config functions + math['import'] = load(importFactory); + math['config'] = load(configFactory); + + // apply options + if (options) { + math.config(options); + } + + return math; + }; + + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Clone an object + * + * clone(x) + * + * Can clone any primitive type, array, and object. + * If x has a function clone, this function will be invoked to clone the object. + * + * @param {*} x + * @return {*} clone + */ + exports.clone = function clone(x) { + var type = typeof x; + + // immutable primitive types + if (type === 'number' || type === 'string' || type === 'boolean' || + x === null || x === undefined) { + return x; + } + + // use clone function of the object when available + if (typeof x.clone === 'function') { + return x.clone(); + } + + // array + if (Array.isArray(x)) { + return x.map(function (value) { + return clone(value); + }); + } + + if (x instanceof Number) return new Number(x.valueOf()); + if (x instanceof String) return new String(x.valueOf()); + if (x instanceof Boolean) return new Boolean(x.valueOf()); + if (x instanceof Date) return new Date(x.valueOf()); + if (x && x.isBigNumber === true) return x; // bignumbers are immutable + if (x instanceof RegExp) throw new TypeError('Cannot clone ' + x); // TODO: clone a RegExp + + // object + var m = {}; + for (var key in x) { + if (x.hasOwnProperty(key)) { + m[key] = clone(x[key]); + } + } + return m; + }; + + /** + * Extend object a with the properties of object b + * @param {Object} a + * @param {Object} b + * @return {Object} a + */ + exports.extend = function(a, b) { + for (var prop in b) { + if (b.hasOwnProperty(prop)) { + a[prop] = b[prop]; + } + } + return a; + }; + + /** + * Deep extend an object a with the properties of object b + * @param {Object} a + * @param {Object} b + * @returns {Object} + */ + exports.deepExtend = function deepExtend (a, b) { + // TODO: add support for Arrays to deepExtend + if (Array.isArray(b)) { + throw new TypeError('Arrays are not supported by deepExtend'); + } + + for (var prop in b) { + if (b.hasOwnProperty(prop)) { + if (b[prop] && b[prop].constructor === Object) { + if (a[prop] === undefined) { + a[prop] = {}; + } + if (a[prop].constructor === Object) { + deepExtend(a[prop], b[prop]); + } + else { + a[prop] = b[prop]; + } + } else if (Array.isArray(b[prop])) { + throw new TypeError('Arrays are not supported by deepExtend'); + } else { + a[prop] = b[prop]; + } + } + } + return a; + }; + + /** + * Deep test equality of all fields in two pairs of arrays or objects. + * @param {Array | Object} a + * @param {Array | Object} b + * @returns {boolean} + */ + exports.deepEqual = function deepEqual (a, b) { + var prop, i, len; + if (Array.isArray(a)) { + if (!Array.isArray(b)) { + return false; + } + + if (a.length != b.length) { + return false; + } + + for (i = 0, len = a.length; i < len; i++) { + if (!exports.deepEqual(a[i], b[i])) { + return false; + } + } + return true; + } + else if (a instanceof Object) { + if (Array.isArray(b) || !(b instanceof Object)) { + return false; + } + + for (prop in a) { + //noinspection JSUnfilteredForInLoop + if (!exports.deepEqual(a[prop], b[prop])) { + return false; + } + } + for (prop in b) { + //noinspection JSUnfilteredForInLoop + if (!exports.deepEqual(a[prop], b[prop])) { + return false; + } + } + return true; + } + else { + return (typeof a === typeof b) && (a == b); + } + }; + + /** + * Test whether the current JavaScript engine supports Object.defineProperty + * @returns {boolean} returns true if supported + */ + exports.canDefineProperty = function () { + // test needed for broken IE8 implementation + try { + if (Object.defineProperty) { + Object.defineProperty({}, 'x', { get: function () {} }); + return true; + } + } catch (e) {} + + return false; + }; + + /** + * Attach a lazy loading property to a constant. + * The given function `fn` is called once when the property is first requested. + * On older browsers (15 digits + if (digits(x) > 15) { + throw new TypeError('Cannot implicitly convert a number with >15 significant digits to BigNumber ' + + '(value: ' + x + '). ' + + 'Use function bignumber(x) to convert to BigNumber.'); + } + return new type.BigNumber(x); + } + }, { + from: 'number', + to: 'Complex', + convert: function (x) { + return new type.Complex(x, 0); + } + }, { + from: 'number', + to: 'string', + convert: function (x) { + return x + ''; + } + }, { + from: 'BigNumber', + to: 'Complex', + convert: function (x) { + return new type.Complex(x.toNumber(), 0); + } + }, { + from: 'Fraction', + to: 'Complex', + convert: function (x) { + return new type.Complex(x.valueOf(), 0); + } + }, { + from: 'number', + to: 'Fraction', + convert: function (x) { + if (digits(x) > 15) { + throw new TypeError('Cannot implicitly convert a number with >15 significant digits to Fraction ' + + '(value: ' + x + '). ' + + 'Use function fraction(x) to convert to Fraction.'); + } + return new type.Fraction(x); + } + }, { + // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))` + // from: 'Fraction', + // to: 'number', + // convert: function (x) { + // return x.valueOf(); + // } + //}, { + from: 'string', + to: 'number', + convert: function (x) { + var n = Number(x); + if (isNaN(n)) { + throw new Error('Cannot convert "' + x + '" to a number'); + } + return n; + } + }, { + from: 'boolean', + to: 'number', + convert: function (x) { + return +x; + } + }, { + from: 'boolean', + to: 'BigNumber', + convert: function (x) { + return new type.BigNumber(+x); + } + }, { + from: 'boolean', + to: 'Fraction', + convert: function (x) { + return new type.Fraction(+x); + } + }, { + from: 'boolean', + to: 'string', + convert: function (x) { + return +x; + } + }, { + from: 'null', + to: 'number', + convert: function () { + return 0; + } + }, { + from: 'null', + to: 'string', + convert: function () { + return 'null'; + } + }, { + from: 'null', + to: 'BigNumber', + convert: function () { + return new type.BigNumber(0); + } + }, { + from: 'null', + to: 'Fraction', + convert: function () { + return new type.Fraction(0); + } + }, { + from: 'Array', + to: 'Matrix', + convert: function (array) { + // TODO: how to decide on the right type of matrix to create? + return new type.DenseMatrix(array); + } + }, { + from: 'Matrix', + to: 'Array', + convert: function (matrix) { + return matrix.valueOf(); + } + } + ]; + + return typed; + }; + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** + * typed-function + * + * Type checking for JavaScript functions + * + * https://github.com/josdejong/typed-function + */ + 'use strict'; + + (function (root, factory) { + if (true) { + // AMD. Register as an anonymous module. + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports === 'object') { + // OldNode. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like OldNode. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.typed = factory(); + } + }(this, function () { + // factory function to create a new instance of typed-function + // TODO: allow passing configuration, types, tests via the factory function + function create() { + /** + * Get a type test function for a specific data type + * @param {string} name Name of a data type like 'number' or 'string' + * @returns {Function(obj: *) : boolean} Returns a type testing function. + * Throws an error for an unknown type. + */ + function getTypeTest(name) { + var test; + for (var i = 0; i < typed.types.length; i++) { + var entry = typed.types[i]; + if (entry.name === name) { + test = entry.test; + break; + } + } + + if (!test) { + var hint; + for (i = 0; i < typed.types.length; i++) { + entry = typed.types[i]; + if (entry.name.toLowerCase() == name.toLowerCase()) { + hint = entry.name; + break; + } + } + + throw new Error('Unknown type "' + name + '"' + + (hint ? ('. Did you mean "' + hint + '"?') : '')); + } + return test; + } + + /** + * Retrieve the function name from a set of functions, and check + * whether the name of all functions match (if given) + * @param {Array.} fns + */ + function getName (fns) { + var name = ''; + + for (var i = 0; i < fns.length; i++) { + var fn = fns[i]; + + // merge function name when this is a typed function + if (fn.signatures && fn.name != '') { + if (name == '') { + name = fn.name; + } + else if (name != fn.name) { + var err = new Error('Function names do not match (expected: ' + name + ', actual: ' + fn.name + ')'); + err.data = { + actual: fn.name, + expected: name + }; + throw err; + } + } + } + + return name; + } + + /** + * Create an ArgumentsError. Creates messages like: + * + * Unexpected type of argument (expected: ..., actual: ..., index: ...) + * Too few arguments (expected: ..., index: ...) + * Too many arguments (expected: ..., actual: ...) + * + * @param {String} fn Function name + * @param {number} argCount Number of arguments + * @param {Number} index Current argument index + * @param {*} actual Current argument + * @param {string} [expected] An optional, comma separated string with + * expected types on given index + * @extends Error + */ + function createError(fn, argCount, index, actual, expected) { + var actualType = getTypeOf(actual); + var _expected = expected ? expected.split(',') : null; + var _fn = (fn || 'unnamed'); + var anyType = _expected && contains(_expected, 'any'); + var message; + var data = { + fn: fn, + index: index, + actual: actual, + expected: _expected + }; + + if (_expected) { + if (argCount > index && !anyType) { + // unexpected type + message = 'Unexpected type of argument in function ' + _fn + + ' (expected: ' + _expected.join(' or ') + ', actual: ' + actualType + ', index: ' + index + ')'; + } + else { + // too few arguments + message = 'Too few arguments in function ' + _fn + + ' (expected: ' + _expected.join(' or ') + ', index: ' + index + ')'; + } + } + else { + // too many arguments + message = 'Too many arguments in function ' + _fn + + ' (expected: ' + index + ', actual: ' + argCount + ')' + } + + var err = new TypeError(message); + err.data = data; + return err; + } + + /** + * Collection with function references (local shortcuts to functions) + * @constructor + * @param {string} [name='refs'] Optional name for the refs, used to generate + * JavaScript code + */ + function Refs(name) { + this.name = name || 'refs'; + this.categories = {}; + } + + /** + * Add a function reference. + * @param {Function} fn + * @param {string} [category='fn'] A function category, like 'fn' or 'signature' + * @returns {string} Returns the function name, for example 'fn0' or 'signature2' + */ + Refs.prototype.add = function (fn, category) { + var cat = category || 'fn'; + if (!this.categories[cat]) this.categories[cat] = []; + + var index = this.categories[cat].indexOf(fn); + if (index == -1) { + index = this.categories[cat].length; + this.categories[cat].push(fn); + } + + return cat + index; + }; + + /** + * Create code lines for all function references + * @returns {string} Returns the code containing all function references + */ + Refs.prototype.toCode = function () { + var code = []; + var path = this.name + '.categories'; + var categories = this.categories; + + for (var cat in categories) { + if (categories.hasOwnProperty(cat)) { + var category = categories[cat]; + + for (var i = 0; i < category.length; i++) { + code.push('var ' + cat + i + ' = ' + path + '[\'' + cat + '\'][' + i + '];'); + } + } + } + + return code.join('\n'); + }; + + /** + * A function parameter + * @param {string | string[] | Param} types A parameter type like 'string', + * 'number | boolean' + * @param {boolean} [varArgs=false] Variable arguments if true + * @constructor + */ + function Param(types, varArgs) { + // parse the types, can be a string with types separated by pipe characters | + if (typeof types === 'string') { + // parse variable arguments operator (ellipses '...number') + var _types = types.trim(); + var _varArgs = _types.substr(0, 3) === '...'; + if (_varArgs) { + _types = _types.substr(3); + } + if (_types === '') { + this.types = ['any']; + } + else { + this.types = _types.split('|'); + for (var i = 0; i < this.types.length; i++) { + this.types[i] = this.types[i].trim(); + } + } + } + else if (Array.isArray(types)) { + this.types = types; + } + else if (types instanceof Param) { + return types.clone(); + } + else { + throw new Error('String or Array expected'); + } + + // can hold a type to which to convert when handling this parameter + this.conversions = []; + // TODO: implement better API for conversions, be able to add conversions via constructor (support a new type Object?) + + // variable arguments + this.varArgs = _varArgs || varArgs || false; + + // check for any type arguments + this.anyType = this.types.indexOf('any') !== -1; + } + + /** + * Order Params + * any type ('any') will be ordered last, and object as second last (as other + * types may be an object as well, like Array). + * + * @param {Param} a + * @param {Param} b + * @returns {number} Returns 1 if a > b, -1 if a < b, and else 0. + */ + Param.compare = function (a, b) { + // TODO: simplify parameter comparison, it's a mess + if (a.anyType) return 1; + if (b.anyType) return -1; + + if (contains(a.types, 'Object')) return 1; + if (contains(b.types, 'Object')) return -1; + + if (a.hasConversions()) { + if (b.hasConversions()) { + var i, ac, bc; + + for (i = 0; i < a.conversions.length; i++) { + if (a.conversions[i] !== undefined) { + ac = a.conversions[i]; + break; + } + } + + for (i = 0; i < b.conversions.length; i++) { + if (b.conversions[i] !== undefined) { + bc = b.conversions[i]; + break; + } + } + + return typed.conversions.indexOf(ac) - typed.conversions.indexOf(bc); + } + else { + return 1; + } + } + else { + if (b.hasConversions()) { + return -1; + } + else { + // both params have no conversions + var ai, bi; + + for (i = 0; i < typed.types.length; i++) { + if (typed.types[i].name === a.types[0]) { + ai = i; + break; + } + } + + for (i = 0; i < typed.types.length; i++) { + if (typed.types[i].name === b.types[0]) { + bi = i; + break; + } + } + + return ai - bi; + } + } + }; + + /** + * Test whether this parameters types overlap an other parameters types. + * @param {Param} other + * @return {boolean} Returns true when there are conflicting types + */ + Param.prototype.overlapping = function (other) { + for (var i = 0; i < this.types.length; i++) { + if (contains(other.types, this.types[i])) { + return true; + } + } + return false; + }; + + /** + * Create a clone of this param + * @returns {Param} Returns a cloned version of this param + */ + Param.prototype.clone = function () { + var param = new Param(this.types.slice(), this.varArgs); + param.conversions = this.conversions.slice(); + return param; + }; + + /** + * Test whether this parameter contains conversions + * @returns {boolean} Returns true if the parameter contains one or + * multiple conversions. + */ + Param.prototype.hasConversions = function () { + return this.conversions.length > 0; + }; + + /** + * Tests whether this parameters contains any of the provided types + * @param {Object} types A Map with types, like {'number': true} + * @returns {boolean} Returns true when the parameter contains any + * of the provided types + */ + Param.prototype.contains = function (types) { + for (var i = 0; i < this.types.length; i++) { + if (types[this.types[i]]) { + return true; + } + } + return false; + }; + + /** + * Return a string representation of this params types, like 'string' or + * 'number | boolean' or '...number' + * @param {boolean} [toConversion] If true, the returned types string + * contains the types where the parameter + * will convert to. If false (default) + * the "from" types are returned + * @returns {string} + */ + Param.prototype.toString = function (toConversion) { + var types = []; + var keys = {}; + + for (var i = 0; i < this.types.length; i++) { + var conversion = this.conversions[i]; + var type = toConversion && conversion ? conversion.to : this.types[i]; + if (!(type in keys)) { + keys[type] = true; + types.push(type); + } + } + + return (this.varArgs ? '...' : '') + types.join('|'); + }; + + /** + * A function signature + * @param {string | string[] | Param[]} params + * Array with the type(s) of each parameter, + * or a comma separated string with types + * @param {Function} fn The actual function + * @constructor + */ + function Signature(params, fn) { + var _params; + if (typeof params === 'string') { + _params = (params !== '') ? params.split(',') : []; + } + else if (Array.isArray(params)) { + _params = params; + } + else { + throw new Error('string or Array expected'); + } + + this.params = new Array(_params.length); + for (var i = 0; i < _params.length; i++) { + var param = new Param(_params[i]); + this.params[i] = param; + if (i === _params.length - 1) { + // the last argument + this.varArgs = param.varArgs; + } + else { + // non-last argument + if (param.varArgs) { + throw new SyntaxError('Unexpected variable arguments operator "..."'); + } + } + } + + this.fn = fn; + } + + /** + * Create a clone of this signature + * @returns {Signature} Returns a cloned version of this signature + */ + Signature.prototype.clone = function () { + return new Signature(this.params.slice(), this.fn); + }; + + /** + * Expand a signature: split params with union types in separate signatures + * For example split a Signature "string | number" into two signatures. + * @return {Signature[]} Returns an array with signatures (at least one) + */ + Signature.prototype.expand = function () { + var signatures = []; + + function recurse(signature, path) { + if (path.length < signature.params.length) { + var i, newParam, conversion; + + var param = signature.params[path.length]; + if (param.varArgs) { + // a variable argument. do not split the types in the parameter + newParam = param.clone(); + + // add conversions to the parameter + // recurse for all conversions + for (i = 0; i < typed.conversions.length; i++) { + conversion = typed.conversions[i]; + if (!contains(param.types, conversion.from) && contains(param.types, conversion.to)) { + var j = newParam.types.length; + newParam.types[j] = conversion.from; + newParam.conversions[j] = conversion; + } + } + + recurse(signature, path.concat(newParam)); + } + else { + // split each type in the parameter + for (i = 0; i < param.types.length; i++) { + recurse(signature, path.concat(new Param(param.types[i]))); + } + + // recurse for all conversions + for (i = 0; i < typed.conversions.length; i++) { + conversion = typed.conversions[i]; + if (!contains(param.types, conversion.from) && contains(param.types, conversion.to)) { + newParam = new Param(conversion.from); + newParam.conversions[0] = conversion; + recurse(signature, path.concat(newParam)); + } + } + } + } + else { + signatures.push(new Signature(path, signature.fn)); + } + } + + recurse(this, []); + + return signatures; + }; + + /** + * Compare two signatures. + * + * When two params are equal and contain conversions, they will be sorted + * by lowest index of the first conversions. + * + * @param {Signature} a + * @param {Signature} b + * @returns {number} Returns 1 if a > b, -1 if a < b, and else 0. + */ + Signature.compare = function (a, b) { + if (a.params.length > b.params.length) return 1; + if (a.params.length < b.params.length) return -1; + + // count the number of conversions + var i; + var len = a.params.length; // a and b have equal amount of params + var ac = 0; + var bc = 0; + for (i = 0; i < len; i++) { + if (a.params[i].hasConversions()) ac++; + if (b.params[i].hasConversions()) bc++; + } + + if (ac > bc) return 1; + if (ac < bc) return -1; + + // compare the order per parameter + for (i = 0; i < a.params.length; i++) { + var cmp = Param.compare(a.params[i], b.params[i]); + if (cmp !== 0) { + return cmp; + } + } + + return 0; + }; + + /** + * Test whether any of the signatures parameters has conversions + * @return {boolean} Returns true when any of the parameters contains + * conversions. + */ + Signature.prototype.hasConversions = function () { + for (var i = 0; i < this.params.length; i++) { + if (this.params[i].hasConversions()) { + return true; + } + } + return false; + }; + + /** + * Test whether this signature should be ignored. + * Checks whether any of the parameters contains a type listed in + * typed.ignore + * @return {boolean} Returns true when the signature should be ignored + */ + Signature.prototype.ignore = function () { + // create a map with ignored types + var types = {}; + for (var i = 0; i < typed.ignore.length; i++) { + types[typed.ignore[i]] = true; + } + + // test whether any of the parameters contains this type + for (i = 0; i < this.params.length; i++) { + if (this.params[i].contains(types)) { + return true; + } + } + + return false; + }; + + /** + * Generate the code to invoke this signature + * @param {Refs} refs + * @param {string} prefix + * @returns {string} Returns code + */ + Signature.prototype.toCode = function (refs, prefix) { + var code = []; + + var args = new Array(this.params.length); + for (var i = 0; i < this.params.length; i++) { + var param = this.params[i]; + var conversion = param.conversions[0]; + if (param.varArgs) { + args[i] = 'varArgs'; + } + else if (conversion) { + args[i] = refs.add(conversion.convert, 'convert') + '(arg' + i + ')'; + } + else { + args[i] = 'arg' + i; + } + } + + var ref = this.fn ? refs.add(this.fn, 'signature') : undefined; + if (ref) { + return prefix + 'return ' + ref + '(' + args.join(', ') + '); // signature: ' + this.params.join(', '); + } + + return code.join('\n'); + }; + + /** + * Return a string representation of the signature + * @returns {string} + */ + Signature.prototype.toString = function () { + return this.params.join(', '); + }; + + /** + * A group of signatures with the same parameter on given index + * @param {Param[]} path + * @param {Signature} [signature] + * @param {Node[]} childs + * @constructor + */ + function Node(path, signature, childs) { + this.path = path || []; + this.param = path[path.length - 1] || null; + this.signature = signature || null; + this.childs = childs || []; + } + + /** + * Generate code for this group of signatures + * @param {Refs} refs + * @param {string} prefix + * @param {Node | undefined} [anyType] Sibling of this node with any type parameter + * @returns {string} Returns the code as string + */ + Node.prototype.toCode = function (refs, prefix, anyType) { + // TODO: split this function in multiple functions, it's too large + var code = []; + + if (this.param) { + var index = this.path.length - 1; + var conversion = this.param.conversions[0]; + var comment = '// type: ' + (conversion ? + (conversion.from + ' (convert to ' + conversion.to + ')') : + this.param); + + // non-root node (path is non-empty) + if (this.param.varArgs) { + if (this.param.anyType) { + // variable arguments with any type + code.push(prefix + 'if (arguments.length > ' + index + ') {'); + code.push(prefix + ' var varArgs = [];'); + code.push(prefix + ' for (var i = ' + index + '; i < arguments.length; i++) {'); + code.push(prefix + ' varArgs.push(arguments[i]);'); + code.push(prefix + ' }'); + code.push(this.signature.toCode(refs, prefix + ' ')); + code.push(prefix + '}'); + } + else { + // variable arguments with a fixed type + var getTests = function (types, arg) { + var tests = []; + for (var i = 0; i < types.length; i++) { + tests[i] = refs.add(getTypeTest(types[i]), 'test') + '(' + arg + ')'; + } + return tests.join(' || '); + }.bind(this); + + var allTypes = this.param.types; + var exactTypes = []; + for (var i = 0; i < allTypes.length; i++) { + if (this.param.conversions[i] === undefined) { + exactTypes.push(allTypes[i]); + } + } + + code.push(prefix + 'if (' + getTests(allTypes, 'arg' + index) + ') { ' + comment); + code.push(prefix + ' var varArgs = [arg' + index + '];'); + code.push(prefix + ' for (var i = ' + (index + 1) + '; i < arguments.length; i++) {'); + code.push(prefix + ' if (' + getTests(exactTypes, 'arguments[i]') + ') {'); + code.push(prefix + ' varArgs.push(arguments[i]);'); + + for (var i = 0; i < allTypes.length; i++) { + var conversion_i = this.param.conversions[i]; + if (conversion_i) { + var test = refs.add(getTypeTest(allTypes[i]), 'test'); + var convert = refs.add(conversion_i.convert, 'convert'); + code.push(prefix + ' }'); + code.push(prefix + ' else if (' + test + '(arguments[i])) {'); + code.push(prefix + ' varArgs.push(' + convert + '(arguments[i]));'); + } + } + code.push(prefix + ' } else {'); + code.push(prefix + ' throw createError(name, arguments.length, i, arguments[i], \'' + exactTypes.join(',') + '\');'); + code.push(prefix + ' }'); + code.push(prefix + ' }'); + code.push(this.signature.toCode(refs, prefix + ' ')); + code.push(prefix + '}'); + } + } + else { + if (this.param.anyType) { + // any type + code.push(prefix + '// type: any'); + code.push(this._innerCode(refs, prefix, anyType)); + } + else { + // regular type + var type = this.param.types[0]; + var test = type !== 'any' ? refs.add(getTypeTest(type), 'test') : null; + + code.push(prefix + 'if (' + test + '(arg' + index + ')) { ' + comment); + code.push(this._innerCode(refs, prefix + ' ', anyType)); + code.push(prefix + '}'); + } + } + } + else { + // root node (path is empty) + code.push(this._innerCode(refs, prefix, anyType)); + } + + return code.join('\n'); + }; + + /** + * Generate inner code for this group of signatures. + * This is a helper function of Node.prototype.toCode + * @param {Refs} refs + * @param {string} prefix + * @param {Node | undefined} [anyType] Sibling of this node with any type parameter + * @returns {string} Returns the inner code as string + * @private + */ + Node.prototype._innerCode = function (refs, prefix, anyType) { + var code = []; + var i; + + if (this.signature) { + code.push(prefix + 'if (arguments.length === ' + this.path.length + ') {'); + code.push(this.signature.toCode(refs, prefix + ' ')); + code.push(prefix + '}'); + } + + var nextAnyType; + for (i = 0; i < this.childs.length; i++) { + if (this.childs[i].param.anyType) { + nextAnyType = this.childs[i]; + break; + } + } + + for (i = 0; i < this.childs.length; i++) { + code.push(this.childs[i].toCode(refs, prefix, nextAnyType)); + } + + if (anyType && !this.param.anyType) { + code.push(anyType.toCode(refs, prefix, nextAnyType)); + } + + var exceptions = this._exceptions(refs, prefix); + if (exceptions) { + code.push(exceptions); + } + + return code.join('\n'); + }; + + /** + * Generate code to throw exceptions + * @param {Refs} refs + * @param {string} prefix + * @returns {string} Returns the inner code as string + * @private + */ + Node.prototype._exceptions = function (refs, prefix) { + var index = this.path.length; + + if (this.childs.length === 0) { + // TODO: can this condition be simplified? (we have a fall-through here) + return [ + prefix + 'if (arguments.length > ' + index + ') {', + prefix + ' throw createError(name, arguments.length, ' + index + ', arguments[' + index + ']);', + prefix + '}' + ].join('\n'); + } + else { + var keys = {}; + var types = []; + + for (var i = 0; i < this.childs.length; i++) { + var node = this.childs[i]; + if (node.param) { + for (var j = 0; j < node.param.types.length; j++) { + var type = node.param.types[j]; + if (!(type in keys) && !node.param.conversions[j]) { + keys[type] = true; + types.push(type); + } + } + } + } + + return prefix + 'throw createError(name, arguments.length, ' + index + ', arguments[' + index + '], \'' + types.join(',') + '\');'; + } + }; + + /** + * Split all raw signatures into an array with expanded Signatures + * @param {Object.} rawSignatures + * @return {Signature[]} Returns an array with expanded signatures + */ + function parseSignatures(rawSignatures) { + // FIXME: need to have deterministic ordering of signatures, do not create via object + var signature; + var keys = {}; + var signatures = []; + var i; + + for (var types in rawSignatures) { + if (rawSignatures.hasOwnProperty(types)) { + var fn = rawSignatures[types]; + signature = new Signature(types, fn); + + if (signature.ignore()) { + continue; + } + + var expanded = signature.expand(); + + for (i = 0; i < expanded.length; i++) { + var signature_i = expanded[i]; + var key = signature_i.toString(); + var existing = keys[key]; + if (!existing) { + keys[key] = signature_i; + } + else { + var cmp = Signature.compare(signature_i, existing); + if (cmp < 0) { + // override if sorted first + keys[key] = signature_i; + } + else if (cmp === 0) { + throw new Error('Signature "' + key + '" is defined twice'); + } + // else: just ignore + } + } + } + } + + // convert from map to array + for (key in keys) { + if (keys.hasOwnProperty(key)) { + signatures.push(keys[key]); + } + } + + // order the signatures + signatures.sort(function (a, b) { + return Signature.compare(a, b); + }); + + // filter redundant conversions from signatures with varArgs + // TODO: simplify this loop or move it to a separate function + for (i = 0; i < signatures.length; i++) { + signature = signatures[i]; + + if (signature.varArgs) { + var index = signature.params.length - 1; + var param = signature.params[index]; + + var t = 0; + while (t < param.types.length) { + if (param.conversions[t]) { + var type = param.types[t]; + + for (var j = 0; j < signatures.length; j++) { + var other = signatures[j]; + var p = other.params[index]; + + if (other !== signature && + p && + contains(p.types, type) && !p.conversions[index]) { + // this (conversion) type already exists, remove it + param.types.splice(t, 1); + param.conversions.splice(t, 1); + t--; + break; + } + } + } + t++; + } + } + } + + return signatures; + } + + /** + * create a map with normalized signatures as key and the function as value + * @param {Signature[]} signatures An array with split signatures + * @return {Object.} Returns a map with normalized + * signatures as key, and the function + * as value. + */ + function mapSignatures(signatures) { + var normalized = {}; + + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signature.fn && !signature.hasConversions()) { + var params = signature.params.join(','); + normalized[params] = signature.fn; + } + } + + return normalized; + } + + /** + * Parse signatures recursively in a node tree. + * @param {Signature[]} signatures Array with expanded signatures + * @param {Param[]} path Traversed path of parameter types + * @return {Node} Returns a node tree + */ + function parseTree(signatures, path) { + var i, signature; + var index = path.length; + var nodeSignature; + + var filtered = []; + for (i = 0; i < signatures.length; i++) { + signature = signatures[i]; + + // filter the first signature with the correct number of params + if (signature.params.length === index && !nodeSignature) { + nodeSignature = signature; + } + + if (signature.params[index] != undefined) { + filtered.push(signature); + } + } + + // sort the filtered signatures by param + filtered.sort(function (a, b) { + return Param.compare(a.params[index], b.params[index]); + }); + + // recurse over the signatures + var entries = []; + for (i = 0; i < filtered.length; i++) { + signature = filtered[i]; + // group signatures with the same param at current index + var param = signature.params[index]; + + // TODO: replace the next filter loop + var existing = entries.filter(function (entry) { + return entry.param.overlapping(param); + })[0]; + + //var existing; + //for (var j = 0; j < entries.length; j++) { + // if (entries[j].param.overlapping(param)) { + // existing = entries[j]; + // break; + // } + //} + + if (existing) { + if (existing.param.varArgs) { + throw new Error('Conflicting types "' + existing.param + '" and "' + param + '"'); + } + existing.signatures.push(signature); + } + else { + entries.push({ + param: param, + signatures: [signature] + }); + } + } + + // parse the childs + var childs = new Array(entries.length); + for (i = 0; i < entries.length; i++) { + var entry = entries[i]; + childs[i] = parseTree(entry.signatures, path.concat(entry.param)) + } + + return new Node(path, nodeSignature, childs); + } + + /** + * Generate an array like ['arg0', 'arg1', 'arg2'] + * @param {number} count Number of arguments to generate + * @returns {Array} Returns an array with argument names + */ + function getArgs(count) { + // create an array with all argument names + var args = []; + for (var i = 0; i < count; i++) { + args[i] = 'arg' + i; + } + + return args; + } + + /** + * Compose a function from sub-functions each handling a single type signature. + * Signatures: + * typed(signature: string, fn: function) + * typed(name: string, signature: string, fn: function) + * typed(signatures: Object.) + * typed(name: string, signatures: Object.) + * + * @param {string | null} name + * @param {Object.} signatures + * @return {Function} Returns the typed function + * @private + */ + function _typed(name, signatures) { + var refs = new Refs(); + + // parse signatures, expand them + var _signatures = parseSignatures(signatures); + if (_signatures.length == 0) { + throw new Error('No signatures provided'); + } + + // parse signatures into a node tree + var node = parseTree(_signatures, []); + + //var util = require('util'); + //console.log('ROOT'); + //console.log(util.inspect(node, { depth: null })); + + // generate code for the typed function + var code = []; + var _name = name || ''; + var _args = getArgs(maxParams(_signatures)); + code.push('function ' + _name + '(' + _args.join(', ') + ') {'); + code.push(' "use strict";'); + code.push(' var name = \'' + _name + '\';'); + code.push(node.toCode(refs, ' ')); + code.push('}'); + + // generate body for the factory function + var body = [ + refs.toCode(), + 'return ' + code.join('\n') + ].join('\n'); + + // evaluate the JavaScript code and attach function references + var factory = (new Function(refs.name, 'createError', body)); + var fn = factory(refs, createError); + + //console.log('FN\n' + fn.toString()); // TODO: cleanup + + // attach the signatures with sub-functions to the constructed function + fn.signatures = mapSignatures(_signatures); + + return fn; + } + + /** + * Calculate the maximum number of parameters in givens signatures + * @param {Signature[]} signatures + * @returns {number} The maximum number of parameters + */ + function maxParams(signatures) { + var max = 0; + + for (var i = 0; i < signatures.length; i++) { + var len = signatures[i].params.length; + if (len > max) { + max = len; + } + } + + return max; + } + + /** + * Get the type of a value + * @param {*} x + * @returns {string} Returns a string with the type of value + */ + function getTypeOf(x) { + var obj; + + for (var i = 0; i < typed.types.length; i++) { + var entry = typed.types[i]; + + if (entry.name === 'Object') { + // Array and Date are also Object, so test for Object afterwards + obj = entry; + } + else { + if (entry.test(x)) return entry.name; + } + } + + // at last, test whether an object + if (obj && obj.test(x)) return obj.name; + + return 'unknown'; + } + + /** + * Test whether an array contains some entry + * @param {Array} array + * @param {*} entry + * @return {boolean} Returns true if array contains entry, false if not. + */ + function contains(array, entry) { + return array.indexOf(entry) !== -1; + } + + // data type tests + var types = [ + { name: 'number', test: function (x) { return typeof x === 'number' } }, + { name: 'string', test: function (x) { return typeof x === 'string' } }, + { name: 'boolean', test: function (x) { return typeof x === 'boolean' } }, + { name: 'Function', test: function (x) { return typeof x === 'function'} }, + { name: 'Array', test: Array.isArray }, + { name: 'Date', test: function (x) { return x instanceof Date } }, + { name: 'RegExp', test: function (x) { return x instanceof RegExp } }, + { name: 'Object', test: function (x) { return typeof x === 'object' } }, + { name: 'null', test: function (x) { return x === null } }, + { name: 'undefined', test: function (x) { return x === undefined } } + ]; + + // configuration + var config = {}; + + // type conversions. Order is important + var conversions = []; + + // types to be ignored + var ignore = []; + + // temporary object for holding types and conversions, for constructing + // the `typed` function itself + // TODO: find a more elegant solution for this + var typed = { + config: config, + types: types, + conversions: conversions, + ignore: ignore + }; + + /** + * Construct the typed function itself with various signatures + * + * Signatures: + * + * typed(signatures: Object.) + * typed(name: string, signatures: Object.) + */ + typed = _typed('typed', { + 'Object': function (signatures) { + var fns = []; + for (var signature in signatures) { + if (signatures.hasOwnProperty(signature)) { + fns.push(signatures[signature]); + } + } + var name = getName(fns); + + return _typed(name, signatures); + }, + 'string, Object': _typed, + // TODO: add a signature 'Array.' + '...Function': function (fns) { + var err; + var name = getName(fns); + var signatures = {}; + + for (var i = 0; i < fns.length; i++) { + var fn = fns[i]; + + // test whether this is a typed-function + if (!(typeof fn.signatures === 'object')) { + err = new TypeError('Function is no typed-function (index: ' + i + ')'); + err.data = {index: i}; + throw err; + } + + // merge the signatures + for (var signature in fn.signatures) { + if (fn.signatures.hasOwnProperty(signature)) { + if (signatures.hasOwnProperty(signature)) { + if (fn.signatures[signature] !== signatures[signature]) { + err = new Error('Signature "' + signature + '" is defined twice'); + err.data = {signature: signature}; + throw err; + } + // else: both signatures point to the same function, that's fine + } + else { + signatures[signature] = fn.signatures[signature]; + } + } + } + } + + return _typed(name, signatures); + } + }); + + /** + * Find a specific signature from a (composed) typed function, for + * example: + * + * typed.find(fn, ['number', 'string']) + * typed.find(fn, 'number, string') + * + * Function find only only works for exact matches. + * + * @param {Function} fn A typed-function + * @param {string | string[]} signature Signature to be found, can be + * an array or a comma separated string. + * @return {Function} Returns the matching signature, or + * throws an errror when no signature + * is found. + */ + function find (fn, signature) { + if (!fn.signatures) { + throw new TypeError('Function is no typed-function'); + } + + // normalize input + var arr; + if (typeof signature === 'string') { + arr = signature.split(','); + for (var i = 0; i < arr.length; i++) { + arr[i] = arr[i].trim(); + } + } + else if (Array.isArray(signature)) { + arr = signature; + } + else { + throw new TypeError('String array or a comma separated string expected'); + } + + var str = arr.join(','); + + // find an exact match + var match = fn.signatures[str]; + if (match) { + return match; + } + + // TODO: extend find to match non-exact signatures + + throw new TypeError('Signature not found (signature: ' + (fn.name || 'unnamed') + '(' + arr.join(', ') + '))'); + } + + /** + * Convert a given value to another data type. + * @param {*} value + * @param {string} type + */ + function convert (value, type) { + var from = getTypeOf(value); + + // check conversion is needed + if (type === from) { + return value; + } + + for (var i = 0; i < typed.conversions.length; i++) { + var conversion = typed.conversions[i]; + if (conversion.from === from && conversion.to === type) { + return conversion.convert(value); + } + } + + throw new Error('Cannot convert from ' + from + ' to ' + type); + } + + // attach types and conversions to the final `typed` function + typed.config = config; + typed.types = types; + typed.conversions = conversions; + typed.ignore = ignore; + typed.create = create; + typed.find = find; + typed.convert = convert; + + // add a type + typed.addType = function (type) { + if (!type || typeof type.name !== 'string' || typeof type.test !== 'function') { + throw new TypeError('Object with properties {name: string, test: function} expected'); + } + + typed.types.push(type); + }; + + // add a conversion + typed.addConversion = function (conversion) { + if (!conversion + || typeof conversion.from !== 'string' + || typeof conversion.to !== 'string' + || typeof conversion.convert !== 'function') { + throw new TypeError('Object with properties {from: string, to: string, convert: function} expected'); + } + + typed.conversions.push(conversion); + }; + + return typed; + } + + return create(); + })); + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var NumberFormatter = __webpack_require__(7); + + /** + * Test whether value is a number + * @param {*} value + * @return {boolean} isNumber + */ + exports.isNumber = function(value) { + return typeof value === 'number'; + }; + + /** + * Check if a number is integer + * @param {number | boolean} value + * @return {boolean} isInteger + */ + exports.isInteger = function(value) { + return isFinite(value) + ? (value == Math.round(value)) + : false; + // Note: we use ==, not ===, as we can have Booleans as well + }; + + /** + * Calculate the sign of a number + * @param {number} x + * @returns {*} + */ + exports.sign = Math.sign || function(x) { + if (x > 0) { + return 1; + } + else if (x < 0) { + return -1; + } + else { + return 0; + } + }; + + /** + * Convert a number to a formatted string representation. + * + * Syntax: + * + * format(value) + * format(value, options) + * format(value, precision) + * format(value, fn) + * + * Where: + * + * {number} value The value to be formatted + * {Object} options An object with formatting options. Available options: + * {string} notation + * Number notation. Choose from: + * 'fixed' Always use regular number notation. + * For example '123.40' and '14000000' + * 'exponential' Always use exponential notation. + * For example '1.234e+2' and '1.4e+7' + * 'engineering' Always use engineering notation. + * For example '123.4e+0' and '14.0e+6' + * 'auto' (default) Regular number notation for numbers + * having an absolute value between + * `lower` and `upper` bounds, and uses + * exponential notation elsewhere. + * Lower bound is included, upper bound + * is excluded. + * For example '123.4' and '1.4e7'. + * {number} precision A number between 0 and 16 to round + * the digits of the number. + * In case of notations 'exponential' and + * 'auto', `precision` defines the total + * number of significant digits returned + * and is undefined by default. + * In case of notation 'fixed', + * `precision` defines the number of + * significant digits after the decimal + * point, and is 0 by default. + * {Object} exponential An object containing two parameters, + * {number} lower and {number} upper, + * used by notation 'auto' to determine + * when to return exponential notation. + * Default values are `lower=1e-3` and + * `upper=1e5`. + * Only applicable for notation `auto`. + * {Function} fn A custom formatting function. Can be used to override the + * built-in notations. Function `fn` is called with `value` as + * parameter and must return a string. Is useful for example to + * format all values inside a matrix in a particular way. + * + * Examples: + * + * format(6.4); // '6.4' + * format(1240000); // '1.24e6' + * format(1/3); // '0.3333333333333333' + * format(1/3, 3); // '0.333' + * format(21385, 2); // '21000' + * format(12.071, {notation: 'fixed'}); // '12' + * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' + * format(52.8, {notation: 'exponential'}); // '5.28e+1' + * format(12345678, {notation: 'engineering'}); // '12.345678e+6' + * + * @param {number} value + * @param {Object | Function | number} [options] + * @return {string} str The formatted value + */ + exports.format = function(value, options) { + if (typeof options === 'function') { + // handle format(value, fn) + return options(value); + } + + // handle special cases + if (value === Infinity) { + return 'Infinity'; + } + else if (value === -Infinity) { + return '-Infinity'; + } + else if (isNaN(value)) { + return 'NaN'; + } + + // default values for options + var notation = 'auto'; + var precision = undefined; + + if (options) { + // determine notation from options + if (options.notation) { + notation = options.notation; + } + + // determine precision from options + if (exports.isNumber(options)) { + precision = options; + } + else if (options.precision) { + precision = options.precision; + } + } + + // handle the various notations + switch (notation) { + case 'fixed': + return exports.toFixed(value, precision); + + case 'exponential': + return exports.toExponential(value, precision); + + case 'engineering': + return exports.toEngineering(value, precision); + + case 'auto': + return exports + .toPrecision(value, precision, options && options.exponential) + + // remove trailing zeros after the decimal point + .replace(/((\.\d*?)(0+))($|e)/, function () { + var digits = arguments[2]; + var e = arguments[4]; + return (digits !== '.') ? digits + e : e; + }); + + default: + throw new Error('Unknown notation "' + notation + '". ' + + 'Choose "auto", "exponential", or "fixed".'); + } + }; + + /** + * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' + * @param {number} value + * @param {number} [precision] Number of digits in formatted output. + * If not provided, the maximum available digits + * is used. + * @returns {string} str + */ + exports.toExponential = function(value, precision) { + return new NumberFormatter(value).toExponential(precision); + }; + + /** + * Format a number in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3' + * @param {number} value + * @param {number} [precision] Number of digits in formatted output. + * If not provided, the maximum available digits + * is used. + * @returns {string} str + */ + exports.toEngineering = function(value, precision) { + return new NumberFormatter(value).toEngineering(precision); + }; + + /** + * Format a number with fixed notation. + * @param {number} value + * @param {number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. + */ + exports.toFixed = function(value, precision) { + return new NumberFormatter(value).toFixed(precision); + }; + + /** + * Format a number with a certain precision + * @param {number} value + * @param {number} [precision=undefined] Optional number of digits. + * @param {{lower: number, upper: number}} [options] By default: + * lower = 1e-3 (excl) + * upper = 1e+5 (incl) + * @return {string} + */ + exports.toPrecision = function(value, precision, options) { + return new NumberFormatter(value).toPrecision(precision, options); + }; + + /** + * Count the number of significant digits of a number. + * + * For example: + * 2.34 returns 3 + * 0.0034 returns 2 + * 120.5e+30 returns 4 + * + * @param {number} value + * @return {number} digits Number of significant digits + */ + exports.digits = function(value) { + return value + .toExponential() + .replace(/e.*$/, '') // remove exponential notation + .replace( /^0\.?0*|\./, '') // remove decimal point and leading zeros + .length + }; + + /** + * Minimum number added to one that makes the result different than one + */ + exports.DBL_EPSILON = Number.EPSILON || 2.2204460492503130808472633361816E-16; + + /** + * Compares two floating point numbers. + * @param {number} x First value to compare + * @param {number} y Second value to compare + * @param {number} [epsilon] The maximum relative difference between x and y + * If epsilon is undefined or null, the function will + * test whether x and y are exactly equal. + * @return {boolean} whether the two numbers are nearly equal + */ + exports.nearlyEqual = function(x, y, epsilon) { + // if epsilon is null or undefined, test whether x and y are exactly equal + if (epsilon == null) { + return x == y; + } + + // use "==" operator, handles infinities + if (x == y) { + return true; + } + + // NaN + if (isNaN(x) || isNaN(y)) { + return false; + } + + // at this point x and y should be finite + if(isFinite(x) && isFinite(y)) { + // check numbers are very close, needed when comparing numbers near zero + var diff = Math.abs(x - y); + if (diff < exports.DBL_EPSILON) { + return true; + } + else { + // use relative error + return diff <= Math.max(Math.abs(x), Math.abs(y)) * epsilon; + } + } + + // Infinite and Number or negative Infinite and positive Infinite cases + return false; + }; + + +/***/ }, +/* 7 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Format a number using methods toPrecision, toFixed, toExponential. + * @param {number | string} value + * @constructor + */ + function NumberFormatter (value) { + // parse the input value + var match = String(value).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/); + if (!match) { + throw new SyntaxError('Invalid number'); + } + + var sign = match[1]; + var coefficients = match[2]; + var exponent = parseFloat(match[4] || '0'); + + var dot = coefficients.indexOf('.'); + exponent += (dot !== -1) ? (dot - 1) : (coefficients.length - 1); + + this.sign = sign; + this.coefficients = coefficients + .replace('.', '') // remove the dot (must be removed before removing leading zeros) + .replace(/^0*/, function (zeros) { + // remove leading zeros, add their count to the exponent + exponent -= zeros.length; + return ''; + }) + .replace(/0*$/, '') // remove trailing zeros + .split('') + .map(function (d) { + return parseInt(d); + }); + + if (this.coefficients.length === 0) { + this.coefficients.push(0); + exponent++; + } + + this.exponent = exponent; + } + + + /** + * Format a number with engineering notation. + * @param {number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. + */ + NumberFormatter.prototype.toEngineering = function(precision) { + var rounded = this.roundDigits(precision); + + var e = rounded.exponent; + var c = rounded.coefficients; + + // find nearest lower multiple of 3 for exponent + var newExp = e % 3 === 0 ? e : (e < 0 ? (e - 3) - (e % 3) : e - (e % 3)); + + // concatenate coefficients with necessary zeros + var significandsDiff = e >= 0 ? e : Math.abs(newExp); + + // add zeros if necessary (for ex: 1e+8) + if (c.length - 1 < significandsDiff) c = c.concat(zeros(significandsDiff - (c.length - 1))); + + // find difference in exponents + var expDiff = Math.abs(e - newExp); + + var decimalIdx = 1; + var str = ''; + + // push decimal index over by expDiff times + while (--expDiff >= 0) decimalIdx++; + + // if all coefficient values are zero after the decimal point, don't add a decimal value. + // otherwise concat with the rest of the coefficients + var decimals = c.slice(decimalIdx).join(''); + var decimalVal = decimals.match(/[1-9]/) ? ('.' + decimals) : ''; + + str = c.slice(0, decimalIdx).join('') + decimalVal; + + str += 'e' + (e >= 0 ? '+' : '') + newExp.toString(); + return rounded.sign + str; + } + + /** + * Format a number with fixed notation. + * @param {number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. + */ + NumberFormatter.prototype.toFixed = function (precision) { + var rounded = this.roundDigits(this.exponent + 1 + (precision || 0)); + var c = rounded.coefficients; + var p = rounded.exponent + 1; // exponent may have changed + + // append zeros if needed + var pp = p + (precision || 0); + if (c.length < pp) { + c = c.concat(zeros(pp - c.length)); + } + + // prepend zeros if needed + if (p < 0) { + c = zeros(-p + 1).concat(c); + p = 1; + } + + // insert a dot if needed + if (precision) { + c.splice(p, 0, (p === 0) ? '0.' : '.'); + } + + return this.sign + c.join(''); + }; + + /** + * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' + * @param {number} [precision] Number of digits in formatted output. + * If not provided, the maximum available digits + * is used. + */ + NumberFormatter.prototype.toExponential = function (precision) { + // round if needed, else create a clone + var rounded = precision ? this.roundDigits(precision) : this.clone(); + var c = rounded.coefficients; + var e = rounded.exponent; + + // append zeros if needed + if (c.length < precision) { + c = c.concat(zeros(precision - c.length)); + } + + // format as `C.CCCe+EEE` or `C.CCCe-EEE` + var first = c.shift(); + return this.sign + first + (c.length > 0 ? ('.' + c.join('')) : '') + + 'e' + (e >= 0 ? '+' : '') + e; + }; + + /** + * Format a number with a certain precision + * @param {number} [precision=undefined] Optional number of digits. + * @param {{lower: number | undefined, upper: number | undefined}} [options] + * By default: + * lower = 1e-3 (excl) + * upper = 1e+5 (incl) + * @return {string} + */ + NumberFormatter.prototype.toPrecision = function(precision, options) { + // determine lower and upper bound for exponential notation. + var lower = (options && options.lower !== undefined) ? options.lower : 1e-3; + var upper = (options && options.upper !== undefined) ? options.upper : 1e+5; + + var abs = Math.abs(Math.pow(10, this.exponent)); + if (abs < lower || abs >= upper) { + // exponential notation + return this.toExponential(precision); + } + else { + var rounded = precision ? this.roundDigits(precision) : this.clone(); + var c = rounded.coefficients; + var e = rounded.exponent; + + // append trailing zeros + if (c.length < precision) { + c = c.concat(zeros(precision - c.length)); + } + + // append trailing zeros + // TODO: simplify the next statement + c = c.concat(zeros(e - c.length + 1 + + (c.length < precision ? precision - c.length : 0))); + + // prepend zeros + c = zeros(-e).concat(c); + + var dot = e > 0 ? e : 0; + if (dot < c.length - 1) { + c.splice(dot + 1, 0, '.'); + } + + return this.sign + c.join(''); + } + }; + + /** + * Crete a clone of the NumberFormatter + * @return {NumberFormatter} Returns a clone of the NumberFormatter + */ + NumberFormatter.prototype.clone = function () { + var clone = new NumberFormatter('0'); + clone.sign = this.sign; + clone.coefficients = this.coefficients.slice(0); + clone.exponent = this.exponent; + return clone; + }; + + /** + * Round the number of digits of a number * + * @param {number} precision A positive integer + * @return {NumberFormatter} Returns a new NumberFormatter with the rounded + * digits + */ + NumberFormatter.prototype.roundDigits = function (precision) { + var rounded = this.clone(); + var c = rounded.coefficients; + + // prepend zeros if needed + while (precision <= 0) { + c.unshift(0); + rounded.exponent++; + precision++; + } + + if (c.length > precision) { + var removed = c.splice(precision, c.length - precision); + + if (removed[0] >= 5) { + var i = precision - 1; + c[i]++; + while (c[i] === 10) { + c.pop(); + if (i === 0) { + c.unshift(0); + rounded.exponent++; + i++; + } + i--; + c[i]++; + } + } + } + + return rounded; + }; + + /** + * Create an array filled with zeros. + * @param {number} length + * @return {Array} + */ + function zeros(length) { + var arr = []; + for (var i = 0; i < length; i++) { + arr.push(0); + } + return arr; + } + + module.exports = NumberFormatter; + + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + var Emitter = __webpack_require__(9); + + /** + * Extend given object with emitter functions `on`, `off`, `once`, `emit` + * @param {Object} obj + * @return {Object} obj + */ + exports.mixin = function (obj) { + // create event emitter + var emitter = new Emitter(); + + // bind methods to obj (we don't want to expose the emitter.e Array...) + obj.on = emitter.on.bind(emitter); + obj.off = emitter.off.bind(emitter); + obj.once = emitter.once.bind(emitter); + obj.emit = emitter.emit.bind(emitter); + + return obj; + }; + + +/***/ }, +/* 9 */ +/***/ function(module, exports) { + + function E () { + // Keep this empty so it's easier to inherit from + // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) + } + + E.prototype = { + on: function (name, callback, ctx) { + var e = this.e || (this.e = {}); + + (e[name] || (e[name] = [])).push({ + fn: callback, + ctx: ctx + }); + + return this; + }, + + once: function (name, callback, ctx) { + var self = this; + function listener () { + self.off(name, listener); + callback.apply(ctx, arguments); + }; + + listener._ = callback + return this.on(name, listener, ctx); + }, + + emit: function (name) { + var data = [].slice.call(arguments, 1); + var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); + var i = 0; + var len = evtArr.length; + + for (i; i < len; i++) { + evtArr[i].fn.apply(evtArr[i].ctx, data); + } + + return this; + }, + + off: function (name, callback) { + var e = this.e || (this.e = {}); + var evts = e[name]; + var liveEvents = []; + + if (evts && callback) { + for (var i = 0, len = evts.length; i < len; i++) { + if (evts[i].fn !== callback && evts[i].fn._ !== callback) + liveEvents.push(evts[i]); + } + } + + // Remove event from queue to prevent memory leak + // Suggested by https://github.com/lazd + // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 + + (liveEvents.length) + ? e[name] = liveEvents + : delete e[name]; + + return this; + } + }; + + module.exports = E; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var lazy = __webpack_require__(3).lazy; + var isFactory = __webpack_require__(3).isFactory; + var traverse = __webpack_require__(3).traverse; + var extend = __webpack_require__(3).extend; + var ArgumentsError = __webpack_require__(11); + + function factory (type, config, load, typed, math) { + /** + * Import functions from an object or a module + * + * Syntax: + * + * math.import(object) + * math.import(object, options) + * + * Where: + * + * - `object: Object` + * An object with functions to be imported. + * - `options: Object` An object with import options. Available options: + * - `override: boolean` + * If true, existing functions will be overwritten. False by default. + * - `silent: boolean` + * If true, the function will not throw errors on duplicates or invalid + * types. False by default. + * - `wrap: boolean` + * If true, the functions will be wrapped in a wrapper function + * which converts data types like Matrix to primitive data types like Array. + * The wrapper is needed when extending math.js with libraries which do not + * support these data type. False by default. + * + * Examples: + * + * // define new functions and variables + * math.import({ + * myvalue: 42, + * hello: function (name) { + * return 'hello, ' + name + '!'; + * } + * }); + * + * // use the imported function and variable + * math.myvalue * 2; // 84 + * math.hello('user'); // 'hello, user!' + * + * // import the npm module 'numbers' + * // (must be installed first with `npm install numbers`) + * math.import(require('numbers'), {wrap: true}); + * + * math.fibonacci(7); // returns 13 + * + * @param {Object | Array} object Object with functions to be imported. + * @param {Object} [options] Import options. + */ + function math_import(object, options) { + var num = arguments.length; + if (num != 1 && num != 2) { + throw new ArgumentsError('import', num, 1, 2); + } + + if (!options) { + options = {}; + } + + if (isFactory(object)) { + _importFactory(object, options); + } + // TODO: allow a typed-function with name too + else if (Array.isArray(object)) { + object.forEach(function (entry) { + math_import(entry, options); + }); + } + else if (typeof object === 'object') { + // a map with functions + for (var name in object) { + if (object.hasOwnProperty(name)) { + var value = object[name]; + if (isSupportedType(value)) { + _import(name, value, options); + } + else if (isFactory(object)) { + _importFactory(object, options); + } + else { + math_import(value, options); + } + } + } + } + else { + if (!options.silent) { + throw new TypeError('Factory, Object, or Array expected'); + } + } + } + + /** + * Add a property to the math namespace and create a chain proxy for it. + * @param {string} name + * @param {*} value + * @param {Object} options See import for a description of the options + * @private + */ + function _import(name, value, options) { + if (options.wrap && typeof value === 'function') { + // create a wrapper around the function + value = _wrap(value); + } + + if (isTypedFunction(math[name]) && isTypedFunction(value)) { + if (options.override) { + // give the typed function the right name + value = typed(name, value.signatures); + } + else { + // merge the existing and typed function + value = typed(math[name], value); + } + + math[name] = value; + _importTransform(name, value); + math.emit('import', name, function resolver() { + return value; + }); + return; + } + + if (math[name] === undefined || options.override) { + math[name] = value; + _importTransform(name, value); + math.emit('import', name, function resolver() { + return value; + }); + return; + } + + if (!options.silent) { + throw new Error('Cannot import "' + name + '": already exists'); + } + } + + function _importTransform (name, value) { + if (value && typeof value.transform === 'function') { + math.expression.transform[name] = value.transform; + } + } + + /** + * Create a wrapper a round an function which converts the arguments + * to their primitive values (like convert a Matrix to Array) + * @param {Function} fn + * @return {Function} Returns the wrapped function + * @private + */ + function _wrap (fn) { + var wrapper = function wrapper () { + var args = []; + for (var i = 0, len = arguments.length; i < len; i++) { + var arg = arguments[i]; + args[i] = arg && arg.valueOf(); + } + return fn.apply(math, args); + }; + + if (fn.transform) { + wrapper.transform = fn.transform; + } + + return wrapper; + } + + /** + * Import an instance of a factory into math.js + * @param {{factory: Function, name: string, path: string, math: boolean}} factory + * @param {Object} options See import for a description of the options + * @private + */ + function _importFactory(factory, options) { + if (typeof factory.name === 'string') { + var name = factory.name; + var namespace = factory.path ? traverse(math, factory.path) : math; + var existing = namespace.hasOwnProperty(name) ? namespace[name] : undefined; + + var resolver = function () { + var instance = load(factory); + + if (isTypedFunction(existing) && isTypedFunction(instance)) { + if (options.override) { + // replace the existing typed function (nothing to do) + } + else { + // merge the existing and new typed function + instance = typed(existing, instance); + } + + return instance; + } + + if (existing === undefined || options.override) { + return instance; + } + + if (!options.silent) { + throw new Error('Cannot import "' + name + '": already exists'); + } + }; + + if (factory.lazy !== false) { + lazy(namespace, name, resolver); + } + else { + namespace[name] = resolver(); + } + + math.emit('import', name, resolver, factory.path); + } + else { + // unnamed factory. + // no lazy loading + load(factory); + } + } + + /** + * Check whether given object is a type which can be imported + * @param {Function | number | string | boolean | null | Unit | Complex} object + * @return {boolean} + * @private + */ + function isSupportedType(object) { + return typeof object == 'function' + || typeof object === 'number' + || typeof object === 'string' + || typeof object === 'boolean' + || object === null + || (object && object.isUnit === true) + || (object && object.isComplex === true) + || (object && object.isBigNumber === true) + || (object && object.isFraction === true) + || (object && object.isMatrix === true) + || (object && Array.isArray(object) === true) + } + + /** + * Test whether a given thing is a typed-function + * @param {*} fn + * @return {boolean} Returns true when `fn` is a typed-function + */ + function isTypedFunction (fn) { + return typeof fn === 'function' && typeof fn.signatures === 'object'; + } + + return math_import; + } + + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.name = 'import'; + exports.factory = factory; + exports.lazy = true; + + +/***/ }, +/* 11 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Create a syntax error with the message: + * 'Wrong number of arguments in function ( provided, - expected)' + * @param {string} fn Function name + * @param {number} count Actual argument count + * @param {number} min Minimum required argument count + * @param {number} [max] Maximum required argument count + * @extends Error + */ + function ArgumentsError(fn, count, min, max) { + if (!(this instanceof ArgumentsError)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.fn = fn; + this.count = count; + this.min = min; + this.max = max; + + this.message = 'Wrong number of arguments in function ' + fn + + ' (' + count + ' provided, ' + + min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; + + this.stack = (new Error()).stack; + } + + ArgumentsError.prototype = new Error(); + ArgumentsError.prototype.constructor = Error; + ArgumentsError.prototype.name = 'ArgumentsError'; + ArgumentsError.prototype.isArgumentsError = true; + + module.exports = ArgumentsError; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(3); + + function factory (type, config, load, typed, math) { + var MATRIX = ['Matrix', 'Array']; // valid values for option matrix + var NUMBER = ['number', 'BigNumber', 'Fraction']; // valid values for option number + + /** + * Set configuration options for math.js, and get current options. + * Will emit a 'config' event, with arguments (curr, prev). + * + * Syntax: + * + * math.config(config: Object): Object + * + * Examples: + * + * math.config().number; // outputs 'number' + * math.eval('0.4'); // outputs number 0.4 + * math.config({number: 'Fraction'}); + * math.eval('0.4'); // outputs Fraction 2/5 + * + * @param {Object} [options] Available options: + * {number} epsilon + * Minimum relative difference between two + * compared values, used by all comparison functions. + * {string} matrix + * A string 'Matrix' (default) or 'Array'. + * {string} number + * A string 'number' (default), 'BigNumber', or 'Fraction' + * {number} precision + * The number of significant digits for BigNumbers. + * Not applicable for Numbers. + * {string} parenthesis + * How to display parentheses in LaTeX and string + * output. + * @return {Object} Returns the current configuration + */ + function _config(options) { + if (options) { + var prev = object.clone(config); + + // validate some of the options + validateOption(options, 'matrix', MATRIX); + validateOption(options, 'number', NUMBER); + + // merge options + object.deepExtend(config, options); + + var curr = object.clone(config); + + // emit 'config' event + math.emit('config', curr, prev); + + return curr; + } + else { + return object.clone(config); + } + } + + // attach the valid options to the function so they can be extended + _config.MATRIX = MATRIX; + _config.NUMBER = NUMBER; + + return _config; + } + + /** + * Test whether an Array contains a specific item. + * @param {Array.} array + * @param {string} item + * @return {boolean} + */ + function contains (array, item) { + return array.indexOf(item) !== -1; + } + + /** + * Find a string in an array. Case insensitive search + * @param {Array.} array + * @param {string} item + * @return {number} Returns the index when found. Returns -1 when not found + */ + function findIndex (array, item) { + return array + .map(function (i) { + return i.toLowerCase(); + }) + .indexOf(item.toLowerCase()); + } + + /** + * Validate an option + * @param {Object} options Object with options + * @param {string} name Name of the option to validate + * @param {Array.} values Array with valid values for this option + */ + function validateOption(options, name, values) { + if (options[name] !== undefined && !contains(values, options[name])) { + var index = findIndex(values, options[name]); + if (index !== -1) { + // right value, wrong casing + // TODO: lower case values are deprecated since v3, remove this warning some day. + console.warn('Warning: Wrong casing for configuration option "' + name + '", should be "' + values[index] + '" instead of "' + options[name] + '".'); + + options[name] = values[index]; // change the option to the right casing + } + else { + // unknown value + console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". Available options: ' + values.map(JSON.stringify).join(', ') + '.'); + } + } + } + + exports.name = 'config'; + exports.math = true; // request the math namespace as fifth argument + exports.factory = factory; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(14), // data types (Matrix, Complex, Unit, ...) + __webpack_require__(93), // constants + __webpack_require__(95), // expression parsing + __webpack_require__(326), // functions + __webpack_require__(489), // serialization utility (math.json.reviver) + __webpack_require__(491) // errors + ]; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(15), + __webpack_require__(20), + __webpack_require__(21), + __webpack_require__(26), + __webpack_require__(33), + __webpack_require__(37), + __webpack_require__(70), + __webpack_require__(71), + __webpack_require__(73), + __webpack_require__(74) + ]; + + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(16), + + // construction function + __webpack_require__(18) + ]; + + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + var Decimal = __webpack_require__(17); + + function factory (type, config, load, typed, math) { + var BigNumber = Decimal.clone({precision: config.precision}); + + /** + * Attach type information + */ + BigNumber.prototype.type = 'BigNumber'; + BigNumber.prototype.isBigNumber = true; + + /** + * Get a JSON representation of a BigNumber containing + * type information + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "BigNumber", "value": "0.2"}` + */ + BigNumber.prototype.toJSON = function () { + return { + mathjs: 'BigNumber', + value: this.toString() + }; + }; + + /** + * Instantiate a BigNumber from a JSON object + * @param {Object} json a JSON object structured as: + * `{"mathjs": "BigNumber", "value": "0.2"}` + * @return {BigNumber} + */ + BigNumber.fromJSON = function (json) { + return new BigNumber(json.value); + }; + + // listen for changed in the configuration, automatically apply changed precision + math.on('config', function (curr, prev) { + if (curr.precision !== prev.precision) { + BigNumber.config({ precision: curr.precision }); + } + }); + + return BigNumber; + } + + exports.name = 'BigNumber'; + exports.path = 'type'; + exports.factory = factory; + exports.math = true; // request access to the math namespace + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v5.0.8 https://github.com/MikeMcl/decimal.js/LICENCE */ + ;(function (globalScope) { + 'use strict'; + + + /* + * decimal.js v5.0.8 + * An arbitrary-precision Decimal type for JavaScript. + * https://github.com/MikeMcl/decimal.js + * Copyright (c) 2016 Michael Mclaughlin + * MIT Expat Licence + */ + + + // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ // + + + // The maximum exponent magnitude. + // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`. + var EXP_LIMIT = 9e15, // 0 to 9e15 + + // The limit on the value of `precision`, and on the value of the first argument to + // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`. + MAX_DIGITS = 1e9, // 0 to 1e9 + + // The base 88 alphabet used by `toJSON` and `fromJSON`. + // 7 printable ASCII characters omitted (space) \ " & ' < > + NUMERALS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~', + + // The natural logarithm of 10 (1025 digits). + LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058', + + // Pi (1025 digits). + PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789', + + + // The initial configuration properties of the Decimal constructor. + Decimal = { + + // These values must be integers within the stated ranges (inclusive). + // Most of these values can be changed during run-time using `Decimal.config`. + + // The maximum number of significant digits of the result of a calculation or base conversion. + // E.g. `Decimal.config({ precision: 20 });` + precision: 20, // 1 to MAX_DIGITS + + // The rounding mode used when rounding to `precision`. + // + // ROUND_UP 0 Away from zero. + // ROUND_DOWN 1 Towards zero. + // ROUND_CEIL 2 Towards +Infinity. + // ROUND_FLOOR 3 Towards -Infinity. + // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up. + // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + // + // E.g. + // `Decimal.rounding = 4;` + // `Decimal.rounding = Decimal.ROUND_HALF_UP;` + rounding: 4, // 0 to 8 + + // The modulo mode used when calculating the modulus: a mod n. + // The quotient (q = a / n) is calculated according to the corresponding rounding mode. + // The remainder (r) is calculated as: r = a - n * q. + // + // UP 0 The remainder is positive if the dividend is negative, else is negative. + // DOWN 1 The remainder has the same sign as the dividend (JavaScript %). + // FLOOR 3 The remainder has the same sign as the divisor (Python %). + // HALF_EVEN 6 The IEEE 754 remainder function. + // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive. + // + // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian + // division (9) are commonly used for the modulus operation. The other rounding modes can also + // be used, but they may not give useful results. + modulo: 1, // 0 to 9 + + // The exponent value at and beneath which `toString` returns exponential notation. + // JavaScript numbers: -7 + toExpNeg: -7, // 0 to -EXP_LIMIT + + // The exponent value at and above which `toString` returns exponential notation. + // JavaScript numbers: 21 + toExpPos: 21, // 0 to EXP_LIMIT + + // The minimum exponent value, beneath which underflow to zero occurs. + // JavaScript numbers: -324 (5e-324) + minE: -EXP_LIMIT, // -1 to -EXP_LIMIT + + // The maximum exponent value, above which overflow to Infinity occurs. + // JavaScript numbers: 308 (1.7976931348623157e+308) + maxE: EXP_LIMIT, // 1 to EXP_LIMIT + + // Whether to use cryptographically-secure random number generation, if available. + crypto: void 0 // true/false/undefined + }, + + + // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- // + + + inexact, noConflict, quadrant, + cryptoObject = typeof crypto != 'undefined' ? crypto : null, + external = true, + + decimalError = '[DecimalError] ', + invalidArgument = decimalError + 'Invalid argument: ', + precisionLimitExceeded = decimalError + 'Precision limit exceeded', + + mathfloor = Math.floor, + mathpow = Math.pow, + + isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, + isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, + isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, + isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, + + BASE = 1e7, + LOG_BASE = 7, + MAX_SAFE_INTEGER = 9007199254740991, + + LN10_PRECISION = LN10.length - 1, + PI_PRECISION = PI.length - 1, + + // Decimal.prototype object + P = {}; + + + // Decimal prototype methods + + + /* + * absoluteValue abs + * ceil + * comparedTo cmp + * cosine cos + * cubeRoot cbrt + * decimalPlaces dp + * dividedBy div + * dividedToIntegerBy divToInt + * equals eq + * floor + * greaterThan gt + * greaterThanOrEqualTo gte + * hyperbolicCosine cosh + * hyperbolicSine sinh + * hyperbolicTangent tanh + * inverseCosine acos + * inverseHyperbolicCosine acosh + * inverseHyperbolicSine asinh + * inverseHyperbolicTangent atanh + * inverseSine asin + * inverseTangent atan + * isFinite + * isInteger isInt + * isNaN + * isNegative isNeg + * isPositive isPos + * isZero + * lessThan lt + * lessThanOrEqualTo lte + * logarithm log + * [maximum] [max] + * [minimum] [min] + * minus sub + * modulo mod + * naturalExponential exp + * naturalLogarithm ln + * negated neg + * plus add + * precision sd + * round + * sine sin + * squareRoot sqrt + * tangent tan + * times mul + * toBinary + * toDecimalPlaces toDP + * toExponential + * toFixed + * toFraction + * toHexadecimal toHex + * toJSON + * toNearest + * toNumber + * toOctal + * toPower pow + * toPrecision + * toSignificantDigits toSD + * toString + * truncated trunc + * valueOf + */ + + + /* + * Return a new Decimal whose value is the absolute value of this Decimal. + * + */ + P.absoluteValue = P.abs = function () { + var x = new this.constructor(this); + if (x.s < 0) x.s = 1; + return finalise(x); + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the + * direction of positive Infinity. + * + */ + P.ceil = function () { + return finalise(new this.constructor(this), this.e + 1, 2); + }; + + + /* + * Return + * 1 if the value of this Decimal is greater than the value of `y`, + * -1 if the value of this Decimal is less than the value of `y`, + * 0 if they have the same value, + * NaN if the value of either Decimal is NaN. + * + */ + P.comparedTo = P.cmp = function (y) { + var i, j, xdL, ydL, + x = this, + xd = x.d, + yd = (y = new x.constructor(y)).d, + xs = x.s, + ys = y.s; + + // Either NaN or ±Infinity? + if (!xd || !yd) { + return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1; + } + + // Either zero? + if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0; + + // Signs differ? + if (xs !== ys) return xs; + + // Compare exponents. + if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1; + + xdL = xd.length; + ydL = yd.length; + + // Compare digit by digit. + for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) { + if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1; + } + + // Compare lengths. + return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1; + }; + + + /* + * Return a new Decimal whose value is the cosine of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * cos(0) = 1 + * cos(-0) = 1 + * cos(Infinity) = NaN + * cos(-Infinity) = NaN + * cos(NaN) = NaN + * + */ + P.cosine = P.cos = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (!x.d) return new Ctor(NaN); + + // cos(0) = cos(-0) = 1 + if (!x.d[0]) return new Ctor(1); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE; + Ctor.rounding = 1; + + x = cosine(Ctor, toLessThanHalfPi(Ctor, x)); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true); + }; + + + /* + * + * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * cbrt(0) = 0 + * cbrt(-0) = -0 + * cbrt(1) = 1 + * cbrt(-1) = -1 + * cbrt(N) = N + * cbrt(-I) = -I + * cbrt(I) = I + * + * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3)) + * + */ + P.cubeRoot = P.cbrt = function () { + var e, m, n, r, rep, s, sd, t, t3, t3plusx, + x = this, + Ctor = x.constructor; + + if (!x.isFinite() || x.isZero()) return new Ctor(x); + external = false; + + // Initial estimate. + s = x.s * Math.pow(x.s * x, 1 / 3); + + // Math.cbrt underflow/overflow? + // Pass x to Math.pow as integer, then adjust the exponent of the result. + if (!s || Math.abs(s) == 1 / 0) { + n = digitsToString(x.d); + e = x.e; + + // Adjust n exponent so it is a multiple of 3 away from x exponent. + if (s = (e - n.length + 1) % 3) n += (s == 1 || s == -2 ? '0' : '00'); + s = Math.pow(n, 1 / 3); + + // Rarely, e may be one less than the result exponent value. + e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)); + + if (s == 1 / 0) { + n = '5e' + e; + } else { + n = s.toExponential(); + n = n.slice(0, n.indexOf('e') + 1) + e; + } + + r = new Ctor(n); + r.s = x.s; + } else { + r = new Ctor(s.toString()); + } + + sd = (e = Ctor.precision) + 3; + + // Halley's method. + // TODO? Compare Newton's method. + for (;;) { + t = r; + t3 = t.times(t).times(t); + t3plusx = t3.plus(x); + r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1); + + // TODO? Replace with for-loop and checkRoundingDigits. + if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) { + n = n.slice(sd - 3, sd + 1); + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999 + // , i.e. approaching a rounding boundary, continue the iteration. + if (n == '9999' || !rep && n == '4999') { + + // On the first iteration only, check to see if rounding up gives the exact result as the + // nines may infinitely repeat. + if (!rep) { + finalise(t, e + 1, 0); + + if (t.times(t).times(t).eq(x)) { + r = t; + break; + } + } + + sd += 4; + rep = 1; + } else { + + // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result. + // If not, then there are further digits and m will be truthy. + if (!+n || !+n.slice(1) && n.charAt(0) == '5') { + + // Truncate to the first rounding digit. + finalise(r, e + 1, 1); + m = !r.times(r).times(r).eq(x); + } + + break; + } + } + } + + external = true; + + return finalise(r, e, Ctor.rounding, m); + }; + + + /* + * Return the number of decimal places of the value of this Decimal. + * + */ + P.decimalPlaces = P.dp = function () { + var w, + d = this.d, + n = NaN; + + if (d) { + w = d.length - 1; + n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE; + + // Subtract the number of trailing zeros of the last word. + w = d[w]; + if (w) for (; w % 10 == 0; w /= 10) n--; + if (n < 0) n = 0; + } + + return n; + }; + + + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + */ + P.dividedBy = P.div = function (y) { + return divide(this, new this.constructor(y)); + }; + + + /* + * Return a new Decimal whose value is the integer part of dividing the value of this Decimal + * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`. + * + */ + P.dividedToIntegerBy = P.divToInt = function (y) { + var x = this, + Ctor = x.constructor; + return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding); + }; + + + /* + * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false. + * + */ + P.equals = P.eq = function (y) { + return this.cmp(y) === 0; + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the + * direction of negative Infinity. + * + */ + P.floor = function () { + return finalise(new this.constructor(this), this.e + 1, 3); + }; + + + /* + * Return true if the value of this Decimal is greater than the value of `y`, otherwise return + * false. + * + */ + P.greaterThan = P.gt = function (y) { + return this.cmp(y) > 0; + }; + + + /* + * Return true if the value of this Decimal is greater than or equal to the value of `y`, + * otherwise return false. + * + */ + P.greaterThanOrEqualTo = P.gte = function (y) { + var k = this.cmp(y); + return k == 1 || k === 0; + }; + + + /* + * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [1, Infinity] + * + * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ... + * + * cosh(0) = 1 + * cosh(-0) = 1 + * cosh(Infinity) = Infinity + * cosh(-Infinity) = Infinity + * cosh(NaN) = NaN + * + * x time taken (ms) result + * 1000 9 9.8503555700852349694e+433 + * 10000 25 4.4034091128314607936e+4342 + * 100000 171 1.4033316802130615897e+43429 + * 1000000 3817 1.5166076984010437725e+434294 + * 10000000 abandoned after 2 minute wait + * + * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x)) + * + */ + P.hyperbolicCosine = P.cosh = function () { + var k, n, pr, rm, len, + x = this, + Ctor = x.constructor, + one = new Ctor(1); + + if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN); + if (x.isZero()) return one; + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + Math.max(x.e, x.sd()) + 4; + Ctor.rounding = 1; + len = x.d.length; + + // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1 + // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4)) + + // Estimate the optimum number of times to use the argument reduction. + // TODO? Estimation reused from cosine() and may not be optimal here. + if (len < 32) { + k = Math.ceil(len / 3); + n = Math.pow(4, -k).toString(); + } else { + k = 16; + n = '2.3283064365386962890625e-10'; + } + + x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true); + + // Reverse argument reduction + var cosh2_x, + i = k, + d8 = new Ctor(8); + for (; i--;) { + cosh2_x = x.times(x); + x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8)))); + } + + return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true); + }; + + + /* + * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ... + * + * sinh(0) = 0 + * sinh(-0) = -0 + * sinh(Infinity) = Infinity + * sinh(-Infinity) = -Infinity + * sinh(NaN) = NaN + * + * x time taken (ms) + * 10 2 ms + * 100 5 ms + * 1000 14 ms + * 10000 82 ms + * 100000 886 ms 1.4033316802130615897e+43429 + * 200000 2613 ms + * 300000 5407 ms + * 400000 8824 ms + * 500000 13026 ms 8.7080643612718084129e+217146 + * 1000000 48543 ms + * + * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x)) + * + */ + P.hyperbolicSine = P.sinh = function () { + var k, pr, rm, len, + x = this, + Ctor = x.constructor; + + if (!x.isFinite() || x.isZero()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + Math.max(x.e, x.sd()) + 4; + Ctor.rounding = 1; + len = x.d.length; + + if (len < 3) { + x = taylorSeries(Ctor, 2, x, x, true); + } else { + + // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x)) + // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3)) + // 3 multiplications and 1 addition + + // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x))) + // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5))) + // 4 multiplications and 2 additions + + // Estimate the optimum number of times to use the argument reduction. + k = 1.4 * Math.sqrt(len); + k = k > 16 ? 16 : k | 0; + + x = x.times(Math.pow(5, -k)); + + x = taylorSeries(Ctor, 2, x, x, true); + + // Reverse argument reduction + var sinh2_x, + d5 = new Ctor(5), + d16 = new Ctor(16), + d20 = new Ctor(20); + for (; k--;) { + sinh2_x = x.times(x); + x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20)))); + } + } + + Ctor.precision = pr; + Ctor.rounding = rm; + + return finalise(x, pr, rm, true); + }; + + + /* + * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * tanh(x) = sinh(x) / cosh(x) + * + * tanh(0) = 0 + * tanh(-0) = -0 + * tanh(Infinity) = 1 + * tanh(-Infinity) = -1 + * tanh(NaN) = NaN + * + */ + P.hyperbolicTangent = P.tanh = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (!x.isFinite()) return new Ctor(x.s); + if (x.isZero()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + 7; + Ctor.rounding = 1; + + return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm); + }; + + + /* + * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of + * this Decimal. + * + * Domain: [-1, 1] + * Range: [0, pi] + * + * acos(x) = pi/2 - asin(x) + * + * acos(0) = pi/2 + * acos(-0) = pi/2 + * acos(1) = 0 + * acos(-1) = pi + * acos(1/2) = pi/3 + * acos(-1/2) = 2*pi/3 + * acos(|x| > 1) = NaN + * acos(NaN) = NaN + * + */ + P.inverseCosine = P.acos = function () { + var halfPi, + x = this, + Ctor = x.constructor, + k = x.abs().cmp(1), + pr = Ctor.precision, + rm = Ctor.rounding; + + if (k !== -1) { + return k === 0 + // |x| is 1 + ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) + // |x| > 1 or x is NaN + : new Ctor(NaN); + } + + if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5); + + // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3 + + Ctor.precision = pr + 6; + Ctor.rounding = 1; + + x = x.asin(); + halfPi = getPi(Ctor, pr + 4, rm).times(0.5); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return halfPi.minus(x); + }; + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the + * value of this Decimal. + * + * Domain: [1, Infinity] + * Range: [0, Infinity] + * + * acosh(x) = ln(x + sqrt(x^2 - 1)) + * + * acosh(x < 1) = NaN + * acosh(NaN) = NaN + * acosh(Infinity) = Infinity + * acosh(-Infinity) = NaN + * acosh(0) = NaN + * acosh(-0) = NaN + * acosh(1) = 0 + * acosh(-1) = NaN + * + */ + P.inverseHyperbolicCosine = P.acosh = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN); + if (!x.isFinite()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4; + Ctor.rounding = 1; + external = false; + + x = x.times(x).minus(1).sqrt().plus(x); + + external = true; + Ctor.precision = pr; + Ctor.rounding = rm; + + return x.ln(); + }; + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value + * of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * asinh(x) = ln(x + sqrt(x^2 + 1)) + * + * asinh(NaN) = NaN + * asinh(Infinity) = Infinity + * asinh(-Infinity) = -Infinity + * asinh(0) = 0 + * asinh(-0) = -0 + * + */ + P.inverseHyperbolicSine = P.asinh = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (!x.isFinite() || x.isZero()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6; + Ctor.rounding = 1; + external = false; + + x = x.times(x).plus(1).sqrt().plus(x); + + external = true; + Ctor.precision = pr; + Ctor.rounding = rm; + + return x.ln(); + }; + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the + * value of this Decimal. + * + * Domain: [-1, 1] + * Range: [-Infinity, Infinity] + * + * atanh(x) = 0.5 * ln((1 + x) / (1 - x)) + * + * atanh(|x| > 1) = NaN + * atanh(NaN) = NaN + * atanh(Infinity) = NaN + * atanh(-Infinity) = NaN + * atanh(0) = 0 + * atanh(-0) = -0 + * atanh(1) = Infinity + * atanh(-1) = -Infinity + * + */ + P.inverseHyperbolicTangent = P.atanh = function () { + var pr, rm, wpr, xsd, + x = this, + Ctor = x.constructor; + + if (!x.isFinite()) return new Ctor(NaN); + if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN); + + pr = Ctor.precision; + rm = Ctor.rounding; + xsd = x.sd(); + + if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true); + + Ctor.precision = wpr = xsd - x.e; + + x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1); + + Ctor.precision = pr + 4; + Ctor.rounding = 1; + + x = x.ln(); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return x.times(0.5); + }; + + + /* + * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this + * Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi/2, pi/2] + * + * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2))) + * + * asin(0) = 0 + * asin(-0) = -0 + * asin(1/2) = pi/6 + * asin(-1/2) = -pi/6 + * asin(1) = pi/2 + * asin(-1) = -pi/2 + * asin(|x| > 1) = NaN + * asin(NaN) = NaN + * + * TODO? Compare performance of Taylor series. + * + */ + P.inverseSine = P.asin = function () { + var halfPi, k, + pr, rm, + x = this, + Ctor = x.constructor; + + if (x.isZero()) return new Ctor(x); + + k = x.abs().cmp(1); + pr = Ctor.precision; + rm = Ctor.rounding; + + if (k !== -1) { + + // |x| is 1 + if (k === 0) { + halfPi = getPi(Ctor, pr + 4, rm).times(0.5); + halfPi.s = x.s; + return halfPi; + } + + // |x| > 1 or x is NaN + return new Ctor(NaN); + } + + // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6 + + Ctor.precision = pr + 6; + Ctor.rounding = 1; + + x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan(); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return x.times(2); + }; + + + /* + * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value + * of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi/2, pi/2] + * + * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... + * + * atan(0) = 0 + * atan(-0) = -0 + * atan(1) = pi/4 + * atan(-1) = -pi/4 + * atan(Infinity) = pi/2 + * atan(-Infinity) = -pi/2 + * atan(NaN) = NaN + * + */ + P.inverseTangent = P.atan = function () { + var i, j, k, n, px, t, r, wpr, x2, + x = this, + Ctor = x.constructor, + pr = Ctor.precision, + rm = Ctor.rounding; + + if (!x.isFinite()) { + if (!x.s) return new Ctor(NaN); + if (pr + 4 <= PI_PRECISION) { + r = getPi(Ctor, pr + 4, rm).times(0.5); + r.s = x.s; + return r; + } + } else if (x.isZero()) { + return new Ctor(x); + } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) { + r = getPi(Ctor, pr + 4, rm).times(0.25); + r.s = x.s; + return r; + } + + Ctor.precision = wpr = pr + 10; + Ctor.rounding = 1; + + // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x); + + // Argument reduction + // Ensure |x| < 0.42 + // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2))) + + k = Math.min(28, wpr / LOG_BASE + 2 | 0); + + for (i = k; i; --i) x = x.div(x.times(x).plus(1).sqrt().plus(1)); + + external = false; + + j = Math.ceil(wpr / LOG_BASE); + n = 1; + x2 = x.times(x); + r = new Ctor(x); + px = x; + + // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... + for (; i !== -1;) { + px = px.times(x2); + t = r.minus(px.div(n += 2)); + + px = px.times(x2); + r = t.plus(px.div(n += 2)); + + if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;); + } + + if (k) r = r.times(2 << (k - 1)); + + external = true; + + return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true); + }; + + + /* + * Return true if the value of this Decimal is a finite number, otherwise return false. + * + */ + P.isFinite = function () { + return !!this.d; + }; + + + /* + * Return true if the value of this Decimal is an integer, otherwise return false. + * + */ + P.isInteger = P.isInt = function () { + return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2; + }; + + + /* + * Return true if the value of this Decimal is NaN, otherwise return false. + * + */ + P.isNaN = function () { + return !this.s; + }; + + + /* + * Return true if the value of this Decimal is negative, otherwise return false. + * + */ + P.isNegative = P.isNeg = function () { + return this.s < 0; + }; + + + /* + * Return true if the value of this Decimal is positive, otherwise return false. + * + */ + P.isPositive = P.isPos = function () { + return this.s > 0; + }; + + + /* + * Return true if the value of this Decimal is 0 or -0, otherwise return false. + * + */ + P.isZero = function () { + return !!this.d && this.d[0] === 0; + }; + + + /* + * Return true if the value of this Decimal is less than `y`, otherwise return false. + * + */ + P.lessThan = P.lt = function (y) { + return this.cmp(y) < 0; + }; + + + /* + * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false. + * + */ + P.lessThanOrEqualTo = P.lte = function (y) { + return this.cmp(y) < 1; + }; + + + /* + * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * If no base is specified, return log[10](arg). + * + * log[base](arg) = ln(arg) / ln(base) + * + * The result will always be correctly rounded if the base of the log is 10, and 'almost always' + * otherwise: + * + * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen + * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error + * between the result and the correctly rounded result will be one ulp (unit in the last place). + * + * log[-b](a) = NaN + * log[0](a) = NaN + * log[1](a) = NaN + * log[NaN](a) = NaN + * log[Infinity](a) = NaN + * log[b](0) = -Infinity + * log[b](-0) = -Infinity + * log[b](-a) = NaN + * log[b](1) = 0 + * log[b](Infinity) = Infinity + * log[b](NaN) = NaN + * + * [base] {number|string|Decimal} The base of the logarithm. + * + */ + P.logarithm = P.log = function (base) { + var isBase10, d, denominator, k, inf, num, sd, r, + arg = this, + Ctor = arg.constructor, + pr = Ctor.precision, + rm = Ctor.rounding, + guard = 5; + + // Default base is 10. + if (base == null) { + base = new Ctor(10); + isBase10 = true; + } else { + base = new Ctor(base); + d = base.d; + + // Return NaN if base is negative, or non-finite, or is 0 or 1. + if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN); + + isBase10 = base.eq(10); + } + + d = arg.d; + + // Is arg negative, non-finite, 0 or 1? + if (arg.s < 0 || !d || !d[0] || arg.eq(1)) { + return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0); + } + + // The result will have a non-terminating decimal expansion if base is 10 and arg is not an + // integer power of 10. + if (isBase10) { + if (d.length > 1) { + inf = true; + } else { + for (k = d[0]; k % 10 === 0;) k /= 10; + inf = k !== 1; + } + } + + external = false; + sd = pr + guard; + num = naturalLogarithm(arg, sd); + denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd); + + // The result will have 5 rounding digits. + r = divide(num, denominator, sd, 1); + + // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000, + // calculate 10 further digits. + // + // If the result is known to have an infinite decimal expansion, repeat this until it is clear + // that the result is above or below the boundary. Otherwise, if after calculating the 10 + // further digits, the last 14 are nines, round up and assume the result is exact. + // Also assume the result is exact if the last 14 are zero. + // + // Example of a result that will be incorrectly rounded: + // log[1048576](4503599627370502) = 2.60000000000000009610279511444746... + // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it + // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so + // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal + // place is still 2.6. + if (checkRoundingDigits(r.d, k = pr, rm)) { + + do { + sd += 10; + num = naturalLogarithm(arg, sd); + denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd); + r = divide(num, denominator, sd, 1); + + if (!inf) { + + // Check for 14 nines from the 2nd rounding digit, as the first may be 4. + if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) { + r = finalise(r, pr + 1, 0); + } + + break; + } + } while (checkRoundingDigits(r.d, k += 10, rm)); + } + + external = true; + + return finalise(r, pr, rm); + }; + + + /* + * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal. + * + * arguments {number|string|Decimal} + * + P.max = function () { + Array.prototype.push.call(arguments, this); + return maxOrMin(this.constructor, arguments, 'lt'); + }; + */ + + + /* + * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal. + * + * arguments {number|string|Decimal} + * + P.min = function () { + Array.prototype.push.call(arguments, this); + return maxOrMin(this.constructor, arguments, 'gt'); + }; + */ + + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + */ + P.minus = P.sub = function (y) { + var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, + x = this, + Ctor = x.constructor; + + y = new Ctor(y); + + // If either is not finite... + if (!x.d || !y.d) { + + // Return NaN if either is NaN. + if (!x.s || !y.s) y = new Ctor(NaN); + + // Return y negated if x is finite and y is ±Infinity. + else if (x.d) y.s = -y.s; + + // Return x if y is finite and x is ±Infinity. + // Return x if both are ±Infinity with different signs. + // Return NaN if both are ±Infinity with the same sign. + else y = new Ctor(y.d || x.s !== y.s ? x : NaN); + + return y; + } + + // If signs differ... + if (x.s != y.s) { + y.s = -y.s; + return x.plus(y); + } + + xd = x.d; + yd = y.d; + pr = Ctor.precision; + rm = Ctor.rounding; + + // If either is zero... + if (!xd[0] || !yd[0]) { + + // Return y negated if x is zero and y is non-zero. + if (yd[0]) y.s = -y.s; + + // Return x if y is zero and x is non-zero. + else if (xd[0]) y = new Ctor(x); + + // Return zero if both are zero. + // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity. + else return new Ctor(rm === 3 ? -0 : 0); + + return external ? finalise(y, pr, rm) : y; + } + + // x and y are finite, non-zero numbers with the same sign. + + // Calculate base 1e7 exponents. + e = mathfloor(y.e / LOG_BASE); + xe = mathfloor(x.e / LOG_BASE); + + xd = xd.slice(); + k = xe - e; + + // If base 1e7 exponents differ... + if (k) { + xLTy = k < 0; + + if (xLTy) { + d = xd; + k = -k; + len = yd.length; + } else { + d = yd; + e = xe; + len = xd.length; + } + + // Numbers with massively different exponents would result in a very high number of + // zeros needing to be prepended, but this can be avoided while still ensuring correct + // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`. + i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2; + + if (k > i) { + k = i; + d.length = 1; + } + + // Prepend zeros to equalise exponents. + d.reverse(); + for (i = k; i--;) d.push(0); + d.reverse(); + + // Base 1e7 exponents equal. + } else { + + // Check digits to determine which is the bigger number. + + i = xd.length; + len = yd.length; + xLTy = i < len; + if (xLTy) len = i; + + for (i = 0; i < len; i++) { + if (xd[i] != yd[i]) { + xLTy = xd[i] < yd[i]; + break; + } + } + + k = 0; + } + + if (xLTy) { + d = xd; + xd = yd; + yd = d; + y.s = -y.s; + } + + len = xd.length; + + // Append zeros to `xd` if shorter. + // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length. + for (i = yd.length - len; i > 0; --i) xd[len++] = 0; + + // Subtract yd from xd. + for (i = yd.length; i > k;) { + + if (xd[--i] < yd[i]) { + for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1; + --xd[j]; + xd[i] += BASE; + } + + xd[i] -= yd[i]; + } + + // Remove trailing zeros. + for (; xd[--len] === 0;) xd.pop(); + + // Remove leading zeros and adjust exponent accordingly. + for (; xd[0] === 0; xd.shift()) --e; + + // Zero? + if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0); + + y.d = xd; + y.e = getBase10Exponent(xd, e); + + return external ? finalise(y, pr, rm) : y; + }; + + + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * The result depends on the modulo mode. + * + */ + P.modulo = P.mod = function (y) { + var q, + x = this, + Ctor = x.constructor; + + y = new Ctor(y); + + // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0. + if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN); + + // Return x if y is ±Infinity or x is ±0. + if (!y.d || x.d && !x.d[0]) { + return finalise(new Ctor(x), Ctor.precision, Ctor.rounding); + } + + // Prevent rounding of intermediate calculations. + external = false; + + if (Ctor.modulo == 9) { + + // Euclidian division: q = sign(y) * floor(x / abs(y)) + // result = x - q * y where 0 <= result < abs(y) + q = divide(x, y.abs(), 0, 3, 1); + q.s *= y.s; + } else { + q = divide(x, y, 0, Ctor.modulo, 1); + } + + q = q.times(y); + + external = true; + + return x.minus(q); + }; + + + /* + * Return a new Decimal whose value is the natural exponential of the value of this Decimal, + * i.e. the base e raised to the power the value of this Decimal, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + */ + P.naturalExponential = P.exp = function () { + return naturalExponential(this); + }; + + + /* + * Return a new Decimal whose value is the natural logarithm of the value of this Decimal, + * rounded to `precision` significant digits using rounding mode `rounding`. + * + */ + P.naturalLogarithm = P.ln = function () { + return naturalLogarithm(this); + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by + * -1. + * + */ + P.negated = P.neg = function () { + var x = new this.constructor(this); + x.s = -x.s; + return finalise(x); + }; + + + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + */ + P.plus = P.add = function (y) { + var carry, d, e, i, k, len, pr, rm, xd, yd, + x = this, + Ctor = x.constructor; + + y = new Ctor(y); + + // If either is not finite... + if (!x.d || !y.d) { + + // Return NaN if either is NaN. + if (!x.s || !y.s) y = new Ctor(NaN); + + // Return x if y is finite and x is ±Infinity. + // Return x if both are ±Infinity with the same sign. + // Return NaN if both are ±Infinity with different signs. + // Return y if x is finite and y is ±Infinity. + else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN); + + return y; + } + + // If signs differ... + if (x.s != y.s) { + y.s = -y.s; + return x.minus(y); + } + + xd = x.d; + yd = y.d; + pr = Ctor.precision; + rm = Ctor.rounding; + + // If either is zero... + if (!xd[0] || !yd[0]) { + + // Return x if y is zero. + // Return y if y is non-zero. + if (!yd[0]) y = new Ctor(x); + + return external ? finalise(y, pr, rm) : y; + } + + // x and y are finite, non-zero numbers with the same sign. + + // Calculate base 1e7 exponents. + k = mathfloor(x.e / LOG_BASE); + e = mathfloor(y.e / LOG_BASE); + + xd = xd.slice(); + i = k - e; + + // If base 1e7 exponents differ... + if (i) { + + if (i < 0) { + d = xd; + i = -i; + len = yd.length; + } else { + d = yd; + e = k; + len = xd.length; + } + + // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1. + k = Math.ceil(pr / LOG_BASE); + len = k > len ? k + 1 : len + 1; + + if (i > len) { + i = len; + d.length = 1; + } + + // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts. + d.reverse(); + for (; i--;) d.push(0); + d.reverse(); + } + + len = xd.length; + i = yd.length; + + // If yd is longer than xd, swap xd and yd so xd points to the longer array. + if (len - i < 0) { + i = len; + d = yd; + yd = xd; + xd = d; + } + + // Only start adding at yd.length - 1 as the further digits of xd can be left as they are. + for (carry = 0; i;) { + carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0; + xd[i] %= BASE; + } + + if (carry) { + xd.unshift(carry); + ++e; + } + + // Remove trailing zeros. + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + for (len = xd.length; xd[--len] == 0;) xd.pop(); + + y.d = xd; + y.e = getBase10Exponent(xd, e); + + return external ? finalise(y, pr, rm) : y; + }; + + + /* + * Return the number of significant digits of the value of this Decimal. + * + * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0. + * + */ + P.precision = P.sd = function (z) { + var k, + x = this; + + if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z); + + if (x.d) { + k = getPrecision(x.d); + if (z && x.e + 1 > k) k = x.e + 1; + } else { + k = NaN; + } + + return k; + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using + * rounding mode `rounding`. + * + */ + P.round = function () { + var x = this, + Ctor = x.constructor; + + return finalise(new Ctor(x), x.e + 1, Ctor.rounding); + }; + + + /* + * Return a new Decimal whose value is the sine of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-1, 1] + * + * sin(x) = x - x^3/3! + x^5/5! - ... + * + * sin(0) = 0 + * sin(-0) = -0 + * sin(Infinity) = NaN + * sin(-Infinity) = NaN + * sin(NaN) = NaN + * + */ + P.sine = P.sin = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (!x.isFinite()) return new Ctor(NaN); + if (x.isZero()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE; + Ctor.rounding = 1; + + x = sine(Ctor, toLessThanHalfPi(Ctor, x)); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true); + }; + + + /* + * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * + */ + P.squareRoot = P.sqrt = function () { + var m, n, sd, r, rep, t, + x = this, + d = x.d, + e = x.e, + s = x.s, + Ctor = x.constructor; + + // Negative/NaN/Infinity/zero? + if (s !== 1 || !d || !d[0]) { + return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0); + } + + external = false; + + // Initial estimate. + s = Math.sqrt(+x); + + // Math.sqrt underflow/overflow? + // Pass x to Math.sqrt as integer, then adjust the exponent of the result. + if (s == 0 || s == 1 / 0) { + n = digitsToString(d); + + if ((n.length + e) % 2 == 0) n += '0'; + s = Math.sqrt(n); + e = mathfloor((e + 1) / 2) - (e < 0 || e % 2); + + if (s == 1 / 0) { + n = '1e' + e; + } else { + n = s.toExponential(); + n = n.slice(0, n.indexOf('e') + 1) + e; + } + + r = new Ctor(n); + } else { + r = new Ctor(s.toString()); + } + + sd = (e = Ctor.precision) + 3; + + // Newton-Raphson iteration. + for (;;) { + t = r; + r = t.plus(divide(x, t, sd + 2, 1)).times(0.5); + + // TODO? Replace with for-loop and checkRoundingDigits. + if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) { + n = n.slice(sd - 3, sd + 1); + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or + // 4999, i.e. approaching a rounding boundary, continue the iteration. + if (n == '9999' || !rep && n == '4999') { + + // On the first iteration only, check to see if rounding up gives the exact result as the + // nines may infinitely repeat. + if (!rep) { + finalise(t, e + 1, 0); + + if (t.times(t).eq(x)) { + r = t; + break; + } + } + + sd += 4; + rep = 1; + } else { + + // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result. + // If not, then there are further digits and m will be truthy. + if (!+n || !+n.slice(1) && n.charAt(0) == '5') { + + // Truncate to the first rounding digit. + finalise(r, e + 1, 1); + m = !r.times(r).eq(x); + } + + break; + } + } + } + + external = true; + + return finalise(r, e, Ctor.rounding, m); + }; + + + /* + * Return a new Decimal whose value is the tangent of the value in radians of this Decimal. + * + * Domain: [-Infinity, Infinity] + * Range: [-Infinity, Infinity] + * + * tan(0) = 0 + * tan(-0) = -0 + * tan(Infinity) = NaN + * tan(-Infinity) = NaN + * tan(NaN) = NaN + * + */ + P.tangent = P.tan = function () { + var pr, rm, + x = this, + Ctor = x.constructor; + + if (!x.isFinite()) return new Ctor(NaN); + if (x.isZero()) return new Ctor(x); + + pr = Ctor.precision; + rm = Ctor.rounding; + Ctor.precision = pr + 10; + Ctor.rounding = 1; + + x = x.sin(); + x.s = 1; + x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0); + + Ctor.precision = pr; + Ctor.rounding = rm; + + return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true); + }; + + + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + */ + P.times = P.mul = function (y) { + var carry, e, i, k, r, rL, t, xdL, ydL, + x = this, + Ctor = x.constructor, + xd = x.d, + yd = (y = new Ctor(y)).d; + + y.s *= x.s; + + // If either is NaN, ±Infinity or ±0... + if (!xd || !xd[0] || !yd || !yd[0]) { + + return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd + + // Return NaN if either is NaN. + // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity. + ? NaN + + // Return ±Infinity if either is ±Infinity. + // Return ±0 if either is ±0. + : !xd || !yd ? y.s / 0 : y.s * 0); + } + + e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE); + xdL = xd.length; + ydL = yd.length; + + // Ensure xd points to the longer array. + if (xdL < ydL) { + r = xd; + xd = yd; + yd = r; + rL = xdL; + xdL = ydL; + ydL = rL; + } + + // Initialise the result array with zeros. + r = []; + rL = xdL + ydL; + for (i = rL; i--;) r.push(0); + + // Multiply! + for (i = ydL; --i >= 0;) { + carry = 0; + for (k = xdL + i; k > i;) { + t = r[k] + yd[i] * xd[k - i - 1] + carry; + r[k--] = t % BASE | 0; + carry = t / BASE | 0; + } + + r[k] = (r[k] + carry) % BASE | 0; + } + + // Remove trailing zeros. + for (; !r[--rL];) r.pop(); + + if (carry) ++e; + else r.shift(); + + // Remove trailing zeros. + for (i = r.length; !r[--i];) r.pop(); + + y.d = r; + y.e = getBase10Exponent(r, e); + + return external ? finalise(y, Ctor.precision, Ctor.rounding) : y; + }; + + + /* + * Return a string representing the value of this Decimal in base 2, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toBinary = function (sd, rm) { + return toStringBinary(this, 2, sd, rm); + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp` + * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted. + * + * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toDecimalPlaces = P.toDP = function (dp, rm) { + var x = this, + Ctor = x.constructor; + + x = new Ctor(x); + if (dp === void 0) return x; + + checkInt32(dp, 0, MAX_DIGITS); + + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + + return finalise(x, dp + x.e + 1, rm); + }; + + + /* + * Return a string representing the value of this Decimal in exponential notation rounded to + * `dp` fixed decimal places using rounding mode `rounding`. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toExponential = function (dp, rm) { + var str, + x = this, + Ctor = x.constructor; + + if (dp === void 0) { + str = finiteToString(x, true); + } else { + checkInt32(dp, 0, MAX_DIGITS); + + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + + x = finalise(new Ctor(x), dp + 1, rm); + str = finiteToString(x, true, dp + 1); + } + + return x.isNeg() && !x.isZero() ? '-' + str : str; + }; + + + /* + * Return a string representing the value of this Decimal in normal (fixed-point) notation to + * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is + * omitted. + * + * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'. + * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'. + * (-0).toFixed(3) is '0.000'. + * (-0.5).toFixed(0) is '-0'. + * + */ + P.toFixed = function (dp, rm) { + var str, y, + x = this, + Ctor = x.constructor; + + if (dp === void 0) { + str = finiteToString(x); + } else { + checkInt32(dp, 0, MAX_DIGITS); + + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + + y = finalise(new Ctor(x), dp + x.e + 1, rm); + str = finiteToString(y, false, dp + y.e + 1); + } + + // To determine whether to add the minus sign look at the value before it was rounded, + // i.e. look at `x` rather than `y`. + return x.isNeg() && !x.isZero() ? '-' + str : str; + }; + + + /* + * Return an array representing the value of this Decimal as a simple fraction with an integer + * numerator and an integer denominator. + * + * The denominator will be a positive non-zero value less than or equal to the specified maximum + * denominator. If a maximum denominator is not specified, the denominator will be the lowest + * value necessary to represent the number exactly. + * + * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity. + * + */ + P.toFraction = function (maxD) { + var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, + x = this, + xd = x.d, + Ctor = x.constructor; + + if (!xd) return new Ctor(x); + + n1 = d0 = new Ctor(1); + d1 = n0 = new Ctor(0); + + d = new Ctor(d1); + e = d.e = getPrecision(xd) - x.e - 1; + k = e % LOG_BASE; + d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k); + + if (maxD == null) { + + // d is 10**e, the minimum max-denominator needed. + maxD = e > 0 ? d : n1; + } else { + n = new Ctor(maxD); + if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n); + maxD = n.gt(d) ? (e > 0 ? d : n1) : n; + } + + external = false; + n = new Ctor(digitsToString(xd)); + pr = Ctor.precision; + Ctor.precision = e = xd.length * LOG_BASE * 2; + + for (;;) { + q = divide(n, d, 0, 1, 1); + d2 = d0.plus(q.times(d1)); + if (d2.cmp(maxD) == 1) break; + d0 = d1; + d1 = d2; + d2 = n1; + n1 = n0.plus(q.times(d2)); + n0 = d2; + d2 = d; + d = n.minus(q.times(d2)); + n = d2; + } + + d2 = divide(maxD.minus(d0), d1, 0, 1, 1); + n0 = n0.plus(d2.times(n1)); + d0 = d0.plus(d2.times(d1)); + n0.s = n1.s = x.s; + + // Determine which fraction is closer to x, n0/d0 or n1/d1? + r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 + ? [n1, d1] : [n0, d0]; + + Ctor.precision = pr; + external = true; + + return r; + }; + + + /* + * Return a string representing the value of this Decimal in base 16, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toHexadecimal = P.toHex = function (sd, rm) { + return toStringBinary(this, 16, sd, rm); + }; + + + /* + * Return a string representing the exact value of this Decimal in a compact base-88 based format. + * + * The number of characters of the string will always be equal to or less than the number of + * characters returned by `toString` or `toExponential` - usually just over half as many. + * + * The original Decimal value can be recreated by passing the string to `Decimal.fromJSON`. + * + * Base 88 alphabet: + * 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~ + * + * The following 7 printable ASCII characters are not used + * (space) \ " & ' < > + * so the return value is safe for strings, HTML, JSON, and XML. + * + * 0 0 g 16 w 32 M 48 $ 64 ] 80 + * 1 1 h 17 x 33 N 49 % 65 ^ 81 + * 2 2 i 18 y 34 O 50 ( 66 _ 82 + * 3 3 j 19 z 35 P 51 ) 67 ` 83 + * 4 4 k 20 A 36 Q 52 * 68 { 84 + * 5 5 l 21 B 37 R 53 + 69 | 85 + * 6 6 m 22 C 38 S 54 , 70 } 86 + * 7 7 n 23 D 39 T 55 - 71 ~ 87 + * 8 8 o 24 E 40 U 56 . 72 + * 9 9 p 25 F 41 V 57 / 73 + * a 10 q 26 G 42 W 58 : 74 + * b 11 r 27 H 43 X 59 ; 75 + * c 12 s 28 I 44 Y 60 = 76 + * d 13 t 29 J 45 Z 61 ? 77 + * e 14 u 30 K 46 ! 62 @ 78 + * f 15 v 31 L 47 # 63 [ 79 + * + * If the return value is just one character, it represents: + * 0-81 [[0, 40][-0, -40]] + * 82 -Infinity + * 83 +Infinity + * 84 NaN + * 85-87 free + * + * 64 32 16 8 4 2 1 + * 1 0 1 0 1 1 1 = 87 + * + */ + P.toJSON = function () { + var arr, e, i, k, len, n, r, str, + x = this, + isNeg = x.s < 0; + + // -Infinity/Infinity/NaN. + if (!x.d) return NUMERALS.charAt(x.s ? isNeg ? 82 : 83 : 84); + e = x.e; + + // Small integer. + if (x.d.length === 1 && e < 4 && e >= 0) { + n = x.d[0]; + + if (n < 2857) { + + // One character. + // [[0, 40][-0, -40]] + if (n < 41) return NUMERALS.charAt(isNeg ? n + 41 : n); + + // Two characters. High bit of first character unset. + // 0XXXXXX + // 63*88 + 87 = 5631 = 5632 values, 5632/2 = 2816 + // [[0, 2815][2816, 5631]] (2816 * 2 = 5632 values) + // [[0, 2815][-0, -2815]] + // [[41, 2856][-41, -2856]] + n -= 41; + if (isNeg) n += 2816; + k = n / 88 | 0; + + return NUMERALS.charAt(k) + NUMERALS.charAt(n - k * 88); + } + } + + str = digitsToString(x.d); + r = ''; + + // Values with a small exponent. Set high bit. + // Positive value: 100XXXX + // 1 0 0 {exponent [0, 15] -> [-7, 8]} + if (!isNeg && e <= 8 && e >= -7) { + k = 64 + e + 7; + + // Negative value: 1010XXX + // 1 0 1 0 {exponent [0, 7] -> [-3, 4]} + } else if (isNeg && e <= 4 && e >= -3) { + k = 64 + 16 + e + 3; + + // Integer without trailing zeros: 0X00000 + // 0 {is negative} 0 0 0 0 0 + } else if (str.length === e + 1) { + k = 32 * isNeg; + + // All remaining values: 0XXXXXX + // Result will have at least 3 characters. + // 0 {is negative} {is exponent negative} {exponent character count [1, 15]} + } else { + k = 32 * isNeg + 16 * (e < 0); + e = Math.abs(e); + + // One character to represent the exponent. + if (e < 88) { + k += 1; + r = NUMERALS.charAt(e); + + // Two characters to represent the exponent. + // 87*88 + 87 = 7743 + } else if (e < 7744) { + k += 2; + n = e / 88 | 0; + r = NUMERALS.charAt(n) + NUMERALS.charAt(e - n * 88); + + // More than two characters to represent the exponent. + } else { + arr = convertBase(String(e), 10, 88); + len = arr.length; + k += len; + for (i = 0; i < len; i++) r += NUMERALS.charAt(arr[i]); + } + } + + // At this point r contains the characters in base 88 representing the exponent value. + // Prepend the first character, which describes the sign, the exponent sign, and the number of + // characters that follow which represent the exponent value. + r = NUMERALS.charAt(k) + r; + arr = convertBase(str, 10, 88); + len = arr.length; + + // Add the base 88 characters that represent the significand. + for (i = 0; i < len; i++) r += NUMERALS.charAt(arr[i]); + + return r; + }; + + + /* + * Returns a new Decimal whose value is the nearest multiple of the magnitude of `y` to the value + * of this Decimal. + * + * If the value of this Decimal is equidistant from two multiples of `y`, the rounding mode `rm`, + * or `Decimal.rounding` if `rm` is omitted, determines the direction of the nearest multiple. + * + * In the context of this method, rounding mode 4 (ROUND_HALF_UP) is the same as rounding mode 0 + * (ROUND_UP), and so on. + * + * The return value will always have the same sign as this Decimal, unless either this Decimal + * or `y` is NaN, in which case the return value will be also be NaN. + * + * The return value is not affected by the value of `precision`. + * + * y {number|string|Decimal} The magnitude to round to a multiple of. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * 'toNearest() rounding mode not an integer: {rm}' + * 'toNearest() rounding mode out of range: {rm}' + * + */ + P.toNearest = function (y, rm) { + var x = this, + Ctor = x.constructor; + + x = new Ctor(x); + + if (y == null) { + + // If x is not finite, return x. + if (!x.d) return x; + + y = new Ctor(1); + rm = Ctor.rounding; + } else { + y = new Ctor(y); + if (rm !== void 0) checkInt32(rm, 0, 8); + + // If x is not finite, return x if y is not NaN, else NaN. + if (!x.d) return y.s ? x : y; + + // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN. + if (!y.d) { + if (y.s) y.s = x.s; + return y; + } + } + + // If y is not zero, calculate the nearest multiple of y to x. + if (y.d[0]) { + external = false; + if (rm < 4) rm = [4, 5, 7, 8][rm]; + x = divide(x, y, 0, rm, 1).times(y); + external = true; + finalise(x); + + // If y is zero, return zero with the sign of x. + } else { + y.s = x.s; + x = y; + } + + return x; + }; + + + /* + * Return the value of this Decimal converted to a number primitive. + * Zero keeps its sign. + * + */ + P.toNumber = function () { + return +this; + }; + + + /* + * Return a string representing the value of this Decimal in base 8, round to `sd` significant + * digits using rounding mode `rm`. + * + * If the optional `sd` argument is present then return binary exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toOctal = function (sd, rm) { + return toStringBinary(this, 8, sd, rm); + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded + * to `precision` significant digits using rounding mode `rounding`. + * + * ECMAScript compliant. + * + * pow(x, NaN) = NaN + * pow(x, ±0) = 1 + + * pow(NaN, non-zero) = NaN + * pow(abs(x) > 1, +Infinity) = +Infinity + * pow(abs(x) > 1, -Infinity) = +0 + * pow(abs(x) == 1, ±Infinity) = NaN + * pow(abs(x) < 1, +Infinity) = +0 + * pow(abs(x) < 1, -Infinity) = +Infinity + * pow(+Infinity, y > 0) = +Infinity + * pow(+Infinity, y < 0) = +0 + * pow(-Infinity, odd integer > 0) = -Infinity + * pow(-Infinity, even integer > 0) = +Infinity + * pow(-Infinity, odd integer < 0) = -0 + * pow(-Infinity, even integer < 0) = +0 + * pow(+0, y > 0) = +0 + * pow(+0, y < 0) = +Infinity + * pow(-0, odd integer > 0) = -0 + * pow(-0, even integer > 0) = +0 + * pow(-0, odd integer < 0) = -Infinity + * pow(-0, even integer < 0) = +Infinity + * pow(finite x < 0, finite non-integer) = NaN + * + * For non-integer or very large exponents pow(x, y) is calculated using + * + * x^y = exp(y*ln(x)) + * + * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the + * probability of an incorrectly rounded result + * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14 + * i.e. 1 in 250,000,000,000,000 + * + * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place). + * + * y {number|string|Decimal} The power to which to raise this Decimal. + * + */ + P.toPower = P.pow = function (y) { + var e, k, pr, r, rm, sign, yIsInt, + x = this, + Ctor = x.constructor, + yn = +(y = new Ctor(y)); + + // Either ±Infinity, NaN or ±0? + if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn)); + + x = new Ctor(x); + + if (x.eq(1)) return x; + + pr = Ctor.precision; + rm = Ctor.rounding; + + if (y.eq(1)) return finalise(x, pr, rm); + + e = mathfloor(y.e / LOG_BASE); + k = y.d.length - 1; + yIsInt = e >= k; + sign = x.s; + + if (!yIsInt) { + if (sign < 0) return new Ctor(NaN); + + // If y is a small integer use the 'exponentiation by squaring' algorithm. + } else if ((k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) { + r = intPow(Ctor, x, k, pr); + return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm); + } + + // Result is negative if x is negative and the last digit of integer y is odd. + sign = sign < 0 && y.d[Math.max(e, k)] & 1 ? -1 : 1; + + // Estimate result exponent. + // x^y = 10^e, where e = y * log10(x) + // log10(x) = log10(x_significand) + x_exponent + // log10(x_significand) = ln(x_significand) / ln(10) + k = mathpow(+x, yn); + e = k == 0 || !isFinite(k) + ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1)) + : new Ctor(k + '').e; + + // Estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1. + + // Overflow/underflow? + if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? sign / 0 : 0); + + external = false; + Ctor.rounding = x.s = 1; + + // Estimate the extra guard digits needed to ensure five correct rounding digits from + // naturalLogarithm(x). Example of failure without these extra digits (precision: 10): + // new Decimal(2.32456).pow('2087987436534566.46411') + // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815 + k = Math.min(12, (e + '').length); + + // r = x^y = exp(y*ln(x)) + r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr); + + // Truncate to the required precision plus five rounding digits. + r = finalise(r, pr + 5, 1); + + // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate + // the result. + if (checkRoundingDigits(r.d, pr, rm)) { + e = pr + 10; + + // Truncate to the increased precision plus five rounding digits. + r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1); + + // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9). + if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) { + r = finalise(r, pr + 1, 0); + } + } + + r.s = sign; + external = true; + Ctor.rounding = rm; + + return finalise(r, pr, rm); + }; + + + /* + * Return a string representing the value of this Decimal rounded to `sd` significant digits + * using rounding mode `rounding`. + * + * Return exponential notation if `sd` is less than the number of digits necessary to represent + * the integer part of the value in normal notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + */ + P.toPrecision = function (sd, rm) { + var str, + x = this, + Ctor = x.constructor; + + if (sd === void 0) { + str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); + } else { + checkInt32(sd, 1, MAX_DIGITS); + + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + + x = finalise(new Ctor(x), sd, rm); + str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd); + } + + return x.isNeg() && !x.isZero() ? '-' + str : str; + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd` + * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if + * omitted. + * + * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * 'toSD() digits out of range: {sd}' + * 'toSD() digits not an integer: {sd}' + * 'toSD() rounding mode not an integer: {rm}' + * 'toSD() rounding mode out of range: {rm}' + * + */ + P.toSignificantDigits = P.toSD = function (sd, rm) { + var x = this, + Ctor = x.constructor; + + if (sd === void 0) { + sd = Ctor.precision; + rm = Ctor.rounding; + } else { + checkInt32(sd, 1, MAX_DIGITS); + + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + } + + return finalise(new Ctor(x), sd, rm); + }; + + + /* + * Return a string representing the value of this Decimal. + * + * Return exponential notation if this Decimal has a positive exponent equal to or greater than + * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`. + * + */ + P.toString = function () { + var x = this, + Ctor = x.constructor, + str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); + + return x.isNeg() && !x.isZero() ? '-' + str : str; + }; + + + /* + * Return a new Decimal whose value is the value of this Decimal truncated to a whole number. + * + */ + P.truncated = P.trunc = function () { + return finalise(new this.constructor(this), this.e + 1, 1); + }; + + + /* + * Return a string representing the value of this Decimal. + * Unlike `toString`, negative zero will include the minus sign. + * + */ + P.valueOf = function () { + var x = this, + Ctor = x.constructor, + str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos); + + return x.isNeg() ? '-' + str : str; + }; + + + /* + // Add aliases to match BigDecimal method names. + // P.add = P.plus; + P.subtract = P.minus; + P.multiply = P.times; + P.divide = P.div; + P.remainder = P.mod; + P.compareTo = P.cmp; + P.negate = P.neg; + */ + + + // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers. + + + /* + * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toJSON, + * P.toPower, finiteToString, naturalExponential, naturalLogarithm + * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest, + * P.toPrecision, P.toSignificantDigits, toStringBinary, random + * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm + * convertBase P.toJSON, toStringBinary, fromJSON, parseOther + * cos P.cos + * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy, + * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction, + * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm, + * taylorSeries, atan2, parseOther + * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh, + * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus, + * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot, + * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed, + * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits, + * P.truncated, divide, getLn10, getPi, naturalExponential, + * naturalLogarithm, ceil, floor, round, trunc + * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf, + * toStringBinary + * getBase10Exponent P.minus, P.plus, P.times, parseOther + * getLn10 P.logarithm, naturalLogarithm + * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2 + * getPrecision P.precision, P.toFraction + * getZeroString digitsToString, finiteToString + * intPow P.toPower, parseOther + * isOdd toLessThanHalfPi + * maxOrMin max, min + * naturalExponential P.naturalExponential, P.toPower + * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm, + * P.toPower, naturalExponential + * nonFiniteToString finiteToString, toStringBinary + * parseDecimal Decimal + * parseOther Decimal + * sin P.sin + * taylorSeries P.cosh, P.sinh, cos, sin + * toLessThanHalfPi P.cos, P.sin + * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal + * truncate intPow + * + * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi, + * naturalLogarithm, config, fromJSON, parseOther, random, Decimal * + */ + + + function digitsToString(d) { + var i, k, ws, + indexOfLastWord = d.length - 1, + str = '', + w = d[0]; + + if (indexOfLastWord > 0) { + str += w; + for (i = 1; i < indexOfLastWord; i++) { + ws = d[i] + ''; + k = LOG_BASE - ws.length; + if (k) str += getZeroString(k); + str += ws; + } + + w = d[i]; + ws = w + ''; + k = LOG_BASE - ws.length; + if (k) str += getZeroString(k); + } else if (w === 0) { + return '0'; + } + + // Remove trailing zeros of last w. + for (; w % 10 === 0;) w /= 10; + + return str + w; + } + + + function checkInt32(i, min, max) { + if (i !== ~~i || i < min || i > max) { + throw Error(invalidArgument + i); + } + } + + + /* + * Check 5 rounding digits if `repeating` is null, 4 otherwise. + * `repeating == null` if caller is `log` or `pow`, + * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`. + */ + function checkRoundingDigits(d, i, rm, repeating) { + var di, k, r, rd; + + // Get the length of the first word of the array d. + for (k = d[0]; k >= 10; k /= 10) --i; + + // Is the rounding digit in the first word of d? + if (--i < 0) { + i += LOG_BASE; + di = 0; + } else { + di = Math.ceil((i + 1) / LOG_BASE); + i %= LOG_BASE; + } + + // i is the index (0 - 6) of the rounding digit. + // E.g. if within the word 3487563 the first rounding digit is 5, + // then i = 4, k = 1000, rd = 3487563 % 1000 = 563 + k = mathpow(10, LOG_BASE - i); + rd = d[di] % k | 0; + + if (repeating == null) { + if (i < 3) { + if (i == 0) rd = rd / 100 | 0; + else if (i == 1) rd = rd / 10 | 0; + r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0; + } else { + r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && + (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || + (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0; + } + } else { + if (i < 4) { + if (i == 0) rd = rd / 1000 | 0; + else if (i == 1) rd = rd / 100 | 0; + else if (i == 2) rd = rd / 10 | 0; + r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999; + } else { + r = ((repeating || rm < 4) && rd + 1 == k || + (!repeating && rm > 3) && rd + 1 == k / 2) && + (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1; + } + } + + return r; + } + + + // Convert string of `baseIn` to an array of numbers of `baseOut`. + // Eg. convertBase('255', 10, 16) returns [15, 15]. + // Eg. convertBase('ff', 16, 10) returns [2, 5, 5]. + function convertBase(str, baseIn, baseOut) { + var j, + arr = [0], + arrL, + i = 0, + strL = str.length; + + for (; i < strL;) { + for (arrL = arr.length; arrL--;) arr[arrL] *= baseIn; + arr[0] += NUMERALS.indexOf(str.charAt(i++)); + for (j = 0; j < arr.length; j++) { + if (arr[j] > baseOut - 1) { + if (arr[j + 1] === void 0) arr[j + 1] = 0; + arr[j + 1] += arr[j] / baseOut | 0; + arr[j] %= baseOut; + } + } + } + + return arr.reverse(); + } + + + /* + * cos(x) = 1 - x^2/2! + x^4/4! - ... + * |x| < pi/2 + * + */ + function cosine(Ctor, x) { + var k, y, + len = x.d.length; + + // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1 + // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1 + + // Estimate the optimum number of times to use the argument reduction. + if (len < 32) { + k = Math.ceil(len / 3); + y = Math.pow(4, -k).toString(); + } else { + k = 16; + y = '2.3283064365386962890625e-10'; + } + + Ctor.precision += k; + + x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1)); + + // Reverse argument reduction + for (var i = k; i--;) { + var cos2x = x.times(x); + x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1); + } + + Ctor.precision -= k; + + return x; + } + + + /* + * Perform division in the specified base. + */ + var divide = (function () { + + // Assumes non-zero x and k, and hence non-zero result. + function multiplyInteger(x, k, base) { + var temp, + carry = 0, + i = x.length; + + for (x = x.slice(); i--;) { + temp = x[i] * k + carry; + x[i] = temp % base | 0; + carry = temp / base | 0; + } + + if (carry) x.unshift(carry); + + return x; + } + + function compare(a, b, aL, bL) { + var i, r; + + if (aL != bL) { + r = aL > bL ? 1 : -1; + } else { + for (i = r = 0; i < aL; i++) { + if (a[i] != b[i]) { + r = a[i] > b[i] ? 1 : -1; + break; + } + } + } + + return r; + } + + function subtract(a, b, aL, base) { + var i = 0; + + // Subtract b from a. + for (; aL--;) { + a[aL] -= i; + i = a[aL] < b[aL] ? 1 : 0; + a[aL] = i * base + a[aL] - b[aL]; + } + + // Remove leading zeros. + for (; !a[0] && a.length > 1;) a.shift(); + } + + return function (x, y, pr, rm, dp, base) { + var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, + yL, yz, + Ctor = x.constructor, + sign = x.s == y.s ? 1 : -1, + xd = x.d, + yd = y.d; + + // Either NaN, Infinity or 0? + if (!xd || !xd[0] || !yd || !yd[0]) { + + return new Ctor(// Return NaN if either NaN, or both Infinity or 0. + !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : + + // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0. + xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0); + } + + if (base) { + logBase = 1; + e = x.e - y.e; + } else { + base = BASE; + logBase = LOG_BASE; + e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase); + } + + yL = yd.length; + xL = xd.length; + q = new Ctor(sign); + qd = q.d = []; + + // Result exponent may be one less than e. + // The digit array of a Decimal from toStringBinary may have trailing zeros. + for (i = 0; yd[i] == (xd[i] || 0); i++); + + if (yd[i] > (xd[i] || 0)) e--; + + if (pr == null) { + sd = pr = Ctor.precision; + rm = Ctor.rounding; + } else if (dp) { + sd = pr + (x.e - y.e) + 1; + } else { + sd = pr; + } + + if (sd < 0) { + qd.push(1); + more = true; + } else { + + // Convert precision in number of base 10 digits to base 1e7 digits. + sd = sd / logBase + 2 | 0; + i = 0; + + // divisor < 1e7 + if (yL == 1) { + k = 0; + yd = yd[0]; + sd++; + + // k is the carry. + for (; (i < xL || k) && sd--; i++) { + t = k * base + (xd[i] || 0); + qd[i] = t / yd | 0; + k = t % yd | 0; + } + + more = k || i < xL; + + // divisor >= 1e7 + } else { + + // Normalise xd and yd so highest order digit of yd is >= base/2 + k = base / (yd[0] + 1) | 0; + + if (k > 1) { + yd = multiplyInteger(yd, k, base); + xd = multiplyInteger(xd, k, base); + yL = yd.length; + xL = xd.length; + } + + xi = yL; + rem = xd.slice(0, yL); + remL = rem.length; + + // Add zeros to make remainder as long as divisor. + for (; remL < yL;) rem[remL++] = 0; + + yz = yd.slice(); + yz.unshift(0); + yd0 = yd[0]; + + if (yd[1] >= base / 2) ++yd0; + + do { + k = 0; + + // Compare divisor and remainder. + cmp = compare(yd, rem, yL, remL); + + // If divisor < remainder. + if (cmp < 0) { + + // Calculate trial digit, k. + rem0 = rem[0]; + if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); + + // k will be how many times the divisor goes into the current remainder. + k = rem0 / yd0 | 0; + + // Algorithm: + // 1. product = divisor * trial digit (k) + // 2. if product > remainder: product -= divisor, k-- + // 3. remainder -= product + // 4. if product was < remainder at 2: + // 5. compare new remainder and divisor + // 6. If remainder > divisor: remainder -= divisor, k++ + + if (k > 1) { + if (k >= base) k = base - 1; + + // product = divisor * trial digit. + prod = multiplyInteger(yd, k, base); + prodL = prod.length; + remL = rem.length; + + // Compare product and remainder. + cmp = compare(prod, rem, prodL, remL); + + // product > remainder. + if (cmp == 1) { + k--; + + // Subtract divisor from product. + subtract(prod, yL < prodL ? yz : yd, prodL, base); + } + } else { + + // cmp is -1. + // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1 + // to avoid it. If k is 1 there is a need to compare yd and rem again below. + if (k == 0) cmp = k = 1; + prod = yd.slice(); + } + + prodL = prod.length; + if (prodL < remL) prod.unshift(0); + + // Subtract product from remainder. + subtract(rem, prod, remL, base); + + // If product was < previous remainder. + if (cmp == -1) { + remL = rem.length; + + // Compare divisor and new remainder. + cmp = compare(yd, rem, yL, remL); + + // If divisor < new remainder, subtract divisor from remainder. + if (cmp < 1) { + k++; + + // Subtract divisor from remainder. + subtract(rem, yL < remL ? yz : yd, remL, base); + } + } + + remL = rem.length; + } else if (cmp === 0) { + k++; + rem = [0]; + } // if cmp === 1, k will be 0 + + // Add the next digit, k, to the result array. + qd[i++] = k; + + // Update the remainder. + if (cmp && rem[0]) { + rem[remL++] = xd[xi] || 0; + } else { + rem = [xd[xi]]; + remL = 1; + } + + } while ((xi++ < xL || rem[0] !== void 0) && sd--); + + more = rem[0] !== void 0; + } + + // Leading zero? + if (!qd[0]) qd.shift(); + } + + // logBase is 1 when divide is being used for base conversion. + if (logBase == 1) { + q.e = e; + inexact = more; + } else { + + // To calculate q.e, first get the number of digits of qd[0]. + for (i = 1, k = qd[0]; k >= 10; k /= 10) i++; + q.e = i + e * logBase - 1; + + finalise(q, dp ? pr + q.e + 1 : pr, rm, more); + } + + return q; + }; + })(); + + + /* + * Round `x` to `sd` significant digits using rounding mode `rm`. + * Check for over/under-flow. + */ + function finalise(x, sd, rm, isTruncated) { + var digits, i, j, k, rd, roundUp, w, xd, xdi, + Ctor = x.constructor; + + // Don't round if sd is null or undefined. + out: if (sd != null) { + xd = x.d; + + // Infinity/NaN. + if (!xd) return x; + + // rd: the rounding digit, i.e. the digit after the digit that may be rounded up. + // w: the word of xd containing rd, a base 1e7 number. + // xdi: the index of w within xd. + // digits: the number of digits of w. + // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if + // they had leading zeros) + // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero). + + // Get the length of the first word of the digits array xd. + for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++; + i = sd - digits; + + // Is the rounding digit in the first word of xd? + if (i < 0) { + i += LOG_BASE; + j = sd; + w = xd[xdi = 0]; + + // Get the rounding digit at index j of w. + rd = w / mathpow(10, digits - j - 1) % 10 | 0; + } else { + xdi = Math.ceil((i + 1) / LOG_BASE); + k = xd.length; + if (xdi >= k) { + if (isTruncated) { + + // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`. + for (; k++ <= xdi;) xd.push(0); + w = rd = 0; + digits = 1; + i %= LOG_BASE; + j = i - LOG_BASE + 1; + } else { + break out; + } + } else { + w = k = xd[xdi]; + + // Get the number of digits of w. + for (digits = 1; k >= 10; k /= 10) digits++; + + // Get the index of rd within w. + i %= LOG_BASE; + + // Get the index of rd within w, adjusted for leading zeros. + // The number of leading zeros of w is given by LOG_BASE - digits. + j = i - LOG_BASE + digits; + + // Get the rounding digit at index j of w. + rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0; + } + } + + // Are there any non-zero digits after the rounding digit? + isTruncated = isTruncated || sd < 0 || + xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1)); + + // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right + // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression + // will give 714. + + roundUp = rm < 4 + ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && + + // Check whether the digit to the left of the rounding digit is odd. + ((i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10) & 1 || + rm == (x.s < 0 ? 8 : 7)); + + if (sd < 1 || !xd[0]) { + xd.length = 0; + if (roundUp) { + + // Convert sd to decimal places. + sd -= x.e + 1; + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE); + x.e = -sd || 0; + } else { + + // Zero. + xd[0] = x.e = 0; + } + + return x; + } + + // Remove excess digits. + if (i == 0) { + xd.length = xdi; + k = 1; + xdi--; + } else { + xd.length = xdi + 1; + k = mathpow(10, LOG_BASE - i); + + // E.g. 56700 becomes 56000 if 7 is the rounding digit. + // j > 0 means i > number of leading zeros of w. + xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0; + } + + if (roundUp) { + for (;;) { + + // Is the digit to be rounded up in the first word of xd? + if (xdi == 0) { + + // i will be the length of xd[0] before k is added. + for (i = 1, j = xd[0]; j >= 10; j /= 10) i++; + j = xd[0] += k; + for (k = 1; j >= 10; j /= 10) k++; + + // if i != k the length has increased. + if (i != k) { + x.e++; + if (xd[0] == BASE) xd[0] = 1; + } + + break; + } else { + xd[xdi] += k; + if (xd[xdi] != BASE) break; + xd[xdi--] = 0; + k = 1; + } + } + } + + // Remove trailing zeros. + for (i = xd.length; xd[--i] === 0;) xd.pop(); + } + + if (external) { + + // Overflow? + if (x.e > Ctor.maxE) { + + // Infinity. + x.d = null; + x.e = NaN; + + // Underflow? + } else if (x.e < Ctor.minE) { + + // Zero. + x.e = 0; + x.d = [0]; + // Ctor.underflow = true; + } // else Ctor.underflow = false; + } + + return x; + } + + + function finiteToString(x, isExp, sd) { + if (!x.isFinite()) return nonFiniteToString(x); + var k, + e = x.e, + str = digitsToString(x.d), + len = str.length; + + if (isExp) { + if (sd && (k = sd - len) > 0) { + str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k); + } else if (len > 1) { + str = str.charAt(0) + '.' + str.slice(1); + } + + str = str + (x.e < 0 ? 'e' : 'e+') + x.e; + } else if (e < 0) { + str = '0.' + getZeroString(-e - 1) + str; + if (sd && (k = sd - len) > 0) str += getZeroString(k); + } else if (e >= len) { + str += getZeroString(e + 1 - len); + if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k); + } else { + if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k); + if (sd && (k = sd - len) > 0) { + if (e + 1 === len) str += '.'; + str += getZeroString(k); + } + } + + return str; + } + + + // Calculate the base 10 exponent from the base 1e7 exponent. + function getBase10Exponent(digits, e) { + + // First get the number of digits of the first word of the digits array. + for (var i = 1, w = digits[0]; w >= 10; w /= 10) i++; + return i + e * LOG_BASE - 1; + } + + + function getLn10(Ctor, sd, pr) { + if (sd > LN10_PRECISION) { + + // Reset global state in case the exception is caught. + external = true; + if (pr) Ctor.precision = pr; + throw Error(precisionLimitExceeded); + } + return finalise(new Ctor(LN10), sd, 1, true); + } + + + function getPi(Ctor, sd, rm) { + if (sd > PI_PRECISION) throw Error(precisionLimitExceeded); + return finalise(new Ctor(PI), sd, rm, true); + } + + + function getPrecision(digits) { + var w = digits.length - 1, + len = w * LOG_BASE + 1; + + w = digits[w]; + + // If non-zero... + if (w) { + + // Subtract the number of trailing zeros of the last word. + for (; w % 10 == 0; w /= 10) len--; + + // Add the number of digits of the first word. + for (w = digits[0]; w >= 10; w /= 10) len++; + } + + return len; + } + + + function getZeroString(k) { + var zs = ''; + for (; k--;) zs += '0'; + return zs; + } + + + /* + * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an + * integer of type number. + * + * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`. + * + */ + function intPow(Ctor, x, n, pr) { + var isTruncated, + r = new Ctor(1), + + // Max n of 9007199254740991 takes 53 loop iterations. + // Maximum digits array length; leaves [28, 34] guard digits. + k = Math.ceil(pr / LOG_BASE + 4); + + external = false; + + for (;;) { + if (n % 2) { + r = r.times(x); + if (truncate(r.d, k)) isTruncated = true; + } + + n = mathfloor(n / 2); + if (n === 0) { + + // To ensure correct rounding when r.d is truncated, increment the last word if it is zero. + n = r.d.length - 1; + if (isTruncated && r.d[n] === 0) ++r.d[n]; + break; + } + + x = x.times(x); + truncate(x.d, k); + } + + external = true; + + return r; + } + + + function isOdd(n) { + return n.d[n.d.length - 1] & 1; + } + + + /* + * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'. + */ + function maxOrMin(Ctor, args, ltgt) { + var y, + x = new Ctor(args[0]), + i = 0; + + for (; ++i < args.length;) { + y = new Ctor(args[i]); + if (!y.s) { + x = y; + break; + } else if (x[ltgt](y)) { + x = y; + } + } + + return x; + } + + + /* + * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant + * digits. + * + * Taylor/Maclaurin series. + * + * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ... + * + * Argument reduction: + * Repeat x = x / 32, k += 5, until |x| < 0.1 + * exp(x) = exp(x / 2^k)^(2^k) + * + * Previously, the argument was initially reduced by + * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10) + * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was + * found to be slower than just dividing repeatedly by 32 as above. + * + * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000 + * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000 + * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324) + * + * exp(Infinity) = Infinity + * exp(-Infinity) = 0 + * exp(NaN) = NaN + * exp(±0) = 1 + * + * exp(x) is non-terminating for any finite, non-zero x. + * + * The result will always be correctly rounded. + * + */ + function naturalExponential(x, sd) { + var denominator, guard, j, pow, sum, t, wpr, + rep = 0, + i = 0, + k = 0, + Ctor = x.constructor, + rm = Ctor.rounding, + pr = Ctor.precision; + + // 0/NaN/Infinity? + if (!x.d || !x.d[0] || x.e > 17) { + + return new Ctor(x.d + ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 + : x.s ? x.s < 0 ? 0 : x : 0 / 0); + } + + if (sd == null) { + external = false; + wpr = pr; + } else { + wpr = sd; + } + + t = new Ctor(0.03125); + + // while abs(x) >= 0.1 + while (x.e > -2) { + + // x = x / 2^5 + x = x.times(t); + k += 5; + } + + // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision + // necessary to ensure the first 4 rounding digits are correct. + guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0; + wpr += guard; + denominator = pow = sum = new Ctor(1); + Ctor.precision = wpr; + + for (;;) { + pow = finalise(pow.times(x), wpr, 1); + denominator = denominator.times(++i); + t = sum.plus(divide(pow, denominator, wpr, 1)); + + if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) { + j = k; + while (j--) sum = finalise(sum.times(sum), wpr, 1); + + // Check to see if the first 4 rounding digits are [49]999. + // If so, repeat the summation with a higher precision, otherwise + // e.g. with precision: 18, rounding: 1 + // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123) + // `wpr - guard` is the index of first rounding digit. + if (sd == null) { + + if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) { + Ctor.precision = wpr += 10; + denominator = pow = t = new Ctor(1); + i = 0; + rep++; + } else { + return finalise(sum, Ctor.precision = pr, rm, external = true); + } + } else { + Ctor.precision = pr; + return sum; + } + } + + sum = t; + } + } + + + /* + * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant + * digits. + * + * ln(-n) = NaN + * ln(0) = -Infinity + * ln(-0) = -Infinity + * ln(1) = 0 + * ln(Infinity) = Infinity + * ln(-Infinity) = NaN + * ln(NaN) = NaN + * + * ln(n) (n != 1) is non-terminating. + * + */ + function naturalLogarithm(y, sd) { + var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2, + n = 1, + guard = 10, + x = y, + xd = x.d, + Ctor = x.constructor, + rm = Ctor.rounding, + pr = Ctor.precision; + + // Is x negative or Infinity, NaN, 0 or 1? + if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) { + return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x); + } + + if (sd == null) { + external = false; + wpr = pr; + } else { + wpr = sd; + } + + Ctor.precision = wpr += guard; + c = digitsToString(xd); + c0 = c.charAt(0); + + if (Math.abs(e = x.e) < 1.5e15) { + + // Argument reduction. + // The series converges faster the closer the argument is to 1, so using + // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b + // multiply the argument by itself until the leading digits of the significand are 7, 8, 9, + // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can + // later be divided by this number, then separate out the power of 10 using + // ln(a*10^b) = ln(a) + b*ln(10). + + // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14). + //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) { + // max n is 6 (gives 0.7 - 1.3) + while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) { + x = x.times(y); + c = digitsToString(x.d); + c0 = c.charAt(0); + n++; + } + + e = x.e; + + if (c0 > 1) { + x = new Ctor('0.' + c); + e++; + } else { + x = new Ctor(c0 + '.' + c.slice(1)); + } + } else { + + // The argument reduction method above may result in overflow if the argument y is a massive + // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this + // function using ln(x*10^e) = ln(x) + e*ln(10). + t = getLn10(Ctor, wpr + 2, pr).times(e + ''); + x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t); + Ctor.precision = pr; + + return sd == null ? finalise(x, pr, rm, external = true) : x; + } + + // x1 is x reduced to a value near 1. + x1 = x; + + // Taylor series. + // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...) + // where x = (y - 1)/(y + 1) (|x| < 1) + sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1); + x2 = finalise(x.times(x), wpr, 1); + denominator = 3; + + for (;;) { + numerator = finalise(numerator.times(x2), wpr, 1); + t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1)); + + if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) { + sum = sum.times(2); + + // Reverse the argument reduction. Check that e is not 0 because, besides preventing an + // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0. + if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + '')); + sum = divide(sum, new Ctor(n), wpr, 1); + + // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has + // been repeated previously) and the first 4 rounding digits 9999? + // If so, restart the summation with a higher precision, otherwise + // e.g. with precision: 12, rounding: 1 + // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463. + // `wpr - guard` is the index of first rounding digit. + if (sd == null) { + if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) { + Ctor.precision = wpr += guard; + t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1); + x2 = finalise(x.times(x), wpr, 1); + denominator = rep = 1; + } else { + return finalise(sum, Ctor.precision = pr, rm, external = true); + } + } else { + Ctor.precision = pr; + return sum; + } + } + + sum = t; + denominator += 2; + } + } + + + // ±Infinity, NaN. + function nonFiniteToString(x) { + // Unsigned. + return String(x.s * x.s / 0); + } + + + /* + * Parse the value of a new Decimal `x` from string `str`. + */ + function parseDecimal(x, str) { + var e, i, len; + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + + // Exponential form? + if ((i = str.search(/e/i)) > 0) { + + // Determine exponent. + if (e < 0) e = i; + e += +str.slice(i + 1); + str = str.substring(0, i); + } else if (e < 0) { + + // Integer. + e = str.length; + } + + // Determine leading zeros. + for (i = 0; str.charCodeAt(i) === 48; i++); + + // Determine trailing zeros. + for (len = str.length; str.charCodeAt(len - 1) === 48; --len); + str = str.slice(i, len); + + if (str) { + len -= i; + x.e = e = e - i - 1; + x.d = []; + + // Transform base + + // e is the base 10 exponent. + // i is where to slice str to get the first word of the digits array. + i = (e + 1) % LOG_BASE; + if (e < 0) i += LOG_BASE; + + if (i < len) { + if (i) x.d.push(+str.slice(0, i)); + for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE)); + str = str.slice(i); + i = LOG_BASE - str.length; + } else { + i -= len; + } + + for (; i--;) str += '0'; + x.d.push(+str); + + if (external) { + + // Overflow? + if (x.e > x.constructor.maxE) { + + // Infinity. + x.d = null; + x.e = NaN; + + // Underflow? + } else if (x.e < x.constructor.minE) { + + // Zero. + x.e = 0; + x.d = [0]; + // x.constructor.underflow = true; + } // else x.constructor.underflow = false; + } + } else { + + // Zero. + x.e = 0; + x.d = [0]; + } + + return x; + } + + + /* + * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value. + */ + function parseOther(x, str) { + var base, Ctor, divisor, i, isFloat, len, p, xd, xe; + + if (str === 'Infinity' || str === 'NaN') { + if (!+str) x.s = NaN; + x.e = NaN; + x.d = null; + return x; + } + + if (isHex.test(str)) { + base = 16; + str = str.toLowerCase(); + } else if (isBinary.test(str)) { + base = 2; + } else if (isOctal.test(str)) { + base = 8; + } else { + throw Error(invalidArgument + str); + } + + // Is there a binary exponent part? + i = str.search(/p/i); + + if (i > 0) { + p = +str.slice(i + 1); + str = str.substring(2, i); + } else { + str = str.slice(2); + } + + // Convert `str` as an integer then divide the result by `base` raised to a power such that the + // fraction part will be restored. + i = str.indexOf('.'); + isFloat = i >= 0; + Ctor = x.constructor; + + if (isFloat) { + str = str.replace('.', ''); + len = str.length; + i = len - i; + + // log[10](16) = 1.2041... , log[10](88) = 1.9444.... + divisor = intPow(Ctor, new Ctor(base), i, i * 2); + } + + xd = convertBase(str, base, BASE); + xe = xd.length - 1; + + // Remove trailing zeros. + for (i = xe; xd[i] === 0; --i) xd.pop(); + if (i < 0) return new Ctor(x.s * 0); + x.e = getBase10Exponent(xd, xe); + x.d = xd; + external = false; + + // At what precision to perform the division to ensure exact conversion? + // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount) + // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412 + // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits. + // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount + // Therefore using 4 * the number of digits of str will always be enough. + if (isFloat) x = divide(x, divisor, len * 4); + + // Multiply by the binary exponent part if present. + if (p) x = x.times(Math.abs(p) < 54 ? Math.pow(2, p) : Decimal.pow(2, p)); + external = true; + + return x; + } + + + /* + * sin(x) = x - x^3/3! + x^5/5! - ... + * |x| < pi/2 + * + */ + function sine(Ctor, x) { + var k, + len = x.d.length; + + if (len < 3) return taylorSeries(Ctor, 2, x, x); + + // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x) + // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5) + // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20)) + + // Estimate the optimum number of times to use the argument reduction. + k = 1.4 * Math.sqrt(len); + k = k > 16 ? 16 : k | 0; + + // Max k before Math.pow precision loss is 22 + x = x.times(Math.pow(5, -k)); + x = taylorSeries(Ctor, 2, x, x); + + // Reverse argument reduction + var sin2_x, + d5 = new Ctor(5), + d16 = new Ctor(16), + d20 = new Ctor(20); + for (; k--;) { + sin2_x = x.times(x); + x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20)))); + } + + return x; + } + + + // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`. + function taylorSeries(Ctor, n, x, y, isHyperbolic) { + var j, t, u, x2, + i = 1, + pr = Ctor.precision, + k = Math.ceil(pr / LOG_BASE); + + external = false; + x2 = x.times(x); + u = new Ctor(y); + + for (;;) { + t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1); + u = isHyperbolic ? y.plus(t) : y.minus(t); + y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1); + t = u.plus(y); + + if (t.d[k] !== void 0) { + for (j = k; t.d[j] === u.d[j] && j--;); + if (j == -1) break; + } + + j = u; + u = y; + y = t; + t = j; + i++; + } + + external = true; + t.d.length = k + 1; + + return t; + } + + + // Return the absolute value of `x` reduced to less than or equal to half pi. + function toLessThanHalfPi(Ctor, x) { + var t, + isNeg = x.s < 0, + pi = getPi(Ctor, Ctor.precision, 1), + halfPi = pi.times(0.5); + + x = x.abs(); + + if (x.lte(halfPi)) { + quadrant = isNeg ? 4 : 1; + return x; + } + + t = x.divToInt(pi); + + if (t.isZero()) { + quadrant = isNeg ? 3 : 2; + } else { + x = x.minus(t.times(pi)); + + // 0 <= x < pi + if (x.lte(halfPi)) { + quadrant = isOdd(t) ? (isNeg ? 2 : 3) : (isNeg ? 4 : 1); + return x; + } + + quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2); + } + + return x.minus(pi).abs(); + } + + + /* + * Return the value of Decimal `x` as a string in base `baseOut`. + * + * If the optional `sd` argument is present include a binary exponent suffix. + */ + function toStringBinary(x, baseOut, sd, rm) { + var base, e, i, k, len, roundUp, str, xd, y, + Ctor = x.constructor, + isExp = sd !== void 0; + + if (isExp) { + checkInt32(sd, 1, MAX_DIGITS); + if (rm === void 0) rm = Ctor.rounding; + else checkInt32(rm, 0, 8); + } else { + sd = Ctor.precision; + rm = Ctor.rounding; + } + + if (!x.isFinite()) { + str = nonFiniteToString(x); + } else { + str = finiteToString(x); + i = str.indexOf('.'); + + // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required: + // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10)) + // minBinaryExponent = floor(decimalExponent * log[2](10)) + // log[2](10) = 3.321928094887362347870319429489390175864 + + if (isExp) { + base = 2; + if (baseOut == 16) { + sd = sd * 4 - 3; + } else if (baseOut == 8) { + sd = sd * 3 - 2; + } + } else { + base = baseOut; + } + + // Convert the number as an integer then divide the result by its base raised to a power such + // that the fraction part will be restored. + + // Non-integer. + if (i >= 0) { + str = str.replace('.', ''); + y = new Ctor(1); + y.e = str.length - i; + y.d = convertBase(finiteToString(y), 10, base); + y.e = y.d.length; + } + + xd = convertBase(str, 10, base); + e = len = xd.length; + + // Remove trailing zeros. + for (; xd[--len] == 0;) xd.pop(); + + if (!xd[0]) { + str = isExp ? '0p+0' : '0'; + } else { + if (i < 0) { + e--; + } else { + x = new Ctor(x); + x.d = xd; + x.e = e; + x = divide(x, y, sd, rm, 0, base); + xd = x.d; + e = x.e; + roundUp = inexact; + } + + // The rounding digit, i.e. the digit after the digit that may be rounded up. + i = xd[sd]; + k = base / 2; + roundUp = roundUp || xd[sd + 1] !== void 0; + + roundUp = rm < 4 + ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) + : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || + rm === (x.s < 0 ? 8 : 7)); + + xd.length = sd; + + if (roundUp) { + + // Rounding up may mean the previous digit has to be rounded up and so on. + for (; ++xd[--sd] > base - 1;) { + xd[sd] = 0; + if (!sd) { + ++e; + xd.unshift(1); + } + } + } + + // Determine trailing zeros. + for (len = xd.length; !xd[len - 1]; --len); + + // E.g. [4, 11, 15] becomes 4bf. + for (i = 0, str = ''; i < len; i++) str += NUMERALS.charAt(xd[i]); + + // Add binary exponent suffix? + if (isExp) { + if (len > 1) { + if (baseOut == 16 || baseOut == 8) { + i = baseOut == 16 ? 4 : 3; + for (--len; len % i; len++) str += '0'; + xd = convertBase(str, base, baseOut); + for (len = xd.length; !xd[len - 1]; --len); + + // xd[0] will always be be 1 + for (i = 1, str = '1.'; i < len; i++) str += NUMERALS.charAt(xd[i]); + } else { + str = str.charAt(0) + '.' + str.slice(1); + } + } + + str = str + (e < 0 ? 'p' : 'p+') + e; + } else if (e < 0) { + for (; ++e;) str = '0' + str; + str = '0.' + str; + } else { + if (++e > len) for (e -= len; e-- ;) str += '0'; + else if (e < len) str = str.slice(0, e) + '.' + str.slice(e); + } + } + + str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str; + } + + return x.s < 0 ? '-' + str : str; + } + + + // Does not strip trailing zeros. + function truncate(arr, len) { + if (arr.length > len) { + arr.length = len; + return true; + } + } + + + // Decimal methods + + + /* + * abs + * acos + * acosh + * add + * asin + * asinh + * atan + * atanh + * atan2 + * cbrt + * ceil + * clone + * config + * cos + * cosh + * div + * exp + * floor + * fromJSON + * hypot + * ln + * log + * log2 + * log10 + * max + * min + * mod + * mul + * pow + * random + * round + * sign + * sin + * sinh + * sqrt + * sub + * tan + * tanh + * trunc + */ + + + /* + * Return a new Decimal whose value is the absolute value of `x`. + * + * x {number|string|Decimal} + * + */ + function abs(x) { + return new this(x).abs(); + } + + + /* + * Return a new Decimal whose value is the arccosine in radians of `x`. + * + * x {number|string|Decimal} + * + */ + function acos(x) { + return new this(x).acos(); + } + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function acosh(x) { + return new this(x).acosh(); + } + + + /* + * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * y {number|string|Decimal} + * + */ + function add(x, y) { + return new this(x).plus(y); + } + + + /* + * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function asin(x) { + return new this(x).asin(); + } + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function asinh(x) { + return new this(x).asinh(); + } + + + /* + * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function atan(x) { + return new this(x).atan(); + } + + + /* + * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to + * `precision` significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function atanh(x) { + return new this(x).atanh(); + } + + + /* + * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi + * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`. + * + * Domain: [-Infinity, Infinity] + * Range: [-pi, pi] + * + * y {number|string|Decimal} The y-coordinate. + * x {number|string|Decimal} The x-coordinate. + * + * atan2(±0, -0) = ±pi + * atan2(±0, +0) = ±0 + * atan2(±0, -x) = ±pi for x > 0 + * atan2(±0, x) = ±0 for x > 0 + * atan2(-y, ±0) = -pi/2 for y > 0 + * atan2(y, ±0) = pi/2 for y > 0 + * atan2(±y, -Infinity) = ±pi for finite y > 0 + * atan2(±y, +Infinity) = ±0 for finite y > 0 + * atan2(±Infinity, x) = ±pi/2 for finite x + * atan2(±Infinity, -Infinity) = ±3*pi/4 + * atan2(±Infinity, +Infinity) = ±pi/4 + * atan2(NaN, x) = NaN + * atan2(y, NaN) = NaN + * + */ + function atan2(y, x) { + y = new this(y); + x = new this(x); + var r, + pr = this.precision, + rm = this.rounding, + wpr = pr + 4; + + // Either NaN + if (!y.s || !x.s) { + r = new this(NaN); + + // Both ±Infinity + } else if (!y.d && !x.d) { + r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75); + r.s = y.s; + + // x is ±Infinity or y is ±0 + } else if (!x.d || y.isZero()) { + r = x.s < 0 ? getPi(this, pr, rm) : new this(0); + r.s = y.s; + + // y is ±Infinity or x is ±0 + } else if (!y.d || x.isZero()) { + r = getPi(this, wpr, 1).times(0.5); + r.s = y.s; + + // Both non-zero and finite + } else if (x.s < 0) { + this.precision = wpr; + this.rounding = 1; + r = this.atan(divide(y, x, wpr, 1)); + x = getPi(this, wpr, 1); + this.precision = pr; + this.rounding = rm; + r = y.s < 0 ? r.minus(x) : r.plus(x); + } else { + r = this.atan(divide(y, x, wpr, 1)); + } + + return r; + } + + + /* + * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function cbrt(x) { + return new this(x).cbrt(); + } + + + /* + * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`. + * + * x {number|string|Decimal} + * + */ + function ceil(x) { + return finalise(x = new this(x), x.e + 1, 2); + } + + + /* + * Configure global settings for a Decimal constructor. + * + * `obj` is an object with one or more of the following properties, + * + * precision {number} + * rounding {number} + * toExpNeg {number} + * toExpPos {number} + * maxE {number} + * minE {number} + * modulo {number} + * crypto {boolean|number|undefined} + * + * E.g. Decimal.config({ precision: 20, rounding: 4 }) + * + */ + function config(obj) { + if (!obj || typeof obj !== 'object') throw Error(decimalError + 'Object expected'); + var i, p, v, + ps = [ + 'precision', 1, MAX_DIGITS, + 'rounding', 0, 8, + 'toExpNeg', -EXP_LIMIT, 0, + 'toExpPos', 0, EXP_LIMIT, + 'maxE', 0, EXP_LIMIT, + 'minE', -EXP_LIMIT, 0, + 'modulo', 0, 9 + ]; + + for (i = 0; i < ps.length; i += 3) { + if ((v = obj[p = ps[i]]) !== void 0) { + if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v; + else throw Error(invalidArgument + p + ': ' + v); + } + } + + if (obj.hasOwnProperty(p = 'crypto')) { + if ((v = obj[p]) === void 0) { + this[p] = v; + } else if (v === true || v === false || v === 0 || v === 1) { + this[p] = !!(v && cryptoObject && + (cryptoObject.getRandomValues || cryptoObject.randomBytes)); + } else { + throw Error(invalidArgument + p + ': ' + v); + } + } + + return this; + } + + + /* + * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function cos(x) { + return new this(x).cos(); + } + + + /* + * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function cosh(x) { + return new this(x).cosh(); + } + + + /* + * Create and return a Decimal constructor with the same configuration properties as this Decimal + * constructor. + * + */ + function clone(obj) { + var i, p, ps; + + /* + * The Decimal constructor and exported function. + * Return a new Decimal instance. + * + * v {number|string|Decimal} A numeric value. + * + */ + function Decimal(v) { + var e, i, t, + x = this; + + // Decimal called without new. + if (!(x instanceof Decimal)) return new Decimal(v); + + // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor + // which points to Object. + x.constructor = Decimal; + + // Duplicate. + if (v instanceof Decimal) { + x.s = v.s; + x.e = v.e; + x.d = (v = v.d) ? v.slice() : v; + return; + } + + t = typeof v; + + if (t === 'number') { + if (v === 0) { + x.s = 1 / v < 0 ? -1 : 1; + x.e = 0; + x.d = [0]; + return; + } + + if (v < 0) { + v = -v; + x.s = -1; + } else { + x.s = 1; + } + + // Fast path for small integers. + if (v === ~~v && v < 1e7) { + for (e = 0, i = v; i >= 10; i /= 10) e++; + x.e = e; + x.d = [v]; + return; + + // Infinity, NaN. + } else if (v * 0 !== 0) { + if (!v) x.s = NaN; + x.e = NaN; + x.d = null; + return; + } + + return parseDecimal(x, v.toString()); + + } else if (t !== 'string') { + throw Error(invalidArgument + v); + } + + // Minus sign? + if (v.charCodeAt(0) === 45) { + v = v.slice(1); + x.s = -1; + } else { + x.s = 1; + } + + return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v); + } + + Decimal.prototype = P; + + Decimal.ROUND_UP = 0; + Decimal.ROUND_DOWN = 1; + Decimal.ROUND_CEIL = 2; + Decimal.ROUND_FLOOR = 3; + Decimal.ROUND_HALF_UP = 4; + Decimal.ROUND_HALF_DOWN = 5; + Decimal.ROUND_HALF_EVEN = 6; + Decimal.ROUND_HALF_CEIL = 7; + Decimal.ROUND_HALF_FLOOR = 8; + Decimal.EUCLID = 9; + + Decimal.config = config; + Decimal.clone = clone; + + Decimal.abs = abs; + Decimal.acos = acos; + Decimal.acosh = acosh; // ES6 + Decimal.add = add; + Decimal.asin = asin; + Decimal.asinh = asinh; // ES6 + Decimal.atan = atan; + Decimal.atanh = atanh; // ES6 + Decimal.atan2 = atan2; + Decimal.cbrt = cbrt; // ES6 + Decimal.ceil = ceil; + Decimal.cos = cos; + Decimal.cosh = cosh; // ES6 + Decimal.div = div; + Decimal.exp = exp; + Decimal.floor = floor; + Decimal.fromJSON = fromJSON; + Decimal.hypot = hypot; // ES6 + Decimal.ln = ln; + Decimal.log = log; + Decimal.log10 = log10; // ES6 + Decimal.log2 = log2; // ES6 + Decimal.max = max; + Decimal.min = min; + Decimal.mod = mod; + Decimal.mul = mul; + Decimal.pow = pow; + Decimal.random = random; + Decimal.round = round; + Decimal.sign = sign; // ES6 + Decimal.sin = sin; + Decimal.sinh = sinh; // ES6 + Decimal.sqrt = sqrt; + Decimal.sub = sub; + Decimal.tan = tan; + Decimal.tanh = tanh; // ES6 + Decimal.trunc = trunc; // ES6 + + if (obj === void 0) obj = {}; + if (obj) { + ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto']; + for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p]; + } + + Decimal.config(obj); + + return Decimal; + } + + + /* + * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * y {number|string|Decimal} + * + */ + function div(x, y) { + return new this(x).div(y); + } + + + /* + * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} The power to which to raise the base of the natural log. + * + */ + function exp(x) { + return new this(x).exp(); + } + + + /* + * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`. + * + * x {number|string|Decimal} + * + */ + function floor(x) { + return finalise(x = new this(x), x.e + 1, 3); + } + + + /* + * Return a new Decimal from `str`, a string value created by `toJSON`. + * + * Base 88 alphabet: + * 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~ + * + * If `str` is just one character: + * 0-81 [[0, 40][-0, -40]] + * 82 -Infinity + * 83 +Infinity + * 84 NaN + * + * 64 32 16 8 4 2 1 + * 1 0 1 0 1 1 1 = 87 + * + */ + function fromJSON(str) { + var e, isNeg, k, n; + + if (typeof str !== 'string' || !str) throw Error(invalidArgument + str); + k = str.length; + n = NUMERALS.indexOf(str.charAt(0)); + + // [0, 81] -> [[0, 40][-0, -40]] + if (k === 1) { + return new this(n > 81 ? [-1 / 0, 1 / 0, 0 / 0][n - 82] : n > 40 ? -(n - 41) : n); + } else if (n & 64) { + isNeg = n & 16; + + // e = isNeg ? [-3, 4] : [-7, 8] + e = isNeg ? (n & 7) - 3 : (n & 15) - 7; + k = 1; + } else if (k === 2) { + n = n * 88 + NUMERALS.indexOf(str.charAt(1)); + + // [0, 5631] -> [[0, 2815][-0, -2815]] -> [[41, 2856][-41, -2856]] + return new this(n >= 2816 ? -(n - 2816) - 41 : n + 41); + } else { + + // 0XXXXXX + // 0 {is negative} {is exponent negative} {exponent digit count [0, 15]} + isNeg = n & 32; + + // Has an exponent been specified? + if (n & 31) { + e = n & 15; // Exponent character count [1, 15] + k = e + 1; // Index of first character of the significand. + + if (e === 1) { + e = NUMERALS.indexOf(str.charAt(1)); + } else if (e === 2) { + e = NUMERALS.indexOf(str.charAt(1)) * 88 + + NUMERALS.indexOf(str.charAt(2)); + } else { + e = +convertBase(str.slice(1, k), 88, 10).join(''); + } + + // Negative exponent? + if (n & 16) e = -e; + } else { + + // Integer without trailing zeros. + // 0X00000 + // 0 {is negative} 0 0 0 0 0 + str = convertBase(str.slice(1), 88, 10).join(''); + return new this(isNeg ? '-' + str : str); + } + } + + str = convertBase(str.slice(k), 88, 10).join(''); + e = e - str.length + 1; + str = str + 'e' + e; + + return new this(isNeg ? '-' + str : str); + } + + + /* + * Return a new Decimal whose value is the square root of the sum of the squares of the arguments, + * rounded to `precision` significant digits using rounding mode `rounding`. + * + * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...) + * + */ + function hypot() { + var i, n, + t = new this(0); + + external = false; + + for (i = 0; i < arguments.length;) { + n = new this(arguments[i++]); + if (!n.d) { + if (n.s) { + external = true; + return new this(1 / 0); + } + t = n; + } else if (t.d) { + t = t.plus(n.times(n)); + } + } + + external = true; + + return t.sqrt(); + } + + + /* + * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function ln(x) { + return new this(x).ln(); + } + + + /* + * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base + * is specified, rounded to `precision` significant digits using rounding mode `rounding`. + * + * log[y](x) + * + * x {number|string|Decimal} The argument of the logarithm. + * y {number|string|Decimal} The base of the logarithm. + * + */ + function log(x, y) { + return new this(x).log(y); + } + + + /* + * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function log2(x) { + return new this(x).log(2); + } + + + /* + * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function log10(x) { + return new this(x).log(10); + } + + + /* + * Return a new Decimal whose value is the maximum of the arguments. + * + * arguments {number|string|Decimal} + * + */ + function max() { + return maxOrMin(this, arguments, 'lt'); + } + + + /* + * Return a new Decimal whose value is the minimum of the arguments. + * + * arguments {number|string|Decimal} + * + */ + function min() { + return maxOrMin(this, arguments, 'gt'); + } + + + /* + * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|Decimal} + * y {number|string|Decimal} + * + */ + function mod(x, y) { + return new this(x).mod(y); + } + + + /* + * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * y {number|string|Decimal} + * + */ + function mul(x, y) { + return new this(x).mul(y); + } + + + /* + * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} The base. + * y {number|string|Decimal} The exponent. + * + */ + function pow(x, y) { + return new this(x).pow(y); + } + + + /* + * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with + * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros + * are produced). + * + * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive. + * + */ + function random(sd) { + var d, e, k, n, + i = 0, + r = new this(1), + rd = []; + + if (sd === void 0) sd = this.precision; + else checkInt32(sd, 1, MAX_DIGITS); + + k = Math.ceil(sd / LOG_BASE); + + if (this.crypto === false) { + for (; i < k;) rd[i++] = Math.random() * 1e7 | 0; + + // Browsers supporting crypto.getRandomValues. + } else if (cryptoObject && cryptoObject.getRandomValues) { + d = cryptoObject.getRandomValues(new Uint32Array(k)); + + for (; i < k;) { + n = d[i]; + + // 0 <= n < 4294967296 + // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865). + if (n >= 4.29e9) { + d[i] = cryptoObject.getRandomValues(new Uint32Array(1))[0]; + } else { + + // 0 <= n <= 4289999999 + // 0 <= (n % 1e7) <= 9999999 + rd[i++] = n % 1e7; + } + } + + // Node.js supporting crypto.randomBytes. + } else if (cryptoObject && cryptoObject.randomBytes) { + + // buffer + d = cryptoObject.randomBytes(k *= 4); + + for (; i < k;) { + + // 0 <= n < 2147483648 + n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24); + + // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286). + if (n >= 2.14e9) { + cryptoObject.randomBytes(4).copy(d, i); + } else { + + // 0 <= n <= 2139999999 + // 0 <= (n % 1e7) <= 9999999 + rd.push(n % 1e7); + i += 4; + } + } + + i = k / 4; + } else if (this.crypto) { + throw Error(decimalError + 'crypto unavailable'); + } else { + for (; i < k;) rd[i++] = Math.random() * 1e7 | 0; + } + + k = rd[--i]; + sd %= LOG_BASE; + + // Convert trailing digits to zeros according to sd. + if (k && sd) { + n = mathpow(10, LOG_BASE - sd); + rd[i] = (k / n | 0) * n; + } + + // Remove trailing words which are zero. + for (; rd[i] === 0; i--) rd.pop(); + + // Zero? + if (i < 0) { + e = 0; + rd = [0]; + } else { + e = -1; + + // Remove leading words which are zero and adjust exponent accordingly. + for (; rd[0] === 0; e -= LOG_BASE) rd.shift(); + + // Count the digits of the first word of rd to determine leading zeros. + for (k = 1, n = rd[0]; n >= 10; n /= 10) k++; + + // Adjust the exponent for leading zeros of the first word of rd. + if (k < LOG_BASE) e -= LOG_BASE - k; + } + + r.e = e; + r.d = rd; + + return r; + } + + + /* + * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`. + * + * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL). + * + * x {number|string|Decimal} + * + */ + function round(x) { + return finalise(x = new this(x), x.e + 1, this.rounding); + } + + + /* + * Return + * 1 if x > 0, + * -1 if x < 0, + * 0 if x is 0, + * -0 if x is -0, + * NaN otherwise + * + */ + function sign(x) { + x = new this(x); + return x.d ? (x.d[0] ? x.s : 0 * x.s) : x.s || NaN; + } + + + /* + * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function sin(x) { + return new this(x).sin(); + } + + + /* + * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function sinh(x) { + return new this(x).sinh(); + } + + + /* + * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} + * + */ + function sqrt(x) { + return new this(x).sqrt(); + } + + + /* + * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits + * using rounding mode `rounding`. + * + * x {number|string|Decimal} + * y {number|string|Decimal} + * + */ + function sub(x, y) { + return new this(x).sub(y); + } + + + /* + * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant + * digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function tan(x) { + return new this(x).tan(); + } + + + /* + * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision` + * significant digits using rounding mode `rounding`. + * + * x {number|string|Decimal} A value in radians. + * + */ + function tanh(x) { + return new this(x).tanh(); + } + + + /* + * Return a new Decimal whose value is `x` truncated to an integer. + * + * x {number|string|Decimal} + * + */ + function trunc(x) { + return finalise(x = new this(x), x.e + 1, 1); + } + + + // Create and configure initial Decimal constructor. + Decimal = clone(Decimal); + + // Create the internal constants from their string values. + LN10 = new Decimal(LN10); + PI = new Decimal(PI); + + + // Export. + + + // AMD. + if (true) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { + return Decimal; + }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + + // Node and other environments that support module.exports. + } else if (typeof module != 'undefined' && module.exports) { + module.exports = Decimal; + + if (!cryptoObject) { + try { + cryptoObject = require('cry' + 'pto'); + } catch (e) { + // Ignore. + } + } + + // Browser. + } else { + if (!globalScope) { + globalScope = typeof self != 'undefined' && self && self.self == self + ? self : Function('return this')(); + } + + noConflict = globalScope.Decimal; + Decimal.noConflict = function () { + globalScope.Decimal = noConflict; + return Decimal; + }; + + globalScope.Decimal = Decimal; + } + })(this); + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Create a BigNumber, which can store numbers with arbitrary precision. + * When a matrix is provided, all elements will be converted to BigNumber. + * + * Syntax: + * + * math.bignumber(x) + * + * Examples: + * + * 0.1 + 0.2; // returns number 0.30000000000000004 + * math.bignumber(0.1) + math.bignumber(0.2); // returns BigNumber 0.3 + * + * + * 7.2e500; // returns number Infinity + * math.bignumber('7.2e500'); // returns BigNumber 7.2e500 + * + * See also: + * + * boolean, complex, index, matrix, string, unit + * + * @param {number | string | Fraction | BigNumber | Array | Matrix | boolean | null} [value] Value for the big number, + * 0 by default. + * @returns {BigNumber} The created bignumber + */ + var bignumber = typed('bignumber', { + '': function () { + return new type.BigNumber(0); + }, + + 'number': function (x) { + // convert to string to prevent errors in case of >15 digits + return new type.BigNumber(x + ''); + }, + + 'string': function (x) { + return new type.BigNumber(x); + }, + + 'BigNumber': function (x) { + // we assume a BigNumber is immutable + return x; + }, + + 'Fraction': function (x) { + return new type.BigNumber(x.n).div(x.d); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, bignumber); + } + }); + + bignumber.toTex = { + 0: '0', + 1: '\\left(${args[0]}\\right)' + }; + + return bignumber; + } + + exports.name = 'bignumber'; + exports.factory = factory; + + +/***/ }, +/* 19 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Execute the callback function element wise for each element in array and any + * nested array + * Returns an array with the results + * @param {Array | Matrix} array + * @param {Function} callback The callback is called with two parameters: + * value1 and value2, which contain the current + * element of both arrays. + * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. + * + * @return {Array | Matrix} res + */ + module.exports = function deepMap(array, callback, skipZeros) { + if (array && (typeof array.map === 'function')) { + // TODO: replace array.map with a for loop to improve performance + return array.map(function (x) { + return deepMap(x, callback, skipZeros); + }); + } + else { + return callback(array); + } + }; + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Create a boolean or convert a string or number to a boolean. + * In case of a number, `true` is returned for non-zero numbers, and `false` in + * case of zero. + * Strings can be `'true'` or `'false'`, or can contain a number. + * When value is a matrix, all elements will be converted to boolean. + * + * Syntax: + * + * math.boolean(x) + * + * Examples: + * + * math.boolean(0); // returns false + * math.boolean(1); // returns true + * math.boolean(-3); // returns true + * math.boolean('true'); // returns true + * math.boolean('false'); // returns false + * math.boolean([1, 0, 1, 1]); // returns [true, false, true, true] + * + * See also: + * + * bignumber, complex, index, matrix, string, unit + * + * @param {string | number | boolean | Array | Matrix | null} value A value of any type + * @return {boolean | Array | Matrix} The boolean value + */ + var bool = typed('bool', { + '': function () { + return false; + }, + + 'boolean': function (x) { + return x; + }, + + 'number': function (x) { + return !!x; + }, + + 'BigNumber': function (x) { + return !x.isZero(); + }, + + 'string': function (x) { + // try case insensitive + var lcase = x.toLowerCase(); + if (lcase === 'true') { + return true; + } + else if (lcase === 'false') { + return false; + } + + // test whether value is a valid number + var num = Number(x); + if (x != '' && !isNaN(num)) { + return !!num; + } + + throw new Error('Cannot convert "' + x + '" to a boolean'); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, bool); + } + }); + + return bool; + } + + exports.name = 'boolean'; + exports.factory = factory; + + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(22), + + // construction function + __webpack_require__(25) + ]; + + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var format = __webpack_require__(23).format; + var lazy = __webpack_require__(3).lazy; + + function factory (type, config, load, typed, math) { + /** + * @constructor Chain + * Wrap any value in a chain, allowing to perform chained operations on + * the value. + * + * All methods available in the math.js library can be called upon the chain, + * and then will be evaluated with the value itself as first argument. + * The chain can be closed by executing chain.done(), which will return + * the final value. + * + * The Chain has a number of special functions: + * - done() Finalize the chained operation and return the + * chain's value. + * - valueOf() The same as done() + * - toString() Returns a string representation of the chain's value. + * + * @param {*} [value] + */ + function Chain (value) { + if (!(this instanceof Chain)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (value && value.isChain) { + this.value = value.value; + } + else { + this.value = value; + } + } + + /** + * Attach type information + */ + Chain.prototype.type = 'Chain'; + Chain.prototype.isChain = true; + + /** + * Close the chain. Returns the final value. + * Does the same as method valueOf() + * @returns {*} value + */ + Chain.prototype.done = function () { + return this.value; + }; + + /** + * Close the chain. Returns the final value. + * Does the same as method done() + * @returns {*} value + */ + Chain.prototype.valueOf = function () { + return this.value; + }; + + /** + * Get a string representation of the value in the chain + * @returns {string} + */ + Chain.prototype.toString = function () { + return format(this.value); + }; + + /** + * Create a proxy method for the chain + * @param {string} name + * @param {Function} fn The function to be proxied + * If fn is no function, it is silently ignored. + * @private + */ + function createProxy(name, fn) { + if (typeof fn === 'function') { + Chain.prototype[name] = chainify(fn); + } + } + + /** + * Create a proxy method for the chain + * @param {string} name + * @param {function} resolver The function resolving with the + * function to be proxied + * @private + */ + function createLazyProxy(name, resolver) { + lazy(Chain.prototype, name, function outerResolver() { + var fn = resolver(); + if (typeof fn === 'function') { + return chainify(fn); + } + + return undefined; // if not a function, ignore + }); + } + + /** + * Make a function chainable + * @param {function} fn + * @return {Function} chain function + * @private + */ + function chainify (fn) { + return function () { + var args = [this.value]; // `this` will be the context of a Chain instance + for (var i = 0; i < arguments.length; i++) { + args[i + 1] = arguments[i]; + } + + return new Chain(fn.apply(fn, args)); + } + } + + /** + * Create a proxy for a single method, or an object with multiple methods. + * Example usage: + * + * Chain.createProxy('add', function add (x, y) {...}); + * Chain.createProxy({ + * add: function add (x, y) {...}, + * subtract: function subtract (x, y) {...} + * } + * + * @param {string | Object} arg0 A name (string), or an object with + * functions + * @param {*} [arg1] A function, when arg0 is a name + */ + Chain.createProxy = function (arg0, arg1) { + if (typeof arg0 === 'string') { + // createProxy(name, value) + createProxy(arg0, arg1); + } + else { + // createProxy(values) + for (var prop in arg0) { + if (arg0.hasOwnProperty(prop)) { + createProxy(prop, arg0[prop]); + } + } + } + }; + + // create proxy for everything that is in math.js + Chain.createProxy(math); + + // register on the import event, automatically add a proxy for every imported function. + math.on('import', function (name, resolver, path) { + if (path === undefined) { + // an imported function (not a data type or something special) + createLazyProxy(name, resolver); + } + }); + + return Chain; + } + + exports.name = 'Chain'; + exports.path = 'type'; + exports.factory = factory; + exports.math = true; // require providing the math namespace as 5th argument + exports.lazy = false; // we need to register a listener on the import events, so no lazy loading + + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var formatNumber = __webpack_require__(6).format; + var formatBigNumber = __webpack_require__(24).format; + + /** + * Test whether value is a string + * @param {*} value + * @return {boolean} isString + */ + exports.isString = function(value) { + return typeof value === 'string'; + }; + + /** + * Check if a text ends with a certain string. + * @param {string} text + * @param {string} search + */ + exports.endsWith = function(text, search) { + var start = text.length - search.length; + var end = text.length; + return (text.substring(start, end) === search); + }; + + /** + * Format a value of any type into a string. + * + * Usage: + * math.format(value) + * math.format(value, precision) + * + * When value is a function: + * + * - When the function has a property `syntax`, it returns this + * syntax description. + * - In other cases, a string `'function'` is returned. + * + * When `value` is an Object: + * + * - When the object contains a property `format` being a function, this + * function is invoked as `value.format(options)` and the result is returned. + * - When the object has its own `toString` method, this method is invoked + * and the result is returned. + * - In other cases the function will loop over all object properties and + * return JSON object notation like '{"a": 2, "b": 3}'. + * + * Example usage: + * math.format(2/7); // '0.2857142857142857' + * math.format(math.pi, 3); // '3.14' + * math.format(new Complex(2, 3)); // '2 + 3i' + * math.format('hello'); // '"hello"' + * + * @param {*} value Value to be stringified + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @return {string} str + */ + exports.format = function(value, options) { + if (typeof value === 'number') { + return formatNumber(value, options); + } + + if (value && value.isBigNumber === true) { + return formatBigNumber(value, options); + } + + if (value && value.isFraction === true) { + if (!options || options.fraction !== 'decimal') { + // output as ratio, like '1/3' + return (value.s * value.n) + '/' + value.d; + } + else { + // output as decimal, like '0.(3)' + return value.toString(); + } + } + + if (Array.isArray(value)) { + return formatArray(value, options); + } + + if (exports.isString(value)) { + return '"' + value + '"'; + } + + if (typeof value === 'function') { + return value.syntax ? String(value.syntax) : 'function'; + } + + if (value && typeof value === 'object') { + if (typeof value.format === 'function') { + return value.format(options); + } + else if (value && value.toString() !== {}.toString()) { + // this object has a non-native toString method, use that one + return value.toString(); + } + else { + var entries = []; + + for (var key in value) { + if (value.hasOwnProperty(key)) { + entries.push('"' + key + '": ' + exports.format(value[key], options)); + } + } + + return '{' + entries.join(', ') + '}'; + } + } + + return String(value); + }; + + /** + * Recursively format an n-dimensional matrix + * Example output: "[[1, 2], [3, 4]]" + * @param {Array} array + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @returns {string} str + */ + function formatArray (array, options) { + if (Array.isArray(array)) { + var str = '['; + var len = array.length; + for (var i = 0; i < len; i++) { + if (i != 0) { + str += ', '; + } + str += formatArray(array[i], options); + } + str += ']'; + return str; + } + else { + return exports.format(array, options); + } + } + + +/***/ }, +/* 24 */ +/***/ function(module, exports) { + + /** + * Convert a BigNumber to a formatted string representation. + * + * Syntax: + * + * format(value) + * format(value, options) + * format(value, precision) + * format(value, fn) + * + * Where: + * + * {number} value The value to be formatted + * {Object} options An object with formatting options. Available options: + * {string} notation + * Number notation. Choose from: + * 'fixed' Always use regular number notation. + * For example '123.40' and '14000000' + * 'exponential' Always use exponential notation. + * For example '1.234e+2' and '1.4e+7' + * 'auto' (default) Regular number notation for numbers + * having an absolute value between + * `lower` and `upper` bounds, and uses + * exponential notation elsewhere. + * Lower bound is included, upper bound + * is excluded. + * For example '123.4' and '1.4e7'. + * {number} precision A number between 0 and 16 to round + * the digits of the number. + * In case of notations 'exponential' and + * 'auto', `precision` defines the total + * number of significant digits returned + * and is undefined by default. + * In case of notation 'fixed', + * `precision` defines the number of + * significant digits after the decimal + * point, and is 0 by default. + * {Object} exponential An object containing two parameters, + * {number} lower and {number} upper, + * used by notation 'auto' to determine + * when to return exponential notation. + * Default values are `lower=1e-3` and + * `upper=1e5`. + * Only applicable for notation `auto`. + * {Function} fn A custom formatting function. Can be used to override the + * built-in notations. Function `fn` is called with `value` as + * parameter and must return a string. Is useful for example to + * format all values inside a matrix in a particular way. + * + * Examples: + * + * format(6.4); // '6.4' + * format(1240000); // '1.24e6' + * format(1/3); // '0.3333333333333333' + * format(1/3, 3); // '0.333' + * format(21385, 2); // '21000' + * format(12.071, {notation: 'fixed'}); // '12' + * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' + * format(52.8, {notation: 'exponential'}); // '5.28e+1' + * + * @param {BigNumber} value + * @param {Object | Function | number} [options] + * @return {string} str The formatted value + */ + exports.format = function (value, options) { + if (typeof options === 'function') { + // handle format(value, fn) + return options(value); + } + + // handle special cases + if (!value.isFinite()) { + return value.isNaN() ? 'NaN' : (value.gt(0) ? 'Infinity' : '-Infinity'); + } + + // default values for options + var notation = 'auto'; + var precision = undefined; + + if (options !== undefined) { + // determine notation from options + if (options.notation) { + notation = options.notation; + } + + // determine precision from options + if (typeof options === 'number') { + precision = options; + } + else if (options.precision) { + precision = options.precision; + } + } + + // handle the various notations + switch (notation) { + case 'fixed': + return exports.toFixed(value, precision); + + case 'exponential': + return exports.toExponential(value, precision); + + case 'auto': + // determine lower and upper bound for exponential notation. + // TODO: implement support for upper and lower to be BigNumbers themselves + var lower = 1e-3; + var upper = 1e5; + if (options && options.exponential) { + if (options.exponential.lower !== undefined) { + lower = options.exponential.lower; + } + if (options.exponential.upper !== undefined) { + upper = options.exponential.upper; + } + } + + // adjust the configuration of the BigNumber constructor (yeah, this is quite tricky...) + var oldConfig = { + toExpNeg: value.constructor.toExpNeg, + toExpPos: value.constructor.toExpPos + }; + + value.constructor.config({ + toExpNeg: Math.round(Math.log(lower) / Math.LN10), + toExpPos: Math.round(Math.log(upper) / Math.LN10) + }); + + // handle special case zero + if (value.isZero()) return '0'; + + // determine whether or not to output exponential notation + var str; + var abs = value.abs(); + if (abs.gte(lower) && abs.lt(upper)) { + // normal number notation + str = value.toSignificantDigits(precision).toFixed(); + } + else { + // exponential notation + str = exports.toExponential(value, precision); + } + + // remove trailing zeros after the decimal point + return str.replace(/((\.\d*?)(0+))($|e)/, function () { + var digits = arguments[2]; + var e = arguments[4]; + return (digits !== '.') ? digits + e : e; + }); + + default: + throw new Error('Unknown notation "' + notation + '". ' + + 'Choose "auto", "exponential", or "fixed".'); + } + }; + + /** + * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' + * @param {BigNumber} value + * @param {number} [precision] Number of digits in formatted output. + * If not provided, the maximum available digits + * is used. + * @returns {string} str + */ + exports.toExponential = function (value, precision) { + if (precision !== undefined) { + return value.toExponential(precision - 1); // Note the offset of one + } + else { + return value.toExponential(); + } + }; + + /** + * Format a number with fixed notation. + * @param {BigNumber} value + * @param {number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. + */ + exports.toFixed = function (value, precision) { + return value.toFixed(precision || 0); + // Note: the (precision || 0) is needed as the toFixed of BigNumber has an + // undefined default precision instead of 0. + }; + + +/***/ }, +/* 25 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Wrap any value in a chain, allowing to perform chained operations on + * the value. + * + * All methods available in the math.js library can be called upon the chain, + * and then will be evaluated with the value itself as first argument. + * The chain can be closed by executing `chain.done()`, which returns + * the final value. + * + * The chain has a number of special functions: + * + * - `done()` Finalize the chain and return the chain's value. + * - `valueOf()` The same as `done()` + * - `toString()` Executes `math.format()` onto the chain's value, returning + * a string representation of the value. + * + * Syntax: + * + * math.chain(value) + * + * Examples: + * + * math.chain(3) + * .add(4) + * .subtract(2) + * .done(); // 5 + * + * math.chain( [[1, 2], [3, 4]] ) + * .subset(math.index(0, 0), 8) + * .multiply(3) + * .done(); // [[24, 6], [9, 12]] + * + * @param {*} [value] A value of any type on which to start a chained operation. + * @return {math.type.Chain} The created chain + */ + return typed('chain', { + '': function() { + return new type.Chain(); + }, + + 'any': function(value) { + return new type.Chain(value); + } + }); + } + + exports.name = 'chain'; + exports.factory = factory; + + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(27), + + // construction function + __webpack_require__(31) + ]; + + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + var Complex = __webpack_require__(28); + var format = __webpack_require__(6).format; + var isNumber = __webpack_require__(6).isNumber; + + function factory (type, config, load, typed, math) { + + /** + * Attach type information + */ + Complex.prototype.type = 'Complex'; + Complex.prototype.isComplex = true; + + + /** + * Get a JSON representation of the complex number + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Complex", "re": 2, "im": 3}` + */ + Complex.prototype.toJSON = function () { + return { + mathjs: 'Complex', + re: this.re, + im: this.im + }; + }; + + /* + * Return the value of the complex number in polar notation + * The angle phi will be set in the interval of [-pi, pi]. + * @return {{r: number, phi: number}} Returns and object with properties r and phi. + */ + Complex.prototype.toPolar = function () { + return { + r: this.abs(), + phi: this.arg() + }; + }; + + /** + * Get a string representation of the complex number, + * with optional formatting options. + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @return {string} str + */ + Complex.prototype.format = function (options) { + var str = ''; + var im = this.im; + var re = this.re; + var strRe = format(this.re, options); + var strIm = format(this.im, options); + + // round either re or im when smaller than the configured precision + var precision = isNumber(options) ? options : options ? options.precision : null; + if (precision !== null) { + var epsilon = Math.pow(10, -precision); + if (Math.abs(re / im) < epsilon) { + re = 0; + } + if (Math.abs(im / re) < epsilon) { + im = 0; + } + } + + if (im == 0) { + // real value + str = strRe; + } else if (re == 0) { + // purely complex value + if (im == 1) { + str = 'i'; + } else if (im == -1) { + str = '-i'; + } else { + str = strIm + 'i'; + } + } else { + // complex value + if (im > 0) { + if (im == 1) { + str = strRe + ' + i'; + } else { + str = strRe + ' + ' + strIm + 'i'; + } + } else { + if (im == -1) { + str = strRe + ' - i'; + } else { + str = strRe + ' - ' + strIm.substring(1) + 'i'; + } + } + } + return str; + }; + + /** + * Create a complex number from polar coordinates + * + * Usage: + * + * Complex.fromPolar(r: number, phi: number) : Complex + * Complex.fromPolar({r: number, phi: number}) : Complex + * + * @param {*} args... + * @return {Complex} + */ + Complex.fromPolar = function (args) { + switch (arguments.length) { + case 1: + var arg = arguments[0]; + if (typeof arg === 'object') { + return Complex(arg); + } + throw new TypeError('Input has to be an object with r and phi keys.'); + + case 2: + var r = arguments[0], + phi = arguments[1]; + if (isNumber(r)) { + if (phi && phi.isUnit && phi.hasBase('ANGLE')) { + // convert unit to a number in radians + phi = phi.toNumber('rad'); + } + + if (isNumber(phi)) { + return new Complex({r: r, phi: phi}); + } + + throw new TypeError('Phi is not a number nor an angle unit.'); + } else { + throw new TypeError('Radius r is not a number.'); + } + + default: + throw new SyntaxError('Wrong number of arguments in function fromPolar'); + } + }; + + + Complex.prototype.valueOf = Complex.prototype.toString; + + /** + * Create a Complex number from a JSON object + * @param {Object} json A JSON Object structured as + * {"mathjs": "Complex", "re": 2, "im": 3} + * All properties are optional, default values + * for `re` and `im` are 0. + * @return {Complex} Returns a new Complex number + */ + Complex.fromJSON = function (json) { + return new Complex(json); + }; + + // apply the current epsilon + Complex.EPSILON = config.epsilon; + + // listen for changed in the configuration, automatically apply changed epsilon + math.on('config', function (curr, prev) { + if (curr.epsilon !== prev.epsilon) { + Complex.EPSILON = curr.epsilon; + } + }); + + return Complex; + } + + exports.name = 'Complex'; + exports.path = 'type'; + exports.factory = factory; + exports.math = true; // request access to the math namespace + + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** + * @license Complex.js v2.0.1 11/02/2016 + * + * Copyright (c) 2016, Robert Eisele (robert@xarg.org) + * Dual licensed under the MIT or GPL Version 2 licenses. + **/ + + /** + * + * This class allows the manipilation of complex numbers. + * You can pass a complex number in different formats. Either as object, double, string or two integer parameters. + * + * Object form + * { re: , im: } + * { arg: , abs: } + * { phi: , r: } + * + * Double form + * 99.3 - Single double value + * + * String form + * "23.1337" - Simple real number + * "15+3i" - a simple complex number + * "3-i" - a simple complex number + * + * Example: + * + * var c = new Complex("99.3+8i"); + * c.mul({r: 3, i: 9}).div(4.9).sub(3, 2); + * + */ + + (function(root) { + + "use strict"; + + var P = {'re': 0, 'im': 0}; + + Math.cosh = Math.cosh || function(x) { + return (Math.exp(x) + Math.exp(-x)) * 0.5; + }; + + Math.sinh = Math.sinh || function(x) { + return (Math.exp(x) - Math.exp(-x)) * 0.5; + }; + + var parser_exit = function() { + throw SyntaxError("Invalid Param"); + }; + + /** + * Calculates log(sqrt(a^2+b^2)) in a way to avoid overflows + * + * @param {number} a + * @param {number} b + * @returns {number} + */ + function logHypot(a, b) { + + var _a = Math.abs(a); + var _b = Math.abs(b); + + if (a === 0) { + return Math.log(_b); + } + + if (b === 0) { + return Math.log(_a); + } + + if (_a < 3000 && _b < 3000) { + return Math.log(a * a + b * b) * 0.5; + } + + /* I got 4 ideas to compute this property without overflow: + * + * Testing 1000000 times with random samples for a,b ∈ [1, 1000000000] against a big decimal library to get an error estimate + * + * 1. Only eliminate the square root: (OVERALL ERROR: 3.9122483030951116e-11) + + Math.log(a * a + b * b) / 2 + + * + * + * 2. Try to use the non-overflowing pythagoras: (OVERALL ERROR: 8.889760039210159e-10) + + var fn = function(a, b) { + a = Math.abs(a); + b = Math.abs(b); + var t = Math.min(a, b); + a = Math.max(a, b); + t = t / a; + + return Math.log(a) + Math.log(1 + t * t) / 2; + }; + + * 3. Abuse the identity cos(atan(y/x) = x / sqrt(x^2+y^2): (OVERALL ERROR: 3.4780178737037204e-10) + + Math.log(a / Math.cos(Math.atan2(b, a))) + + * 4. Use 3. and apply log rules: (OVERALL ERROR: 1.2014087502620896e-9) + + Math.log(a) - Math.log(Math.cos(Math.atan2(b, a))) + + */ + + return Math.log(a / Math.cos(Math.atan2(b, a))); + } + + var parse = function(a, b) { + + if (a === undefined || a === null) { + P["re"] = + P["im"] = 0; + } else if (b !== undefined) { + P["re"] = a; + P["im"] = b; + } else switch (typeof a) { + + case "object": + + if ("im" in a && "re" in a) { + P["re"] = a["re"]; + P["im"] = a["im"]; + } else if ("abs" in a && "arg" in a) { + P["re"] = a["abs"] * Math.cos(a["arg"]); + P["im"] = a["abs"] * Math.sin(a["arg"]); + } else if ("r" in a && "phi" in a) { + P["re"] = a["r"] * Math.cos(a["phi"]); + P["im"] = a["r"] * Math.sin(a["phi"]); + } else { + parser_exit(); + } + break; + + case "string": + + P["im"] = /* void */ + P["re"] = 0; + + var tokens = a.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g); + var plus = 1; + var minus = 0; + + if (tokens === null) { + parser_exit(); + } + + for (var i = 0; i < tokens.length; i++) { + + var c = tokens[i]; + + if (c === ' ' || c === '\t' || c === '\n') { + /* void */ + } else if (c === '+') { + plus++; + } else if (c === '-') { + minus++; + } else if (c === 'i' || c === 'I') { + + if (plus + minus === 0) { + parser_exit(); + } + + if (tokens[i + 1] !== ' ' && !isNaN(tokens[i + 1])) { + P["im"]+= parseFloat((minus % 2 ? "-" : "") + tokens[i + 1]); + i++; + } else { + P["im"]+= parseFloat((minus % 2 ? "-" : "") + "1"); + } + plus = minus = 0; + + } else { + + if (plus + minus === 0 || isNaN(c)) { + parser_exit(); + } + + if (tokens[i + 1] === 'i' || tokens[i + 1] === 'I') { + P["im"]+= parseFloat((minus % 2 ? "-" : "") + c); + i++; + } else { + P["re"]+= parseFloat((minus % 2 ? "-" : "") + c); + } + plus = minus = 0; + } + } + + // Still something on the stack + if (plus + minus > 0) { + parser_exit(); + } + break; + + case "number": + P["im"] = 0; + P["re"] = a; + break; + + default: + parser_exit(); + } + + if (isNaN(P["re"]) || isNaN(P["im"])) { + // If a calculation is NaN, we treat it as NaN and don't throw + //parser_exit(); + } + }; + + /** + * @constructor + * @returns {Complex} + */ + function Complex(a, b) { + + if (!(this instanceof Complex)) { + return new Complex(a, b); + } + + parse(a, b); // mutates P + + this["re"] = P["re"]; + this["im"] = P["im"]; + } + + Complex.prototype = { + + "re": 0, + "im": 0, + + /** + * Calculates the sign of a complex number + * + * @returns {Complex} + */ + "sign": function() { + + var abs = this["abs"](); + + return new Complex( + this["re"] / abs, + this["im"] / abs); + }, + + /** + * Adds two complex numbers + * + * @returns {Complex} + */ + "add": function(a, b) { + + parse(a, b); // mutates P + + return new Complex( + this["re"] + P["re"], + this["im"] + P["im"]); + }, + + /** + * Subtracts two complex numbers + * + * @returns {Complex} + */ + "sub": function(a, b) { + + parse(a, b); // mutates P + + return new Complex( + this["re"] - P["re"], + this["im"] - P["im"]); + }, + + /** + * Multiplies two complex numbers + * + * @returns {Complex} + */ + "mul": function(a, b) { + + parse(a, b); // mutates P + + // Besides the addition/subtraction, this helps having a solution for rational Infinity + if (P['im'] === 0 && this['im'] === 0) { + return new Complex(this['re'] * P['re'], 0); + } + + return new Complex( + this["re"] * P["re"] - this["im"] * P["im"], + this["re"] * P["im"] + this["im"] * P["re"]); + }, + + /** + * Divides two complex numbers + * + * @returns {Complex} + */ + "div": function(a, b) { + + parse(a, b); // mutates P + + a = this["re"]; + b = this["im"]; + + var c = P["re"]; + var d = P["im"]; + var t, x; + + // Divisor is zero + if (0 === c && 0 === d) { + return new Complex( + (a !== 0) ? (a / 0) : 0, + (b !== 0) ? (b / 0) : 0); + } + + // Divisor is rational + if (0 === d) { + return new Complex(a / c, b / c); + } + + if (Math.abs(c) < Math.abs(d)) { + + x = c / d; + t = c * x + d; + + return new Complex( + (a * x + b) / t, + (b * x - a) / t); + + } else { + + x = d / c; + t = d * x + c; + + return new Complex( + (a + b * x) / t, + (b - a * x) / t); + } + }, + + /** + * Calculate the power of two complex numbers + * + * @returns {Complex} + */ + "pow": function(a, b) { + + parse(a, b); // mutates P + + a = this["re"]; + b = this["im"]; + + if (a === 0 && b === 0) { + return new Complex(0, 0); + } + + var arg = Math.atan2(b, a); + var loh = logHypot(a, b); + + if (P["im"] === 0) { + + if (b === 0 && a >= 0) { + + return new Complex(Math.pow(a, P["re"]), 0); + + } else if (a === 0) { + + switch (P["re"] % 4) { + case 0: + return new Complex(Math.pow(b, P["re"]), 0); + case 1: + return new Complex(0, Math.pow(b, P["re"])); + case 2: + return new Complex(-Math.pow(b, P["re"]), 0); + case 3: + return new Complex(0, -Math.pow(b, P["re"])); + } + } + } + + /* I couldn"t find a good formula, so here is a derivation and optimization + * + * z_1^z_2 = (a + bi)^(c + di) + * = exp((c + di) * log(a + bi) + * = pow(a^2 + b^2, (c + di) / 2) * exp(i(c + di)atan2(b, a)) + * =>... + * Re = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * cos(d * log(a^2 + b^2) / 2 + c * atan2(b, a)) + * Im = (pow(a^2 + b^2, c / 2) * exp(-d * atan2(b, a))) * sin(d * log(a^2 + b^2) / 2 + c * atan2(b, a)) + * + * =>... + * Re = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * cos(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a)) + * Im = exp(c * log(sqrt(a^2 + b^2)) - d * atan2(b, a)) * sin(d * log(sqrt(a^2 + b^2)) + c * atan2(b, a)) + * + * => + * Re = exp(c * logsq2 - d * arg(z_1)) * cos(d * logsq2 + c * arg(z_1)) + * Im = exp(c * logsq2 - d * arg(z_1)) * sin(d * logsq2 + c * arg(z_1)) + * + */ + + a = Math.exp(P["re"] * loh - P["im"] * arg); + b = P["im"] * loh + P["re"] * arg; + return new Complex( + a * Math.cos(b), + a * Math.sin(b)); + }, + + /** + * Calculate the complex square root + * + * @returns {Complex} + */ + "sqrt": function() { + + var a = this["re"]; + var b = this["im"]; + var r = this["abs"](); + + var re, im; + + if (a >= 0 && b === 0) { + return new Complex(Math.sqrt(a), 0); + } + + if (a >= 0) { + re = 0.5 * Math.sqrt(2.0 * (r + a)); + } else { + re = Math.abs(b) / Math.sqrt(2 * (r - a)); + } + + if (a <= 0) { + im = 0.5 * Math.sqrt(2.0 * (r - a)); + } else { + im = Math.abs(b) / Math.sqrt(2 * (r + a)); + } + + return new Complex(re, b >= 0 ? im : -im); + }, + + /** + * Calculate the complex exponent + * + * @returns {Complex} + */ + "exp": function() { + + var tmp = Math.exp(this["re"]); + + if (this["im"] === 0) { + //return new Complex(tmp, 0); + } + return new Complex( + tmp * Math.cos(this["im"]), + tmp * Math.sin(this["im"])); + }, + + /** + * Calculate the natural log + * + * @returns {Complex} + */ + "log": function() { + + var a = this["re"]; + var b = this["im"]; + + if (b === 0 && a > 0) { + //return new Complex(Math.log(a), 0); + } + + return new Complex( + logHypot(a, b), + Math.atan2(b, a)); + }, + + /** + * Calculate the magniture of the complex number + * + * @returns {number} + */ + "abs": function() { + + var a = Math.abs(this["re"]); + var b = Math.abs(this["im"]); + + if (a < 3000 && b < 3000) { + return Math.sqrt(a * a + b * b); + } + + if (a < b) { + a = b; + b = this["re"] / this["im"]; + } else { + b = this["im"] / this["re"]; + } + return a * Math.sqrt(1 + b * b); + }, + + /** + * Calculate the angle of the complex number + * + * @returns {number} + */ + "arg": function() { + + return Math.atan2(this["im"], this["re"]); + }, + + /** + * Calculate the sine of the complex number + * + * @returns {Complex} + */ + "sin": function() { + + var a = this["re"]; + var b = this["im"]; + + return new Complex( + Math.sin(a) * Math.cosh(b), + Math.cos(a) * Math.sinh(b)); + }, + + /** + * Calculate the cosine + * + * @returns {Complex} + */ + "cos": function() { + + var a = this["re"]; + var b = this["im"]; + + return new Complex( + Math.cos(a) * Math.cosh(b), + -Math.sin(a) * Math.sinh(b)); + }, + + /** + * Calculate the tangent + * + * @returns {Complex} + */ + "tan": function() { + + var a = 2 * this["re"]; + var b = 2 * this["im"]; + var d = Math.cos(a) + Math.cosh(b); + + return new Complex( + Math.sin(a) / d, + Math.sinh(b) / d); + }, + + /** + * Calculate the cotangent + * + * @returns {Complex} + */ + "cot": function() { + + var a = 2 * this["re"]; + var b = 2 * this["im"]; + var d = Math.cos(a) - Math.cosh(b); + + return new Complex( + -Math.sin(a) / d, + Math.sinh(b) / d); + }, + + /** + * Calculate the secant + * + * @returns {Complex} + */ + "sec": function() { + + var a = this["re"]; + var b = this["im"]; + var d = 0.5 * Math.cosh(2 * b) + 0.5 * Math.cos(2 * a); + + return new Complex( + Math.cos(a) * Math.cosh(b) / d, + Math.sin(a) * Math.sinh(b) / d); + }, + + /** + * Calculate the cosecans + * + * @returns {Complex} + */ + "csc": function() { + + var a = this["re"]; + var b = this["im"]; + var d = 0.5 * Math.cosh(2 * b) - 0.5 * Math.cos(2 * a); + + return new Complex( + Math.sin(a) * Math.cosh(b) / d, + -Math.cos(a) * Math.sinh(b) / d); + }, + + /** + * Calculate the complex arcus sinus + * + * @returns {Complex} + */ + "asin": function() { + + var a = this["re"]; + var b = this["im"]; + + var t1 = new Complex( + b * b - a * a + 1, + -2 * a * b)['sqrt'](); + + var t2 = new Complex( + t1['re'] - b, + t1['im'] + a)['log'](); + + return new Complex(t2['im'], -t2['re']); + }, + + /** + * Calculate the complex arcus cosinus + * + * @returns {Complex} + */ + "acos": function() { + + var a = this["re"]; + var b = this["im"]; + + var t1 = new Complex( + b * b - a * a + 1, + -2 * a * b)['sqrt'](); + + var t2 = new Complex( + t1["re"] - b, + t1["im"] + a)['log'](); + + return new Complex(Math.PI / 2 - t2["im"], t2["re"]); + }, + + /** + * Calculate the complex arcus tangent + * + * @returns {Complex} + */ + "atan": function() { + + var a = this["re"]; + var b = this["im"]; + + if (a === 0) { + + if (b === 1) { + return new Complex(0, Infinity); + } + + if (b === -1) { + return new Complex(0, -Infinity); + } + } + + var d = a * a + (1.0 - b) * (1.0 - b); + + var t1 = new Complex( + (1 - b * b - a * a) / d, + -2 * a / d).log(); + + return new Complex(-0.5 * t1["im"], 0.5 * t1["re"]); + }, + + /** + * Calculate the complex arcus cotangent + * + * @returns {Complex} + */ + "acot": function() { + + var a = this["re"]; + var b = this["im"]; + + if (b === 0) { + return new Complex(Math.atan2(1, a), 0); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).atan() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).atan(); + }, + + /** + * Calculate the complex arcus secant + * + * @returns {Complex} + */ + "asec": function() { + + var a = this["re"]; + var b = this["im"]; + + if (a === 0 && b === 0) { + return new Complex(0, Infinity); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).acos() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).acos(); + }, + + /** + * Calculate the complex arcus cosecans + * + * @returns {Complex} + */ + "acsc": function() { + + var a = this["re"]; + var b = this["im"]; + + if (a === 0 && b === 0) { + return new Complex(Math.PI / 2, Infinity); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).asin() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).asin(); + }, + + /** + * Calculate the complex sinh + * + * @returns {Complex} + */ + "sinh": function() { + + var a = this["re"]; + var b = this["im"]; + + return new Complex( + Math.sinh(a) * Math.cos(b), + Math.cosh(a) * Math.sin(b)); + }, + + /** + * Calculate the complex cosh + * + * @returns {Complex} + */ + "cosh": function() { + + var a = this["re"]; + var b = this["im"]; + + return new Complex( + Math.cosh(a) * Math.cos(b), + Math.sinh(a) * Math.sin(b)); + }, + + /** + * Calculate the complex tanh + * + * @returns {Complex} + */ + "tanh": function() { + + var a = 2 * this["re"]; + var b = 2 * this["im"]; + var d = Math.cosh(a) + Math.cos(b); + + return new Complex( + Math.sinh(a) / d, + Math.sin(b) / d); + }, + + /** + * Calculate the complex coth + * + * @returns {Complex} + */ + "coth": function() { + + var a = 2 * this["re"]; + var b = 2 * this["im"]; + var d = Math.cosh(a) - Math.cos(b); + + return new Complex( + Math.sinh(a) / d, + -Math.sin(b) / d); + }, + + /** + * Calculate the complex coth + * + * @returns {Complex} + */ + "csch": function() { + + var a = this["re"]; + var b = this["im"]; + var d = Math.cos(2 * b) - Math.cosh(2 * a); + + return new Complex( + -2 * Math.sinh(a) * Math.cos(b) / d, + 2 * Math.cosh(a) * Math.sin(b) / d); + }, + + /** + * Calculate the complex sech + * + * @returns {Complex} + */ + "sech": function() { + + var a = this["re"]; + var b = this["im"]; + var d = Math.cos(2 * b) + Math.cosh(2 * a); + + return new Complex( + 2 * Math.cosh(a) * Math.cos(b) / d, + -2 * Math.sinh(a) * Math.sin(b) / d); + }, + + /** + * Calculate the complex asinh + * + * @returns {Complex} + */ + "asinh": function() { + + 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; + }, + + /** + * Calculate the complex asinh + * + * @returns {Complex} + */ + "acosh": function() { + + var tmp; + var res = this["acos"](); + if (res["im"] <= 0) { + tmp = res["re"]; + res["re"] = -res["im"]; + res["im"] = tmp; + } else { + tmp = res["im"]; + res["im"] = -res["re"]; + res["re"] = tmp; + } + return res; + }, + + /** + * Calculate the complex atanh + * + * @returns {Complex} + */ + "atanh": function() { + + var a = this["re"]; + var b = this["im"]; + + var noIM = a > 1 && b === 0; + var oneMinus = 1 - a; + var onePlus = 1 + a; + var d = oneMinus * oneMinus + b * b; + + var x = (d !== 0) + ? new Complex( + (onePlus * oneMinus - b * b) / d, + (b * oneMinus + onePlus * b) / d) + : new Complex( + (a !== -1) ? (a / 0) : 0, + (b !== 0) ? (b / 0) : 0); + + var temp = x["re"]; + x["re"] = logHypot(x["re"], x["im"]) / 2; + x["im"] = Math.atan2(x["im"], temp) / 2; + if (noIM) { + x["im"] = -x["im"]; + } + return x; + }, + + /** + * Calculate the complex acoth + * + * @returns {Complex} + */ + "acoth": function() { + + var a = this["re"]; + var b = this["im"]; + + if (a === 0 && b === 0) { + + return new Complex(0, Math.PI / 2); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).atanh() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).atanh(); + }, + + /** + * Calculate the complex acsch + * + * @returns {Complex} + */ + "acsch": function() { + + var a = this["re"]; + var b = this["im"]; + + if (b === 0) { + + return new Complex( + (a !== 0) + ? Math.log(a + Math.sqrt(a * a + 1)) + : Infinity, 0); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).asinh() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).asinh(); + }, + + /** + * Calculate the complex asech + * + * @returns {Complex} + */ + "asech": function() { + + var a = this["re"]; + var b = this["im"]; + + if (a === 0 && b === 0) { + return new Complex(Infinity, 0); + } + + var d = a * a + b * b; + return (d !== 0) + ? new Complex( + a / d, + -b / d).acosh() + : new Complex( + (a !== 0) ? a / 0 : 0, + (b !== 0) ?-b / 0 : 0).acosh(); + }, + + /** + * Calculate the complex inverse 1/z + * + * @returns {Complex} + */ + "inverse": function() { + + var a = this["re"]; + var b = this["im"]; + + var d = a * a + b * b; + + return new Complex( + a !== 0 ? a / d : 0, + b !== 0 ?-b / d : 0); + }, + + /** + * Returns the complex conjugate + * + * @returns {Complex} + */ + "conjugate": function() { + + return new Complex(this["re"], -this["im"]); + }, + + /** + * Gets the negated complex number + * + * @returns {Complex} + */ + "neg": function() { + + return new Complex(-this["re"], -this["im"]); + }, + + /** + * Ceils the actual complex number + * + * @returns {Complex} + */ + "ceil": function(places) { + + places = Math.pow(10, places || 0); + + return new Complex( + Math.ceil(this["re"] * places) / places, + Math.ceil(this["im"] * places) / places); + }, + + /** + * Floors the actual complex number + * + * @returns {Complex} + */ + "floor": function(places) { + + places = Math.pow(10, places || 0); + + return new Complex( + Math.floor(this["re"] * places) / places, + Math.floor(this["im"] * places) / places); + }, + + /** + * Ceils the actual complex number + * + * @returns {Complex} + */ + "round": function(places) { + + places = Math.pow(10, places || 0); + + return new Complex( + Math.round(this["re"] * places) / places, + Math.round(this["im"] * places) / places); + }, + + /** + * Compares two complex numbers + * + * @returns {boolean} + */ + "equals": function(a, b) { + + parse(a, b); // mutates P + + return Math.abs(P["re"] - this["re"]) <= Complex["EPSILON"] && + Math.abs(P["im"] - this["im"]) <= Complex["EPSILON"]; + }, + + /** + * Clones the actual object + * + * @returns {Complex} + */ + "clone": function() { + + return new Complex(this["re"], this["im"]); + }, + + /** + * Gets a string of the actual complex number + * + * @returns {string} + */ + "toString": function() { + + var a = this["re"]; + var b = this["im"]; + var ret = ""; + + if (isNaN(a) || isNaN(b)) { + return "NaN"; + } + + if (a !== 0) { + ret+= a; + } + + if (b !== 0) { + + if (a !== 0) { + ret+= b < 0 ? " - " : " + "; + } else if (b < 0) { + ret+= "-"; + } + + b = Math.abs(b); + + if (1 !== b) { + ret+= b; + } + ret+= "i"; + } + + if (!ret) + return "0"; + + return ret; + }, + + /** + * Returns the actual number as a vector + * + * @returns {Array} + */ + "toVector": function() { + + return [this["re"], this["im"]]; + }, + + /** + * Returns the actual real value of the current object + * + * @returns {number|null} + */ + "valueOf": function() { + + if (this["im"] === 0) { + return this["re"]; + } + return null; + }, + + /** + * Checks if the given complex number is not a number + * + * @returns {boolean} + */ + isNaN: function() { + return isNaN(this['re']) || isNaN(this['im']); + } + }; + + Complex["ZERO"] = new Complex(0, 0); + Complex["ONE"] = new Complex(1, 0); + Complex["I"] = new Complex(0, 1); + Complex["PI"] = new Complex(Math.PI, 0); + Complex["E"] = new Complex(Math.E, 0); + Complex['EPSILON'] = 1e-16; + + if ("function" === "function" && __webpack_require__(30)["amd"]) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { + return Complex; + }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (true) { + module["exports"] = Complex; + } else { + root["Complex"] = Complex; + } + + })(this); + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(29)(module))) + +/***/ }, +/* 29 */ +/***/ function(module, exports) { + + module.exports = function(module) { + if(!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + } + + +/***/ }, +/* 30 */ +/***/ function(module, exports) { + + module.exports = function() { throw new Error("define cannot be used indirect"); }; + + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + /** + * Create a complex value or convert a value to a complex value. + * + * Syntax: + * + * math.complex() // creates a complex value with zero + * // as real and imaginary part. + * math.complex(re : number, im : string) // creates a complex value with provided + * // values for real and imaginary part. + * math.complex(re : number) // creates a complex value with provided + * // real value and zero imaginary part. + * math.complex(complex : Complex) // clones the provided complex value. + * math.complex(arg : string) // parses a string into a complex value. + * math.complex(array : Array) // converts the elements of the array + * // or matrix element wise into a + * // complex value. + * math.complex({re: number, im: number}) // creates a complex value with provided + * // values for real an imaginary part. + * math.complex({r: number, phi: number}) // creates a complex value with provided + * // polar coordinates + * + * Examples: + * + * var a = math.complex(3, -4); // a = Complex 3 - 4i + * a.re = 5; // a = Complex 5 - 4i + * var i = a.im; // Number -4; + * var b = math.complex('2 + 6i'); // Complex 2 + 6i + * var c = math.complex(); // Complex 0 + 0i + * var d = math.add(a, b); // Complex 5 + 2i + * + * See also: + * + * bignumber, boolean, index, matrix, number, string, unit + * + * @param {* | Array | Matrix} [args] + * Arguments specifying the real and imaginary part of the complex number + * @return {Complex | Array | Matrix} Returns a complex value + */ + var complex = typed('complex', { + '': function () { + return type.Complex.ZERO; + }, + + 'number': function (x) { + return new type.Complex(x, 0); + }, + + 'number, number': function (re, im) { + return new type.Complex(re, im); + }, + + // TODO: this signature should be redundant + 'BigNumber, BigNumber': function (re, im) { + return new type.Complex(re.toNumber(), im.toNumber()); + }, + + 'Complex': function (x) { + return x.clone(); + }, + + 'string': function (x) { + return type.Complex(x); // for example '2 + 3i' + }, + + 'Object': function (x) { + if('re' in x && 'im' in x) { + return new type.Complex(x.re, x.im); + } + + if ('r' in x && 'phi' in x) { + return new type.Complex(x); + } + + throw new Error('Expected object with either properties re and im, or properties r and phi.'); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, complex); + } + }); + + complex.toTex = { + 0: '0', + 1: '\\left(${args[0]}\\right)', + 2: '\\left(\\left(${args[0]}\\right)+' + + latex.symbols['i'] + '\\cdot\\left(${args[1]}\\right)\\right)' + }; + + return complex; + } + + exports.name = 'complex'; + exports.factory = factory; + + +/***/ }, +/* 32 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.symbols = { + // GREEK LETTERS + Alpha: 'A', alpha: '\\alpha', + Beta: 'B', beta: '\\beta', + Gamma: '\\Gamma', gamma: '\\gamma', + Delta: '\\Delta', delta: '\\delta', + Epsilon: 'E', epsilon: '\\epsilon', varepsilon: '\\varepsilon', + Zeta: 'Z', zeta: '\\zeta', + Eta: 'H', eta: '\\eta', + Theta: '\\Theta', theta: '\\theta', vartheta: '\\vartheta', + Iota: 'I', iota: '\\iota', + Kappa: 'K', kappa: '\\kappa', varkappa: '\\varkappa', + Lambda: '\\Lambda', lambda: '\\lambda', + Mu: 'M', mu: '\\mu', + Nu: 'N', nu: '\\nu', + Xi: '\\Xi', xi: '\\xi', + Omicron: 'O', omicron: 'o', + Pi: '\\Pi', pi: '\\pi', varpi: '\\varpi', + Rho: 'P', rho: '\\rho', varrho: '\\varrho', + Sigma: '\\Sigma', sigma: '\\sigma', varsigma: '\\varsigma', + Tau: 'T', tau: '\\tau', + Upsilon: '\\Upsilon', upsilon: '\\upsilon', + Phi: '\\Phi', phi: '\\phi', varphi: '\\varphi', + Chi: 'X', chi: '\\chi', + Psi: '\\Psi', psi: '\\psi', + Omega: '\\Omega', omega: '\\omega', + //logic + 'true': '\\mathrm{True}', + 'false': '\\mathrm{False}', + //other + i: 'i', //TODO use \i ?? + inf: '\\infty', + Inf: '\\infty', + infinity: '\\infty', + Infinity: '\\infty', + oo: '\\infty', + lim: '\\lim', + 'undefined': '\\mathbf{?}' + }; + + exports.operators = { + 'transpose': '^\\top', + 'factorial': '!', + 'pow': '^', + 'dotPow': '.^\\wedge', //TODO find ideal solution + 'unaryPlus': '+', + 'unaryMinus': '-', + 'bitNot': '~', //TODO find ideal solution + 'not': '\\neg', + 'multiply': '\\cdot', + 'divide': '\\frac', //TODO how to handle that properly? + 'dotMultiply': '.\\cdot', //TODO find ideal solution + 'dotDivide': '.:', //TODO find ideal solution + 'mod': '\\mod', + 'add': '+', + 'subtract': '-', + 'to': '\\rightarrow', + 'leftShift': '<<', + 'rightArithShift': '>>', + 'rightLogShift': '>>>', + 'equal': '=', + 'unequal': '\\neq', + 'smaller': '<', + 'larger': '>', + 'smallerEq': '\\leq', + 'largerEq': '\\geq', + 'bitAnd': '\\&', + 'bitXor': '\\underline{|}', + 'bitOr': '|', + 'and': '\\wedge', + 'xor': '\\veebar', + 'or': '\\vee' + }; + + exports.defaultTemplate = '\\mathrm{${name}}\\left(${args}\\right)'; + + var units = { + deg: '^\\circ' + }; + + //@param {string} name + //@param {boolean} isUnit + exports.toSymbol = function (name, isUnit) { + isUnit = typeof isUnit === 'undefined' ? false : isUnit; + if (isUnit) { + if (units.hasOwnProperty(name)) { + return units[name]; + } + return '\\mathrm{' + name + '}'; + } + + if (exports.symbols.hasOwnProperty(name)) { + return exports.symbols[name]; + } + else if (name.indexOf('_') !== -1) { + //symbol with index (eg. alpha_1) + var index = name.indexOf('_'); + return exports.toSymbol(name.substring(0, index)) + '_{' + + exports.toSymbol(name.substring(index + 1)) + '}'; + } + return name; + }; + + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(34), + + // construction function + __webpack_require__(36) + ]; + + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + var Fraction = __webpack_require__(35); + + /** + * Attach type information + */ + Fraction.prototype.type = 'Fraction'; + Fraction.prototype.isFraction = true; + + /** + * Get a JSON representation of a Fraction containing type information + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Fraction", "n": 3, "d": 8}` + */ + Fraction.prototype.toJSON = function () { + return { + mathjs: 'Fraction', + n: this.s * this.n, + d: this.d + }; + }; + + /** + * Instantiate a Fraction from a JSON object + * @param {Object} json a JSON object structured as: + * `{"mathjs": "Fraction", "n": 3, "d": 8}` + * @return {BigNumber} + */ + Fraction.fromJSON = function (json) { + return new Fraction(json); + }; + + + function factory (type, config, load, typed) { + return Fraction; + } + + exports.name = 'Fraction'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** + * @license Fraction.js v3.3.1 09/09/2015 + * http://www.xarg.org/2014/03/precise-calculations-in-javascript/ + * + * Copyright (c) 2015, Robert Eisele (robert@xarg.org) + * Dual licensed under the MIT or GPL Version 2 licenses. + **/ + + + /** + * + * This class offers the possibility to calculate fractions. + * You can pass a fraction in different formats. Either as array, as double, as string or as an integer. + * + * Array/Object form + * [ 0 => , 1 => ] + * [ n => , d => ] + * + * Integer form + * - Single integer value + * + * Double form + * - Single double value + * + * String form + * 123.456 - a simple double + * 123/456 - a string fraction + * 123.'456' - a double with repeating decimal places + * 123.(456) - synonym + * 123.45'6' - a double with repeating last place + * 123.45(6) - synonym + * + * Example: + * + * var f = new Fraction("9.4'31'"); + * f.mul([-4, 3]).div(4.9); + * + */ + + (function(root) { + + "use strict"; + + // Maximum search depth for cyclic rational numbers. 2000 should be more than enough. + // Example: 1/7 = 0.(142857) has 6 repeating decimal places. + // If MAX_CYCLE_LEN gets reduced, long cycles will not be detected and toString() only gets the first 10 digits + var MAX_CYCLE_LEN = 2000; + + // Parsed data to avoid calling "new" all the time + var P = { + "s": 1, + "n": 0, + "d": 1 + }; + + function assign(n, s) { + + if (isNaN(n = parseInt(n, 10))) { + throwInvalidParam(); + } + return n * s; + } + + function throwInvalidParam() { + throw "Invalid Param"; + } + + var parse = function(p1, p2) { + + var n = 0, d = 1, s = 1; + var v = 0, w = 0, x = 0, y = 1, z = 1; + + var A = 0, B = 1; + var C = 1, D = 1; + + var N = 10000000; + var M; + + if (p1 === undefined || p1 === null) { + /* void */ + } else if (p2 !== undefined) { + n = p1; + d = p2; + s = n * d; + } else + switch (typeof p1) { + + case "object": + { + if ("d" in p1 && "n" in p1) { + n = p1["n"]; + d = p1["d"]; + if ("s" in p1) + n*= p1["s"]; + } else if (0 in p1) { + n = p1[0]; + if (1 in p1) + d = p1[1]; + } else { + throwInvalidParam(); + } + s = n * d; + break; + } + case "number": + { + if (p1 < 0) { + s = p1; + p1 = -p1; + } + + if (p1 % 1 === 0) { + n = p1; + } else if (p1 > 0) { // check for != 0, scale would become NaN (log(0)), which converges really slow + + if (p1 >= 1) { + z = Math.pow(10, Math.floor(1 + Math.log(p1) / Math.LN10)); + p1/= z; + } + + // Using Farey Sequences + // http://www.johndcook.com/blog/2010/10/20/best-rational-approximation/ + + while (B <= N && D <= N) { + M = (A + C) / (B + D); + + if (p1 === M) { + if (B + D <= N) { + n = A + C; + d = B + D; + } else if (D > B) { + n = C; + d = D; + } else { + n = A; + d = B; + } + break; + + } else { + + if (p1 > M) { + A+= C; + B+= D; + } else { + C+= A; + D+= B; + } + + if (B > N) { + n = C; + d = D; + } else { + n = A; + d = B; + } + } + } + n*= z; + } else if (isNaN(p1) || isNaN(p2)) { + d = n = NaN; + } + break; + } + case "string": + { + B = p1.match(/\d+|./g); + + if (B[A] === '-') {// Check for minus sign at the beginning + s = -1; + A++; + } else if (B[A] === '+') {// Check for plus sign at the beginning + A++; + } + + if (B.length === A + 1) { // Check if it's just a simple number "1234" + w = assign(B[A++], s); + } else if (B[A + 1] === '.' || B[A] === '.') { // Check if it's a decimal number + + if (B[A] !== '.') { // Handle 0.5 and .5 + v = assign(B[A++], s); + } + A++; + + // Check for decimal places + if (A + 1 === B.length || B[A + 1] === '(' && B[A + 3] === ')' || B[A + 1] === "'" && B[A + 3] === "'") { + w = assign(B[A], s); + y = Math.pow(10, B[A].length); + A++; + } + + // Check for repeating places + if (B[A] === '(' && B[A + 2] === ')' || B[A] === "'" && B[A + 2] === "'") { + x = assign(B[A + 1], s); + z = Math.pow(10, B[A + 1].length) - 1; + A+= 3; + } + + } else if (B[A + 1] === '/' || B[A + 1] === ':') { // Check for a simple fraction "123/456" or "123:456" + w = assign(B[A], s); + y = assign(B[A + 2], 1); + A+= 3; + } else if (B[A + 3] === '/' && B[A + 1] === ' ') { // Check for a complex fraction "123 1/2" + v = assign(B[A], s); + w = assign(B[A + 2], s); + y = assign(B[A + 4], 1); + A+= 5; + } + + if (B.length <= A) { // Check for more tokens on the stack + d = y * z; + s = /* void */ + n = x + d * v + z * w; + break; + } + + /* Fall through on error */ + } + default: + throwInvalidParam(); + } + + if (d === 0) { + throw "DIV/0"; + } + + P["s"] = s < 0 ? -1 : 1; + P["n"] = Math.abs(n); + P["d"] = Math.abs(d); + }; + + var modpow = function(b, e, m) { + + for (var r = 1; e > 0; b = (b * b) % m, e >>= 1) { + + if (e & 1) { + r = (r * b) % m; + } + } + return r; + }; + + var cycleLen = function(n, d) { + + for (; d % 2 === 0; + d/= 2) {} + + for (; d % 5 === 0; + d/= 5) {} + + if (d === 1) // Catch non-cyclic numbers + return 0; + + // If we would like to compute really large numbers quicker, we could make use of Fermat's little theorem: + // 10^(d-1) % d == 1 + // However, we don't need such large numbers and MAX_CYCLE_LEN should be the capstone, + // as we want to translate the numbers to strings. + + var rem = 10 % d; + + for (var t = 1; rem !== 1; t++) { + rem = rem * 10 % d; + + if (t > MAX_CYCLE_LEN) + return 0; // Returning 0 here means that we don't print it as a cyclic number. It's likely that the answer is `d-1` + } + return t; + }; + + var cycleStart = function(n, d, len) { + + var rem1 = 1; + var rem2 = modpow(10, len, d); + + for (var t = 0; t < 300; t++) { // s < ~log10(Number.MAX_VALUE) + // Solve 10^s == 10^(s+t) (mod d) + + if (rem1 === rem2) + return t; + + rem1 = rem1 * 10 % d; + rem2 = rem2 * 10 % d; + } + return 0; + }; + + var gcd = function(a, b) { + + if (!a) return b; + if (!b) return a; + + while (1) { + a%= b; + if (!a) return b; + b%= a; + if (!b) return a; + } + }; + + /** + * Module constructor + * + * @constructor + * @param {number|Fraction} a + * @param {number=} b + */ + function Fraction(a, b) { + + if (!(this instanceof Fraction)) { + return new Fraction(a, b); + } + + parse(a, b); + + if (Fraction['REDUCE']) { + a = gcd(P["d"], P["n"]); // Abuse a + } else { + a = 1; + } + + this["s"] = P["s"]; + this["n"] = P["n"] / a; + this["d"] = P["d"] / a; + } + + /** + * Boolean global variable to be able to disable automatic reduction of the fraction + * + */ + Fraction['REDUCE'] = 1; + + Fraction.prototype = { + + "s": 1, + "n": 0, + "d": 1, + + /** + * Calculates the absolute value + * + * Ex: new Fraction(-4).abs() => 4 + **/ + "abs": function() { + + return new Fraction(this["n"], this["d"]); + }, + + /** + * Inverts the sign of the current fraction + * + * Ex: new Fraction(-4).neg() => 4 + **/ + "neg": function() { + + return new Fraction(-this["s"] * this["n"], this["d"]); + }, + + /** + * Adds two rational numbers + * + * Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30 + **/ + "add": function(a, b) { + + parse(a, b); + return new Fraction( + this["s"] * this["n"] * P["d"] + P["s"] * this["d"] * P["n"], + this["d"] * P["d"] + ); + }, + + /** + * Subtracts two rational numbers + * + * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30 + **/ + "sub": function(a, b) { + + parse(a, b); + return new Fraction( + this["s"] * this["n"] * P["d"] - P["s"] * this["d"] * P["n"], + this["d"] * P["d"] + ); + }, + + /** + * Multiplies two rational numbers + * + * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111 + **/ + "mul": function(a, b) { + + parse(a, b); + return new Fraction( + this["s"] * P["s"] * this["n"] * P["n"], + this["d"] * P["d"] + ); + }, + + /** + * Divides two rational numbers + * + * Ex: new Fraction("-17.(345)").inverse().div(3) + **/ + "div": function(a, b) { + + parse(a, b); + return new Fraction( + this["s"] * P["s"] * this["n"] * P["d"], + this["d"] * P["n"] + ); + }, + + /** + * Clones the actual object + * + * Ex: new Fraction("-17.(345)").clone() + **/ + "clone": function() { + return new Fraction(this); + }, + + /** + * Calculates the modulo of two rational numbers - a more precise fmod + * + * Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6) + **/ + "mod": function(a, b) { + + if (isNaN(this['n']) || isNaN(this['d'])) { + return new Fraction(NaN); + } + + if (a === undefined) { + return new Fraction(this["s"] * this["n"] % this["d"], 1); + } + + parse(a, b); + if (0 === P["n"] && 0 === this["d"]) { + Fraction(0, 0); // Throw div/0 + } + + /* + * First silly attempt, kinda slow + * + return that["sub"]({ + "n": num["n"] * Math.floor((this.n / this.d) / (num.n / num.d)), + "d": num["d"], + "s": this["s"] + });*/ + + /* + * New attempt: a1 / b1 = a2 / b2 * q + r + * => b2 * a1 = a2 * b1 * q + b1 * b2 * r + * => (b2 * a1 % a2 * b1) / (b1 * b2) + */ + return new Fraction( + (this["s"] * P["d"] * this["n"]) % (P["n"] * this["d"]), + P["d"] * this["d"] + ); + }, + + /** + * Calculates the fractional gcd of two rational numbers + * + * Ex: new Fraction(5,8).gcd(3,7) => 1/56 + */ + "gcd": function(a, b) { + + parse(a, b); + + // gcd(a / b, c / d) = gcd(a, c) / lcm(b, d) + + return new Fraction(gcd(P["n"], this["n"]), P["d"] * this["d"] / gcd(P["d"], this["d"])); + }, + + /** + * Calculates the fractional lcm of two rational numbers + * + * Ex: new Fraction(5,8).lcm(3,7) => 15 + */ + "lcm": function(a, b) { + + parse(a, b); + + // lcm(a / b, c / d) = lcm(a, c) / gcd(b, d) + + if (P["n"] === 0 && this["n"] === 0) { + return new Fraction; + } + return new Fraction(P["n"] * this["n"] / gcd(P["n"], this["n"]), gcd(P["d"], this["d"])); + }, + + /** + * Calculates the ceil of a rational number + * + * Ex: new Fraction('4.(3)').ceil() => (5 / 1) + **/ + "ceil": function(places) { + + places = Math.pow(10, places || 0); + + if (isNaN(this["n"]) || isNaN(this["d"])) { + return new Fraction(NaN); + } + return new Fraction(Math.ceil(places * this["s"] * this["n"] / this["d"]), places); + }, + + /** + * Calculates the floor of a rational number + * + * Ex: new Fraction('4.(3)').floor() => (4 / 1) + **/ + "floor": function(places) { + + places = Math.pow(10, places || 0); + + if (isNaN(this["n"]) || isNaN(this["d"])) { + return new Fraction(NaN); + } + return new Fraction(Math.floor(places * this["s"] * this["n"] / this["d"]), places); + }, + + /** + * Rounds a rational numbers + * + * Ex: new Fraction('4.(3)').round() => (4 / 1) + **/ + "round": function(places) { + + places = Math.pow(10, places || 0); + + if (isNaN(this["n"]) || isNaN(this["d"])) { + return new Fraction(NaN); + } + return new Fraction(Math.round(places * this["s"] * this["n"] / this["d"]), places); + }, + + /** + * Gets the inverse of the fraction, means numerator and denumerator are exchanged + * + * Ex: new Fraction([-3, 4]).inverse() => -4 / 3 + **/ + "inverse": function() { + + return new Fraction(this["s"] * this["d"], this["n"]); + }, + + /** + * Calculates the fraction to some integer exponent + * + * Ex: new Fraction(-1,2).pow(-3) => -8 + */ + "pow": function(m) { + + if (m < 0) { + return new Fraction(Math.pow(this['s'] * this["d"],-m), Math.pow(this["n"],-m)); + } else { + return new Fraction(Math.pow(this['s'] * this["n"], m), Math.pow(this["d"], m)); + } + }, + + /** + * Check if two rational numbers are the same + * + * Ex: new Fraction(19.6).equals([98, 5]); + **/ + "equals": function(a, b) { + + parse(a, b); + return this["s"] * this["n"] * P["d"] === P["s"] * P["n"] * this["d"]; // Same as compare() === 0 + }, + + /** + * Check if two rational numbers are the same + * + * Ex: new Fraction(19.6).equals([98, 5]); + **/ + "compare": function(a, b) { + + parse(a, b); + var t = (this["s"] * this["n"] * P["d"] - P["s"] * P["n"] * this["d"]); + return (0 < t) - (t < 0); + }, + + /** + * Check if two rational numbers are divisible + * + * Ex: new Fraction(19.6).divisible(1.5); + */ + "divisible": function(a, b) { + + parse(a, b); + return !(!(P["n"] * this["d"]) || ((this["n"] * P["d"]) % (P["n"] * this["d"]))); + }, + + /** + * Returns a decimal representation of the fraction + * + * Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183 + **/ + 'valueOf': function() { + + return this["s"] * this["n"] / this["d"]; + }, + + /** + * Returns a string-fraction representation of a Fraction object + * + * Ex: new Fraction("1.'3'").toFraction() => "4 1/3" + **/ + 'toFraction': function(excludeWhole) { + + var whole, str = ""; + var n = this["n"]; + var d = this["d"]; + if (this["s"] < 0) { + str+= '-'; + } + + if (d === 1) { + str+= n; + } else { + + if (excludeWhole && (whole = Math.floor(n / d)) > 0) { + str+= whole; + str+= " "; + n%= d; + } + + str+= n; + str+= '/'; + str+= d; + } + return str; + }, + + /** + * Returns a latex representation of a Fraction object + * + * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}" + **/ + 'toLatex': function(excludeWhole) { + + var whole, str = ""; + var n = this["n"]; + var d = this["d"]; + if (this["s"] < 0) { + str+= '-'; + } + + if (d === 1) { + str+= n; + } else { + + if (excludeWhole && (whole = Math.floor(n / d)) > 0) { + str+= whole; + n%= d; + } + + str+= "\\frac{"; + str+= n; + str+= '}{'; + str+= d; + str+= '}'; + } + return str; + }, + + /** + * Returns an array of continued fraction elements + * + * Ex: new Fraction("7/8").toContinued() => [0,1,7] + */ + 'toContinued': function() { + + var t; + var a = this['n']; + var b = this['d']; + var res = []; + + do { + res.push(Math.floor(a / b)); + t = a % b; + a = b; + b = t; + } while (a !== 1); + + return res; + }, + + /** + * Creates a string representation of a fraction with all digits + * + * Ex: new Fraction("100.'91823'").toString() => "100.(91823)" + **/ + 'toString': function() { + + var g; + var N = this["n"]; + var D = this["d"]; + + if (isNaN(N) || isNaN(D)) { + return "NaN"; + } + + if (!Fraction['REDUCE']) { + g = gcd(N, D); + N/= g; + D/= g; + } + + var p = String(N).split(""); // Numerator chars + var t = 0; // Tmp var + + var ret = [~this["s"] ? "" : "-", "", ""]; // Return array, [0] is zero sign, [1] before comma, [2] after + var zeros = ""; // Collection variable for zeros + + var cycLen = cycleLen(N, D); // Cycle length + var cycOff = cycleStart(N, D, cycLen); // Cycle start + + var j = -1; + var n = 1; // str index + + // rough estimate to fill zeros + var length = 15 + cycLen + cycOff + p.length; // 15 = decimal places when no repitation + + for (var i = 0; i < length; i++, t*= 10) { + + if (i < p.length) { + t+= Number(p[i]); + } else { + n = 2; + j++; // Start now => after comma + } + + if (cycLen > 0) { // If we have a repeating part + if (j === cycOff) { + ret[n]+= zeros + "("; + zeros = ""; + } else if (j === cycLen + cycOff) { + ret[n]+= zeros + ")"; + break; + } + } + + if (t >= D) { + ret[n]+= zeros + ((t / D) | 0); // Flush zeros, Add current digit + zeros = ""; + t = t % D; + } else if (n > 1) { // Add zeros to the zero buffer + zeros+= "0"; + } else if (ret[n]) { // If before comma, add zero only if already something was added + ret[n]+= "0"; + } + } + + // If it's empty, it's a leading zero only + ret[0]+= ret[1] || "0"; + + // If there is something after the comma, add the comma sign + if (ret[2]) { + return ret[0] + "." + ret[2]; + } + return ret[0]; + } + }; + + if ("function" === "function" && __webpack_require__(30)["amd"]) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { + return Fraction; + }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (true) { + module["exports"] = Fraction; + } else { + root['Fraction'] = Fraction; + } + + })(this); + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(29)(module))) + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Create a fraction convert a value to a fraction. + * + * Syntax: + * math.fraction(numerator, denominator) + * math.fraction({n: numerator, d: denominator}) + * math.fraction(matrix: Array | Matrix) Turn all matrix entries + * into fractions + * + * Examples: + * + * math.fraction(1, 3); + * math.fraction('2/3'); + * math.fraction({n: 2, d: 3}); + * math.fraction([0.2, 0.25, 1.25]); + * + * See also: + * + * bignumber, number, string, unit + * + * @param {number | string | Fraction | BigNumber | Array | Matrix} [args] + * Arguments specifying the numerator and denominator of + * the fraction + * @return {Fraction | Array | Matrix} Returns a fraction + */ + var fraction = typed('fraction', { + 'number': function (x) { + if (!isFinite(x) || isNaN(x)) { + throw new Error(x + ' cannot be represented as a fraction'); + } + + return new type.Fraction(x); + }, + + 'string': function (x) { + return new type.Fraction(x); + }, + + 'number, number': function (numerator, denominator) { + return new type.Fraction(numerator, denominator); + }, + + 'BigNumber': function (x) { + return new type.Fraction(x.toString()); + }, + + 'Fraction': function (x) { + return x; // fractions are immutable + }, + + 'Object': function (x) { + return new type.Fraction(x); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, fraction); + } + }); + + return fraction; + } + + exports.name = 'fraction'; + exports.factory = factory; + + +/***/ }, +/* 37 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // types + __webpack_require__(38), + __webpack_require__(46), + __webpack_require__(47), + __webpack_require__(50), + __webpack_require__(59), + __webpack_require__(65), + __webpack_require__(66), + __webpack_require__(67), + + // construction functions + __webpack_require__(68), + __webpack_require__(52), + __webpack_require__(69) + ]; + + +/***/ }, +/* 38 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + + var string = util.string; + + var isString = string.isString; + + function factory (type, config, load, typed) { + /** + * @constructor Matrix + * + * A Matrix is a wrapper around an Array. A matrix can hold a multi dimensional + * array. A matrix can be constructed as: + * var matrix = math.matrix(data) + * + * Matrix contains the functions to resize, get and set values, get the size, + * clone the matrix and to convert the matrix to a vector, array, or scalar. + * Furthermore, one can iterate over the matrix using map and forEach. + * The internal Array of the Matrix can be accessed using the function valueOf. + * + * Example usage: + * var matrix = math.matrix([[1, 2], [3, 4]]); + * matix.size(); // [2, 2] + * matrix.resize([3, 2], 5); + * matrix.valueOf(); // [[1, 2], [3, 4], [5, 5]] + * matrix.subset([1,2]) // 3 (indexes are zero-based) + * + */ + function Matrix() { + if (!(this instanceof Matrix)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + } + + /** + * Attach type information + */ + Matrix.prototype.type = 'Matrix'; + Matrix.prototype.isMatrix = true; + + /** + * Get the Matrix storage constructor for the given format. + * + * @param {string} format The Matrix storage format. + * + * @return {Function} The Matrix storage constructor. + */ + Matrix.storage = function (format) { + // check storage format is a string + if (!isString(format)) { + throw new TypeError('format must be a string value'); + } + + // get storage format constructor + var constructor = Matrix._storage[format]; + if (!constructor) { + throw new SyntaxError('Unsupported matrix storage format: ' + format); + } + + // return storage constructor + return constructor; + }; + + // a map with all constructors for all storage types + Matrix._storage = {}; + + /** + * Get the storage format used by the matrix. + * + * Usage: + * var format = matrix.storage() // retrieve storage format + * + * @return {string} The storage format. + */ + Matrix.prototype.storage = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke storage on a Matrix interface'); + }; + + /** + * Get the datatype of the data stored in the matrix. + * + * Usage: + * var format = matrix.datatype() // retrieve matrix datatype + * + * @return {string} The datatype. + */ + Matrix.prototype.datatype = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke datatype on a Matrix interface'); + }; + + /** + * Create a new Matrix With the type of the current matrix instance + * @param {Array | Object} data + * @param {string} [datatype] + */ + Matrix.prototype.create = function (data, datatype) { + throw new Error('Cannot invoke create on a Matrix interface'); + }; + + /** + * Get a subset of the matrix, or replace a subset of the matrix. + * + * Usage: + * var subset = matrix.subset(index) // retrieve subset + * var value = matrix.subset(index, replacement) // replace subset + * + * @param {Index} index + * @param {Array | Matrix | *} [replacement] + * @param {*} [defaultValue=0] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be filled with zeros. + */ + Matrix.prototype.subset = function (index, replacement, defaultValue) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke subset on a Matrix interface'); + }; + + /** + * Get a single element from the matrix. + * @param {number[]} index Zero-based index + * @return {*} value + */ + Matrix.prototype.get = function (index) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke get on a Matrix interface'); + }; + + /** + * Replace a single element in the matrix. + * @param {number[]} index Zero-based index + * @param {*} value + * @param {*} [defaultValue] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be left undefined. + * @return {Matrix} self + */ + Matrix.prototype.set = function (index, value, defaultValue) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke set on a Matrix interface'); + }; + + /** + * Resize the matrix to the given size. Returns a copy of the matrix when + * `copy=true`, otherwise return the matrix itself (resize in place). + * + * @param {number[]} size The new size the matrix should have. + * @param {*} [defaultValue=0] Default value, filled in on new entries. + * If not provided, the matrix elements will + * be filled with zeros. + * @param {boolean} [copy] Return a resized copy of the matrix + * + * @return {Matrix} The resized matrix + */ + Matrix.prototype.resize = function (size, defaultValue) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke resize on a Matrix interface'); + }; + + /** + * Create a clone of the matrix + * @return {Matrix} clone + */ + Matrix.prototype.clone = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke clone on a Matrix interface'); + }; + + /** + * Retrieve the size of the matrix. + * @returns {number[]} size + */ + Matrix.prototype.size = function() { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke size on a Matrix interface'); + }; + + /** + * Create a new matrix with the results of the callback function executed on + * each entry of the matrix. + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. + * + * @return {Matrix} matrix + */ + Matrix.prototype.map = function (callback, skipZeros) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke map on a Matrix interface'); + }; + + /** + * Execute a callback function on each entry of the matrix. + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + */ + Matrix.prototype.forEach = function (callback) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke forEach on a Matrix interface'); + }; + + /** + * Create an Array with a copy of the data of the Matrix + * @returns {Array} array + */ + Matrix.prototype.toArray = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke toArray on a Matrix interface'); + }; + + /** + * Get the primitive value of the Matrix: a multidimensional array + * @returns {Array} array + */ + Matrix.prototype.valueOf = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke valueOf on a Matrix interface'); + }; + + /** + * Get a string representation of the matrix, with optional formatting options. + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @returns {string} str + */ + Matrix.prototype.format = function (options) { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke format on a Matrix interface'); + }; + + /** + * Get a string representation of the matrix + * @returns {string} str + */ + Matrix.prototype.toString = function () { + // must be implemented by each of the Matrix implementations + throw new Error('Cannot invoke toString on a Matrix interface'); + }; + + // exports + return Matrix; + } + + exports.name = 'Matrix'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.array = __webpack_require__(40); + exports['boolean'] = __webpack_require__(44); + exports['function'] = __webpack_require__(45); + exports.number = __webpack_require__(6); + exports.object = __webpack_require__(3); + exports.string = __webpack_require__(23); + exports.types = __webpack_require__(41); + exports.emitter = __webpack_require__(8); + + +/***/ }, +/* 40 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var number = __webpack_require__(6); + var string = __webpack_require__(23); + var object = __webpack_require__(3); + var types = __webpack_require__(41); + + var DimensionError = __webpack_require__(42); + var IndexError = __webpack_require__(43); + + /** + * Calculate the size of a multi dimensional array. + * This function checks the size of the first entry, it does not validate + * whether all dimensions match. (use function `validate` for that) + * @param {Array} x + * @Return {Number[]} size + */ + exports.size = function (x) { + var s = []; + + while (Array.isArray(x)) { + s.push(x.length); + x = x[0]; + } + + return s; + }; + + /** + * Recursively validate whether each element in a multi dimensional array + * has a size corresponding to the provided size array. + * @param {Array} array Array to be validated + * @param {number[]} size Array with the size of each dimension + * @param {number} dim Current dimension + * @throws DimensionError + * @private + */ + function _validate(array, size, dim) { + var i; + var len = array.length; + + if (len != size[dim]) { + throw new DimensionError(len, size[dim]); + } + + if (dim < size.length - 1) { + // recursively validate each child array + var dimNext = dim + 1; + for (i = 0; i < len; i++) { + var child = array[i]; + if (!Array.isArray(child)) { + throw new DimensionError(size.length - 1, size.length, '<'); + } + _validate(array[i], size, dimNext); + } + } + else { + // last dimension. none of the childs may be an array + for (i = 0; i < len; i++) { + if (Array.isArray(array[i])) { + throw new DimensionError(size.length + 1, size.length, '>'); + } + } + } + } + + /** + * Validate whether each element in a multi dimensional array has + * a size corresponding to the provided size array. + * @param {Array} array Array to be validated + * @param {number[]} size Array with the size of each dimension + * @throws DimensionError + */ + exports.validate = function(array, size) { + var isScalar = (size.length == 0); + if (isScalar) { + // scalar + if (Array.isArray(array)) { + throw new DimensionError(array.length, 0); + } + } + else { + // array + _validate(array, size, 0); + } + }; + + /** + * Test whether index is an integer number with index >= 0 and index < length + * when length is provided + * @param {number} index Zero-based index + * @param {number} [length] Length of the array + */ + exports.validateIndex = function(index, length) { + if (!number.isNumber(index) || !number.isInteger(index)) { + throw new TypeError('Index must be an integer (value: ' + index + ')'); + } + if (index < 0 || (typeof length === 'number' && index >= length)) { + throw new IndexError(index, length); + } + }; + + // a constant used to specify an undefined defaultValue + exports.UNINITIALIZED = {}; + + /** + * Resize a multi dimensional array. The resized array is returned. + * @param {Array} array Array to be resized + * @param {Array.} size Array with the size of each dimension + * @param {*} [defaultValue=0] Value to be filled in in new entries, + * zero by default. To leave new entries undefined, + * specify array.UNINITIALIZED as defaultValue + * @return {Array} array The resized array + */ + exports.resize = function(array, size, defaultValue) { + // TODO: add support for scalars, having size=[] ? + + // check the type of the arguments + if (!Array.isArray(array) || !Array.isArray(size)) { + throw new TypeError('Array expected'); + } + if (size.length === 0) { + throw new Error('Resizing to scalar is not supported'); + } + + // check whether size contains positive integers + size.forEach(function (value) { + if (!number.isNumber(value) || !number.isInteger(value) || value < 0) { + throw new TypeError('Invalid size, must contain positive integers ' + + '(size: ' + string.format(size) + ')'); + } + }); + + // recursively resize the array + var _defaultValue = (defaultValue !== undefined) ? defaultValue : 0; + _resize(array, size, 0, _defaultValue); + + return array; + }; + + /** + * Recursively resize a multi dimensional array + * @param {Array} array Array to be resized + * @param {number[]} size Array with the size of each dimension + * @param {number} dim Current dimension + * @param {*} [defaultValue] Value to be filled in in new entries, + * undefined by default. + * @private + */ + function _resize (array, size, dim, defaultValue) { + var i; + var elem; + var oldLen = array.length; + var newLen = size[dim]; + var minLen = Math.min(oldLen, newLen); + + // apply new length + array.length = newLen; + + if (dim < size.length - 1) { + // non-last dimension + var dimNext = dim + 1; + + // resize existing child arrays + for (i = 0; i < minLen; i++) { + // resize child array + elem = array[i]; + if (!Array.isArray(elem)) { + elem = [elem]; // add a dimension + array[i] = elem; + } + _resize(elem, size, dimNext, defaultValue); + } + + // create new child arrays + for (i = minLen; i < newLen; i++) { + // get child array + elem = []; + array[i] = elem; + + // resize new child array + _resize(elem, size, dimNext, defaultValue); + } + } + else { + // last dimension + + // remove dimensions of existing values + for (i = 0; i < minLen; i++) { + while (Array.isArray(array[i])) { + array[i] = array[i][0]; + } + } + + if(defaultValue !== exports.UNINITIALIZED) { + // fill new elements with the default value + for (i = minLen; i < newLen; i++) { + array[i] = defaultValue; + } + } + } + } + + /** + * Squeeze a multi dimensional array + * @param {Array} array + * @param {Array} [size] + * @returns {Array} returns the array itself + */ + exports.squeeze = function(array, size) { + var s = size || exports.size(array); + + // squeeze outer dimensions + while (Array.isArray(array) && array.length === 1) { + array = array[0]; + s.shift(); + } + + // find the first dimension to be squeezed + var dims = s.length; + while (s[dims - 1] === 1) { + dims--; + } + + // squeeze inner dimensions + if (dims < s.length) { + array = _squeeze(array, dims, 0); + s.length = dims; + } + + return array; + }; + + /** + * Recursively squeeze a multi dimensional array + * @param {Array} array + * @param {number} dims Required number of dimensions + * @param {number} dim Current dimension + * @returns {Array | *} Returns the squeezed array + * @private + */ + function _squeeze (array, dims, dim) { + var i, ii; + + if (dim < dims) { + var next = dim + 1; + for (i = 0, ii = array.length; i < ii; i++) { + array[i] = _squeeze(array[i], dims, next); + } + } + else { + while (Array.isArray(array)) { + array = array[0]; + } + } + + return array; + } + + /** + * Unsqueeze a multi dimensional array: add dimensions when missing + * + * Paramter `size` will be mutated to match the new, unqueezed matrix size. + * + * @param {Array} array + * @param {number} dims Desired number of dimensions of the array + * @param {number} [outer] Number of outer dimensions to be added + * @param {Array} [size] Current size of array. + * @returns {Array} returns the array itself + * @private + */ + exports.unsqueeze = function(array, dims, outer, size) { + var s = size || exports.size(array); + + // unsqueeze outer dimensions + if (outer) { + for (var i = 0; i < outer; i++) { + array = [array]; + s.unshift(1); + } + } + + // unsqueeze inner dimensions + array = _unsqueeze(array, dims, 0); + while (s.length < dims) { + s.push(1); + } + + return array; + }; + + /** + * Recursively unsqueeze a multi dimensional array + * @param {Array} array + * @param {number} dims Required number of dimensions + * @param {number} dim Current dimension + * @returns {Array | *} Returns the squeezed array + * @private + */ + function _unsqueeze (array, dims, dim) { + var i, ii; + + if (Array.isArray(array)) { + var next = dim + 1; + for (i = 0, ii = array.length; i < ii; i++) { + array[i] = _unsqueeze(array[i], dims, next); + } + } + else { + for (var d = dim; d < dims; d++) { + array = [array]; + } + } + + return array; + } + /** + * Flatten a multi dimensional array, put all elements in a one dimensional + * array + * @param {Array} array A multi dimensional array + * @return {Array} The flattened array (1 dimensional) + */ + exports.flatten = function(array) { + if (!Array.isArray(array)) { + //if not an array, return as is + return array; + } + var flat = []; + + array.forEach(function callback(value) { + if (Array.isArray(value)) { + value.forEach(callback); //traverse through sub-arrays recursively + } + else { + flat.push(value); + } + }); + + return flat; + }; + + /** + * Test whether an object is an array + * @param {*} value + * @return {boolean} isArray + */ + exports.isArray = Array.isArray; + + +/***/ }, +/* 41 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Determine the type of a variable + * + * type(x) + * + * The following types are recognized: + * + * 'undefined' + * 'null' + * 'boolean' + * 'number' + * 'string' + * 'Array' + * 'Function' + * 'Date' + * 'RegExp' + * 'Object' + * + * @param {*} x + * @return {string} Returns the name of the type. Primitive types are lower case, + * non-primitive types are upper-camel-case. + * For example 'number', 'string', 'Array', 'Date'. + */ + exports.type = function(x) { + var type = typeof x; + + if (type === 'object') { + if (x === null) return 'null'; + if (x instanceof Boolean) return 'boolean'; + if (x instanceof Number) return 'number'; + if (x instanceof String) return 'string'; + if (Array.isArray(x)) return 'Array'; + if (x instanceof Date) return 'Date'; + if (x instanceof RegExp) return 'RegExp'; + + return 'Object'; + } + + if (type === 'function') return 'Function'; + + return type; + }; + + /** + * Test whether a value is a scalar + * @param x + * @return {boolean} Returns true when x is a scalar, returns false when + * x is a Matrix or Array. + */ + exports.isScalar = function (x) { + return !((x && x.isMatrix) || Array.isArray(x)); + }; + + +/***/ }, +/* 42 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Create a range error with the message: + * 'Dimension mismatch ( != )' + * @param {number | number[]} actual The actual size + * @param {number | number[]} expected The expected size + * @param {string} [relation='!='] Optional relation between actual + * and expected size: '!=', '<', etc. + * @extends RangeError + */ + function DimensionError(actual, expected, relation) { + if (!(this instanceof DimensionError)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.actual = actual; + this.expected = expected; + this.relation = relation; + + this.message = 'Dimension mismatch (' + + (Array.isArray(actual) ? ('[' + actual.join(', ') + ']') : actual) + + ' ' + (this.relation || '!=') + ' ' + + (Array.isArray(expected) ? ('[' + expected.join(', ') + ']') : expected) + + ')'; + + this.stack = (new Error()).stack; + } + + DimensionError.prototype = new RangeError(); + DimensionError.prototype.constructor = RangeError; + DimensionError.prototype.name = 'DimensionError'; + DimensionError.prototype.isDimensionError = true; + + module.exports = DimensionError; + + +/***/ }, +/* 43 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Create a range error with the message: + * 'Index out of range (index < min)' + * 'Index out of range (index < max)' + * + * @param {number} index The actual index + * @param {number} [min=0] Minimum index (included) + * @param {number} [max] Maximum index (excluded) + * @extends RangeError + */ + function IndexError(index, min, max) { + if (!(this instanceof IndexError)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.index = index; + if (arguments.length < 3) { + this.min = 0; + this.max = min; + } + else { + this.min = min; + this.max = max; + } + + if (this.min !== undefined && this.index < this.min) { + this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')'; + } + else if (this.max !== undefined && this.index >= this.max) { + this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')'; + } + else { + this.message = 'Index out of range (' + this.index + ')'; + } + + this.stack = (new Error()).stack; + } + + IndexError.prototype = new RangeError(); + IndexError.prototype.constructor = RangeError; + IndexError.prototype.name = 'IndexError'; + IndexError.prototype.isIndexError = true; + + module.exports = IndexError; + + +/***/ }, +/* 44 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Test whether value is a boolean + * @param {*} value + * @return {boolean} isBoolean + */ + exports.isBoolean = function(value) { + return typeof value == 'boolean'; + }; + + +/***/ }, +/* 45 */ +/***/ function(module, exports) { + + // function utils + + /* + * Memoize a given function by caching the computed result. + * The cache of a memoized function can be cleared by deleting the `cache` + * property of the function. + * + * @param {function} fn The function to be memoized. + * Must be a pure function. + * @param {function(args: Array)} [hasher] A custom hash builder. + * Is JSON.stringify by default. + * @return {function} Returns the memoized function + */ + exports.memoize = function(fn, hasher) { + return function memoize() { + if (typeof memoize.cache !== 'object') { + memoize.cache = {}; + } + + var args = []; + for (var i = 0; i < arguments.length; i++) { + args[i] = arguments[i]; + } + + var hash = hasher ? hasher(args) : JSON.stringify(args); + if (!(hash in memoize.cache)) { + return memoize.cache[hash] = fn.apply(fn, args); + } + return memoize.cache[hash]; + }; + }; + + +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + var DimensionError = __webpack_require__(42); + + var string = util.string; + var array = util.array; + var object = util.object; + var number = util.number; + + var isArray = Array.isArray; + var isNumber = number.isNumber; + var isInteger = number.isInteger; + var isString = string.isString; + + var validateIndex = array.validateIndex; + + function factory (type, config, load, typed) { + var Matrix = load(__webpack_require__(38)); // force loading Matrix (do not use via type.Matrix) + + /** + * Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type. + * @class DenseMatrix + */ + function DenseMatrix(data, datatype) { + if (!(this instanceof DenseMatrix)) + throw new SyntaxError('Constructor must be called with the new operator'); + if (datatype && !isString(datatype)) + throw new Error('Invalid datatype: ' + datatype); + + if (data && data.isMatrix === true) { + // check data is a DenseMatrix + if (data.type === 'DenseMatrix') { + // clone data & size + this._data = object.clone(data._data); + this._size = object.clone(data._size); + this._datatype = datatype || data._datatype; + } + else { + // build data from existing matrix + this._data = data.toArray(); + this._size = data.size(); + this._datatype = datatype || data._datatype; + } + } + else if (data && isArray(data.data) && isArray(data.size)) { + // initialize fields from JSON representation + this._data = data.data; + this._size = data.size; + this._datatype = datatype || data.datatype; + } + else if (isArray(data)) { + // replace nested Matrices with Arrays + this._data = preprocess(data); + // get the dimensions of the array + this._size = array.size(this._data); + // verify the dimensions of the array, TODO: compute size while processing array + array.validate(this._data, this._size); + // data type unknown + this._datatype = datatype; + } + else if (data) { + // unsupported type + throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); + } + else { + // nothing provided + this._data = []; + this._size = [0]; + this._datatype = datatype; + } + } + + DenseMatrix.prototype = new Matrix(); + + /** + * Attach type information + */ + DenseMatrix.prototype.type = 'DenseMatrix'; + DenseMatrix.prototype.isDenseMatrix = true; + + /** + * Get the storage format used by the matrix. + * + * Usage: + * var format = matrix.storage() // retrieve storage format + * + * @memberof DenseMatrix + * @return {string} The storage format. + */ + DenseMatrix.prototype.storage = function () { + return 'dense'; + }; + + /** + * Get the datatype of the data stored in the matrix. + * + * Usage: + * var format = matrix.datatype() // retrieve matrix datatype + * + * @memberof DenseMatrix + * @return {string} The datatype. + */ + DenseMatrix.prototype.datatype = function () { + return this._datatype; + }; + + /** + * Create a new DenseMatrix + * @memberof DenseMatrix + * @param {Array} data + * @param {string} [datatype] + */ + DenseMatrix.prototype.create = function (data, datatype) { + return new DenseMatrix(data, datatype); + }; + + /** + * Get a subset of the matrix, or replace a subset of the matrix. + * + * Usage: + * var subset = matrix.subset(index) // retrieve subset + * var value = matrix.subset(index, replacement) // replace subset + * + * @memberof DenseMatrix + * @param {Index} index + * @param {Array | DenseMatrix | *} [replacement] + * @param {*} [defaultValue=0] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be filled with zeros. + */ + DenseMatrix.prototype.subset = function (index, replacement, defaultValue) { + switch (arguments.length) { + case 1: + return _get(this, index); + + // intentional fall through + case 2: + case 3: + return _set(this, index, replacement, defaultValue); + + default: + throw new SyntaxError('Wrong number of arguments'); + } + }; + + /** + * Get a single element from the matrix. + * @memberof DenseMatrix + * @param {number[]} index Zero-based index + * @return {*} value + */ + DenseMatrix.prototype.get = function (index) { + if (!isArray(index)) + throw new TypeError('Array expected'); + if (index.length != this._size.length) + throw new DimensionError(index.length, this._size.length); + + // check index + for (var x = 0; x < index.length; x++) + validateIndex(index[x], this._size[x]); + + var data = this._data; + for (var i = 0, ii = index.length; i < ii; i++) { + var index_i = index[i]; + validateIndex(index_i, data.length); + data = data[index_i]; + } + + return data; + }; + + /** + * Replace a single element in the matrix. + * @memberof DenseMatrix + * @param {number[]} index Zero-based index + * @param {*} value + * @param {*} [defaultValue] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be left undefined. + * @return {DenseMatrix} self + */ + DenseMatrix.prototype.set = function (index, value, defaultValue) { + if (!isArray(index)) + throw new TypeError('Array expected'); + if (index.length < this._size.length) + throw new DimensionError(index.length, this._size.length, '<'); + + var i, ii, index_i; + + // enlarge matrix when needed + var size = index.map(function (i) { + return i + 1; + }); + _fit(this, size, defaultValue); + + // traverse over the dimensions + var data = this._data; + for (i = 0, ii = index.length - 1; i < ii; i++) { + index_i = index[i]; + validateIndex(index_i, data.length); + data = data[index_i]; + } + + // set new value + index_i = index[index.length - 1]; + validateIndex(index_i, data.length); + data[index_i] = value; + + return this; + }; + + /** + * Get a submatrix of this matrix + * @memberof DenseMatrix + * @param {DenseMatrix} matrix + * @param {Index} index Zero-based index + * @private + */ + function _get (matrix, index) { + if (!index || index.isIndex !== true) { + throw new TypeError('Invalid index'); + } + + var isScalar = index.isScalar(); + if (isScalar) { + // return a scalar + return matrix.get(index.min()); + } + else { + // validate dimensions + var size = index.size(); + if (size.length != matrix._size.length) { + throw new DimensionError(size.length, matrix._size.length); + } + + // validate if any of the ranges in the index is out of range + var min = index.min(); + var max = index.max(); + for (var i = 0, ii = matrix._size.length; i < ii; i++) { + validateIndex(min[i], matrix._size[i]); + validateIndex(max[i], matrix._size[i]); + } + + // retrieve submatrix + // TODO: more efficient when creating an empty matrix and setting _data and _size manually + return new DenseMatrix(_getSubmatrix(matrix._data, index, size.length, 0), matrix._datatype); + } + } + + /** + * Recursively get a submatrix of a multi dimensional matrix. + * Index is not checked for correct number or length of dimensions. + * @memberof DenseMatrix + * @param {Array} data + * @param {Index} index + * @param {number} dims Total number of dimensions + * @param {number} dim Current dimension + * @return {Array} submatrix + * @private + */ + function _getSubmatrix (data, index, dims, dim) { + var last = (dim == dims - 1); + var range = index.dimension(dim); + + if (last) { + return range.map(function (i) { + return data[i]; + }).valueOf(); + } + else { + return range.map(function (i) { + var child = data[i]; + return _getSubmatrix(child, index, dims, dim + 1); + }).valueOf(); + } + } + + /** + * Replace a submatrix in this matrix + * Indexes are zero-based. + * @memberof DenseMatrix + * @param {DenseMatrix} matrix + * @param {Index} index + * @param {DenseMatrix | Array | *} submatrix + * @param {*} defaultValue Default value, filled in on new entries when + * the matrix is resized. + * @return {DenseMatrix} matrix + * @private + */ + function _set (matrix, index, submatrix, defaultValue) { + if (!index || index.isIndex !== true) { + throw new TypeError('Invalid index'); + } + + // get index size and check whether the index contains a single value + var iSize = index.size(), + isScalar = index.isScalar(); + + // calculate the size of the submatrix, and convert it into an Array if needed + var sSize; + if (submatrix && submatrix.isMatrix === true) { + sSize = submatrix.size(); + submatrix = submatrix.valueOf(); + } + else { + sSize = array.size(submatrix); + } + + if (isScalar) { + // set a scalar + + // check whether submatrix is a scalar + if (sSize.length !== 0) { + throw new TypeError('Scalar expected'); + } + + matrix.set(index.min(), submatrix, defaultValue); + } + else { + // set a submatrix + + // validate dimensions + if (iSize.length < matrix._size.length) { + throw new DimensionError(iSize.length, matrix._size.length, '<'); + } + + if (sSize.length < iSize.length) { + // calculate number of missing outer dimensions + var i = 0; + var outer = 0; + while (iSize[i] === 1 && sSize[i] === 1) { + i++; + } + while (iSize[i] === 1) { + outer++; + i++; + } + + // unsqueeze both outer and inner dimensions + submatrix = array.unsqueeze(submatrix, iSize.length, outer, sSize); + } + + // check whether the size of the submatrix matches the index size + if (!object.deepEqual(iSize, sSize)) { + throw new DimensionError(iSize, sSize, '>'); + } + + // enlarge matrix when needed + var size = index.max().map(function (i) { + return i + 1; + }); + _fit(matrix, size, defaultValue); + + // insert the sub matrix + var dims = iSize.length, + dim = 0; + _setSubmatrix (matrix._data, index, submatrix, dims, dim); + } + + return matrix; + } + + /** + * Replace a submatrix of a multi dimensional matrix. + * @memberof DenseMatrix + * @param {Array} data + * @param {Index} index + * @param {Array} submatrix + * @param {number} dims Total number of dimensions + * @param {number} dim + * @private + */ + function _setSubmatrix (data, index, submatrix, dims, dim) { + var last = (dim == dims - 1), + range = index.dimension(dim); + + if (last) { + range.forEach(function (dataIndex, subIndex) { + validateIndex(dataIndex); + data[dataIndex] = submatrix[subIndex[0]]; + }); + } + else { + range.forEach(function (dataIndex, subIndex) { + validateIndex(dataIndex); + _setSubmatrix(data[dataIndex], index, submatrix[subIndex[0]], dims, dim + 1); + }); + } + } + + /** + * Resize the matrix to the given size. Returns a copy of the matrix when + * `copy=true`, otherwise return the matrix itself (resize in place). + * + * @memberof DenseMatrix + * @param {number[]} size The new size the matrix should have. + * @param {*} [defaultValue=0] Default value, filled in on new entries. + * If not provided, the matrix elements will + * be filled with zeros. + * @param {boolean} [copy] Return a resized copy of the matrix + * + * @return {Matrix} The resized matrix + */ + DenseMatrix.prototype.resize = function (size, defaultValue, copy) { + // validate arguments + if (!isArray(size)) + throw new TypeError('Array expected'); + + // matrix to resize + var m = copy ? this.clone() : this; + // resize matrix + return _resize(m, size, defaultValue); + }; + + var _resize = function (matrix, size, defaultValue) { + // check size + if (size.length === 0) { + // first value in matrix + var v = matrix._data; + // go deep + while (isArray(v)) { + v = v[0]; + } + return v; + } + // resize matrix + matrix._size = size.slice(0); // copy the array + matrix._data = array.resize(matrix._data, matrix._size, defaultValue); + // return matrix + return matrix; + }; + + /** + * Enlarge the matrix when it is smaller than given size. + * If the matrix is larger or equal sized, nothing is done. + * @memberof DenseMatrix + * @param {DenseMatrix} matrix The matrix to be resized + * @param {number[]} size + * @param {*} defaultValue Default value, filled in on new entries. + * @private + */ + function _fit(matrix, size, defaultValue) { + var newSize = matrix._size.slice(0), // copy the array + changed = false; + + // add dimensions when needed + while (newSize.length < size.length) { + newSize.push(0); + changed = true; + } + + // enlarge size when needed + for (var i = 0, ii = size.length; i < ii; i++) { + if (size[i] > newSize[i]) { + newSize[i] = size[i]; + changed = true; + } + } + + if (changed) { + // resize only when size is changed + _resize(matrix, newSize, defaultValue); + } + } + + /** + * Create a clone of the matrix + * @memberof DenseMatrix + * @return {DenseMatrix} clone + */ + DenseMatrix.prototype.clone = function () { + var m = new DenseMatrix({ + data: object.clone(this._data), + size: object.clone(this._size), + datatype: this._datatype + }); + return m; + }; + + /** + * Retrieve the size of the matrix. + * @memberof DenseMatrix + * @returns {number[]} size + */ + DenseMatrix.prototype.size = function() { + return this._size.slice(0); // return a clone of _size + }; + + /** + * Create a new matrix with the results of the callback function executed on + * each entry of the matrix. + * @memberof DenseMatrix + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * + * @return {DenseMatrix} matrix + */ + DenseMatrix.prototype.map = function (callback) { + // matrix instance + var me = this; + var recurse = function (value, index) { + if (isArray(value)) { + return value.map(function (child, i) { + return recurse(child, index.concat(i)); + }); + } + else { + return callback(value, index, me); + } + }; + // return dense format + return new DenseMatrix({ + data: recurse(this._data, []), + size: object.clone(this._size), + datatype: this._datatype + }); + }; + + /** + * Execute a callback function on each entry of the matrix. + * @memberof DenseMatrix + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + */ + DenseMatrix.prototype.forEach = function (callback) { + // matrix instance + var me = this; + var recurse = function (value, index) { + if (isArray(value)) { + value.forEach(function (child, i) { + recurse(child, index.concat(i)); + }); + } + else { + callback(value, index, me); + } + }; + recurse(this._data, []); + }; + + /** + * Create an Array with a copy of the data of the DenseMatrix + * @memberof DenseMatrix + * @returns {Array} array + */ + DenseMatrix.prototype.toArray = function () { + return object.clone(this._data); + }; + + /** + * Get the primitive value of the DenseMatrix: a multidimensional array + * @memberof DenseMatrix + * @returns {Array} array + */ + DenseMatrix.prototype.valueOf = function () { + return this._data; + }; + + /** + * Get a string representation of the matrix, with optional formatting options. + * @memberof DenseMatrix + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @returns {string} str + */ + DenseMatrix.prototype.format = function (options) { + return string.format(this._data, options); + }; + + /** + * Get a string representation of the matrix + * @memberof DenseMatrix + * @returns {string} str + */ + DenseMatrix.prototype.toString = function () { + return string.format(this._data); + }; + + /** + * Get a JSON representation of the matrix + * @memberof DenseMatrix + * @returns {Object} + */ + DenseMatrix.prototype.toJSON = function () { + return { + mathjs: 'DenseMatrix', + data: this._data, + size: this._size, + datatype: this._datatype + }; + }; + + /** + * Get the kth Matrix diagonal. + * + * @memberof DenseMatrix + * @param {number | BigNumber} [k=0] The kth diagonal where the vector will retrieved. + * + * @returns {Array} The array vector with the diagonal values. + */ + DenseMatrix.prototype.diagonal = function(k) { + // validate k if any + if (k) { + // convert BigNumber to a number + if (k.isBigNumber === true) + k = k.toNumber(); + // is must be an integer + if (!isNumber(k) || !isInteger(k)) { + throw new TypeError ('The parameter k must be an integer number'); + } + } + else { + // default value + k = 0; + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // rows & columns + var rows = this._size[0]; + var columns = this._size[1]; + + // number diagonal values + var n = Math.min(rows - kSub, columns - kSuper); + + // x is a matrix get diagonal from matrix + var data = []; + + // loop rows + for (var i = 0; i < n; i++) { + data[i] = this._data[i + kSub][i + kSuper]; + } + + // create DenseMatrix + return new DenseMatrix({ + data: data, + size: [n], + datatype: this._datatype + }); + }; + + /** + * Create a diagonal matrix. + * + * @memberof DenseMatrix + * @param {Array} size The matrix size. + * @param {number | Array} value The values for the diagonal. + * @param {number | BigNumber} [k=0] The kth diagonal where the vector will be filled in. + * @param {number} [defaultValue] The default value for non-diagonal + * + * @returns {DenseMatrix} + */ + DenseMatrix.diagonal = function (size, value, k, defaultValue, datatype) { + if (!isArray(size)) + throw new TypeError('Array expected, size parameter'); + if (size.length !== 2) + throw new Error('Only two dimensions matrix are supported'); + + // map size & validate + size = size.map(function (s) { + // check it is a big number + if (s && s.isBigNumber === true) { + // convert it + s = s.toNumber(); + } + // validate arguments + if (!isNumber(s) || !isInteger(s) || s < 1) { + throw new Error('Size values must be positive integers'); + } + return s; + }); + + // validate k if any + if (k) { + // convert BigNumber to a number + if (k && k.isBigNumber === true) + k = k.toNumber(); + // is must be an integer + if (!isNumber(k) || !isInteger(k)) { + throw new TypeError ('The parameter k must be an integer number'); + } + } + else { + // default value + k = 0; + } + + if (defaultValue && isString(datatype)) { + // convert defaultValue to the same datatype + defaultValue = typed.convert(defaultValue, datatype); + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // rows and columns + var rows = size[0]; + var columns = size[1]; + + // number of non-zero items + var n = Math.min(rows - kSub, columns - kSuper); + + // value extraction function + var _value; + + // check value + if (isArray(value)) { + // validate array + if (value.length !== n) { + // number of values in array must be n + throw new Error('Invalid value array length'); + } + // define function + _value = function (i) { + // return value @ i + return value[i]; + }; + } + else if (value && value.isMatrix === true) { + // matrix size + var ms = value.size(); + // validate matrix + if (ms.length !== 1 || ms[0] !== n) { + // number of values in array must be n + throw new Error('Invalid matrix length'); + } + // define function + _value = function (i) { + // return value @ i + return value.get([i]); + }; + } + else { + // define function + _value = function () { + // return value + return value; + }; + } + + // discover default value if needed + if (!defaultValue) { + // check first value in array + defaultValue = (_value(0) && _value(0).isBigNumber === true) ? new type.BigNumber(0) : 0; + } + + // empty array + var data = []; + + // check we need to resize array + if (size.length > 0) { + // resize array + data = array.resize(data, size, defaultValue); + // fill diagonal + for (var d = 0; d < n; d++) { + data[d + kSub][d + kSuper] = _value(d); + } + } + + // create DenseMatrix + return new DenseMatrix({ + data: data, + size: [rows, columns] + }); + }; + + /** + * Generate a matrix from a JSON object + * @memberof DenseMatrix + * @param {Object} json An object structured like + * `{"mathjs": "DenseMatrix", data: [], size: []}`, + * where mathjs is optional + * @returns {DenseMatrix} + */ + DenseMatrix.fromJSON = function (json) { + return new DenseMatrix(json); + }; + + /** + * Swap rows i and j in Matrix. + * + * @memberof DenseMatrix + * @param {number} i Matrix row index 1 + * @param {number} j Matrix row index 2 + * + * @return {Matrix} The matrix reference + */ + DenseMatrix.prototype.swapRows = function (i, j) { + // check index + if (!isNumber(i) || !isInteger(i) || !isNumber(j) || !isInteger(j)) { + throw new Error('Row index must be positive integers'); + } + // check dimensions + if (this._size.length !== 2) { + throw new Error('Only two dimensional matrix is supported'); + } + // validate index + validateIndex(i, this._size[0]); + validateIndex(j, this._size[0]); + + // swap rows + DenseMatrix._swapRows(i, j, this._data); + // return current instance + return this; + }; + + /** + * Swap rows i and j in Dense Matrix data structure. + * + * @param {number} i Matrix row index 1 + * @param {number} j Matrix row index 2 + */ + DenseMatrix._swapRows = function (i, j, data) { + // swap values i <-> j + var vi = data[i]; + data[i] = data[j]; + data[j] = vi; + }; + + /** + * Preprocess data, which can be an Array or DenseMatrix with nested Arrays and + * Matrices. Replaces all nested Matrices with Arrays + * @memberof DenseMatrix + * @param {Array} data + * @return {Array} data + */ + function preprocess(data) { + for (var i = 0, ii = data.length; i < ii; i++) { + var elem = data[i]; + if (isArray(elem)) { + data[i] = preprocess(elem); + } + else if (elem && elem.isMatrix === true) { + data[i] = preprocess(elem.valueOf()); + } + } + + return data; + } + + // register this type in the base class Matrix + type.Matrix._storage.dense = DenseMatrix; + type.Matrix._storage['default'] = DenseMatrix; + + // exports + return DenseMatrix; + } + + exports.name = 'DenseMatrix'; + exports.path = 'type'; + exports.factory = factory; + exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + var DimensionError = __webpack_require__(42); + + var array = util.array; + var object = util.object; + var string = util.string; + var number = util.number; + + var isArray = Array.isArray; + var isNumber = number.isNumber; + var isInteger = number.isInteger; + var isString = string.isString; + + var validateIndex = array.validateIndex; + + function factory (type, config, load, typed) { + var Matrix = load(__webpack_require__(38)); // force loading Matrix (do not use via type.Matrix) + var equalScalar = load(__webpack_require__(48)); + + /** + * Sparse Matrix implementation. This type implements a Compressed Column Storage format + * for sparse matrices. + * @class SparseMatrix + */ + function SparseMatrix(data, datatype) { + if (!(this instanceof SparseMatrix)) + throw new SyntaxError('Constructor must be called with the new operator'); + if (datatype && !isString(datatype)) + throw new Error('Invalid datatype: ' + datatype); + + if (data && data.isMatrix === true) { + // create from matrix + _createFromMatrix(this, data, datatype); + } + else if (data && isArray(data.index) && isArray(data.ptr) && isArray(data.size)) { + // initialize fields + this._values = data.values; + this._index = data.index; + this._ptr = data.ptr; + this._size = data.size; + this._datatype = datatype || data.datatype; + } + else if (isArray(data)) { + // create from array + _createFromArray(this, data, datatype); + } + else if (data) { + // unsupported type + throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); + } + else { + // nothing provided + this._values = []; + this._index = []; + this._ptr = [0]; + this._size = [0, 0]; + this._datatype = datatype; + } + } + + var _createFromMatrix = function (matrix, source, datatype) { + // check matrix type + if (source.type === 'SparseMatrix') { + // clone arrays + matrix._values = source._values ? object.clone(source._values) : undefined; + matrix._index = object.clone(source._index); + matrix._ptr = object.clone(source._ptr); + matrix._size = object.clone(source._size); + matrix._datatype = datatype || source._datatype; + } + else { + // build from matrix data + _createFromArray(matrix, source.valueOf(), datatype || source._datatype); + } + }; + + var _createFromArray = function (matrix, data, datatype) { + // initialize fields + matrix._values = []; + matrix._index = []; + matrix._ptr = []; + matrix._datatype = datatype; + // discover rows & columns, do not use math.size() to avoid looping array twice + var rows = data.length; + var columns = 0; + + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + if (isString(datatype)) { + // find signature that matches (datatype, datatype) + eq = typed.find(equalScalar, [datatype, datatype]) || equalScalar; + // convert 0 to the same datatype + zero = typed.convert(0, datatype); + } + + // check we have rows (empty array) + if (rows > 0) { + // column index + var j = 0; + do { + // store pointer to values index + matrix._ptr.push(matrix._index.length); + // loop rows + for (var i = 0; i < rows; i++) { + // current row + var row = data[i]; + // check row is an array + if (isArray(row)) { + // update columns if needed (only on first column) + if (j === 0 && columns < row.length) + columns = row.length; + // check row has column + if (j < row.length) { + // value + var v = row[j]; + // check value != 0 + if (!eq(v, zero)) { + // store value + matrix._values.push(v); + // index + matrix._index.push(i); + } + } + } + else { + // update columns if needed (only on first column) + if (j === 0 && columns < 1) + columns = 1; + // check value != 0 (row is a scalar) + if (!eq(row, zero)) { + // store value + matrix._values.push(row); + // index + matrix._index.push(i); + } + } + } + // increment index + j++; + } + while (j < columns); + } + // store number of values in ptr + matrix._ptr.push(matrix._index.length); + // size + matrix._size = [rows, columns]; + }; + + SparseMatrix.prototype = new Matrix(); + + /** + * Attach type information + */ + SparseMatrix.prototype.type = 'SparseMatrix'; + SparseMatrix.prototype.isSparseMatrix = true; + + /** + * Get the storage format used by the matrix. + * + * Usage: + * var format = matrix.storage() // retrieve storage format + * + * @memberof SparseMatrix + * @return {string} The storage format. + */ + SparseMatrix.prototype.storage = function () { + return 'sparse'; + }; + + /** + * Get the datatype of the data stored in the matrix. + * + * Usage: + * var format = matrix.datatype() // retrieve matrix datatype + * + * @memberof SparseMatrix + * @return {string} The datatype. + */ + SparseMatrix.prototype.datatype = function () { + return this._datatype; + }; + + /** + * Create a new SparseMatrix + * @memberof SparseMatrix + * @param {Array} data + * @param {string} [datatype] + */ + SparseMatrix.prototype.create = function (data, datatype) { + return new SparseMatrix(data, datatype); + }; + + /** + * Get the matrix density. + * + * Usage: + * var density = matrix.density() // retrieve matrix density + * + * @memberof SparseMatrix + * @return {number} The matrix density. + */ + SparseMatrix.prototype.density = function () { + // rows & columns + var rows = this._size[0]; + var columns = this._size[1]; + // calculate density + return rows !== 0 && columns !== 0 ? (this._index.length / (rows * columns)) : 0; + }; + + /** + * Get a subset of the matrix, or replace a subset of the matrix. + * + * Usage: + * var subset = matrix.subset(index) // retrieve subset + * var value = matrix.subset(index, replacement) // replace subset + * + * @memberof SparseMatrix + * @param {Index} index + * @param {Array | Maytrix | *} [replacement] + * @param {*} [defaultValue=0] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be filled with zeros. + */ + SparseMatrix.prototype.subset = function (index, replacement, defaultValue) { // check it is a pattern matrix + if (!this._values) + throw new Error('Cannot invoke subset on a Pattern only matrix'); + + // check arguments + switch (arguments.length) { + case 1: + return _getsubset(this, index); + + // intentional fall through + case 2: + case 3: + return _setsubset(this, index, replacement, defaultValue); + + default: + throw new SyntaxError('Wrong number of arguments'); + } + }; + + var _getsubset = function (matrix, idx) { + // check idx + if (!idx || idx.isIndex !== true) { + throw new TypeError('Invalid index'); + } + + var isScalar = idx.isScalar(); + if (isScalar) { + // return a scalar + return matrix.get(idx.min()); + } + // validate dimensions + var size = idx.size(); + if (size.length != matrix._size.length) { + throw new DimensionError(size.length, matrix._size.length); + } + + // vars + var i, ii, k, kk; + + // validate if any of the ranges in the index is out of range + var min = idx.min(); + var max = idx.max(); + for (i = 0, ii = matrix._size.length; i < ii; i++) { + validateIndex(min[i], matrix._size[i]); + validateIndex(max[i], matrix._size[i]); + } + + // matrix arrays + var mvalues = matrix._values; + var mindex = matrix._index; + var mptr = matrix._ptr; + + // rows & columns dimensions for result matrix + var rows = idx.dimension(0); + var columns = idx.dimension(1); + + // workspace & permutation vector + var w = []; + var pv = []; + + // loop rows in resulting matrix + rows.forEach(function (i, r) { + // update permutation vector + pv[i] = r[0]; + // mark i in workspace + w[i] = true; + }); + + // result matrix arrays + var values = mvalues ? [] : undefined; + var index = []; + var ptr = []; + + // loop columns in result matrix + columns.forEach(function (j) { + // update ptr + ptr.push(index.length); + // loop values in column j + for (k = mptr[j], kk = mptr[j + 1]; k < kk; k++) { + // row + i = mindex[k]; + // check row is in result matrix + if (w[i] === true) { + // push index + index.push(pv[i]); + // check we need to process values + if (values) + values.push(mvalues[k]); + } + } + }); + // update ptr + ptr.push(index.length); + + // return matrix + return new SparseMatrix({ + values: values, + index: index, + ptr: ptr, + size: size, + datatype: matrix._datatype + }); + }; + + var _setsubset = function (matrix, index, submatrix, defaultValue) { + // check index + if (!index || index.isIndex !== true) { + throw new TypeError('Invalid index'); + } + + // get index size and check whether the index contains a single value + var iSize = index.size(), + isScalar = index.isScalar(); + + // calculate the size of the submatrix, and convert it into an Array if needed + var sSize; + if (submatrix && submatrix.isMatrix === true) { + // submatrix size + sSize = submatrix.size(); + // use array representation + submatrix = submatrix.toArray(); + } + else { + // get submatrix size (array, scalar) + sSize = array.size(submatrix); + } + + // check index is a scalar + if (isScalar) { + // verify submatrix is a scalar + if (sSize.length !== 0) { + throw new TypeError('Scalar expected'); + } + // set value + matrix.set(index.min(), submatrix, defaultValue); + } + else { + // validate dimensions, index size must be one or two dimensions + if (iSize.length !== 1 && iSize.length !== 2) { + throw new DimensionError(iSize.length, matrix._size.length, '<'); + } + + // check submatrix and index have the same dimensions + if (sSize.length < iSize.length) { + // calculate number of missing outer dimensions + var i = 0; + var outer = 0; + while (iSize[i] === 1 && sSize[i] === 1) { + i++; + } + while (iSize[i] === 1) { + outer++; + i++; + } + // unsqueeze both outer and inner dimensions + submatrix = array.unsqueeze(submatrix, iSize.length, outer, sSize); + } + + // check whether the size of the submatrix matches the index size + if (!object.deepEqual(iSize, sSize)) { + throw new DimensionError(iSize, sSize, '>'); + } + + // offsets + var x0 = index.min()[0]; + var y0 = index.min()[1]; + + // submatrix rows and columns + var m = sSize[0]; + var n = sSize[1]; + + // loop submatrix + for (var x = 0; x < m; x++) { + // loop columns + for (var y = 0; y < n; y++) { + // value at i, j + var v = submatrix[x][y]; + // invoke set (zero value will remove entry from matrix) + matrix.set([x + x0, y + y0], v, defaultValue); + } + } + } + return matrix; + }; + + /** + * Get a single element from the matrix. + * @memberof SparseMatrix + * @param {number[]} index Zero-based index + * @return {*} value + */ + SparseMatrix.prototype.get = function (index) { + if (!isArray(index)) + throw new TypeError('Array expected'); + if (index.length != this._size.length) + throw new DimensionError(index.length, this._size.length); + + // check it is a pattern matrix + if (!this._values) + throw new Error('Cannot invoke get on a Pattern only matrix'); + + // row and column + var i = index[0]; + var j = index[1]; + + // check i, j are valid + validateIndex(i, this._size[0]); + validateIndex(j, this._size[1]); + + // find value index + var k = _getValueIndex(i, this._ptr[j], this._ptr[j + 1], this._index); + // check k is prior to next column k and it is in the correct row + if (k < this._ptr[j + 1] && this._index[k] === i) + return this._values[k]; + + return 0; + }; + + /** + * Replace a single element in the matrix. + * @memberof SparseMatrix + * @param {number[]} index Zero-based index + * @param {*} value + * @param {*} [defaultValue] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be set to zero. + * @return {SparseMatrix} self + */ + SparseMatrix.prototype.set = function (index, v, defaultValue) { + if (!isArray(index)) + throw new TypeError('Array expected'); + if (index.length != this._size.length) + throw new DimensionError(index.length, this._size.length); + + // check it is a pattern matrix + if (!this._values) + throw new Error('Cannot invoke set on a Pattern only matrix'); + + // row and column + var i = index[0]; + var j = index[1]; + + // rows & columns + var rows = this._size[0]; + var columns = this._size[1]; + + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + if (isString(this._datatype)) { + // find signature that matches (datatype, datatype) + eq = typed.find(equalScalar, [this._datatype, this._datatype]) || equalScalar; + // convert 0 to the same datatype + zero = typed.convert(0, this._datatype); + } + + // check we need to resize matrix + if (i > rows - 1 || j > columns - 1) { + // resize matrix + _resize(this, Math.max(i + 1, rows), Math.max(j + 1, columns), defaultValue); + // update rows & columns + rows = this._size[0]; + columns = this._size[1]; + } + + // check i, j are valid + validateIndex(i, rows); + validateIndex(j, columns); + + // find value index + var k = _getValueIndex(i, this._ptr[j], this._ptr[j + 1], this._index); + // check k is prior to next column k and it is in the correct row + if (k < this._ptr[j + 1] && this._index[k] === i) { + // check value != 0 + if (!eq(v, zero)) { + // update value + this._values[k] = v; + } + else { + // remove value from matrix + _remove(k, j, this._values, this._index, this._ptr); + } + } + else { + // insert value @ (i, j) + _insert(k, i, j, v, this._values, this._index, this._ptr); + } + + return this; + }; + + var _getValueIndex = function(i, top, bottom, index) { + // check row is on the bottom side + if (bottom - top === 0) + return bottom; + // loop rows [top, bottom[ + for (var r = top; r < bottom; r++) { + // check we found value index + if (index[r] === i) + return r; + } + // we did not find row + return top; + }; + + var _remove = function (k, j, values, index, ptr) { + // remove value @ k + values.splice(k, 1); + index.splice(k, 1); + // update pointers + for (var x = j + 1; x < ptr.length; x++) + ptr[x]--; + }; + + var _insert = function (k, i, j, v, values, index, ptr) { + // insert value + values.splice(k, 0, v); + // update row for k + index.splice(k, 0, i); + // update column pointers + for (var x = j + 1; x < ptr.length; x++) + ptr[x]++; + }; + + /** + * Resize the matrix to the given size. Returns a copy of the matrix when + * `copy=true`, otherwise return the matrix itself (resize in place). + * + * @memberof SparseMatrix + * @param {number[]} size The new size the matrix should have. + * @param {*} [defaultValue=0] Default value, filled in on new entries. + * If not provided, the matrix elements will + * be filled with zeros. + * @param {boolean} [copy] Return a resized copy of the matrix + * + * @return {Matrix} The resized matrix + */ + SparseMatrix.prototype.resize = function (size, defaultValue, copy) { + // validate arguments + if (!isArray(size)) + throw new TypeError('Array expected'); + if (size.length !== 2) + throw new Error('Only two dimensions matrix are supported'); + + // check sizes + size.forEach(function (value) { + if (!number.isNumber(value) || !number.isInteger(value) || value < 0) { + throw new TypeError('Invalid size, must contain positive integers ' + + '(size: ' + string.format(size) + ')'); + } + }); + + // matrix to resize + var m = copy ? this.clone() : this; + // resize matrix + return _resize(m, size[0], size[1], defaultValue); + }; + + var _resize = function (matrix, rows, columns, defaultValue) { + // value to insert at the time of growing matrix + var value = defaultValue || 0; + + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + if (isString(matrix._datatype)) { + // find signature that matches (datatype, datatype) + eq = typed.find(equalScalar, [matrix._datatype, matrix._datatype]) || equalScalar; + // convert 0 to the same datatype + zero = typed.convert(0, matrix._datatype); + // convert value to the same datatype + value = typed.convert(value, matrix._datatype); + } + + // should we insert the value? + var ins = !eq(value, zero); + + // old columns and rows + var r = matrix._size[0]; + var c = matrix._size[1]; + + var i, j, k; + + // check we need to increase columns + if (columns > c) { + // loop new columns + for (j = c; j < columns; j++) { + // update matrix._ptr for current column + matrix._ptr[j] = matrix._values.length; + // check we need to insert matrix._values + if (ins) { + // loop rows + for (i = 0; i < r; i++) { + // add new matrix._values + matrix._values.push(value); + // update matrix._index + matrix._index.push(i); + } + } + } + // store number of matrix._values in matrix._ptr + matrix._ptr[columns] = matrix._values.length; + } + else if (columns < c) { + // truncate matrix._ptr + matrix._ptr.splice(columns + 1, c - columns); + // truncate matrix._values and matrix._index + matrix._values.splice(matrix._ptr[columns], matrix._values.length); + matrix._index.splice(matrix._ptr[columns], matrix._index.length); + } + // update columns + c = columns; + + // check we need to increase rows + if (rows > r) { + // check we have to insert values + if (ins) { + // inserts + var n = 0; + // loop columns + for (j = 0; j < c; j++) { + // update matrix._ptr for current column + matrix._ptr[j] = matrix._ptr[j] + n; + // where to insert matrix._values + k = matrix._ptr[j + 1] + n; + // pointer + var p = 0; + // loop new rows, initialize pointer + for (i = r; i < rows; i++, p++) { + // add value + matrix._values.splice(k + p, 0, value); + // update matrix._index + matrix._index.splice(k + p, 0, i); + // increment inserts + n++; + } + } + // store number of matrix._values in matrix._ptr + matrix._ptr[c] = matrix._values.length; + } + } + else if (rows < r) { + // deletes + var d = 0; + // loop columns + for (j = 0; j < c; j++) { + // update matrix._ptr for current column + matrix._ptr[j] = matrix._ptr[j] - d; + // where matrix._values start for next column + var k0 = matrix._ptr[j]; + var k1 = matrix._ptr[j + 1] - d; + // loop matrix._index + for (k = k0; k < k1; k++) { + // row + i = matrix._index[k]; + // check we need to delete value and matrix._index + if (i > rows - 1) { + // remove value + matrix._values.splice(k, 1); + // remove item from matrix._index + matrix._index.splice(k, 1); + // increase deletes + d++; + } + } + } + // update matrix._ptr for current column + matrix._ptr[j] = matrix._values.length; + } + // update matrix._size + matrix._size[0] = rows; + matrix._size[1] = columns; + // return matrix + return matrix; + }; + + /** + * Create a clone of the matrix + * @memberof SparseMatrix + * @return {SparseMatrix} clone + */ + SparseMatrix.prototype.clone = function () { + var m = new SparseMatrix({ + values: this._values ? object.clone(this._values) : undefined, + index: object.clone(this._index), + ptr: object.clone(this._ptr), + size: object.clone(this._size), + datatype: this._datatype + }); + return m; + }; + + /** + * Retrieve the size of the matrix. + * @memberof SparseMatrix + * @returns {number[]} size + */ + SparseMatrix.prototype.size = function() { + return this._size.slice(0); // copy the Array + }; + + /** + * Create a new matrix with the results of the callback function executed on + * each entry of the matrix. + * @memberof SparseMatrix + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. + * + * @return {SparseMatrix} matrix + */ + SparseMatrix.prototype.map = function (callback, skipZeros) { + // check it is a pattern matrix + if (!this._values) + throw new Error('Cannot invoke map on a Pattern only matrix'); + // matrix instance + var me = this; + // rows and columns + var rows = this._size[0]; + var columns = this._size[1]; + // invoke callback + var invoke = function (v, i, j) { + // invoke callback + return callback(v, [i, j], me); + }; + // invoke _map + return _map(this, 0, rows - 1, 0, columns - 1, invoke, skipZeros); + }; + + /** + * Create a new matrix with the results of the callback function executed on the interval + * [minRow..maxRow, minColumn..maxColumn]. + */ + var _map = function (matrix, minRow, maxRow, minColumn, maxColumn, callback, skipZeros) { + // result arrays + var values = []; + var index = []; + var ptr = []; + + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + if (isString(matrix._datatype)) { + // find signature that matches (datatype, datatype) + eq = typed.find(equalScalar, [matrix._datatype, matrix._datatype]) || equalScalar; + // convert 0 to the same datatype + zero = typed.convert(0, matrix._datatype); + } + + // invoke callback + var invoke = function (v, x, y) { + // invoke callback + v = callback(v, x, y); + // check value != 0 + if (!eq(v, zero)) { + // store value + values.push(v); + // index + index.push(x); + } + }; + // loop columns + for (var j = minColumn; j <= maxColumn; j++) { + // store pointer to values index + ptr.push(values.length); + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = matrix._ptr[j]; + var k1 = matrix._ptr[j + 1]; + // row pointer + var p = minRow; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + var i = matrix._index[k]; + // check i is in range + if (i >= minRow && i <= maxRow) { + // zero values + if (!skipZeros) { + for (var x = p; x < i; x++) + invoke(0, x - minRow, j - minColumn); + } + // value @ k + invoke(matrix._values[k], i - minRow, j - minColumn); + } + // update pointer + p = i + 1; + } + // zero values + if (!skipZeros) { + for (var y = p; y <= maxRow; y++) + invoke(0, y - minRow, j - minColumn); + } + } + // store number of values in ptr + ptr.push(values.length); + // return sparse matrix + return new SparseMatrix({ + values: values, + index: index, + ptr: ptr, + size: [maxRow - minRow + 1, maxColumn - minColumn + 1] + }); + }; + + /** + * Execute a callback function on each entry of the matrix. + * @memberof SparseMatrix + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * @param {boolean} [skipZeros] Invoke callback function for non-zero values only. + */ + SparseMatrix.prototype.forEach = function (callback, skipZeros) { + // check it is a pattern matrix + if (!this._values) + throw new Error('Cannot invoke forEach on a Pattern only matrix'); + // matrix instance + var me = this; + // rows and columns + var rows = this._size[0]; + var columns = this._size[1]; + // loop columns + for (var j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = this._ptr[j]; + var k1 = this._ptr[j + 1]; + // column pointer + var p = 0; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + var i = this._index[k]; + // check we need to process zeros + if (!skipZeros) { + // zero values + for (var x = p; x < i; x++) + callback(0, [x, j], me); + } + // value @ k + callback(this._values[k], [i, j], me); + // update pointer + p = i + 1; + } + // check we need to process zeros + if (!skipZeros) { + // zero values + for (var y = p; y < rows; y++) + callback(0, [y, j], me); + } + } + }; + + /** + * Create an Array with a copy of the data of the SparseMatrix + * @memberof SparseMatrix + * @returns {Array} array + */ + SparseMatrix.prototype.toArray = function () { + return _toArray(this._values, this._index, this._ptr, this._size, true); + }; + + /** + * Get the primitive value of the SparseMatrix: a two dimensions array + * @memberof SparseMatrix + * @returns {Array} array + */ + SparseMatrix.prototype.valueOf = function () { + return _toArray(this._values, this._index, this._ptr, this._size, false); + }; + + var _toArray = function (values, index, ptr, size, copy) { + // rows and columns + var rows = size[0]; + var columns = size[1]; + // result + var a = []; + // vars + var i, j; + // initialize array + for (i = 0; i < rows; i++) { + a[i] = []; + for (j = 0; j < columns; j++) + a[i][j] = 0; + } + + // loop columns + for (j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + i = index[k]; + // set value (use one for pattern matrix) + a[i][j] = values ? (copy ? object.clone(values[k]) : values[k]) : 1; + } + } + return a; + }; + + /** + * Get a string representation of the matrix, with optional formatting options. + * @memberof SparseMatrix + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @returns {string} str + */ + SparseMatrix.prototype.format = function (options) { + // rows and columns + var rows = this._size[0]; + var columns = this._size[1]; + // density + var density = this.density(); + // rows & columns + var str = 'Sparse Matrix [' + string.format(rows, options) + ' x ' + string.format(columns, options) + '] density: ' + string.format(density, options) + '\n'; + // loop columns + for (var j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = this._ptr[j]; + var k1 = this._ptr[j + 1]; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + var i = this._index[k]; + // append value + str += '\n (' + string.format(i, options) + ', ' + string.format(j, options) + ') ==> ' + (this._values ? string.format(this._values[k], options) : 'X'); + } + } + return str; + }; + + /** + * Get a string representation of the matrix + * @memberof SparseMatrix + * @returns {string} str + */ + SparseMatrix.prototype.toString = function () { + return string.format(this.toArray()); + }; + + /** + * Get a JSON representation of the matrix + * @memberof SparseMatrix + * @returns {Object} + */ + SparseMatrix.prototype.toJSON = function () { + return { + mathjs: 'SparseMatrix', + values: this._values, + index: this._index, + ptr: this._ptr, + size: this._size, + datatype: this._datatype + }; + }; + + /** + * Get the kth Matrix diagonal. + * + * @memberof SparseMatrix + * @param {number | BigNumber} [k=0] The kth diagonal where the vector will retrieved. + * + * @returns {Matrix} The matrix vector with the diagonal values. + */ + SparseMatrix.prototype.diagonal = function(k) { + // validate k if any + if (k) { + // convert BigNumber to a number + if (k.isBigNumber === true) + k = k.toNumber(); + // is must be an integer + if (!isNumber(k) || !isInteger(k)) { + throw new TypeError ('The parameter k must be an integer number'); + } + } + else { + // default value + k = 0; + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // rows & columns + var rows = this._size[0]; + var columns = this._size[1]; + + // number diagonal values + var n = Math.min(rows - kSub, columns - kSuper); + + // diagonal arrays + var values = []; + var index = []; + var ptr = []; + // initial ptr value + ptr[0] = 0; + // loop columns + for (var j = kSuper; j < columns && values.length < n; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = this._ptr[j]; + var k1 = this._ptr[j + 1]; + // loop x within [k0, k1[ + for (var x = k0; x < k1; x++) { + // row index + var i = this._index[x]; + // check row + if (i === j - kSuper + kSub) { + // value on this column + values.push(this._values[x]); + // store row + index[values.length - 1] = i - kSub; + // exit loop + break; + } + } + } + // close ptr + ptr.push(values.length); + // return matrix + return new SparseMatrix({ + values: values, + index: index, + ptr: ptr, + size: [n, 1] + }); + }; + + /** + * Generate a matrix from a JSON object + * @memberof SparseMatrix + * @param {Object} json An object structured like + * `{"mathjs": "SparseMatrix", "values": [], "index": [], "ptr": [], "size": []}`, + * where mathjs is optional + * @returns {SparseMatrix} + */ + SparseMatrix.fromJSON = function (json) { + return new SparseMatrix(json); + }; + + /** + * Create a diagonal matrix. + * + * @memberof SparseMatrix + * @param {Array} size The matrix size. + * @param {number | Array | Matrix } value The values for the diagonal. + * @param {number | BigNumber} [k=0] The kth diagonal where the vector will be filled in. + * @param {string} [datatype] The Matrix datatype, values must be of this datatype. + * + * @returns {SparseMatrix} + */ + SparseMatrix.diagonal = function (size, value, k, defaultValue, datatype) { + if (!isArray(size)) + throw new TypeError('Array expected, size parameter'); + if (size.length !== 2) + throw new Error('Only two dimensions matrix are supported'); + + // map size & validate + size = size.map(function (s) { + // check it is a big number + if (s && s.isBigNumber === true) { + // convert it + s = s.toNumber(); + } + // validate arguments + if (!isNumber(s) || !isInteger(s) || s < 1) { + throw new Error('Size values must be positive integers'); + } + return s; + }); + + // validate k if any + if (k) { + // convert BigNumber to a number + if (k.isBigNumber === true) + k = k.toNumber(); + // is must be an integer + if (!isNumber(k) || !isInteger(k)) { + throw new TypeError ('The parameter k must be an integer number'); + } + } + else { + // default value + k = 0; + } + + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + if (isString(datatype)) { + // find signature that matches (datatype, datatype) + eq = typed.find(equalScalar, [datatype, datatype]) || equalScalar; + // convert 0 to the same datatype + zero = typed.convert(0, datatype); + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // rows and columns + var rows = size[0]; + var columns = size[1]; + + // number of non-zero items + var n = Math.min(rows - kSub, columns - kSuper); + + // value extraction function + var _value; + + // check value + if (isArray(value)) { + // validate array + if (value.length !== n) { + // number of values in array must be n + throw new Error('Invalid value array length'); + } + // define function + _value = function (i) { + // return value @ i + return value[i]; + }; + } + else if (value && value.isMatrix === true) { + // matrix size + var ms = value.size(); + // validate matrix + if (ms.length !== 1 || ms[0] !== n) { + // number of values in array must be n + throw new Error('Invalid matrix length'); + } + // define function + _value = function (i) { + // return value @ i + return value.get([i]); + }; + } + else { + // define function + _value = function () { + // return value + return value; + }; + } + + // create arrays + var values = []; + var index = []; + var ptr = []; + + // loop items + for (var j = 0; j < columns; j++) { + // number of rows with value + ptr.push(values.length); + // diagonal index + var i = j - kSuper; + // check we need to set diagonal value + if (i >= 0 && i < n) { + // get value @ i + var v = _value(i); + // check for zero + if (!eq(v, zero)) { + // column + index.push(i + kSub); + // add value + values.push(v); + } + } + } + // last value should be number of values + ptr.push(values.length); + // create SparseMatrix + return new SparseMatrix({ + values: values, + index: index, + ptr: ptr, + size: [rows, columns] + }); + }; + + /** + * Swap rows i and j in Matrix. + * + * @memberof SparseMatrix + * @param {number} i Matrix row index 1 + * @param {number} j Matrix row index 2 + * + * @return {Matrix} The matrix reference + */ + SparseMatrix.prototype.swapRows = function (i, j) { + // check index + if (!isNumber(i) || !isInteger(i) || !isNumber(j) || !isInteger(j)) { + throw new Error('Row index must be positive integers'); + } + // check dimensions + if (this._size.length !== 2) { + throw new Error('Only two dimensional matrix is supported'); + } + // validate index + validateIndex(i, this._size[0]); + validateIndex(j, this._size[0]); + + // swap rows + SparseMatrix._swapRows(i, j, this._size[1], this._values, this._index, this._ptr); + // return current instance + return this; + }; + + /** + * Loop rows with data in column j. + * + * @param {number} j Column + * @param {Array} values Matrix values + * @param {Array} index Matrix row indeces + * @param {Array} ptr Matrix column pointers + * @param {Function} callback Callback function invoked for every row in column j + */ + SparseMatrix._forEachRow = function (j, values, index, ptr, callback) { + // indeces for column j + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // loop + for (var k = k0; k < k1; k++) { + // invoke callback + callback(index[k], values[k]); + } + }; + + /** + * Swap rows x and y in Sparse Matrix data structures. + * + * @param {number} x Matrix row index 1 + * @param {number} y Matrix row index 2 + * @param {number} columns Number of columns in matrix + * @param {Array} values Matrix values + * @param {Array} index Matrix row indeces + * @param {Array} ptr Matrix column pointers + */ + SparseMatrix._swapRows = function (x, y, columns, values, index, ptr) { + // loop columns + for (var j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // find value index @ x + var kx = _getValueIndex(x, k0, k1, index); + // find value index @ x + var ky = _getValueIndex(y, k0, k1, index); + // check both rows exist in matrix + if (kx < k1 && ky < k1 && index[kx] === x && index[ky] === y) { + // swap values (check for pattern matrix) + if (values) { + var v = values[kx]; + values[kx] = values[ky]; + values[ky] = v; + } + // next column + continue; + } + // check x row exist & no y row + if (kx < k1 && index[kx] === x && (ky >= k1 || index[ky] !== y)) { + // value @ x (check for pattern matrix) + var vx = values ? values[kx] : undefined; + // insert value @ y + index.splice(ky, 0, y); + if (values) + values.splice(ky, 0, vx); + // remove value @ x (adjust array index if needed) + index.splice(ky <= kx ? kx + 1 : kx, 1); + if (values) + values.splice(ky <= kx ? kx + 1 : kx, 1); + // next column + continue; + } + // check y row exist & no x row + if (ky < k1 && index[ky] === y && (kx >= k1 || index[kx] !== x)) { + // value @ y (check for pattern matrix) + var vy = values ? values[ky] : undefined; + // insert value @ x + index.splice(kx, 0, x); + if (values) + values.splice(kx, 0, vy); + // remove value @ y (adjust array index if needed) + index.splice(kx <= ky ? ky + 1 : ky, 1); + if (values) + values.splice(kx <= ky ? ky + 1 : ky, 1); + } + } + }; + + // register this type in the base class Matrix + type.Matrix._storage.sparse = SparseMatrix; + + return SparseMatrix; + } + + exports.name = 'SparseMatrix'; + exports.path = 'type'; + exports.factory = factory; + exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage + + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + /** + * Test whether two values are equal. + * + * @param {number | BigNumber | Fraction | boolean | Complex | Unit} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Complex} y Second value to compare + * @return {boolean} Returns true when the compared values are equal, else returns false + * @private + */ + var equalScalar = typed('equalScalar', { + + 'boolean, boolean': function (x, y) { + return x === y; + }, + + 'number, number': function (x, y) { + return x === y || nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.eq(y) || bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return x.equals(y); + }, + + 'Complex, Complex': function (x, y) { + return x.equals(y); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return equalScalar(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x === y; + } + }); + + return equalScalar; + } + + exports.factory = factory; + + +/***/ }, +/* 49 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Compares two BigNumbers. + * @param {BigNumber} x First value to compare + * @param {BigNumber} y Second value to compare + * @param {number} [epsilon] The maximum relative difference between x and y + * If epsilon is undefined or null, the function will + * test whether x and y are exactly equal. + * @return {boolean} whether the two numbers are nearly equal + */ + module.exports = function nearlyEqual(x, y, epsilon) { + // if epsilon is null or undefined, test whether x and y are exactly equal + if (epsilon == null) { + return x.eq(y); + } + + + // use "==" operator, handles infinities + if (x.eq(y)) { + return true; + } + + // NaN + if (x.isNaN() || y.isNaN()) { + return false; + } + + // at this point x and y should be finite + if(x.isFinite() && y.isFinite()) { + // check numbers are very close, needed when comparing numbers near zero + var diff = x.minus(y).abs(); + if (diff.isZero()) { + return true; + } + else { + // use relative error + var max = x.constructor.max(x.abs(), y.abs()); + return diff.lte(max.times(epsilon)); + } + } + + // Infinite and Number or negative Infinite and positive Infinite cases + return false; + }; + + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var add = load(__webpack_require__(51)); + var equalScalar = load(__webpack_require__(48)); + + /** + * An ordered Sparse Accumulator is a representation for a sparse vector that includes a dense array + * of the vector elements and an ordered list of non-zero elements. + */ + function Spa() { + if (!(this instanceof Spa)) + throw new SyntaxError('Constructor must be called with the new operator'); + + // allocate vector, TODO use typed arrays + this._values = []; + this._heap = new type.FibonacciHeap(); + } + + /** + * Attach type information + */ + Spa.prototype.type = 'Spa'; + Spa.prototype.isSpa = true; + + /** + * Set the value for index i. + * + * @param {number} i The index + * @param {number | BigNumber | Complex} The value at index i + */ + Spa.prototype.set = function (i, v) { + // check we have a value @ i + if (!this._values[i]) { + // insert in heap + var node = this._heap.insert(i, v); + // set the value @ i + this._values[i] = node; + } + else { + // update the value @ i + this._values[i].value = v; + } + }; + + Spa.prototype.get = function (i) { + var node = this._values[i]; + if (node) + return node.value; + return 0; + }; + + Spa.prototype.accumulate = function (i, v) { + // node @ i + var node = this._values[i]; + if (!node) { + // insert in heap + node = this._heap.insert(i, v); + // initialize value + this._values[i] = node; + } + else { + // accumulate value + node.value = add(node.value, v); + } + }; + + Spa.prototype.forEach = function (from, to, callback) { + // references + var heap = this._heap; + var values = this._values; + // nodes + var nodes = []; + // node with minimum key, save it + var node = heap.extractMinimum(); + if (node) + nodes.push(node); + // extract nodes from heap (ordered) + while (node && node.key <= to) { + // check it is in range + if (node.key >= from) { + // check value is not zero + if (!equalScalar(node.value, 0)) { + // invoke callback + callback(node.key, node.value, this); + } + } + // extract next node, save it + node = heap.extractMinimum(); + if (node) + nodes.push(node); + } + // reinsert all nodes in heap + for (var i = 0; i < nodes.length; i++) { + // current node + var n = nodes[i]; + // insert node in heap + node = heap.insert(n.key, n.value); + // update values + values[node.key] = node; + } + }; + + Spa.prototype.swap = function (i, j) { + // node @ i and j + var nodei = this._values[i]; + var nodej = this._values[j]; + // check we need to insert indeces + if (!nodei && nodej) { + // insert in heap + nodei = this._heap.insert(i, nodej.value); + // remove from heap + this._heap.remove(nodej); + // set values + this._values[i] = nodei; + this._values[j] = undefined; + } + else if (nodei && !nodej) { + // insert in heap + nodej = this._heap.insert(j, nodei.value); + // remove from heap + this._heap.remove(nodei); + // set values + this._values[j] = nodej; + this._values[i] = undefined; + } + else if (nodei && nodej) { + // swap values + var v = nodei.value; + nodei.value = nodej.value; + nodej.value = v; + } + }; + + return Spa; + } + + exports.name = 'Spa'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var extend = __webpack_require__(3).extend; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var addScalar = load(__webpack_require__(53)); + var latex = __webpack_require__(32); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm04 = load(__webpack_require__(55)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Add two values, `x + y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.add(x, y) + * + * Examples: + * + * math.add(2, 3); // returns number 5 + * + * var a = math.complex(2, 3); + * var b = math.complex(-4, 1); + * math.add(a, b); // returns Complex -2 + 4i + * + * math.add([1, 2, 3], 4); // returns Array [5, 6, 7] + * + * var c = math.unit('5 cm'); + * var d = math.unit('2.1 mm'); + * math.add(c, d); // returns Unit 52.1 mm + * + * math.add("2.3", "4"); // returns number 6.3 + * + * See also: + * + * subtract + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First value to add + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second value to add + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Sum of `x` and `y` + */ + var add = typed('add', extend({ + // we extend the signatures of addScalar with signatures dealing with matrices + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm04(x, y, addScalar); + break; + default: + // sparse + dense + c = algorithm01(y, x, addScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm01(x, y, addScalar, false); + break; + default: + // dense + dense + c = algorithm13(x, y, addScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return add(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return add(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return add(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm10(x, y, addScalar, false); + break; + default: + c = algorithm14(x, y, addScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, addScalar, true); + break; + default: + c = algorithm14(y, x, addScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, addScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, addScalar, true).valueOf(); + } + }, addScalar.signatures)); + + add.toTex = { + 2: '\\left(${args[0]}' + latex.operators['add'] + '${args[1]}\\right)' + }; + + return add; + } + + exports.name = 'add'; + exports.factory = factory; + + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Create a Matrix. The function creates a new `math.type.Matrix` object from + * an `Array`. A Matrix has utility functions to manipulate the data in the + * matrix, like getting the size and getting or setting values in the matrix. + * Supported storage formats are 'dense' and 'sparse'. + * + * Syntax: + * + * math.matrix() // creates an empty matrix using default storage format (dense). + * math.matrix(data) // creates a matrix with initial data using default storage format (dense). + * math.matrix('dense') // creates an empty matrix using the given storage format. + * math.matrix(data, 'dense') // creates a matrix with initial data using the given storage format. + * math.matrix(data, 'sparse') // creates a sparse matrix with initial data. + * math.matrix(data, 'sparse', 'number') // creates a sparse matrix with initial data, number data type. + * + * Examples: + * + * var m = math.matrix([[1, 2], [3, 4]]); + * m.size(); // Array [2, 2] + * m.resize([3, 2], 5); + * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] + * m.get([1, 0]) // number 3 + * + * See also: + * + * bignumber, boolean, complex, index, number, string, unit, sparse + * + * @param {Array | Matrix} [data] A multi dimensional array + * @param {string} [format] The Matrix storage format + * + * @return {Matrix} The created matrix + */ + var matrix = typed('matrix', { + '': function () { + return _create([]); + }, + + 'string': function (format) { + return _create([], format); + }, + + 'string, string': function (format, datatype) { + return _create([], format, datatype); + }, + + 'Array': function (data) { + return _create(data); + }, + + 'Matrix': function (data) { + return _create(data, data.storage()); + }, + + 'Array | Matrix, string': _create, + + 'Array | Matrix, string, string': _create + }); + + matrix.toTex = { + 0: '\\begin{bmatrix}\\end{bmatrix}', + 1: '\\left(${args[0]}\\right)', + 2: '\\left(${args[0]}\\right)' + }; + + return matrix; + + /** + * Create a new Matrix with given storage format + * @param {Array} data + * @param {string} [format] + * @param {string} [datatype] + * @returns {Matrix} Returns a new Matrix + * @private + */ + function _create(data, format, datatype) { + // get storage format constructor + var M = type.Matrix.storage(format || 'default'); + + // create instance + return new M(data, datatype); + } + } + + exports.name = 'matrix'; + exports.factory = factory; + + +/***/ }, +/* 53 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory(type, config, load, typed) { + + /** + * Add two scalar values, `x + y`. + * This function is meant for internal use: it is used by the public function + * `add` + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {number | BigNumber | Fraction | Complex | Unit} x First value to add + * @param {number | BigNumber | Fraction | Complex} y Second value to add + * @return {number | BigNumber | Fraction | Complex | Unit} Sum of `x` and `y` + * @private + */ + var add = typed('add', { + + 'number, number': function (x, y) { + return x + y; + }, + + 'Complex, Complex': function (x, y) { + return x.add(y); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.plus(y); + }, + + 'Fraction, Fraction': function (x, y) { + return x.add(y); + }, + + 'Unit, Unit': function (x, y) { + if (x.value == null) throw new Error('Parameter x contains a unit with undefined value'); + if (y.value == null) throw new Error('Parameter y contains a unit with undefined value'); + if (!x.equalBase(y)) throw new Error('Units do not match'); + + var res = x.clone(); + res.value = add(res.value, y.value); + res.fixPrefix = false; + return res; + } + }); + + return add; + } + + exports.factory = factory; + + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). + * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ Dij ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (S) + * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm01 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types + var dt = typeof adt === 'string' && adt === bdt ? adt : undefined; + // callback function + var cf = dt ? typed.find(callback, [dt, dt]) : callback; + + // vars + var i, j; + + // result (DenseMatrix) + var cdata = []; + // initialize c + for (i = 0; i < rows; i++) + cdata[i] = []; + + // workspace + var x = []; + // marks indicating we have a value in x for a given column + var w = []; + + // loop columns in b + for (j = 0; j < columns; j++) { + // column mark + var mark = j + 1; + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + i = bindex[k]; + // update workspace + x[i] = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); + // mark i as updated + w[i] = mark; + } + // loop rows + for (i = 0; i < rows; i++) { + // check row is in workspace + if (w[i] === mark) { + // c[i][j] was already calculated + cdata[i][j] = x[i]; + } + else { + // item does not exist in S + cdata[i][j] = adata[i][j]; + } + } + } + + // return dense matrix + return new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + }; + + return algorithm01; + } + + exports.name = 'algorithm01'; + exports.factory = factory; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 + * └ B(i,j) ; B(i,j) !== 0 + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm04 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspace + var xa = avalues && bvalues ? [] : undefined; + var xb = avalues && bvalues ? [] : undefined; + // marks indicating we have a value in x for a given column + var wa = []; + var wb = []; + + // vars + var i, j, k, k0, k1; + + // loop columns + for (j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // loop A(:,j) + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // update c + cindex.push(i); + // update workspace + wa[i] = mark; + // check we need to process values + if (xa) + xa[i] = avalues[k]; + } + // loop B(:,j) + for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + i = bindex[k]; + // check row exists in A + if (wa[i] === mark) { + // update record in xa @ i + if (xa) { + // invoke callback + var v = cf(xa[i], bvalues[k]); + // check for zero + if (!eq(v, zero)) { + // update workspace + xa[i] = v; + } + else { + // remove mark (index will be removed later) + wa[i] = null; + } + } + } + else { + // update c + cindex.push(i); + // update workspace + wb[i] = mark; + // check we need to process values + if (xb) + xb[i] = bvalues[k]; + } + } + // check we need to process values (non pattern matrix) + if (xa && xb) { + // initialize first index in j + k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + i = cindex[k]; + // check workspace has value @ i + if (wa[i] === mark) { + // push value (Aij != 0 || (Aij != 0 && Bij != 0)) + cvalues[k] = xa[i]; + // increment pointer + k++; + } + else if (wb[i] === mark) { + // push value (bij != 0) + cvalues[k] = xb[i]; + // increment pointer + k++; + } + else { + // remove index @ k + cindex.splice(k, 1); + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm04; + } + + exports.name = 'algorithm04'; + exports.factory = factory; + + +/***/ }, +/* 56 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked NZ times (number of nonzero items in S). + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ b ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {Function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm10 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + var adt = s._datatype; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string') { + // datatype + dt = adt; + // convert b to the same datatype + b = typed.convert(b, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cdata = []; + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var x = []; + // marks indicating we have a value in x for a given column + var w = []; + + // loop columns + for (var j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var r = aindex[k]; + // update workspace + x[r] = avalues[k]; + w[r] = mark; + } + // loop rows + for (var i = 0; i < rows; i++) { + // initialize C on first column + if (j === 0) { + // create row array + cdata[i] = []; + } + // check sparse matrix has a value @ i,j + if (w[i] === mark) { + // invoke callback, update C + cdata[i][j] = inverse ? cf(b, x[i]) : cf(x[i], b); + } + else { + // dense matrix value @ i, j + cdata[i][j] = b; + } + } + } + + // return sparse matrix + return c; + }; + + return algorithm10; + } + + exports.name = 'algorithm10'; + exports.factory = factory; + + +/***/ }, +/* 57 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + var DimensionError = __webpack_require__(42); + + var string = util.string, + isString = string.isString; + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, Bij..z). + * Callback function invoked MxN times. + * + * C(i,j,...z) = f(Aij..z, Bij..z) + * + * @param {Matrix} a The DenseMatrix instance (A) + * @param {Matrix} b The DenseMatrix instance (B) + * @param {Function} callback The f(Aij..z,Bij..z) operation to invoke + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97658658 + */ + var algorithm13 = function (a, b, callback) { + // a arrays + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b arrays + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + // c arrays + var csize = []; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // validate each one of the dimension sizes + for (var s = 0; s < asize.length; s++) { + // must match + if (asize[s] !== bsize[s]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + // update dimension in c + csize[s] = asize[s]; + } + + // datatype + var dt; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // convert b to the same datatype + b = typed.convert(b, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // populate cdata, iterate through dimensions + var cdata = csize.length > 0 ? _iterate(cf, 0, csize, csize[0], adata, bdata) : []; + + // c matrix + return new DenseMatrix({ + data: cdata, + size: csize, + datatype: dt + }); + }; + + // recursive function + var _iterate = function (f, level, s, n, av, bv) { + // initialize array for this level + var cv = []; + // check we reach the last level + if (level === s.length - 1) { + // loop arrays in last level + for (var i = 0; i < n; i++) { + // invoke callback and store value + cv[i] = f(av[i], bv[i]); + } + } + else { + // iterate current level + for (var j = 0; j < n; j++) { + // iterate next level + cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv[j]); + } + } + return cv; + }; + + return algorithm13; + } + + exports.name = 'algorithm13'; + exports.factory = factory; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, b). + * Callback function invoked MxN times. + * + * C(i,j,...z) = f(Aij..z, b) + * + * @param {Matrix} a The DenseMatrix instance (A) + * @param {Scalar} b The Scalar value + * @param {Function} callback The f(Aij..z,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Aij..z) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97659042 + */ + var algorithm14 = function (a, b, callback, inverse) { + // a arrays + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + + // datatype + var dt; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string') { + // datatype + dt = adt; + // convert b to the same datatype + b = typed.convert(b, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // populate cdata, iterate through dimensions + var cdata = asize.length > 0 ? _iterate(cf, 0, asize, asize[0], adata, b, inverse) : []; + + // c matrix + return new DenseMatrix({ + data: cdata, + size: clone(asize), + datatype: dt + }); + }; + + // recursive function + var _iterate = function (f, level, s, n, av, bv, inverse) { + // initialize array for this level + var cv = []; + // check we reach the last level + if (level === s.length - 1) { + // loop arrays in last level + for (var i = 0; i < n; i++) { + // invoke callback and store value + cv[i] = inverse ? f(bv, av[i]) : f(av[i], bv); + } + } + else { + // iterate current level + for (var j = 0; j < n; j++) { + // iterate next level + cv[j] = _iterate(f, level + 1, s, s[level + 1], av[j], bv, inverse); + } + } + return cv; + }; + + return algorithm14; + } + + exports.name = 'algorithm14'; + exports.factory = factory; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var smaller = load(__webpack_require__(60)); + var larger = load(__webpack_require__(64)); + + var oneOverLogPhi = 1.0 / Math.log((1.0 + Math.sqrt(5.0)) / 2.0); + + /** + * Fibonacci Heap implementation, used interally for Matrix math. + * @class FibonacciHeap + * @constructor FibonacciHeap + */ + function FibonacciHeap() { + if (!(this instanceof FibonacciHeap)) + throw new SyntaxError('Constructor must be called with the new operator'); + + // initialize fields + this._minimum = null; + this._size = 0; + } + + /** + * Attach type information + */ + FibonacciHeap.prototype.type = 'FibonacciHeap'; + FibonacciHeap.prototype.isFibonacciHeap = true; + + /** + * Inserts a new data element into the heap. No heap consolidation is + * performed at this time, the new node is simply inserted into the root + * list of this heap. Running time: O(1) actual. + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.insert = function (key, value) { + // create node + var node = { + key: key, + value: value, + degree: 0 + }; + // check we have a node in the minimum + if (this._minimum) { + // minimum node + var minimum = this._minimum; + // update left & right of node + node.left = minimum; + node.right = minimum.right; + minimum.right = node; + node.right.left = node; + // update minimum node in heap if needed + if (smaller(key, minimum.key)) { + // node has a smaller key, use it as minimum + this._minimum = node; + } + } + else { + // set left & right + node.left = node; + node.right = node; + // this is the first node + this._minimum = node; + } + // increment number of nodes in heap + this._size++; + // return node + return node; + }; + + /** + * Returns the number of nodes in heap. Running time: O(1) actual. + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.size = function () { + return this._size; + }; + + /** + * Removes all elements from this heap. + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.clear = function () { + this._minimum = null; + this._size = 0; + }; + + /** + * Returns true if the heap is empty, otherwise false. + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.isEmpty = function () { + return !!this._minimum; + }; + + /** + * Extracts the node with minimum key from heap. Amortized running + * time: O(log n). + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.extractMinimum = function () { + // node to remove + var node = this._minimum; + // check we have a minimum + if (node === null) + return node; + // current minimum + var minimum = this._minimum; + // get number of children + var numberOfChildren = node.degree; + // pointer to the first child + var x = node.child; + // for each child of node do... + while (numberOfChildren > 0) { + // store node in right side + var tempRight = x.right; + // remove x from child list + x.left.right = x.right; + x.right.left = x.left; + // add x to root list of heap + x.left = minimum; + x.right = minimum.right; + minimum.right = x; + x.right.left = x; + // set Parent[x] to null + x.parent = null; + x = tempRight; + numberOfChildren--; + } + // remove node from root list of heap + node.left.right = node.right; + node.right.left = node.left; + // update minimum + if (node == node.right) { + // empty + minimum = null; + } + else { + // update minimum + minimum = node.right; + // we need to update the pointer to the root with minimum key + minimum = _findMinimumNode(minimum, this._size); + } + // decrement size of heap + this._size--; + // update minimum + this._minimum = minimum; + // return node + return node; + }; + + /** + * Removes a node from the heap given the reference to the node. The trees + * in the heap will be consolidated, if necessary. This operation may fail + * to remove the correct element if there are nodes with key value -Infinity. + * Running time: O(log n) amortized. + * @memberof FibonacciHeap + */ + FibonacciHeap.prototype.remove = function (node) { + // decrease key value + this._minimum = _decreaseKey(this._minimum, node, -1); + // remove the smallest + this.extractMinimum(); + }; + + /** + * Decreases the key value for a heap node, given the new value to take on. + * The structure of the heap may be changed and will not be consolidated. + * Running time: O(1) amortized. + * @memberof FibonacciHeap + */ + var _decreaseKey = function (minimum, node, key) { + // set node key + node.key = key; + // get parent node + var parent = node.parent; + if (parent && smaller(node.key, parent.key)) { + // remove node from parent + _cut(minimum, node, parent); + // remove all nodes from parent to the root parent + _cascadingCut(minimum, parent); + } + // update minimum node if needed + if (smaller(node.key, minimum.key)) + minimum = node; + // return minimum + return minimum; + }; + + /** + * The reverse of the link operation: removes node from the child list of parent. + * This method assumes that min is non-null. Running time: O(1). + * @memberof FibonacciHeap + */ + var _cut = function (minimum, node, parent) { + // remove node from parent children and decrement Degree[parent] + node.left.right = node.right; + node.right.left = node.left; + parent.degree--; + // reset y.child if necessary + if (parent.child == node) + parent.child = node.right; + // remove child if degree is 0 + if (parent.degree === 0) + parent.child = null; + // add node to root list of heap + node.left = minimum; + node.right = minimum.right; + minimum.right = node; + node.right.left = node; + // set parent[node] to null + node.parent = null; + // set mark[node] to false + node.mark = false; + }; + + /** + * Performs a cascading cut operation. This cuts node from its parent and then + * does the same for its parent, and so on up the tree. + * Running time: O(log n); O(1) excluding the recursion. + * @memberof FibonacciHeap + */ + var _cascadingCut= function (minimum, node) { + // store parent node + var parent = node.parent; + // if there's a parent... + if (!parent) + return; + // if node is unmarked, set it marked + if (!node.mark) { + node.mark = true; + } + else { + // it's marked, cut it from parent + _cut(minimum, node, parent); + // cut its parent as well + _cascadingCut(parent); + } + }; + + /** + * Make the first node a child of the second one. Running time: O(1) actual. + * @memberof FibonacciHeap + */ + var _linkNodes = function (node, parent) { + // remove node from root list of heap + node.left.right = node.right; + node.right.left = node.left; + // make node a Child of parent + node.parent = parent; + if (!parent.child) { + parent.child = node; + node.right = node; + node.left = node; + } + else { + node.left = parent.child; + node.right = parent.child.right; + parent.child.right = node; + node.right.left = node; + } + // increase degree[parent] + parent.degree++; + // set mark[node] false + node.mark = false; + }; + + var _findMinimumNode = function (minimum, size) { + // to find trees of the same degree efficiently we use an array of length O(log n) in which we keep a pointer to one root of each degree + var arraySize = Math.floor(Math.log(size) * oneOverLogPhi) + 1; + // create list with initial capacity + var array = new Array(arraySize); + // find the number of root nodes. + var numRoots = 0; + var x = minimum; + if (x) { + numRoots++; + x = x.right; + while (x !== minimum) { + numRoots++; + x = x.right; + } + } + // vars + var y; + // For each node in root list do... + while (numRoots > 0) { + // access this node's degree.. + var d = x.degree; + // get next node + var next = x.right; + // check if there is a node already in array with the same degree + while (true) { + // get node with the same degree is any + y = array[d]; + if (!y) + break; + // make one node with the same degree a child of the other, do this based on the key value. + if (larger(x.key, y.key)) { + var temp = y; + y = x; + x = temp; + } + // make y a child of x + _linkNodes(y, x); + // we have handled this degree, go to next one. + array[d] = null; + d++; + } + // save this node for later when we might encounter another of the same degree. + array[d] = x; + // move forward through list. + x = next; + numRoots--; + } + // Set min to null (effectively losing the root list) and reconstruct the root list from the array entries in array[]. + minimum = null; + // loop nodes in array + for (var i = 0; i < arraySize; i++) { + // get current node + y = array[i]; + if (!y) + continue; + // check if we have a linked list + if (minimum) { + // First remove node from root list. + y.left.right = y.right; + y.right.left = y.left; + // now add to root list, again. + y.left = minimum; + y.right = minimum.right; + minimum.right = y; + y.right.left = y; + // check if this is a new min. + if (smaller(y.key, minimum.key)) + minimum = y; + } + else + minimum = y; + } + return minimum; + }; + + return FibonacciHeap; + } + + exports.name = 'FibonacciHeap'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 60 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether value x is smaller than y. + * + * The function returns true when x is smaller than y and the relative + * difference between x and y is smaller than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.smaller(x, y) + * + * Examples: + * + * math.smaller(2, 3); // returns true + * math.smaller(5, 2 * 2); // returns false + * + * var a = math.unit('5 cm'); + * var b = math.unit('2 inch'); + * math.smaller(a, b); // returns true + * + * See also: + * + * equal, unequal, smallerEq, smaller, smallerEq, compare + * + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false + */ + var smaller = typed('smaller', { + + 'boolean, boolean': function (x, y) { + return x < y; + }, + + 'number, number': function (x, y) { + return x < y && !nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.lt(y) && !bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return x.compare(y) === -1; + }, + + 'Complex, Complex': function (x, y) { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return smaller(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x < y; + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, smaller); + break; + default: + // sparse + dense + c = algorithm03(y, x, smaller, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, smaller, false); + break; + default: + // dense + dense + c = algorithm13(x, y, smaller); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return smaller(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return smaller(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return smaller(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, smaller, false); + break; + default: + c = algorithm14(x, y, smaller, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, smaller, true); + break; + default: + c = algorithm14(y, x, smaller, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, smaller, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, smaller, true).valueOf(); + } + }); + + smaller.toTex = { + 2: '\\left(${args[0]}' + latex.operators['smaller'] + '${args[1]}\\right)' + }; + + return smaller; + } + + exports.name = 'smaller'; + exports.factory = factory; + + +/***/ }, +/* 61 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over SparseMatrix items and invokes the callback function f(Dij, Sij). + * Callback function invoked M*N times. + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ f(Dij, 0) ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (C) + * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm03 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result (DenseMatrix) + var cdata = []; + + // initialize dense matrix + for (var z = 0; z < rows; z++) { + // initialize row + cdata[z] = []; + } + + // workspace + var x = []; + // marks indicating we have a value in x for a given column + var w = []; + + // loop columns in b + for (var j = 0; j < columns; j++) { + // column mark + var mark = j + 1; + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + var i = bindex[k]; + // update workspace + x[i] = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); + w[i] = mark; + } + // process workspace + for (var y = 0; y < rows; y++) { + // check we have a calculated value for current row + if (w[y] === mark) { + // use calculated value + cdata[y][j] = x[y]; + } + else { + // calculate value + cdata[y][j] = inverse ? cf(zero, adata[y][j]) : cf(adata[y][j], zero); + } + } + } + + // return dense matrix + return new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + }; + + return algorithm03; + } + + exports.name = 'algorithm03'; + exports.factory = factory; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over SparseMatrix A and SparseMatrix B items (zero and nonzero) and invokes the callback function f(Aij, Bij). + * Callback function invoked MxN times. + * + * C(i,j) = f(Aij, Bij) + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm07 = function (a, b, callback) { + // sparse matrix arrays + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // vars + var i, j; + + // result arrays + var cdata = []; + // initialize c + for (i = 0; i < rows; i++) + cdata[i] = []; + + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var xa = []; + var xb = []; + // marks indicating we have a value in x for a given column + var wa = []; + var wb = []; + + // loop columns + for (j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + _scatter(a, j, wa, xa, mark); + // scatter the values of B(:,j) into workspace + _scatter(b, j, wb, xb, mark); + // loop rows + for (i = 0; i < rows; i++) { + // matrix values @ i,j + var va = wa[i] === mark ? xa[i] : zero; + var vb = wb[i] === mark ? xb[i] : zero; + // invoke callback + cdata[i][j] = cf(va, vb); + } + } + + // return sparse matrix + return c; + }; + + var _scatter = function (m, j, w, x, mark) { + // a arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // loop values in column j + for (var k = ptr[j], k1 = ptr[j + 1]; k < k1; k++) { + // row + var i = index[k]; + // update workspace + w[i] = mark; + x[i] = values[k]; + } + }; + + return algorithm07; + } + + exports.name = 'algorithm07'; + exports.factory = factory; + + +/***/ }, +/* 63 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked MxN times. + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ f(0, b) ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {Function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm12 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + var adt = s._datatype; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string') { + // datatype + dt = adt; + // convert b to the same datatype + b = typed.convert(b, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cdata = []; + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var x = []; + // marks indicating we have a value in x for a given column + var w = []; + + // loop columns + for (var j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var r = aindex[k]; + // update workspace + x[r] = avalues[k]; + w[r] = mark; + } + // loop rows + for (var i = 0; i < rows; i++) { + // initialize C on first column + if (j === 0) { + // create row array + cdata[i] = []; + } + // check sparse matrix has a value @ i,j + if (w[i] === mark) { + // invoke callback, update C + cdata[i][j] = inverse ? cf(b, x[i]) : cf(x[i], b); + } + else { + // dense matrix value @ i, j + cdata[i][j] = inverse ? cf(b, 0) : cf(0, b); + } + } + } + + // return sparse matrix + return c; + }; + + return algorithm12; + } + + exports.name = 'algorithm12'; + exports.factory = factory; + + +/***/ }, +/* 64 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether value x is larger than y. + * + * The function returns true when x is larger than y and the relative + * difference between x and y is larger than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.larger(x, y) + * + * Examples: + * + * math.larger(2, 3); // returns false + * math.larger(5, 2 + 2); // returns true + * + * var a = math.unit('5 cm'); + * var b = math.unit('2 inch'); + * math.larger(a, b); // returns false + * + * See also: + * + * equal, unequal, smaller, smallerEq, largerEq, compare + * + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the x is larger than y, else returns false + */ + var larger = typed('larger', { + + 'boolean, boolean': function (x, y) { + return x > y; + }, + + 'number, number': function (x, y) { + return x > y && !nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.gt(y) && !bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return x.compare(y) === 1; + }, + + 'Complex, Complex': function () { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return larger(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x > y; + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, larger); + break; + default: + // sparse + dense + c = algorithm03(y, x, larger, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, larger, false); + break; + default: + // dense + dense + c = algorithm13(x, y, larger); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return larger(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return larger(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return larger(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, larger, false); + break; + default: + c = algorithm14(x, y, larger, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, larger, true); + break; + default: + c = algorithm14(y, x, larger, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, larger, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, larger, true).valueOf(); + } + }); + + larger.toTex = { + 2: '\\left(${args[0]}' + latex.operators['larger'] + '${args[1]}\\right)' + }; + + return larger; + } + + exports.name = 'larger'; + exports.factory = factory; + + +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + + var string = util.string; + var object = util.object; + + var isArray = Array.isArray; + var isString = string.isString; + + function factory (type, config, load) { + + var DenseMatrix = load(__webpack_require__(46)); + + var smaller = load(__webpack_require__(60)); + + function ImmutableDenseMatrix(data, datatype) { + if (!(this instanceof ImmutableDenseMatrix)) + throw new SyntaxError('Constructor must be called with the new operator'); + if (datatype && !isString(datatype)) + throw new Error('Invalid datatype: ' + datatype); + + if ((data && data.isMatrix === true) || isArray(data)) { + // use DenseMatrix implementation + var matrix = new DenseMatrix(data, datatype); + // internal structures + this._data = matrix._data; + this._size = matrix._size; + this._datatype = matrix._datatype; + this._min = null; + this._max = null; + } + else if (data && isArray(data.data) && isArray(data.size)) { + // initialize fields from JSON representation + this._data = data.data; + this._size = data.size; + this._datatype = data.datatype; + this._min = typeof data.min !== 'undefined' ? data.min : null; + this._max = typeof data.max !== 'undefined' ? data.max : null; + } + else if (data) { + // unsupported type + throw new TypeError('Unsupported type of data (' + util.types.type(data) + ')'); + } + else { + // nothing provided + this._data = []; + this._size = [0]; + this._datatype = datatype; + this._min = null; + this._max = null; + } + } + + ImmutableDenseMatrix.prototype = new DenseMatrix(); + + /** + * Attach type information + */ + ImmutableDenseMatrix.prototype.type = 'ImmutableDenseMatrix'; + ImmutableDenseMatrix.prototype.isImmutableDenseMatrix = true; + + /** + * Get a subset of the matrix, or replace a subset of the matrix. + * + * Usage: + * var subset = matrix.subset(index) // retrieve subset + * var value = matrix.subset(index, replacement) // replace subset + * + * @param {Index} index + * @param {Array | ImmutableDenseMatrix | *} [replacement] + * @param {*} [defaultValue=0] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be filled with zeros. + */ + ImmutableDenseMatrix.prototype.subset = function (index) { + switch (arguments.length) { + case 1: + // use base implementation + var m = DenseMatrix.prototype.subset.call(this, index); + // check result is a matrix + if (m.isMatrix) { + // return immutable matrix + return new ImmutableDenseMatrix({ + data: m._data, + size: m._size, + datatype: m._datatype + }); + } + return m; + + // intentional fall through + case 2: + case 3: + throw new Error('Cannot invoke set subset on an Immutable Matrix instance'); + + default: + throw new SyntaxError('Wrong number of arguments'); + } + }; + + /** + * Replace a single element in the matrix. + * @param {Number[]} index Zero-based index + * @param {*} value + * @param {*} [defaultValue] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * new matrix elements will be left undefined. + * @return {ImmutableDenseMatrix} self + */ + ImmutableDenseMatrix.prototype.set = function () { + throw new Error('Cannot invoke set on an Immutable Matrix instance'); + }; + + /** + * Resize the matrix to the given size. Returns a copy of the matrix when + * `copy=true`, otherwise return the matrix itself (resize in place). + * + * @param {Number[]} size The new size the matrix should have. + * @param {*} [defaultValue=0] Default value, filled in on new entries. + * If not provided, the matrix elements will + * be filled with zeros. + * @param {boolean} [copy] Return a resized copy of the matrix + * + * @return {Matrix} The resized matrix + */ + ImmutableDenseMatrix.prototype.resize = function () { + throw new Error('Cannot invoke resize on an Immutable Matrix instance'); + }; + + /** + * Create a clone of the matrix + * @return {ImmutableDenseMatrix} clone + */ + ImmutableDenseMatrix.prototype.clone = function () { + var m = new ImmutableDenseMatrix({ + data: object.clone(this._data), + size: object.clone(this._size), + datatype: this._datatype + }); + return m; + }; + + /** + * Get a JSON representation of the matrix + * @returns {Object} + */ + ImmutableDenseMatrix.prototype.toJSON = function () { + return { + mathjs: 'ImmutableDenseMatrix', + data: this._data, + size: this._size, + datatype: this._datatype + }; + }; + + /** + * Generate a matrix from a JSON object + * @param {Object} json An object structured like + * `{"mathjs": "ImmutableDenseMatrix", data: [], size: []}`, + * where mathjs is optional + * @returns {ImmutableDenseMatrix} + */ + ImmutableDenseMatrix.fromJSON = function (json) { + return new ImmutableDenseMatrix(json); + }; + + /** + * Swap rows i and j in Matrix. + * + * @param {Number} i Matrix row index 1 + * @param {Number} j Matrix row index 2 + * + * @return {Matrix} The matrix reference + */ + ImmutableDenseMatrix.prototype.swapRows = function () { + throw new Error('Cannot invoke swapRows on an Immutable Matrix instance'); + }; + + /** + * Calculate the minimum value in the set + * @return {Number | undefined} min + */ + ImmutableDenseMatrix.prototype.min = function () { + // check min has been calculated before + if (this._min === null) { + // minimum + var m = null; + // compute min + this.forEach(function (v) { + if (m === null || smaller(v, m)) + m = v; + }); + this._min = m !== null ? m : undefined; + } + return this._min; + }; + + /** + * Calculate the maximum value in the set + * @return {Number | undefined} max + */ + ImmutableDenseMatrix.prototype.max = function () { + // check max has been calculated before + if (this._max === null) { + // maximum + var m = null; + // compute max + this.forEach(function (v) { + if (m === null || smaller(m, v)) + m = v; + }); + this._max = m !== null ? m : undefined; + } + return this._max; + }; + + // exports + return ImmutableDenseMatrix; + } + + exports.name = 'ImmutableDenseMatrix'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 66 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var isInteger = __webpack_require__(6).isInteger; + + function factory (type) { + + /** + * Create an index. An Index can store ranges and sets for multiple dimensions. + * Matrix.get, Matrix.set, and math.subset accept an Index as input. + * + * Usage: + * var index = new Index(range1, range2, matrix1, array1, ...); + * + * Where each parameter can be any of: + * A number + * A string (containing a name of an object property) + * An instance of Range + * An Array with the Set values + * A Matrix with the Set values + * + * The parameters start, end, and step must be integer numbers. + * + * @class Index + * @Constructor Index + * @param {...*} ranges + */ + function Index(ranges) { + if (!(this instanceof Index)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this._dimensions = []; + this._isScalar = true; + + for (var i = 0, ii = arguments.length; i < ii; i++) { + var arg = arguments[i]; + + if (arg && (arg.isRange === true)) { + this._dimensions.push(arg); + this._isScalar = false; + } + else if (arg && (Array.isArray(arg) || arg.isMatrix === true)) { + // create matrix + var m = _createImmutableMatrix(arg.valueOf()); + this._dimensions.push(m); + // size + var size = m.size(); + // scalar + if (size.length !== 1 || size[0] !== 1) { + this._isScalar = false; + } + } + else if (typeof arg === 'number') { + this._dimensions.push(_createImmutableMatrix([arg])); + } + else if (typeof arg === 'string') { + // object property (arguments.count should be 1) + this._dimensions.push(arg); + } + // TODO: implement support for wildcard '*' + else { + throw new TypeError('Dimension must be an Array, Matrix, number, string, or Range'); + } + } + } + + /** + * Attach type information + */ + Index.prototype.type = 'Index'; + Index.prototype.isIndex = true; + + function _createImmutableMatrix(arg) { + // loop array elements + for (var i = 0, l = arg.length; i < l; i++) { + if (typeof arg[i] !== 'number' || !isInteger(arg[i])) { + throw new TypeError('Index parameters must be positive integer numbers'); + } + } + // create matrix + return new type.ImmutableDenseMatrix(arg); + } + + /** + * Create a clone of the index + * @memberof Index + * @return {Index} clone + */ + Index.prototype.clone = function () { + var index = new Index(); + index._dimensions = clone(this._dimensions); + index._isScalar = this._isScalar; + return index; + }; + + /** + * Create an index from an array with ranges/numbers + * @memberof Index + * @param {Array.} ranges + * @return {Index} index + * @private + */ + Index.create = function (ranges) { + var index = new Index(); + Index.apply(index, ranges); + return index; + }; + + /** + * Retrieve the size of the index, the number of elements for each dimension. + * @memberof Index + * @returns {number[]} size + */ + Index.prototype.size = function () { + var size = []; + + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + var d = this._dimensions[i]; + size[i] = (typeof d === 'string') ? 1 : d.size()[0]; + } + + return size; + }; + + /** + * Get the maximum value for each of the indexes ranges. + * @memberof Index + * @returns {number[]} max + */ + Index.prototype.max = function () { + var values = []; + + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + var range = this._dimensions[i]; + values[i] = (typeof range === 'string') ? range : range.max(); + } + + return values; + }; + + /** + * Get the minimum value for each of the indexes ranges. + * @memberof Index + * @returns {number[]} min + */ + Index.prototype.min = function () { + var values = []; + + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + var range = this._dimensions[i]; + values[i] = (typeof range === 'string') ? range : range.min(); + } + + return values; + }; + + /** + * Loop over each of the ranges of the index + * @memberof Index + * @param {Function} callback Called for each range with a Range as first + * argument, the dimension as second, and the + * index object as third. + */ + Index.prototype.forEach = function (callback) { + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + callback(this._dimensions[i], i, this); + } + }; + + /** + * Retrieve the dimension for the given index + * @memberof Index + * @param {Number} dim Number of the dimension + * @returns {Range | null} range + */ + Index.prototype.dimension = function (dim) { + return this._dimensions[dim] || null; + }; + + /** + * Test whether this index contains an object property + * @returns {boolean} Returns true if the index is an object property + */ + Index.prototype.isObjectProperty = function () { + return this._dimensions.length === 1 && typeof this._dimensions[0] === 'string'; + }; + + /** + * Returns the object property name when the Index holds a single object property, + * else returns null + * @returns {string | null} + */ + Index.prototype.getObjectProperty = function () { + return this.isObjectProperty() ? this._dimensions[0] : null; + }; + + /** + * Test whether this index contains only a single value. + * + * This is the case when the index is created with only scalar values as ranges, + * not for ranges resolving into a single value. + * @memberof Index + * @return {boolean} isScalar + */ + Index.prototype.isScalar = function () { + return this._isScalar; + }; + + /** + * Expand the Index into an array. + * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] + * @memberof Index + * @returns {Array} array + */ + Index.prototype.toArray = function () { + var array = []; + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + var dimension = this._dimensions[i]; + array.push((typeof dimension === 'string') ? dimension : dimension.toArray()); + } + return array; + }; + + /** + * Get the primitive value of the Index, a two dimensional array. + * Equivalent to Index.toArray(). + * @memberof Index + * @returns {Array} array + */ + Index.prototype.valueOf = Index.prototype.toArray; + + /** + * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7, [1,2,3]]' + * @memberof Index + * @returns {String} str + */ + Index.prototype.toString = function () { + var strings = []; + + for (var i = 0, ii = this._dimensions.length; i < ii; i++) { + var dimension = this._dimensions[i]; + if (typeof dimension === 'string') { + strings.push(JSON.stringify(dimension)); + } + else { + strings.push(dimension.toString()); + } + } + + return '[' + strings.join(', ') + ']'; + }; + + /** + * Get a JSON representation of the Index + * @memberof Index + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` + */ + Index.prototype.toJSON = function () { + return { + mathjs: 'Index', + dimensions: this._dimensions + }; + }; + + /** + * Instantiate an Index from a JSON object + * @memberof Index + * @param {Object} json A JSON object structured as: + * `{"mathjs": "Index", "dimensions": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` + * @return {Index} + */ + Index.fromJSON = function (json) { + return Index.create(json.dimensions); + }; + + return Index; + } + + exports.name = 'Index'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 67 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Create a range. A range has a start, step, and end, and contains functions + * to iterate over the range. + * + * A range can be constructed as: + * var range = new Range(start, end); + * var range = new Range(start, end, step); + * + * To get the result of the range: + * range.forEach(function (x) { + * console.log(x); + * }); + * range.map(function (x) { + * return math.sin(x); + * }); + * range.toArray(); + * + * Example usage: + * var c = new Range(2, 6); // 2:1:5 + * c.toArray(); // [2, 3, 4, 5] + * var d = new Range(2, -3, -1); // 2:-1:-2 + * d.toArray(); // [2, 1, 0, -1, -2] + * + * @class Range + * @constructor Range + * @param {number} start included lower bound + * @param {number} end excluded upper bound + * @param {number} [step] step size, default value is 1 + */ + function Range(start, end, step) { + if (!(this instanceof Range)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (start != null) { + if (start.isBigNumber === true) + start = start.toNumber(); + else if (typeof start !== 'number') + throw new TypeError('Parameter start must be a number'); + } + if (end != null) { + if (end.isBigNumber === true) + end = end.toNumber(); + else if (typeof end !== 'number') + throw new TypeError('Parameter end must be a number'); + } + if (step != null) { + if (step.isBigNumber === true) + step = step.toNumber(); + else if (typeof step !== 'number') + throw new TypeError('Parameter step must be a number'); + } + + this.start = (start != null) ? parseFloat(start) : 0; + this.end = (end != null) ? parseFloat(end) : 0; + this.step = (step != null) ? parseFloat(step) : 1; + } + + /** + * Attach type information + */ + Range.prototype.type = 'Range'; + Range.prototype.isRange = true; + + /** + * Parse a string into a range, + * The string contains the start, optional step, and end, separated by a colon. + * If the string does not contain a valid range, null is returned. + * For example str='0:2:11'. + * @memberof Range + * @param {string} str + * @return {Range | null} range + */ + Range.parse = function (str) { + if (typeof str !== 'string') { + return null; + } + + var args = str.split(':'); + var nums = args.map(function (arg) { + return parseFloat(arg); + }); + + var invalid = nums.some(function (num) { + return isNaN(num); + }); + if (invalid) { + return null; + } + + switch (nums.length) { + case 2: + return new Range(nums[0], nums[1]); + case 3: + return new Range(nums[0], nums[2], nums[1]); + default: + return null; + } + }; + + /** + * Create a clone of the range + * @return {Range} clone + */ + Range.prototype.clone = function () { + return new Range(this.start, this.end, this.step); + }; + + /** + * Retrieve the size of the range. + * Returns an array containing one number, the number of elements in the range. + * @memberof Range + * @returns {number[]} size + */ + Range.prototype.size = function () { + var len = 0, + start = this.start, + step = this.step, + end = this.end, + diff = end - start; + + if (number.sign(step) == number.sign(diff)) { + len = Math.ceil((diff) / step); + } + else if (diff == 0) { + len = 0; + } + + if (isNaN(len)) { + len = 0; + } + return [len]; + }; + + /** + * Calculate the minimum value in the range + * @memberof Range + * @return {number | undefined} min + */ + Range.prototype.min = function () { + var size = this.size()[0]; + + if (size > 0) { + if (this.step > 0) { + // positive step + return this.start; + } + else { + // negative step + return this.start + (size - 1) * this.step; + } + } + else { + return undefined; + } + }; + + /** + * Calculate the maximum value in the range + * @memberof Range + * @return {number | undefined} max + */ + Range.prototype.max = function () { + var size = this.size()[0]; + + if (size > 0) { + if (this.step > 0) { + // positive step + return this.start + (size - 1) * this.step; + } + else { + // negative step + return this.start; + } + } + else { + return undefined; + } + }; + + + /** + * Execute a callback function for each value in the range. + * @memberof Range + * @param {function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the Range being traversed. + */ + Range.prototype.forEach = function (callback) { + var x = this.start; + var step = this.step; + var end = this.end; + var i = 0; + + if (step > 0) { + while (x < end) { + callback(x, [i], this); + x += step; + i++; + } + } + else if (step < 0) { + while (x > end) { + callback(x, [i], this); + x += step; + i++; + } + } + }; + + /** + * Execute a callback function for each value in the Range, and return the + * results as an array + * @memberof Range + * @param {function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * @returns {Array} array + */ + Range.prototype.map = function (callback) { + var array = []; + this.forEach(function (value, index, obj) { + array[index[0]] = callback(value, index, obj); + }); + return array; + }; + + /** + * Create an Array with a copy of the Ranges data + * @memberof Range + * @returns {Array} array + */ + Range.prototype.toArray = function () { + var array = []; + this.forEach(function (value, index) { + array[index[0]] = value; + }); + return array; + }; + + /** + * Get the primitive value of the Range, a one dimensional array + * @memberof Range + * @returns {Array} array + */ + Range.prototype.valueOf = function () { + // TODO: implement a caching mechanism for range.valueOf() + return this.toArray(); + }; + + /** + * Get a string representation of the range, with optional formatting options. + * Output is formatted as 'start:step:end', for example '2:6' or '0:0.2:11' + * @memberof Range + * @param {Object | number | function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @returns {string} str + */ + Range.prototype.format = function (options) { + var str = number.format(this.start, options); + + if (this.step != 1) { + str += ':' + number.format(this.step, options); + } + str += ':' + number.format(this.end, options); + return str; + }; + + /** + * Get a string representation of the range. + * @memberof Range + * @returns {string} + */ + Range.prototype.toString = function () { + return this.format(); + }; + + /** + * Get a JSON representation of the range + * @memberof Range + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` + */ + Range.prototype.toJSON = function () { + return { + mathjs: 'Range', + start: this.start, + end: this.end, + step: this.step + }; + }; + + /** + * Instantiate a Range from a JSON object + * @memberof Range + * @param {Object} json A JSON object structured as: + * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` + * @return {Range} + */ + Range.fromJSON = function (json) { + return new Range(json.start, json.end, json.step); + }; + + return Range; + } + + exports.name = 'Range'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 68 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Create an index. An Index can store ranges having start, step, and end + * for multiple dimensions. + * Matrix.get, Matrix.set, and math.subset accept an Index as input. + * + * Syntax: + * + * math.index(range1, range2, ...) + * + * Where each range can be any of: + * + * - A number + * - A string for getting/setting an object property + * - An instance of `Range` + * - A one-dimensional Array or a Matrix with numbers + * + * Indexes must be zero-based, integer numbers. + * + * Examples: + * + * var math = math.js + * + * var b = [1, 2, 3, 4, 5]; + * math.subset(b, math.index([1, 2, 3])); // returns [2, 3, 4] + * + * var a = math.matrix([[1, 2], [3, 4]]); + * a.subset(math.index(0, 1)); // returns 2 + * + * See also: + * + * bignumber, boolean, complex, matrix, number, string, unit + * + * @param {...*} ranges Zero or more ranges or numbers. + * @return {Index} Returns the created index + */ + return typed('index', { + '...number | string | BigNumber | Range | Array | Matrix': function (args) { + var ranges = args.map(function (arg) { + if (arg && arg.isBigNumber === true) { + return arg.toNumber(); // convert BigNumber to Number + } + else if (arg && (Array.isArray(arg) || arg.isMatrix === true)) { + return arg.map(function (elem) { + // convert BigNumber to Number + return (elem && elem.isBigNumber === true) ? elem.toNumber() : elem; + }); + } + else { + return arg; + } + }); + + var res = new type.Index(); + type.Index.apply(res, ranges); + return res; + } + }); + } + + exports.name = 'index'; + exports.factory = factory; + + +/***/ }, +/* 69 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var SparseMatrix = type.SparseMatrix; + + /** + * Create a Sparse Matrix. The function creates a new `math.type.Matrix` object from + * an `Array`. A Matrix has utility functions to manipulate the data in the + * matrix, like getting the size and getting or setting values in the matrix. + * + * Syntax: + * + * math.sparse() // creates an empty sparse matrix. + * math.sparse(data) // creates a sparse matrix with initial data. + * math.sparse(data, 'number') // creates a sparse matrix with initial data, number datatype. + * + * Examples: + * + * var m = math.sparse([[1, 2], [3, 4]]); + * m.size(); // Array [2, 2] + * m.resize([3, 2], 5); + * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] + * m.get([1, 0]) // number 3 + * + * See also: + * + * bignumber, boolean, complex, index, number, string, unit, matrix + * + * @param {Array | Matrix} [data] A two dimensional array + * + * @return {Matrix} The created matrix + */ + var sparse = typed('sparse', { + '': function () { + return new SparseMatrix([]); + }, + + 'string': function (datatype) { + return new SparseMatrix([], datatype); + }, + + 'Array | Matrix': function (data) { + return new SparseMatrix(data); + }, + + 'Array | Matrix, string': function (data, datatype) { + return new SparseMatrix(data, datatype); + } + }); + + sparse.toTex = { + 0: '\\begin{bsparse}\\end{bsparse}', + 1: '\\left(${args[0]}\\right)' + }; + + return sparse; + } + + exports.name = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 70 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Create a number or convert a string, boolean, or unit to a number. + * When value is a matrix, all elements will be converted to number. + * + * Syntax: + * + * math.number(value) + * math.number(unit, valuelessUnit) + * + * Examples: + * + * math.number(2); // returns number 2 + * math.number('7.2'); // returns number 7.2 + * math.number(true); // returns number 1 + * math.number([true, false, true, true]); // returns [1, 0, 1, 1] + * math.number(math.unit('52cm'), 'm'); // returns 0.52 + * + * See also: + * + * bignumber, boolean, complex, index, matrix, string, unit + * + * @param {string | number | BigNumber | Fraction | boolean | Array | Matrix | Unit | null} [value] Value to be converted + * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number + * @return {number | Array | Matrix} The created number + */ + var number = typed('number', { + '': function () { + return 0; + }, + + 'number': function (x) { + return x; + }, + + 'string': function (x) { + var num = Number(x); + if (isNaN(num)) { + throw new SyntaxError('String "' + x + '" is no valid number'); + } + return num; + }, + + 'BigNumber': function (x) { + return x.toNumber(); + }, + + 'Fraction': function (x) { + return x.valueOf(); + }, + + 'Unit': function (x) { + throw new Error('Second argument with valueless unit expected'); + }, + + 'Unit, string | Unit': function (unit, valuelessUnit) { + return unit.toNumber(valuelessUnit); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, number); + } + }); + + number.toTex = { + 0: '0', + 1: '\\left(${args[0]}\\right)', + 2: '\\left(\\left(${args[0]}\\right)${args[1]}\\right)' + }; + + return number; + } + + exports.name = 'number'; + exports.factory = factory; + + +/***/ }, +/* 71 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(72) + ]; + + +/***/ }, +/* 72 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * A ResultSet contains a list or results + * @class ResultSet + * @param {Array} entries + * @constructor ResultSet + */ + function ResultSet(entries) { + if (!(this instanceof ResultSet)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.entries = entries || []; + } + + /** + * Attach type information + */ + ResultSet.prototype.type = 'ResultSet'; + ResultSet.prototype.isResultSet = true; + + /** + * Returns the array with results hold by this ResultSet + * @memberof ResultSet + * @returns {Array} entries + */ + ResultSet.prototype.valueOf = function () { + return this.entries; + }; + + /** + * Returns the stringified results of the ResultSet + * @memberof ResultSet + * @returns {string} string + */ + ResultSet.prototype.toString = function () { + return '[' + this.entries.join(', ') + ']'; + }; + + /** + * Get a JSON representation of the ResultSet + * @memberof ResultSet + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "ResultSet", "entries": [...]}` + */ + ResultSet.prototype.toJSON = function () { + return { + mathjs: 'ResultSet', + entries: this.entries + }; + }; + + /** + * Instantiate a ResultSet from a JSON object + * @memberof ResultSet + * @param {Object} json A JSON object structured as: + * `{"mathjs": "ResultSet", "entries": [...]}` + * @return {ResultSet} + */ + ResultSet.fromJSON = function (json) { + return new ResultSet(json.entries); + }; + + return ResultSet; + } + + exports.name = 'ResultSet'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 73 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Create a string or convert any object into a string. + * Elements of Arrays and Matrices are processed element wise. + * + * Syntax: + * + * math.string(value) + * + * Examples: + * + * math.string(4.2); // returns string '4.2' + * math.string(math.complex(3, 2); // returns string '3 + 2i' + * + * var u = math.unit(5, 'km'); + * math.string(u.to('m')); // returns string '5000 m' + * + * math.string([true, false]); // returns ['true', 'false'] + * + * See also: + * + * bignumber, boolean, complex, index, matrix, number, unit + * + * @param {* | Array | Matrix | null} [value] A value to convert to a string + * @return {string | Array | Matrix} The created string + */ + var string = typed('string', { + '': function () { + return ''; + }, + + 'number': number.format, + + 'null': function (x) { + return 'null'; + }, + + 'boolean': function (x) { + return x + ''; + }, + + 'string': function (x) { + return x; + }, + + 'Array | Matrix': function (x) { + return deepMap(x, string); + }, + + 'any': function (x) { + return String(x); + } + }); + + string.toTex = { + 0: '\\mathtt{""}', + 1: '\\mathrm{string}\\left(${args[0]}\\right)' + }; + + return string; + } + + exports.name = 'string'; + exports.factory = factory; + + +/***/ }, +/* 74 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // type + __webpack_require__(75), + + // construction function + __webpack_require__(91), + + // physical constants + __webpack_require__(92) + ]; + + +/***/ }, +/* 75 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var endsWith = __webpack_require__(23).endsWith; + var clone = __webpack_require__(3).clone; + var constants = __webpack_require__(76); + + function factory (type, config, load, typed, math) { + var add = load(__webpack_require__(53)); + var subtract = load(__webpack_require__(77)); + var multiply = load(__webpack_require__(80)); + var divide = load(__webpack_require__(81)); + var pow = load(__webpack_require__(82)); + var abs = load(__webpack_require__(86)); + var equal = load(__webpack_require__(87)); + var isNumeric = load(__webpack_require__(88)); + var format = load(__webpack_require__(89)); + var getTypeOf = load(__webpack_require__(90)); + var toNumber = load(__webpack_require__(70)); + var Complex = load(__webpack_require__(27)); + + /** + * A unit can be constructed in the following ways: + * var a = new Unit(value, name); + * var b = new Unit(null, name); + * var c = Unit.parse(str); + * + * Example usage: + * var a = new Unit(5, 'cm'); // 50 mm + * var b = Unit.parse('23 kg'); // 23 kg + * var c = math.in(a, new Unit(null, 'm'); // 0.05 m + * var d = new Unit(9.81, "m/s^2"); // 9.81 m/s^2 + * + * @class Unit + * @constructor Unit + * @param {number | BigNumber | Fraction | Complex | boolean} [value] A value like 5.2 + * @param {string} [name] A unit name like "cm" or "inch", or a derived unit of the form: "u1[^ex1] [u2[^ex2] ...] [/ u3[^ex3] [u4[^ex4]]]", such as "kg m^2/s^2", where each unit appearing after the forward slash is taken to be in the denominator. "kg m^2 s^-2" is a synonym and is also acceptable. Any of the units can include a prefix. + */ + function Unit(value, name) { + if (!(this instanceof Unit)) { + throw new Error('Constructor must be called with the new operator'); + } + + if (!(value === undefined || isNumeric(value) || value.isComplex)) { + throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined'); + } + if (name != undefined && (typeof name !== 'string' || name == '')) { + throw new TypeError('Second parameter in Unit constructor must be a string'); + } + + if (name != undefined) { + var u = Unit.parse(name); + this.units = u.units; + this.dimensions = u.dimensions; + } + else { + this.units = [ + { + unit: UNIT_NONE, + prefix: PREFIXES.NONE, // link to a list with supported prefixes + power: 0 + } + ]; + this.dimensions = [0, 0, 0, 0, 0, 0, 0, 0, 0]; + } + + this.value = (value != undefined) ? this._normalize(value) : null; + + this.fixPrefix = false; // if true, function format will not search for the + // best prefix but leave it as initially provided. + // fixPrefix is set true by the method Unit.to + + // The justification behind this is that if the constructor is explicitly called, + // the caller wishes the units to be returned exactly as he supplied. + this.isUnitListSimplified = true; + + } + + /** + * Attach type information + */ + Unit.prototype.type = 'Unit'; + Unit.prototype.isUnit = true; + + // private variables and functions for the Unit parser + var text, index, c; + + function skipWhitespace() { + while (c == ' ' || c == '\t') { + next(); + } + } + + function isDigitDot(c) { + return ((c >= '0' && c <= '9') || c == '.'); + } + + function isDigit(c) { + return ((c >= '0' && c <= '9')); + } + + function next() { + index++; + c = text.charAt(index); + } + + function revert(oldIndex) { + index = oldIndex; + c = text.charAt(index); + } + + function parseNumber() { + var number = ''; + var oldIndex; + oldIndex = index; + + if (c == '+') { + next(); + } + else if (c == '-') { + number += c; + next(); + } + + if (!isDigitDot(c)) { + // a + or - must be followed by a digit + revert(oldIndex); + return null; + } + + // get number, can have a single dot + if (c == '.') { + number += c; + next(); + if (!isDigit(c)) { + // this is no legal number, it is just a dot + revert(oldIndex); + return null; + } + } + else { + while (isDigit(c)) { + number += c; + next(); + } + if (c == '.') { + number += c; + next(); + } + } + while (isDigit(c)) { + number += c; + next(); + } + + // check for exponential notation like "2.3e-4" or "1.23e50" + if (c == 'E' || c == 'e') { + // The grammar branches here. This could either be part of an exponent or the start of a unit that begins with the letter e, such as "4exabytes" + + var tentativeNumber = ''; + var tentativeIndex = index; + + tentativeNumber += c; + next(); + + if (c == '+' || c == '-') { + tentativeNumber += c; + next(); + } + + // Scientific notation MUST be followed by an exponent (otherwise we assume it is not scientific notation) + if (!isDigit(c)) { + // The e or E must belong to something else, so return the number without the e or E. + revert(tentativeIndex); + return number; + } + + // We can now safely say that this is scientific notation. + number = number + tentativeNumber; + while (isDigit(c)) { + number += c; + next(); + } + } + + return number; + } + + function parseUnit() { + var unitName = ''; + + // Alphanumeric characters only; matches [a-zA-Z0-9] + var code = text.charCodeAt(index); + while ( (code >= 48 && code <= 57) || + (code >= 65 && code <= 90) || + (code >= 97 && code <= 122)) { + unitName += c; + next(); + code = text.charCodeAt(index); + } + + // Must begin with [a-zA-Z] + code = unitName.charCodeAt(0); + if ((code >= 65 && code <= 90) || + (code >= 97 && code <= 122)) { + return unitName || null; + } + else { + return null; + } + } + + function parseCharacter(toFind) { + if (c === toFind) { + next(); + return toFind; + } + else { + return null; + } + } + + /** + * Parse a string into a unit. The value of the unit is parsed as number, + * BigNumber, or Fraction depending on the math.js config setting `number`. + * + * Throws an exception if the provided string does not contain a valid unit or + * cannot be parsed. + * @memberof Unit + * @param {string} str A string like "5.2 inch", "4e2 cm/s^2" + * @return {Unit} unit + */ + Unit.parse = function (str) { + text = str; + index = -1; + c = ''; + + if (typeof text !== 'string') { + throw new TypeError('Invalid argument in Unit.parse, string expected'); + } + + var unit = new Unit(); + unit.units = []; + + // A unit should follow this pattern: + // [number]unit[^number] [unit[^number]]...[/unit[^number] [unit[^number]]] + + // Rules: + // number is any floating point number. + // unit is any alphanumeric string beginning with an alpha. Units with names like e3 should be avoided because they look like the exponent of a floating point number! + // The string may optionally begin with a number. + // Each unit may optionally be followed by ^number. + // Whitespace or a forward slash is recommended between consecutive units, although the following technically is parseable: + // 2m^2kg/s^2 + // it is not good form. If a unit starts with e, then it could be confused as a floating point number: + // 4erg + + next(); + skipWhitespace(); + // Optional number at the start of the string + var valueStr = parseNumber(); + var value = null; + if(valueStr) { + if (config.number === 'BigNumber') { + value = new type.BigNumber(valueStr); + } + else if (config.number === 'Fraction') { + value = new type.Fraction(valueStr); + } + else { // number + value = parseFloat(valueStr); + } + } + skipWhitespace(); // Whitespace is not required here + + // Next, we read any number of unit[^number] + var powerMultiplierCurrent = 1; + var expectingUnit = false; + + // Stack to keep track of powerMultipliers applied to each parentheses group + var powerMultiplierStack = []; + + // Running product of all elements in powerMultiplierStack + var powerMultiplierStackProduct = 1; + + while (true) { + skipWhitespace(); + + // Check for and consume opening parentheses, pushing powerMultiplierCurrent to the stack + // A '(' will always appear directly before a unit. + while (c === '(') { + powerMultiplierStack.push(powerMultiplierCurrent); + powerMultiplierStackProduct *= powerMultiplierCurrent; + powerMultiplierCurrent = 1; + next(); + skipWhitespace(); + } + + // Is there something here? + if(c) { + var oldC = c; + var uStr = parseUnit(); + if(uStr == null) { + throw new SyntaxError('Unexpected "' + oldC + '" in "' + text + '" at index ' + index.toString()); + } + } + else { + // End of input. + break; + } + + // Verify the unit exists and get the prefix (if any) + var res = _findUnit(uStr); + if(res == null) { + // Unit not found. + throw new SyntaxError('Unit "' + uStr + '" not found.'); + } + + var power = powerMultiplierCurrent * powerMultiplierStackProduct; + // Is there a "^ number"? + skipWhitespace(); + if (parseCharacter('^')) { + skipWhitespace(); + var p = parseNumber(); + if(p == null) { + // No valid number found for the power! + throw new SyntaxError('In "' + str + '", "^" must be followed by a floating-point number'); + } + power *= p; + } + + // Add the unit to the list + unit.units.push( { + unit: res.unit, + prefix: res.prefix, + power: power + }); + for(var i=0; i 1 || Math.abs(this.units[0].power - 1.0) > 1e-15; + }; + + /** + * Normalize a value, based on its currently set unit(s) + * @memberof Unit + * @param {number | BigNumber | Fraction | boolean} value + * @return {number | BigNumber | Fraction | boolean} normalized value + * @private + */ + Unit.prototype._normalize = function (value) { + var unitValue, unitOffset, unitPower, unitPrefixValue; + var convert; + + if (value == null || this.units.length === 0) { + return value; + } + else if (this._isDerived()) { + // This is a derived unit, so do not apply offsets. + // For example, with J kg^-1 degC^-1 you would NOT want to apply the offset. + var res = value; + convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed + + for(var i=0; i < this.units.length; i++) { + unitValue = convert(this.units[i].unit.value); + unitPrefixValue = convert(this.units[i].prefix.value); + unitPower = convert(this.units[i].power); + res = multiply(res, pow(multiply(unitValue, unitPrefixValue), unitPower)); + } + + return res; + } + else { + // This is a single unit of power 1, like kg or degC + convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed + + unitValue = convert(this.units[0].unit.value); + unitOffset = convert(this.units[0].unit.offset); + unitPrefixValue = convert(this.units[0].prefix.value); + + return multiply(add(value, unitOffset), multiply(unitValue, unitPrefixValue)); + } + }; + + /** + * Denormalize a value, based on its currently set unit(s) + * @memberof Unit + * @param {number} value + * @param {number} [prefixValue] Optional prefix value to be used (ignored if this is a derived unit) + * @return {number} denormalized value + * @private + */ + Unit.prototype._denormalize = function (value, prefixValue) { + var unitValue, unitOffset, unitPower, unitPrefixValue; + var convert; + + if (value == null || this.units.length === 0) { + return value; + } + else if (this._isDerived()) { + // This is a derived unit, so do not apply offsets. + // For example, with J kg^-1 degC^-1 you would NOT want to apply the offset. + // Also, prefixValue is ignored--but we will still use the prefix value stored in each unit, since kg is usually preferable to g unless the user decides otherwise. + var res = value; + convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed + + for (var i = 0; i < this.units.length; i++) { + unitValue = convert(this.units[i].unit.value); + unitPrefixValue = convert(this.units[i].prefix.value); + unitPower = convert(this.units[i].power); + res = divide(res, pow(multiply(unitValue, unitPrefixValue), unitPower)); + } + + return res; + } + else { + // This is a single unit of power 1, like kg or degC + convert = Unit._getNumberConverter(getTypeOf(value)); // convert to Fraction or BigNumber if needed + + unitValue = convert(this.units[0].unit.value); + unitPrefixValue = convert(this.units[0].prefix.value); + unitOffset = convert(this.units[0].unit.offset); + + if (prefixValue == undefined) { + return subtract(divide(divide(value, unitValue), unitPrefixValue), unitOffset); + } + else { + return subtract(divide(divide(value, unitValue), prefixValue), unitOffset); + } + } + }; + + /** + * Find a unit from a string + * @memberof Unit + * @param {string} str A string like 'cm' or 'inch' + * @returns {Object | null} result When found, an object with fields unit and + * prefix is returned. Else, null is returned. + * @private + */ + function _findUnit(str) { + for (var name in UNITS) { + if (UNITS.hasOwnProperty(name)) { + if (endsWith(str, name)) { + var unit = UNITS[name]; + var prefixLen = (str.length - name.length); + var prefixName = str.substring(0, prefixLen); + var prefix = unit.prefixes[prefixName]; + if (prefix !== undefined) { + // store unit, prefix, and value + return { + unit: unit, + prefix: prefix + }; + } + } + } + } + + return null; + } + + /** + * Test if the given expression is a unit. + * The unit can have a prefix but cannot have a value. + * @memberof Unit + * @param {string} name A string to be tested whether it is a value less unit. + * The unit can have prefix, like "cm" + * @return {boolean} true if the given string is a unit + */ + Unit.isValuelessUnit = function (name) { + return (_findUnit(name) != null); + }; + + /** + * check if this unit has given base unit + * If this unit is a derived unit, this will ALWAYS return false, since by definition base units are not derived. + * @memberof Unit + * @param {BASE_UNITS | string | undefined} base + */ + Unit.prototype.hasBase = function (base) { + + if(typeof(base) === "string") { + base = BASE_UNITS[base]; + } + + if(!base) + return false; + + + // All dimensions must be the same + for(var i=0; i 1e-12) { + return false; + } + } + return true; + + }; + + /** + * Check if this unit has a base or bases equal to another base or bases + * For derived units, the exponent on each base also must match + * @memberof Unit + * @param {Unit} other + * @return {boolean} true if equal base + */ + Unit.prototype.equalBase = function (other) { + // All dimensions must be the same + for(var i=0; i 1e-12) { + return false; + } + } + return true; + }; + + /** + * Check if this unit equals another unit + * @memberof Unit + * @param {Unit} other + * @return {boolean} true if both units are equal + */ + Unit.prototype.equals = function (other) { + return (this.equalBase(other) && equal(this.value, other.value)); + }; + + /** + * Multiply this unit with another one + * @memberof Unit + * @param {Unit} other + * @return {Unit} product of this unit and the other unit + */ + Unit.prototype.multiply = function (other) { + var res = this.clone(); + + for(var i = 0; i 1e-12) { + proposedUnitList.push({ + unit: currentUnitSystem[baseDim].unit, + prefix: currentUnitSystem[baseDim].prefix, + power: this.dimensions[i] + }); + } + } + + // Is the proposed unit list "simpler" than the existing one? + if(proposedUnitList.length < this.units.length) { + // Replace this unit list with the proposed list + this.units = proposedUnitList; + } + } + } + + this.isUnitListSimplified = true; + }; + + /** + * Get a string representation of the units of this Unit, without the value. + * @memberof Unit + * @return {string} + */ + Unit.prototype.formatUnits = function () { + + // Lazy evaluation of the unit list + this.simplifyUnitListLazy(); + + var strNum = ""; + var strDen = ""; + var nNum = 0; + var nDen = 0; + + for(var i=0; i 0) { + nNum++; + strNum += " " + this.units[i].prefix.name + this.units[i].unit.name; + if(Math.abs(this.units[i].power - 1.0) > 1e-15) { + strNum += "^" + this.units[i].power; + } + } + else if(this.units[i].power < 0) { + nDen++; + } + } + + if(nDen > 0) { + for(var i=0; i 0) { + strDen += " " + this.units[i].prefix.name + this.units[i].unit.name; + if(Math.abs(this.units[i].power + 1.0) > 1e-15) { + strDen += "^" + (-this.units[i].power); + } + } + else { + strDen += " " + this.units[i].prefix.name + this.units[i].unit.name; + strDen += "^" + (this.units[i].power); + } + } + } + } + // Remove leading " " + strNum = strNum.substr(1); + strDen = strDen.substr(1); + + // Add parans for better copy/paste back into the eval, for example, or for better pretty print formatting + if(nNum > 1 && nDen > 0) { + strNum = "(" + strNum + ")"; + } + if(nDen > 1 && nNum > 0) { + strDen = "(" + strDen + ")"; + } + + var str = strNum; + if(nNum > 0 && nDen > 0) { + str += " / "; + } + str += strDen; + + return str; + }; + + /** + * Get a string representation of the Unit, with optional formatting options. + * @memberof Unit + * @param {Object | number | Function} [options] Formatting options. See + * lib/utils/number:format for a + * description of the available + * options. + * @return {string} + */ + Unit.prototype.format = function (options) { + + // Simplfy the unit list, if necessary + this.simplifyUnitListLazy(); + + // Apply some custom logic for handling VA and VAR. The goal is to express the value of the unit as a real value, if possible. Otherwise, use a real-valued unit instead of a complex-valued one. + var isImaginary = false; + var isReal = true; + if(typeof(this.value) !== 'undefined' && this.value !== null && this.value.isComplex) { + // TODO: Make this better, for example, use relative magnitude of re and im rather than absolute + isImaginary = Math.abs(this.value.re) < 1e-14; + isReal = Math.abs(this.value.im) < 1e-14; + } + + for(var i in this.units) { + if(this.units[i].unit) { + if(this.units[i].unit.name === 'VA' && isImaginary) { + this.units[i].unit = UNITS["VAR"]; + } + else if(this.units[i].unit.name === 'VAR' && !isImaginary) { + this.units[i].unit = UNITS["VA"]; + } + } + } + + + // Now apply the best prefix + // Units must have only one unit and not have the fixPrefix flag set + if (this.units.length === 1 && !this.fixPrefix) { + // Units must have integer powers, otherwise the prefix will change the + // outputted value by not-an-integer-power-of-ten + if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) < 1e-14) { + // Apply the best prefix + this.units[0].prefix = this._bestPrefix(); + } + } + + var value = this._denormalize(this.value); + var str = (this.value !== null) ? format(value, options || {}) : ''; + var unitStr = this.formatUnits(); + if(this.value && this.value.isComplex) { + str = "(" + str + ")"; // Surround complex values with ( ) to enable better parsing + } + if(unitStr.length > 0 && str.length > 0) { + str += " "; + } + str += unitStr; + + return str; + }; + + /** + * Calculate the best prefix using current value. + * @memberof Unit + * @returns {Object} prefix + * @private + */ + Unit.prototype._bestPrefix = function () { + if (this.units.length !== 1) { + throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!"); + } + if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) >= 1e-14) { + throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!"); + } + + // find the best prefix value (resulting in the value of which + // the absolute value of the log10 is closest to zero, + // though with a little offset of 1.2 for nicer values: you get a + // sequence 1mm 100mm 500mm 0.6m 1m 10m 100m 500m 0.6km 1km ... + + // Note: the units value can be any numeric type, but to find the best + // prefix it's enough to work with limited precision of a regular number + // Update: using mathjs abs since we also allow complex numbers + var absValue = abs(this.value); + var absUnitValue = abs(this.units[0].unit.value); + var bestPrefix = this.units[0].prefix; + if (absValue === 0) { + return bestPrefix; + } + var power = this.units[0].power; + var bestDiff = Math.abs( + Math.log(absValue / Math.pow(bestPrefix.value * absUnitValue, power)) / Math.LN10 - 1.2); + + var prefixes = this.units[0].unit.prefixes; + for (var p in prefixes) { + if (prefixes.hasOwnProperty(p)) { + var prefix = prefixes[p]; + if (prefix.scientific) { + + var diff = Math.abs( + Math.log(absValue / Math.pow(prefix.value * absUnitValue, power)) / Math.LN10 - 1.2); + + if (diff < bestDiff + || (diff === bestDiff && prefix.name.length < bestPrefix.name.length)) { + // choose the prefix with the smallest diff, or if equal, choose the one + // with the shortest name (can happen with SHORTLONG for example) + bestPrefix = prefix; + bestDiff = diff; + } + } + } + } + + return bestPrefix; + }; + + var PREFIXES = { + NONE: { + '': {name: '', value: 1, scientific: true} + }, + SHORT: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e1, scientific: false}, + 'h': {name: 'h', value: 1e2, scientific: false}, + 'k': {name: 'k', value: 1e3, scientific: true}, + 'M': {name: 'M', value: 1e6, scientific: true}, + 'G': {name: 'G', value: 1e9, scientific: true}, + 'T': {name: 'T', value: 1e12, scientific: true}, + 'P': {name: 'P', value: 1e15, scientific: true}, + 'E': {name: 'E', value: 1e18, scientific: true}, + 'Z': {name: 'Z', value: 1e21, scientific: true}, + 'Y': {name: 'Y', value: 1e24, scientific: true}, + + 'd': {name: 'd', value: 1e-1, scientific: false}, + 'c': {name: 'c', value: 1e-2, scientific: false}, + 'm': {name: 'm', value: 1e-3, scientific: true}, + 'u': {name: 'u', value: 1e-6, scientific: true}, + 'n': {name: 'n', value: 1e-9, scientific: true}, + 'p': {name: 'p', value: 1e-12, scientific: true}, + 'f': {name: 'f', value: 1e-15, scientific: true}, + 'a': {name: 'a', value: 1e-18, scientific: true}, + 'z': {name: 'z', value: 1e-21, scientific: true}, + 'y': {name: 'y', value: 1e-24, scientific: true} + }, + LONG: { + '': {name: '', value: 1, scientific: true}, + + 'deca': {name: 'deca', value: 1e1, scientific: false}, + 'hecto': {name: 'hecto', value: 1e2, scientific: false}, + 'kilo': {name: 'kilo', value: 1e3, scientific: true}, + 'mega': {name: 'mega', value: 1e6, scientific: true}, + 'giga': {name: 'giga', value: 1e9, scientific: true}, + 'tera': {name: 'tera', value: 1e12, scientific: true}, + 'peta': {name: 'peta', value: 1e15, scientific: true}, + 'exa': {name: 'exa', value: 1e18, scientific: true}, + 'zetta': {name: 'zetta', value: 1e21, scientific: true}, + 'yotta': {name: 'yotta', value: 1e24, scientific: true}, + + 'deci': {name: 'deci', value: 1e-1, scientific: false}, + 'centi': {name: 'centi', value: 1e-2, scientific: false}, + 'milli': {name: 'milli', value: 1e-3, scientific: true}, + 'micro': {name: 'micro', value: 1e-6, scientific: true}, + 'nano': {name: 'nano', value: 1e-9, scientific: true}, + 'pico': {name: 'pico', value: 1e-12, scientific: true}, + 'femto': {name: 'femto', value: 1e-15, scientific: true}, + 'atto': {name: 'atto', value: 1e-18, scientific: true}, + 'zepto': {name: 'zepto', value: 1e-21, scientific: true}, + 'yocto': {name: 'yocto', value: 1e-24, scientific: true} + }, + SQUARED: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e2, scientific: false}, + 'h': {name: 'h', value: 1e4, scientific: false}, + 'k': {name: 'k', value: 1e6, scientific: true}, + 'M': {name: 'M', value: 1e12, scientific: true}, + 'G': {name: 'G', value: 1e18, scientific: true}, + 'T': {name: 'T', value: 1e24, scientific: true}, + 'P': {name: 'P', value: 1e30, scientific: true}, + 'E': {name: 'E', value: 1e36, scientific: true}, + 'Z': {name: 'Z', value: 1e42, scientific: true}, + 'Y': {name: 'Y', value: 1e48, scientific: true}, + + 'd': {name: 'd', value: 1e-2, scientific: false}, + 'c': {name: 'c', value: 1e-4, scientific: false}, + 'm': {name: 'm', value: 1e-6, scientific: true}, + 'u': {name: 'u', value: 1e-12, scientific: true}, + 'n': {name: 'n', value: 1e-18, scientific: true}, + 'p': {name: 'p', value: 1e-24, scientific: true}, + 'f': {name: 'f', value: 1e-30, scientific: true}, + 'a': {name: 'a', value: 1e-36, scientific: true}, + 'z': {name: 'z', value: 1e-42, scientific: true}, + 'y': {name: 'y', value: 1e-48, scientific: true} + }, + CUBIC: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e3, scientific: false}, + 'h': {name: 'h', value: 1e6, scientific: false}, + 'k': {name: 'k', value: 1e9, scientific: true}, + 'M': {name: 'M', value: 1e18, scientific: true}, + 'G': {name: 'G', value: 1e27, scientific: true}, + 'T': {name: 'T', value: 1e36, scientific: true}, + 'P': {name: 'P', value: 1e45, scientific: true}, + 'E': {name: 'E', value: 1e54, scientific: true}, + 'Z': {name: 'Z', value: 1e63, scientific: true}, + 'Y': {name: 'Y', value: 1e72, scientific: true}, + + 'd': {name: 'd', value: 1e-3, scientific: false}, + 'c': {name: 'c', value: 1e-6, scientific: false}, + 'm': {name: 'm', value: 1e-9, scientific: true}, + 'u': {name: 'u', value: 1e-18, scientific: true}, + 'n': {name: 'n', value: 1e-27, scientific: true}, + 'p': {name: 'p', value: 1e-36, scientific: true}, + 'f': {name: 'f', value: 1e-45, scientific: true}, + 'a': {name: 'a', value: 1e-54, scientific: true}, + 'z': {name: 'z', value: 1e-63, scientific: true}, + 'y': {name: 'y', value: 1e-72, scientific: true} + }, + BINARY_SHORT: { + '': {name: '', value: 1, scientific: true}, + 'k': {name: 'k', value: 1e3, scientific: true}, + 'M': {name: 'M', value: 1e6, scientific: true}, + 'G': {name: 'G', value: 1e9, scientific: true}, + 'T': {name: 'T', value: 1e12, scientific: true}, + 'P': {name: 'P', value: 1e15, scientific: true}, + 'E': {name: 'E', value: 1e18, scientific: true}, + 'Z': {name: 'Z', value: 1e21, scientific: true}, + 'Y': {name: 'Y', value: 1e24, scientific: true}, + + 'Ki': {name: 'Ki', value: 1024, scientific: true}, + 'Mi': {name: 'Mi', value: Math.pow(1024, 2), scientific: true}, + 'Gi': {name: 'Gi', value: Math.pow(1024, 3), scientific: true}, + 'Ti': {name: 'Ti', value: Math.pow(1024, 4), scientific: true}, + 'Pi': {name: 'Pi', value: Math.pow(1024, 5), scientific: true}, + 'Ei': {name: 'Ei', value: Math.pow(1024, 6), scientific: true}, + 'Zi': {name: 'Zi', value: Math.pow(1024, 7), scientific: true}, + 'Yi': {name: 'Yi', value: Math.pow(1024, 8), scientific: true} + }, + BINARY_LONG: { + '': {name: '', value: 1, scientific: true}, + 'kilo': {name: 'kilo', value: 1e3, scientific: true}, + 'mega': {name: 'mega', value: 1e6, scientific: true}, + 'giga': {name: 'giga', value: 1e9, scientific: true}, + 'tera': {name: 'tera', value: 1e12, scientific: true}, + 'peta': {name: 'peta', value: 1e15, scientific: true}, + 'exa': {name: 'exa', value: 1e18, scientific: true}, + 'zetta': {name: 'zetta', value: 1e21, scientific: true}, + 'yotta': {name: 'yotta', value: 1e24, scientific: true}, + + 'kibi': {name: 'kibi', value: 1024, scientific: true}, + 'mebi': {name: 'mebi', value: Math.pow(1024, 2), scientific: true}, + 'gibi': {name: 'gibi', value: Math.pow(1024, 3), scientific: true}, + 'tebi': {name: 'tebi', value: Math.pow(1024, 4), scientific: true}, + 'pebi': {name: 'pebi', value: Math.pow(1024, 5), scientific: true}, + 'exi': {name: 'exi', value: Math.pow(1024, 6), scientific: true}, + 'zebi': {name: 'zebi', value: Math.pow(1024, 7), scientific: true}, + 'yobi': {name: 'yobi', value: Math.pow(1024, 8), scientific: true} + }, + BTU: { + '': {name: '', value: 1, scientific: true}, + 'MM': {name: 'MM', value: 1e6, scientific: true} + } + }; + + // Add a prefix list for both short and long prefixes (for ohm in particular, since Mohm and megaohm are both acceptable): + PREFIXES.SHORTLONG = {}; + for (var key in PREFIXES.SHORT) { + if(PREFIXES.SHORT.hasOwnProperty(key)) { + PREFIXES.SHORTLONG[key] = PREFIXES.SHORT[key]; + } + } + for (var key in PREFIXES.LONG) { + if(PREFIXES.LONG.hasOwnProperty(key)) { + PREFIXES.SHORTLONG[key] = PREFIXES.LONG[key]; + } + } + + /* Internally, each unit is represented by a value and a dimension array. The elements of the dimensions array have the following meaning: + * Index Dimension + * ----- --------- + * 0 Length + * 1 Mass + * 2 Time + * 3 Current + * 4 Temperature + * 5 Luminous intensity + * 6 Amount of substance + * 7 Angle + * 8 Bit (digital) + * For example, the unit "298.15 K" is a pure temperature and would have a value of 298.15 and a dimension array of [0, 0, 0, 0, 1, 0, 0, 0, 0]. The unit "1 cal / (gm °C)" can be written in terms of the 9 fundamental dimensions as [length^2] / ([time^2] * [temperature]), and would a value of (after conversion to SI) 4184.0 and a dimensions array of [2, 0, -2, 0, -1, 0, 0, 0, 0]. + * + */ + + var BASE_DIMENSIONS = ["MASS", "LENGTH", "TIME", "CURRENT", "TEMPERATURE", "LUMINOUS_INTENSITY", "AMOUNT_OF_SUBSTANCE", "ANGLE", "BIT"]; + + var BASE_UNITS = { + NONE: { + dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 0] + }, + MASS: { + dimensions: [1, 0, 0, 0, 0, 0, 0, 0, 0] + }, + LENGTH: { + dimensions: [0, 1, 0, 0, 0, 0, 0, 0, 0] + }, + TIME: { + dimensions: [0, 0, 1, 0, 0, 0, 0, 0, 0] + }, + CURRENT: { + dimensions: [0, 0, 0, 1, 0, 0, 0, 0, 0] + }, + TEMPERATURE: { + dimensions: [0, 0, 0, 0, 1, 0, 0, 0, 0] + }, + LUMINOUS_INTENSITY: { + dimensions: [0, 0, 0, 0, 0, 1, 0, 0, 0] + }, + AMOUNT_OF_SUBSTANCE: { + dimensions: [0, 0, 0, 0, 0, 0, 1, 0, 0] + }, + + FORCE: { + dimensions: [1, 1, -2, 0, 0, 0, 0, 0, 0] + }, + SURFACE: { + dimensions: [0, 2, 0, 0, 0, 0, 0, 0, 0] + }, + VOLUME: { + dimensions: [0, 3, 0, 0, 0, 0, 0, 0, 0] + }, + ENERGY: { + dimensions: [1, 2, -2, 0, 0, 0, 0, 0, 0] + }, + POWER: { + dimensions: [1, 2, -3, 0, 0, 0, 0, 0, 0] + }, + PRESSURE: { + dimensions: [1, -1, -2, 0, 0, 0, 0, 0, 0] + }, + + ELECTRIC_CHARGE: { + dimensions: [0, 0, 1, 1, 0, 0, 0, 0, 0] + }, + ELECTRIC_CAPACITANCE: { + dimensions: [-1, -2, 4, 2, 0, 0, 0, 0, 0] + }, + ELECTRIC_POTENTIAL: { + dimensions: [1, 2, -3, -1, 0, 0, 0, 0, 0] + }, + ELECTRIC_RESISTANCE: { + dimensions: [1, 2, -3, -2, 0, 0, 0, 0, 0] + }, + ELECTRIC_INDUCTANCE: { + dimensions: [1, 2, -2, -2, 0, 0, 0, 0, 0] + }, + ELECTRIC_CONDUCTANCE: { + dimensions: [-1, -2, 3, 2, 0, 0, 0, 0, 0] + }, + MAGNETIC_FLUX: { + dimensions: [1, 2, -2, -1, 0, 0, 0, 0, 0] + }, + MAGNETIC_FLUX_DENSITY: { + dimensions: [1, 0, -2, -1, 0, 0, 0, 0, 0] + }, + + FREQUENCY: { + dimensions: [0, 0, -1, 0, 0, 0, 0, 0, 0] + }, + ANGLE: { + dimensions: [0, 0, 0, 0, 0, 0, 0, 1, 0] + }, + BIT: { + dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 1] + } + }; + + for(var key in BASE_UNITS) { + BASE_UNITS[key].key = key; + } + + var BASE_UNIT_NONE = {}; + + var UNIT_NONE = {name: '', base: BASE_UNIT_NONE, value: 1, offset: 0, dimensions: [0,0,0,0,0,0,0,0,0]}; + + var UNITS = { + // length + meter: { + name: 'meter', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + inch: { + name: 'inch', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0254, + offset: 0 + }, + foot: { + name: 'foot', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.3048, + offset: 0 + }, + yard: { + name: 'yard', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.9144, + offset: 0 + }, + mile: { + name: 'mile', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1609.344, + offset: 0 + }, + link: { + name: 'link', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.201168, + offset: 0 + }, + rod: { + name: 'rod', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 5.029210, + offset: 0 + }, + chain: { + name: 'chain', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 20.1168, + offset: 0 + }, + angstrom: { + name: 'angstrom', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1e-10, + offset: 0 + }, + + m: { + name: 'm', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + 'in': { + name: 'in', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0254, + offset: 0 + }, + ft: { + name: 'ft', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.3048, + offset: 0 + }, + yd: { + name: 'yd', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.9144, + offset: 0 + }, + mi: { + name: 'mi', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1609.344, + offset: 0 + }, + li: { + name: 'li', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.201168, + offset: 0 + }, + rd: { + name: 'rd', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 5.029210, + offset: 0 + }, + ch: { + name: 'ch', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 20.1168, + offset: 0 + }, + mil: { + name: 'mil', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0000254, + offset: 0 + }, // 1/1000 inch + + // Surface + m2: { + name: 'm2', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.SQUARED, + value: 1, + offset: 0 + }, + sqin: { + name: 'sqin', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.00064516, + offset: 0 + }, // 645.16 mm2 + sqft: { + name: 'sqft', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.09290304, + offset: 0 + }, // 0.09290304 m2 + sqyd: { + name: 'sqyd', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.83612736, + offset: 0 + }, // 0.83612736 m2 + sqmi: { + name: 'sqmi', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 2589988.110336, + offset: 0 + }, // 2.589988110336 km2 + sqrd: { + name: 'sqrd', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 25.29295, + offset: 0 + }, // 25.29295 m2 + sqch: { + name: 'sqch', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 404.6873, + offset: 0 + }, // 404.6873 m2 + sqmil: { + name: 'sqmil', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 6.4516e-10, + offset: 0 + }, // 6.4516 * 10^-10 m2 + acre: { + name: 'acre', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 4046.86, + offset: 0 + }, // 4046.86 m2 + hectare: { + name: 'hectare', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 10000, + offset: 0 + }, // 10000 m2 + + // Volume + m3: { + name: 'm3', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.CUBIC, + value: 1, + offset: 0 + }, + L: { + name: 'L', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, // litre + l: { + name: 'l', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, // litre + litre: { + name: 'litre', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.LONG, + value: 0.001, + offset: 0 + }, + cuin: { + name: 'cuin', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 1.6387064e-5, + offset: 0 + }, // 1.6387064e-5 m3 + cuft: { + name: 'cuft', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.028316846592, + offset: 0 + }, // 28.316 846 592 L + cuyd: { + name: 'cuyd', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.764554857984, + offset: 0 + }, // 764.554 857 984 L + teaspoon: { + name: 'teaspoon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.000005, + offset: 0 + }, // 5 mL + tablespoon: { + name: 'tablespoon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.000015, + offset: 0 + }, // 15 mL + //{name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup + drop: { + name: 'drop', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 5e-8, + offset: 0 + }, // 0.05 mL = 5e-8 m3 + gtt: { + name: 'gtt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 5e-8, + offset: 0 + }, // 0.05 mL = 5e-8 m3 + + // Liquid volume + minim: { + name: 'minim', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00000006161152, + offset: 0 + }, // 0.06161152 mL + fluiddram: { + name: 'fluiddram', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0000036966911, + offset: 0 + }, // 3.696691 mL + fluidounce: { + name: 'fluidounce', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00002957353, + offset: 0 + }, // 29.57353 mL + gill: { + name: 'gill', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0001182941, + offset: 0 + }, // 118.2941 mL + cc: { + name: 'cc', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 1e-6, + offset: 0 + }, // 1e-6 L + cup: { + name: 'cup', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0002365882, + offset: 0 + }, // 236.5882 mL + pint: { + name: 'pint', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0004731765, + offset: 0 + }, // 473.1765 mL + quart: { + name: 'quart', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0009463529, + offset: 0 + }, // 946.3529 mL + gallon: { + name: 'gallon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.003785412, + offset: 0 + }, // 3.785412 L + beerbarrel: { + name: 'beerbarrel', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1173478, + offset: 0 + }, // 117.3478 L + oilbarrel: { + name: 'oilbarrel', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1589873, + offset: 0 + }, // 158.9873 L + hogshead: { + name: 'hogshead', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.2384810, + offset: 0 + }, // 238.4810 L + + //{name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute + fldr: { + name: 'fldr', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0000036966911, + offset: 0 + }, // 3.696691 mL + floz: { + name: 'floz', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00002957353, + offset: 0 + }, // 29.57353 mL + gi: { + name: 'gi', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0001182941, + offset: 0 + }, // 118.2941 mL + cp: { + name: 'cp', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0002365882, + offset: 0 + }, // 236.5882 mL + pt: { + name: 'pt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0004731765, + offset: 0 + }, // 473.1765 mL + qt: { + name: 'qt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0009463529, + offset: 0 + }, // 946.3529 mL + gal: { + name: 'gal', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.003785412, + offset: 0 + }, // 3.785412 L + bbl: { + name: 'bbl', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1173478, + offset: 0 + }, // 117.3478 L + obl: { + name: 'obl', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1589873, + offset: 0 + }, // 158.9873 L + //{name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh? + + // Mass + g: { + name: 'g', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, + gram: { + name: 'gram', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.LONG, + value: 0.001, + offset: 0 + }, + + ton: { + name: 'ton', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 907.18474, + offset: 0 + }, + tonne: { + name: 'tonne', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 1000, + offset: 0 + }, + + grain: { + name: 'grain', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 64.79891e-6, + offset: 0 + }, + dram: { + name: 'dram', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 1.7718451953125e-3, + offset: 0 + }, + ounce: { + name: 'ounce', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 28.349523125e-3, + offset: 0 + }, + poundmass: { + name: 'poundmass', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 453.59237e-3, + offset: 0 + }, + hundredweight: { + name: 'hundredweight', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 45.359237, + offset: 0 + }, + stick: { + name: 'stick', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 115e-3, + offset: 0 + }, + stone: { + name: 'stone', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 6.35029318, + offset: 0 + }, + + gr: { + name: 'gr', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 64.79891e-6, + offset: 0 + }, + dr: { + name: 'dr', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 1.7718451953125e-3, + offset: 0 + }, + oz: { + name: 'oz', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 28.349523125e-3, + offset: 0 + }, + lbm: { + name: 'lbm', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 453.59237e-3, + offset: 0 + }, + cwt: { + name: 'cwt', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 45.359237, + offset: 0 + }, + + // Time + s: { + name: 's', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + min: { + name: 'min', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 60, + offset: 0 + }, + h: { + name: 'h', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 3600, + offset: 0 + }, + second: { + name: 'second', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + sec: { + name: 'sec', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + minute: { + name: 'minute', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 60, + offset: 0 + }, + hour: { + name: 'hour', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 3600, + offset: 0 + }, + day: { + name: 'day', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 86400, + offset: 0 + }, + week: { + name: 'week', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 7*86400, + offset: 0 + }, + month: { + name: 'month', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 2629800, //1/12th of Julian year + offset: 0 + }, + year: { + name: 'year', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 31557600, //Julian year + offset: 0 + }, + decade: { + name: 'year', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 315576000, //Julian decade + offset: 0 + }, + century: { + name: 'century', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 3155760000, //Julian century + offset: 0 + }, + millennium: { + name: 'millennium', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 31557600000, //Julian millennium + offset: 0 + }, + + // Frequency + hertz: { + name: 'Hertz', + base: BASE_UNITS.FREQUENCY, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0, + reciprocal: true + }, + Hz: { + name: 'Hz', + base: BASE_UNITS.FREQUENCY, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0, + reciprocal: true + }, + + // Angle + rad: { + name: 'rad', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888 + deg: { + name: 'deg', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: null, // will be filled in by calculateAngleValues() + offset: 0 + }, + // grad = rad / (2*pi) * 400 = rad / 0.015707963267948966192313216916399 + grad: { + name: 'grad', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: null, // will be filled in by calculateAngleValues() + offset: 0 + }, + // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793 + cycle: { + name: 'cycle', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: null, // will be filled in by calculateAngleValues() + offset: 0 + }, + // arcsec = rad / (3600 * (360 / 2 * pi)) = rad / 0.0000048481368110953599358991410235795 + arcsec: { + name: 'arcsec', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: null, // will be filled in by calculateAngleValues() + offset: 0 + }, + // arcmin = rad / (60 * (360 / 2 * pi)) = rad / 0.00029088820866572159615394846141477 + arcmin: { + name: 'arcmin', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: null, // will be filled in by calculateAngleValues() + offset: 0 + }, + + // Electric current + A: { + name: 'A', + base: BASE_UNITS.CURRENT, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + ampere: { + name: 'ampere', + base: BASE_UNITS.CURRENT, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + + // Temperature + // K(C) = °C + 273.15 + // K(F) = (°F + 459.67) / 1.8 + // K(R) = °R / 1.8 + K: { + name: 'K', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + degC: { + name: 'degC', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 273.15 + }, + degF: { + name: 'degF', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 459.67 + }, + degR: { + name: 'degR', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 0 + }, + kelvin: { + name: 'kelvin', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + celsius: { + name: 'celsius', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 273.15 + }, + fahrenheit: { + name: 'fahrenheit', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 459.67 + }, + rankine: { + name: 'rankine', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 0 + }, + + // amount of substance + mol: { + name: 'mol', + base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + mole: { + name: 'mole', + base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + + // luminous intensity + cd: { + name: 'cd', + base: BASE_UNITS.LUMINOUS_INTENSITY, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + candela: { + name: 'candela', + base: BASE_UNITS.LUMINOUS_INTENSITY, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + // TODO: units STERADIAN + //{name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, + //{name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, + + // Force + N: { + name: 'N', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + newton: { + name: 'newton', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + dyn: { + name: 'dyn', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.SHORT, + value: 0.00001, + offset: 0 + }, + dyne: { + name: 'dyne', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.LONG, + value: 0.00001, + offset: 0 + }, + lbf: { + name: 'lbf', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.NONE, + value: 4.4482216152605, + offset: 0 + }, + poundforce: { + name: 'poundforce', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.NONE, + value: 4.4482216152605, + offset: 0 + }, + kip: { + name: 'kip', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.LONG, + value: 4448.2216, + offset: 0 + }, + + // Energy + J: { + name: 'J', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + joule: { + name: 'joule', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + erg: { + name: 'erg', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.NONE, + value: 1e-5, + offset: 0 + }, + Wh: { + name: 'Wh', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.SHORT, + value: 3600, + offset: 0 + }, + BTU: { + name: 'BTU', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.BTU, + value: 1055.05585262, + offset: 0 + }, + eV: { + name: 'eV', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.SHORT, + value: 1.602176565e-19, + offset: 0 + }, + electronvolt: { + name: 'electronvolt', + base: BASE_UNITS.ENERGY, + prefixes: PREFIXES.LONG, + value: 1.602176565e-19, + offset: 0 + }, + + + // Power + W: { + name: 'W', + base: BASE_UNITS.POWER, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + watt: { + name: 'W', + base: BASE_UNITS.POWER, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + hp: { + name: 'hp', + base: BASE_UNITS.POWER, + prefixes: PREFIXES.NONE, + value: 745.6998715386, + offset: 0 + }, + + // Electrical power units + VAR: { + name: 'VAR', + base: BASE_UNITS.POWER, + prefixes: PREFIXES.SHORT, + value: Complex.I, + offset: 0 + }, + + VA: { + name: 'VA', + base: BASE_UNITS.POWER, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + + // Pressure + Pa: { + name: 'Pa', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + psi: { + name: 'psi', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 6894.75729276459, + offset: 0 + }, + atm: { + name: 'atm', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 101325, + offset: 0 + }, + bar: { + name: 'bar', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 100000, + offset: 0 + }, + torr: { + name: 'torr', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 133.322, + offset: 0 + }, + mmHg: { + name: 'mmHg', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 133.322, + offset: 0 + }, + mmH2O: { + name: 'mmH2O', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 9.80665, + offset: 0 + }, + cmH2O: { + name: 'cmH2O', + base: BASE_UNITS.PRESSURE, + prefixes: PREFIXES.NONE, + value: 98.0665, + offset: 0 + }, + + // Electric charge + coulomb: { + name: 'coulomb', + base: BASE_UNITS.ELECTRIC_CHARGE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + C: { + name: 'C', + base: BASE_UNITS.ELECTRIC_CHARGE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Electric capacitance + farad: { + name: 'farad', + base: BASE_UNITS.ELECTRIC_CAPACITANCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + F: { + name: 'F', + base: BASE_UNITS.ELECTRIC_CAPACITANCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Electric potential + volt: { + name: 'volt', + base: BASE_UNITS.ELECTRIC_POTENTIAL, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + V: { + name: 'V', + base: BASE_UNITS.ELECTRIC_POTENTIAL, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Electric resistance + ohm: { + name: 'ohm', + base: BASE_UNITS.ELECTRIC_RESISTANCE, + prefixes: PREFIXES.SHORTLONG, // Both Mohm and megaohm are acceptable + value: 1, + offset: 0 + }, + /* + * Unicode breaks in browsers if charset is not specified + Ω: { + name: 'Ω', + base: BASE_UNITS.ELECTRIC_RESISTANCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + */ + // Electric inductance + henry: { + name: 'henry', + base: BASE_UNITS.ELECTRIC_INDUCTANCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + H: { + name: 'H', + base: BASE_UNITS.ELECTRIC_INDUCTANCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Electric conductance + siemens: { + name: 'siemens', + base: BASE_UNITS.ELECTRIC_CONDUCTANCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + S: { + name: 'S', + base: BASE_UNITS.ELECTRIC_CONDUCTANCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Magnetic flux + weber: { + name: 'weber', + base: BASE_UNITS.MAGNETIC_FLUX, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + Wb: { + name: 'Wb', + base: BASE_UNITS.MAGNETIC_FLUX, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + // Magnetic flux density + tesla: { + name: 'tesla', + base: BASE_UNITS.MAGNETIC_FLUX_DENSITY, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + T: { + name: 'T', + base: BASE_UNITS.MAGNETIC_FLUX_DENSITY, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + + // Binary + b: { + name: 'b', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_SHORT, + value: 1, + offset: 0 + }, + bits: { + name: 'bits', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_LONG, + value: 1, + offset: 0 + }, + B: { + name: 'B', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_SHORT, + value: 8, + offset: 0 + }, + bytes: { + name: 'bytes', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_LONG, + value: 8, + offset: 0 + } + }; + + // aliases (formerly plurals) + var ALIASES = { + meters: 'meter', + inches: 'inch', + feet: 'foot', + yards: 'yard', + miles: 'mile', + links: 'link', + rods: 'rod', + chains: 'chain', + angstroms: 'angstrom', + + lt: 'l', + litres: 'litre', + liter: 'litre', + liters: 'litre', + teaspoons: 'teaspoon', + tablespoons: 'tablespoon', + minims: 'minim', + fluiddrams: 'fluiddram', + fluidounces: 'fluidounce', + gills: 'gill', + cups: 'cup', + pints: 'pint', + quarts: 'quart', + gallons: 'gallon', + beerbarrels: 'beerbarrel', + oilbarrels: 'oilbarrel', + hogsheads: 'hogshead', + gtts: 'gtt', + + grams: 'gram', + tons: 'ton', + tonnes: 'tonne', + grains: 'grain', + drams: 'dram', + ounces: 'ounce', + poundmasses: 'poundmass', + hundredweights: 'hundredweight', + sticks: 'stick', + lb: 'lbm', + lbs: 'lbm', + + kips: 'kip', + + acres: 'acre', + hectares: 'hectare', + sqfeet: 'sqft', + sqyard: 'sqyd', + sqmile: 'sqmi', + sqmiles: 'sqmi', + + mmhg: 'mmHg', + mmh2o: 'mmH2O', + cmh2o: 'cmH2O', + + seconds: 'second', + secs: 'second', + minutes: 'minute', + mins: 'minute', + hours: 'hour', + hr: 'hour', + hrs: 'hour', + days: 'day', + weeks: 'week', + months: 'month', + years: 'year', + + hertz: 'hertz', + + radians: 'rad', + degree: 'deg', + degrees: 'deg', + gradian: 'grad', + gradians: 'grad', + cycles: 'cycle', + arcsecond: 'arcsec', + arcseconds: 'arcsec', + arcminute: 'arcmin', + arcminutes: 'arcmin', + + BTUs: 'BTU', + watts: 'watt', + joules: 'joule', + + amperes: 'ampere', + coulombs: 'coulomb', + volts: 'volt', + ohms: 'ohm', + farads: 'farad', + webers: 'weber', + teslas: 'tesla', + electronvolts: 'electronvolt', + moles: 'mole' + + }; + + /** + * Calculate the values for the angle units. + * Value is calculated as number or BigNumber depending on the configuration + * @param {{number: 'number' | 'BigNumber'}} config + */ + function calculateAngleValues (config) { + if (config.number === 'BigNumber') { + var pi = constants.pi(type.BigNumber); + UNITS.rad.value = new type.BigNumber(1); + UNITS.deg.value = pi.div(180); // 2 * pi / 360; + UNITS.grad.value = pi.div(200); // 2 * pi / 400; + UNITS.cycle.value = pi.times(2); // 2 * pi + UNITS.arcsec.value = pi.div(648000); // 2 * pi / 360 / 3600 + UNITS.arcmin.value = pi.div(10800); // 2 * pi / 360 / 60 + } + else { // number + UNITS.rad.value = 1; + UNITS.deg.value = Math.PI / 180; // 2 * pi / 360; + UNITS.grad.value = Math.PI / 200; // 2 * pi / 400; + UNITS.cycle.value = Math.PI * 2; // 2 * pi + UNITS.arcsec.value = Math.PI / 648000; // 2 * pi / 360 / 3600; + UNITS.arcmin.value = Math.PI / 10800; // 2 * pi / 360 / 60; + } + } + + // apply the angle values now + calculateAngleValues(config); + + // recalculate the values on change of configuration + math.on('config', function (curr, prev) { + if (curr.number !== prev.number) { + calculateAngleValues(curr); + } + }); + + /** + * A unit system is a set of dimensionally independent base units plus a set of derived units, formed by multiplication and division of the base units, that are by convention used with the unit system. + * A user perhaps could issue a command to select a preferred unit system, or use the default (see below). + * Auto unit system: The default unit system is updated on the fly anytime a unit is parsed. The corresponding unit in the default unit system is updated, so that answers are given in the same units the user supplies. + */ + var UNIT_SYSTEMS = { + si: { + // Base units + NONE: {unit: UNIT_NONE, prefix: PREFIXES.NONE['']}, + LENGTH: {unit: UNITS.m, prefix: PREFIXES.SHORT['']}, + MASS: {unit: UNITS.g, prefix: PREFIXES.SHORT['k']}, + TIME: {unit: UNITS.s, prefix: PREFIXES.SHORT['']}, + CURRENT: {unit: UNITS.A, prefix: PREFIXES.SHORT['']}, + TEMPERATURE: {unit: UNITS.K, prefix: PREFIXES.SHORT['']}, + LUMINOUS_INTENSITY: {unit: UNITS.cd, prefix: PREFIXES.SHORT['']}, + AMOUNT_OF_SUBSTANCE: {unit: UNITS.mol, prefix: PREFIXES.SHORT['']}, + ANGLE: {unit: UNITS.rad, prefix: PREFIXES.SHORT['']}, + BIT: {unit: UNITS.bit, prefix: PREFIXES.SHORT['']}, + + // Derived units + FORCE: {unit: UNITS.N, prefix: PREFIXES.SHORT['']}, + ENERGY: {unit: UNITS.J, prefix: PREFIXES.SHORT['']}, + POWER: {unit: UNITS.W, prefix: PREFIXES.SHORT['']}, + PRESSURE: {unit: UNITS.Pa, prefix: PREFIXES.SHORT['']}, + ELECTRIC_CHARGE: {unit: UNITS.C, prefix: PREFIXES.SHORT['']}, + ELECTRIC_CAPACITANCE: {unit: UNITS.F, prefix: PREFIXES.SHORT['']}, + ELECTRIC_POTENTIAL: {unit: UNITS.V, prefix: PREFIXES.SHORT['']}, + ELECTRIC_RESISTANCE: {unit: UNITS.ohm, prefix: PREFIXES.SHORT['']}, + ELECTRIC_INDUCTANCE: {unit: UNITS.H, prefix: PREFIXES.SHORT['']}, + ELECTRIC_CONDUCTANCE: {unit: UNITS.S, prefix: PREFIXES.SHORT['']}, + MAGNETIC_FLUX: {unit: UNITS.Wb, prefix: PREFIXES.SHORT['']}, + MAGNETIC_FLUX_DENSITY: {unit: UNITS.T, prefix: PREFIXES.SHORT['']}, + FREQUENCY: {unit: UNITS.Hz, prefix: PREFIXES.SHORT['']} + } + }; + + // Clone to create the other unit systems + UNIT_SYSTEMS.cgs = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); + UNIT_SYSTEMS.cgs.LENGTH = {unit: UNITS.m, prefix: PREFIXES.SHORT['c']}; + UNIT_SYSTEMS.cgs.MASS = {unit: UNITS.g, prefix: PREFIXES.SHORT['']}; + UNIT_SYSTEMS.cgs.FORCE = {unit: UNITS.dyn, prefix: PREFIXES.SHORT['']}; + UNIT_SYSTEMS.cgs.ENERGY = {unit: UNITS.erg, prefix: PREFIXES.NONE['']}; + // there are wholly 4 unique cgs systems for electricity and magnetism, + // so let's not worry about it unless somebody complains + + UNIT_SYSTEMS.us = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); + UNIT_SYSTEMS.us.LENGTH = {unit: UNITS.ft, prefix: PREFIXES.NONE['']}; + UNIT_SYSTEMS.us.MASS = {unit: UNITS.lbm, prefix: PREFIXES.NONE['']}; + UNIT_SYSTEMS.us.TEMPERATURE = {unit: UNITS.degF, prefix: PREFIXES.NONE['']}; + UNIT_SYSTEMS.us.FORCE = {unit: UNITS.lbf, prefix: PREFIXES.NONE['']}; + UNIT_SYSTEMS.us.ENERGY = {unit: UNITS.BTU, prefix: PREFIXES.BTU['']}; + UNIT_SYSTEMS.us.POWER = {unit: UNITS.hp, prefix: PREFIXES.NONE['']}; + UNIT_SYSTEMS.us.PRESSURE = {unit: UNITS.psi, prefix: PREFIXES.NONE['']}; + + // Add additional unit systems here. + + + + // Choose a unit system to seed the auto unit system. + UNIT_SYSTEMS.auto = JSON.parse(JSON.stringify(UNIT_SYSTEMS.si)); + + // Set the current unit system + var currentUnitSystem = UNIT_SYSTEMS.auto; + + /** + * Set a unit system for formatting derived units. + * @param {string} [name] The name of the unit system. + */ + Unit.setUnitSystem = function(name) { + if(UNIT_SYSTEMS.hasOwnProperty(name)) { + currentUnitSystem = UNIT_SYSTEMS[name]; + } + else { + throw new Error('Unit system ' + name + ' does not exist. Choices are: ' + Object.keys(UNIT_SYSTEMS).join(', ')); + } + }; + + /** + * Return the current unit system. + * @return {string} The current unit system. + */ + Unit.getUnitSystem = function() { + for(var key in UNIT_SYSTEMS) { + if(UNIT_SYSTEMS[key] === currentUnitSystem) { + return key; + } + } + }; + + /** + * Converters to convert from number to an other numeric type like BigNumber + * or Fraction + */ + Unit.typeConverters = { + BigNumber: function (x) { + return new type.BigNumber(x + ''); // stringify to prevent constructor error + }, + + Fraction: function (x) { + return new type.Fraction(x); + }, + + Complex: function (x) { + return x; + }, + + number: function (x) { + return x; + } + }; + + /** + * Retrieve the right convertor function corresponding with the type + * of provided exampleValue. + * + * @param {string} type A string 'number', 'BigNumber', or 'Fraction' + * In case of an unknown type, + * @return {Function} + */ + Unit._getNumberConverter = function (type) { + if (!Unit.typeConverters[type]) { + throw new TypeError('Unsupported type "' + type + '"'); + } + + return Unit.typeConverters[type]; + }; + + // Add dimensions to each built-in unit + for (var key in UNITS) { + var unit = UNITS[key]; + unit.dimensions = unit.base.dimensions; + } + + // Create aliases + for (var name in ALIASES) { + /* istanbul ignore next (we cannot really test next statement) */ + if (ALIASES.hasOwnProperty(name)) { + var unit = UNITS[ALIASES[name]]; + var alias = Object.create(unit); + alias.name = name; + UNITS[name] = alias; + } + } + + Unit.PREFIXES = PREFIXES; + Unit.BASE_UNITS = BASE_UNITS; + Unit.UNITS = UNITS; + Unit.UNIT_SYSTEMS = UNIT_SYSTEMS; + + return Unit; + } + + exports.name = 'Unit'; + exports.path = 'type'; + exports.factory = factory; + exports.math = true; // request access to the math namespace + + +/***/ }, +/* 76 */ +/***/ function(module, exports, __webpack_require__) { + + var memoize = __webpack_require__(45).memoize; + + /** + * Calculate BigNumber e + * @param {function} BigNumber BigNumber constructor + * @returns {BigNumber} Returns e + */ + exports.e = memoize(function (BigNumber) { + return new BigNumber(1).exp(); + }, hasher); + + /** + * Calculate BigNumber golden ratio, phi = (1+sqrt(5))/2 + * @param {function} BigNumber BigNumber constructor + * @returns {BigNumber} Returns phi + */ + exports.phi = memoize(function (BigNumber) { + return new BigNumber(1).plus(new BigNumber(5).sqrt()).div(2); + }, hasher); + + /** + * Calculate BigNumber pi. + * @param {function} BigNumber BigNumber constructor + * @returns {BigNumber} Returns pi + */ + exports.pi = memoize(function (BigNumber) { + return pi = BigNumber.acos(-1); + }, hasher); + + /** + * Calculate BigNumber tau, tau = 2 * pi + * @param {function} BigNumber BigNumber constructor + * @returns {BigNumber} Returns tau + */ + exports.tau = memoize(function (BigNumber) { + return exports.pi(BigNumber).times(2); + }, hasher); + + /** + * Create a hash for a BigNumber constructor function. The created has is + * the configured precision + * @param {Array} args Supposed to contain a single entry with + * a BigNumber constructor + * @return {number} precision + * @private + */ + function hasher (args) { + return args[0].precision; + } + + +/***/ }, +/* 77 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var addScalar = load(__webpack_require__(53)); + var unaryMinus = load(__webpack_require__(78)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm03 = load(__webpack_require__(61)); + var algorithm05 = load(__webpack_require__(79)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + // TODO: split function subtract in two: subtract and subtractScalar + + /** + * Subtract two values, `x - y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.subtract(x, y) + * + * Examples: + * + * math.subtract(5.3, 2); // returns number 3.3 + * + * var a = math.complex(2, 3); + * var b = math.complex(4, 1); + * math.subtract(a, b); // returns Complex -2 + 2i + * + * math.subtract([5, 7, 4], 4); // returns Array [1, 3, 0] + * + * var c = math.unit('2.1 km'); + * var d = math.unit('500m'); + * math.subtract(c, d); // returns Unit 1.6 km + * + * See also: + * + * add + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x + * Initial value + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y + * Value to subtract from `x` + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} + * Subtraction of `x` and `y` + */ + var subtract = typed('subtract', { + + 'number, number': function (x, y) { + return x - y; + }, + + 'Complex, Complex': function (x, y) { + return x.sub(y); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.minus(y); + }, + + 'Fraction, Fraction': function (x, y) { + return x.sub(y); + }, + + 'Unit, Unit': function (x, y) { + if (x.value == null) { + throw new Error('Parameter x contains a unit with undefined value'); + } + + if (y.value == null) { + throw new Error('Parameter y contains a unit with undefined value'); + } + + if (!x.equalBase(y)) { + throw new Error('Units do not match'); + } + + var res = x.clone(); + res.value = subtract(res.value, y.value); + res.fixPrefix = false; + + return res; + }, + + 'Matrix, Matrix': function (x, y) { + // matrix sizes + var xsize = x.size(); + var ysize = y.size(); + + // check dimensions + if (xsize.length !== ysize.length) + throw new DimensionError(xsize.length, ysize.length); + + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse - sparse + c = algorithm05(x, y, subtract); + break; + default: + // sparse - dense + c = algorithm03(y, x, subtract, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense - sparse + c = algorithm01(x, y, subtract, false); + break; + default: + // dense - dense + c = algorithm13(x, y, subtract); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return subtract(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return subtract(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return subtract(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + // algorithm 7 is faster than 9 since it calls f() for nonzero items only! + c = algorithm10(x, unaryMinus(y), addScalar); + break; + default: + c = algorithm14(x, y, subtract); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, subtract, true); + break; + default: + c = algorithm14(y, x, subtract, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, subtract, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, subtract, true).valueOf(); + } + }); + + subtract.toTex = { + 2: '\\left(${args[0]}' + latex.operators['subtract'] + '${args[1]}\\right)' + }; + + return subtract; + } + + exports.name = 'subtract'; + exports.factory = factory; + + +/***/ }, +/* 78 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + /** + * Inverse the sign of a value, apply a unary minus operation. + * + * For matrices, the function is evaluated element wise. Boolean values and + * strings will be converted to a number. For complex numbers, both real and + * complex value are inverted. + * + * Syntax: + * + * math.unaryMinus(x) + * + * Examples: + * + * math.unaryMinus(3.5); // returns -3.5 + * math.unaryMinus(-4.2); // returns 4.2 + * + * See also: + * + * add, subtract, unaryPlus + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Number to be inverted. + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Returns the value with inverted sign. + */ + var unaryMinus = typed('unaryMinus', { + 'number': function (x) { + return -x; + }, + + 'Complex': function (x) { + return x.neg(); + }, + + 'BigNumber': function (x) { + return x.neg(); + }, + + 'Fraction': function (x) { + return x.neg(); + }, + + 'Unit': function (x) { + var res = x.clone(); + res.value = unaryMinus(x.value); + return res; + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since unaryMinus(0) = 0 + return deepMap(x, unaryMinus, true); + } + + // TODO: add support for string + }); + + unaryMinus.toTex = { + 1: latex.operators['unaryMinus'] + '\\left(${args[0]}\\right)' + }; + + return unaryMinus; + } + + exports.name = 'unaryMinus'; + exports.factory = factory; + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 || B(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm05 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var xa = cvalues ? [] : undefined; + var xb = cvalues ? [] : undefined; + // marks indicating we have a value in x for a given column + var wa = []; + var wb = []; + + // vars + var i, j, k, k1; + + // loop columns + for (j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // loop values A(:,j) + for (k = aptr[j], k1 = aptr[j + 1]; k < k1; k++) { + // row + i = aindex[k]; + // push index + cindex.push(i); + // update workspace + wa[i] = mark; + // check we need to process values + if (xa) + xa[i] = avalues[k]; + } + // loop values B(:,j) + for (k = bptr[j], k1 = bptr[j + 1]; k < k1; k++) { + // row + i = bindex[k]; + // check row existed in A + if (wa[i] !== mark) { + // push index + cindex.push(i); + } + // update workspace + wb[i] = mark; + // check we need to process values + if (xb) + xb[i] = bvalues[k]; + } + // check we need to process values (non pattern matrix) + if (cvalues) { + // initialize first index in j + k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + i = cindex[k]; + // marks + var wai = wa[i]; + var wbi = wb[i]; + // check Aij or Bij are nonzero + if (wai === mark || wbi === mark) { + // matrix values @ i,j + var va = wai === mark ? xa[i] : zero; + var vb = wbi === mark ? xb[i] : zero; + // Cij + var vc = cf(va, vb); + // check for zero + if (!eq(vc, zero)) { + // push value + cvalues.push(vc); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm05; + } + + exports.name = 'algorithm05'; + exports.factory = factory; + + +/***/ }, +/* 80 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory(type, config, load, typed) { + + /** + * Multiply two scalar values, `x * y`. + * This function is meant for internal use: it is used by the public function + * `multiply` + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {number | BigNumber | Fraction | Complex | Unit} x First value to multiply + * @param {number | BigNumber | Fraction | Complex} y Second value to multiply + * @return {number | BigNumber | Fraction | Complex | Unit} Multiplication of `x` and `y` + * @private + */ + var multiplyScalar = typed('multiplyScalar', { + + 'number, number': function (x, y) { + return x * y; + }, + + 'Complex, Complex': function (x, y) { + return x.mul(y); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.times(y); + }, + + 'Fraction, Fraction': function (x, y) { + return x.mul(y); + }, + + 'number | Fraction | BigNumber | Complex, Unit': function (x, y) { + var res = y.clone(); + res.value = (res.value === null) ? res._normalize(x) : multiplyScalar(res.value, x); + return res; + }, + + 'Unit, number | Fraction | BigNumber | Complex': function (x, y) { + var res = x.clone(); + res.value = (res.value === null) ? res._normalize(y) : multiplyScalar(res.value, y); + return res; + }, + + 'Unit, Unit': function (x, y) { + return x.multiply(y); + } + + }); + + return multiplyScalar; + } + + exports.factory = factory; + + +/***/ }, +/* 81 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory(type, config, load, typed) { + var multiplyScalar = load(__webpack_require__(80)); + + /** + * Divide two scalar values, `x / y`. + * This function is meant for internal use: it is used by the public functions + * `divide` and `inv`. + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {number | BigNumber | Fraction | Complex | Unit} x Numerator + * @param {number | BigNumber | Fraction | Complex} y Denominator + * @return {number | BigNumber | Fraction | Complex | Unit} Quotient, `x / y` + * @private + */ + var divideScalar = typed('divide', { + 'number, number': function (x, y) { + return x / y; + }, + + 'Complex, Complex': function (x, y) { + return x.div(y); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.div(y); + }, + + 'Fraction, Fraction': function (x, y) { + return x.div(y); + }, + + 'Unit, number | Fraction | BigNumber': function (x, y) { + var res = x.clone(); + // TODO: move the divide function to Unit.js, it uses internals of Unit + res.value = divideScalar(((res.value === null) ? res._normalize(1) : res.value), y); + return res; + }, + + 'number | Fraction | BigNumber, Unit': function (x, y) { + var res = y.pow(-1); + // TODO: move the divide function to Unit.js, it uses internals of Unit + res.value = multiplyScalar(((res.value === null) ? res._normalize(1) : res.value), x); + return res; + }, + + 'Unit, Unit': function (x, y) { + return x.divide(y); + } + + }); + + return divideScalar; + } + + exports.factory = factory; + + +/***/ }, +/* 82 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var size = __webpack_require__(40).size; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + var eye = load(__webpack_require__(83)); + var multiply = load(__webpack_require__(84)); + var matrix = load(__webpack_require__(52)); + var fraction = load(__webpack_require__(36)); + var number = load(__webpack_require__(70)); + + /** + * Calculates the power of x to y, `x ^ y`. + * Matrix exponentiation is supported for square matrices `x`, and positive + * integer exponents `y`. + * + * For cubic roots of negative numbers, the function returns the principal + * root by default. In order to let the function return the real root, + * math.js can be configured with `math.config({predictable: true})`. + * To retrieve all cubic roots of a value, use `math.cbrt(x, true)`. + * + * Syntax: + * + * math.pow(x, y) + * + * Examples: + * + * math.pow(2, 3); // returns number 8 + * + * var a = math.complex(2, 3); + * math.pow(a, 2) // returns Complex -5 + 12i + * + * var b = [[1, 2], [4, 3]]; + * math.pow(b, 2); // returns Array [[9, 8], [16, 17]] + * + * See also: + * + * multiply, sqrt, cbrt, nthRoot + * + * @param {number | BigNumber | Complex | Array | Matrix} x The base + * @param {number | BigNumber | Complex} y The exponent + * @return {number | BigNumber | Complex | Array | Matrix} The value of `x` to the power `y` + */ + var pow = typed('pow', { + 'number, number': _pow, + + 'Complex, Complex': function (x, y) { + return x.pow(y); + }, + + 'BigNumber, BigNumber': function (x, y) { + if (y.isInteger() || x >= 0 || config.predictable) { + return x.pow(y); + } + else { + return new type.Complex(x.toNumber(), 0).pow(y.toNumber(), 0); + } + }, + + 'Fraction, Fraction': function (x, y) { + if (y.d !== 1) { + if (config.predictable) { + throw new Error('Function pow does not support non-integer exponents for fractions.'); + } + else { + return _pow(x.valueOf(), y.valueOf()); + } + } + else { + return x.pow(y); + } + }, + + 'Array, number': _powArray, + + 'Array, BigNumber': function (x, y) { + return _powArray(x, y.toNumber()); + }, + + 'Matrix, number': _powMatrix, + + 'Matrix, BigNumber': function (x, y) { + return _powMatrix(x, y.toNumber()); + }, + + 'Unit, number': function (x, y) { + return x.pow(y); + } + + }); + + /** + * Calculates the power of x to y, x^y, for two numbers. + * @param {number} x + * @param {number} y + * @return {number | Complex} res + * @private + */ + function _pow(x, y) { + + // Alternatively could define a 'realmode' config option or something, but + // 'predictable' will work for now + if (config.predictable && !isInteger(y) && x < 0) { + // Check to see if y can be represented as a fraction + try { + var yFrac = fraction(y); + var yNum = number(yFrac); + if(y === yNum || Math.abs((y - yNum) / y) < 1e-14) { + if(yFrac.d % 2 === 1) { + return (yFrac.n % 2 === 0 ? 1 : -1) * Math.pow(-x, y); + } + } + } + catch (ex) { + // fraction() throws an error if y is Infinity, etc. + } + + // Unable to express y as a fraction, so continue on + } + + if (isInteger(y) || x >= 0 || config.predictable) { + return Math.pow(x, y); + } + else { + return new type.Complex(x, 0).pow(y, 0); + } + } + + /** + * Calculate the power of a 2d array + * @param {Array} x must be a 2 dimensional, square matrix + * @param {number} y a positive, integer value + * @returns {Array} + * @private + */ + function _powArray(x, y) { + if (!isInteger(y) || y < 0) { + throw new TypeError('For A^b, b must be a positive integer (value is ' + y + ')'); + } + // verify that A is a 2 dimensional square matrix + var s = size(x); + if (s.length != 2) { + throw new Error('For A^b, A must be 2 dimensional (A has ' + s.length + ' dimensions)'); + } + if (s[0] != s[1]) { + throw new Error('For A^b, A must be square (size is ' + s[0] + 'x' + s[1] + ')'); + } + + var res = eye(s[0]).valueOf(); + var px = x; + while (y >= 1) { + if ((y & 1) == 1) { + res = multiply(px, res); + } + y >>= 1; + px = multiply(px, px); + } + return res; + } + + /** + * Calculate the power of a 2d matrix + * @param {Matrix} x must be a 2 dimensional, square matrix + * @param {number} y a positive, integer value + * @returns {Matrix} + * @private + */ + function _powMatrix (x, y) { + return matrix(_powArray(x.valueOf(), y)); + } + + + + pow.toTex = { + 2: '\\left(${args[0]}\\right)' + latex.operators['pow'] + '{${args[1]}}' + }; + + return pow; + } + + exports.name = 'pow'; + exports.factory = factory; + + +/***/ }, +/* 83 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(40); + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + /** + * Create a 2-dimensional identity matrix with size m x n or n x n. + * The matrix has ones on the diagonal and zeros elsewhere. + * + * Syntax: + * + * math.eye(n) + * math.eye(n, format) + * math.eye(m, n) + * math.eye(m, n, format) + * math.eye([m, n]) + * math.eye([m, n], format) + * + * Examples: + * + * math.eye(3); // returns [[1, 0, 0], [0, 1, 0], [0, 0, 1]] + * math.eye(3, 2); // returns [[1, 0], [0, 1], [0, 0]] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.eye(math.size(A)); // returns [[1, 0, 0], [0, 1, 0]] + * + * See also: + * + * diag, ones, zeros, size, range + * + * @param {...number | Matrix | Array} size The size for the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Matrix | Array | number} A matrix with ones on the diagonal. + */ + var eye = typed('eye', { + '': function () { + return (config.matrix === 'Matrix') ? matrix([]) : []; + }, + + 'string': function (format) { + return matrix(format); + }, + + 'number | BigNumber': function (rows) { + return _eye(rows, rows, config.matrix === 'Matrix' ? 'default' : undefined); + }, + + 'number | BigNumber, string': function (rows, format) { + return _eye(rows, rows, format); + }, + + 'number | BigNumber, number | BigNumber': function (rows, cols) { + return _eye(rows, cols, config.matrix === 'Matrix' ? 'default' : undefined); + }, + + 'number | BigNumber, number | BigNumber, string': function (rows, cols, format) { + return _eye(rows, cols, format); + }, + + 'Array': function (size) { + return _eyeVector(size); + }, + + 'Array, string': function (size, format) { + return _eyeVector(size, format); + }, + + 'Matrix': function (size) { + return _eyeVector(size.valueOf(), size.storage()); + }, + + 'Matrix, string': function (size, format) { + return _eyeVector(size.valueOf(), format); + } + }); + + eye.toTex = undefined; // use default template + + return eye; + + function _eyeVector (size, format) { + switch (size.length) { + case 0: return format ? matrix(format) : []; + case 1: return _eye(size[0], size[0], format); + case 2: return _eye(size[0], size[1], format); + default: throw new Error('Vector containing two values expected'); + } + } + + /** + * Create an identity matrix + * @param {number | BigNumber} rows + * @param {number | BigNumber} cols + * @param {string} [format] + * @returns {Matrix} + * @private + */ + function _eye (rows, cols, format) { + // BigNumber constructor with the right precision + var Big = (rows && rows.isBigNumber === true) + ? type.BigNumber + : (cols && cols.isBigNumber === true) + ? type.BigNumber + : null; + + if (rows && rows.isBigNumber === true) rows = rows.toNumber(); + if (cols && cols.isBigNumber === true) cols = cols.toNumber(); + + if (!isInteger(rows) || rows < 1) { + throw new Error('Parameters in function eye must be positive integers'); + } + if (!isInteger(cols) || cols < 1) { + throw new Error('Parameters in function eye must be positive integers'); + } + + var one = Big ? new type.BigNumber(1) : 1; + var defaultValue = Big ? new Big(0) : 0; + var size = [rows, cols]; + + // check we need to return a matrix + if (format) { + // get matrix storage constructor + var F = type.Matrix.storage(format); + // create diagonal matrix (use optimized implementation for storage format) + return F.diagonal(size, one, 0, defaultValue); + } + + // create and resize array + var res = array.resize([], size, defaultValue); + // fill in ones on the diagonal + var minimum = rows < cols ? rows : cols; + // fill diagonal + for (var d = 0; d < minimum; d++) { + res[d][d] = one; + } + return res; + } + } + + exports.name = 'eye'; + exports.factory = factory; + + +/***/ }, +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var extend = __webpack_require__(3).extend; + var array = __webpack_require__(40); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var addScalar = load(__webpack_require__(53)); + var multiplyScalar = load(__webpack_require__(80)); + var equalScalar = load(__webpack_require__(48)); + + var algorithm11 = load(__webpack_require__(85)); + var algorithm14 = load(__webpack_require__(58)); + + var DenseMatrix = type.DenseMatrix; + var SparseMatrix = type.SparseMatrix; + + /** + * Multiply two values, `x * y`. + * For matrices, the matrix product is calculated. + * + * Syntax: + * + * math.multiply(x, y) + * + * Examples: + * + * math.multiply(4, 5.2); // returns number 20.8 + * + * var a = math.complex(2, 3); + * var b = math.complex(4, 1); + * math.multiply(a, b); // returns Complex 5 + 14i + * + * var c = [[1, 2], [4, 3]]; + * var d = [[1, 2, 3], [3, -4, 7]]; + * math.multiply(c, d); // returns Array [[7, -6, 17], [13, -4, 33]] + * + * var e = math.unit('2.1 km'); + * math.multiply(3, e); // returns Unit 6.3 km + * + * See also: + * + * divide + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First value to multiply + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second value to multiply + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` + */ + var multiply = typed('multiply', extend({ + // we extend the signatures of multiplyScalar with signatures dealing with matrices + + 'Array, Array': function (x, y) { + // check dimensions + _validateMatrixDimensions(array.size(x), array.size(y)); + + // use dense matrix implementation + var m = multiply(matrix(x), matrix(y)); + // return array or scalar + return (m && m.isMatrix === true) ? m.valueOf() : m; + }, + + 'Matrix, Matrix': function (x, y) { + // dimensions + var xsize = x.size(); + var ysize = y.size(); + + // check dimensions + _validateMatrixDimensions(xsize, ysize); + + // process dimensions + if (xsize.length === 1) { + // process y dimensions + if (ysize.length === 1) { + // Vector * Vector + return _multiplyVectorVector(x, y, xsize[0]); + } + // Vector * Matrix + return _multiplyVectorMatrix(x, y); + } + // process y dimensions + if (ysize.length === 1) { + // Matrix * Vector + return _multiplyMatrixVector(x, y); + } + // Matrix * Matrix + return _multiplyMatrixMatrix(x, y); + }, + + 'Matrix, Array': function (x, y) { + // use Matrix * Matrix implementation + return multiply(x, matrix(y)); + }, + + 'Array, Matrix': function (x, y) { + // use Matrix * Matrix implementation + return multiply(matrix(x, y.storage()), y); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + + // process storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, multiplyScalar, false); + break; + case 'dense': + c = algorithm14(x, y, multiplyScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm11(y, x, multiplyScalar, true); + break; + case 'dense': + c = algorithm14(y, x, multiplyScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, multiplyScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, multiplyScalar, true).valueOf(); + } + }, multiplyScalar.signatures)); + + var _validateMatrixDimensions = function (size1, size2) { + // check left operand dimensions + switch (size1.length) { + case 1: + // check size2 + switch (size2.length) { + case 1: + // Vector x Vector + if (size1[0] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Vectors must have the same length'); + } + break; + case 2: + // Vector x Matrix + if (size1[0] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Vector length (' + size1[0] + ') must match Matrix rows (' + size2[0] + ')'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); + } + break; + case 2: + // check size2 + switch (size2.length) { + case 1: + // Matrix x Vector + if (size1[1] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Matrix columns (' + size1[1] + ') must match Vector length (' + size2[0] + ')'); + } + break; + case 2: + // Matrix x Matrix + if (size1[1] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Matrix A columns (' + size1[1] + ') must match Matrix B rows (' + size2[0] + ')'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix A has ' + size1.length + ' dimensions)'); + } + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (N) + * @param {Matrix} b Dense Vector (N) + * + * @return {number} Scalar value + */ + var _multiplyVectorVector = function (a, b, n) { + // check empty vector + if (n === 0) + throw new Error('Cannot multiply two empty vectors'); + + // a dense + var adata = a._data; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bdt = b._datatype; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + } + + // result (do not initialize it with zero) + var c = mf(adata[0], bdata[0]); + // loop data + for (var i = 1; i < n; i++) { + // multiply and accumulate + c = af(c, mf(adata[i], bdata[i])); + } + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (M) + * @param {Matrix} b Matrix (MxN) + * + * @return {Matrix} Dense Vector (N) + */ + var _multiplyVectorMatrix = function (a, b) { + // process storage + switch (b.storage()) { + case 'dense': + return _multiplyVectorDenseMatrix(a, b); + } + throw new Error('Not implemented'); + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (M) + * @param {Matrix} b Dense Matrix (MxN) + * + * @return {Matrix} Dense Vector (N) + */ + var _multiplyVectorDenseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + // rows & columns + var alength = asize[0]; + var bcolumns = bsize[1]; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + } + + // result + var c = []; + + // loop matrix columns + for (var j = 0; j < bcolumns; j++) { + // sum (do not initialize it with zero) + var sum = mf(adata[0], bdata[0][j]); + // loop vector + for (var i = 1; i < alength; i++) { + // multiply & accumulate + sum = af(sum, mf(adata[i], bdata[i][j])); + } + c[j] = sum; + } + + // return matrix + return new DenseMatrix({ + data: c, + size: [bcolumns], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a Matrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} Dense Vector (M) + */ + var _multiplyMatrixVector = function (a, b) { + // process storage + switch (a.storage()) { + case 'dense': + return _multiplyDenseMatrixVector(a, b); + case 'sparse': + return _multiplySparseMatrixVector(a, b); + } + }; + + /** + * C = A * B + * + * @param {Matrix} a Matrix (MxN) + * @param {Matrix} b Matrix (NxC) + * + * @return {Matrix} Matrix (MxC) + */ + var _multiplyMatrixMatrix = function (a, b) { + // process storage + switch (a.storage()) { + case 'dense': + // process storage + switch (b.storage()) { + case 'dense': + return _multiplyDenseMatrixDenseMatrix(a, b); + case 'sparse': + return _multiplyDenseMatrixSparseMatrix(a, b); + } + break; + case 'sparse': + // process storage + switch (b.storage()) { + case 'dense': + return _multiplySparseMatrixDenseMatrix(a, b); + case 'sparse': + return _multiplySparseMatrixSparseMatrix(a, b); + } + break; + } + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} Dense Vector (M) + */ + var _multiplyDenseMatrixVector = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = asize[0]; + var acolumns = asize[1]; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + } + + // result + var c = []; + + // loop matrix a rows + for (var i = 0; i < arows; i++) { + // current row + var row = adata[i]; + // sum (do not initialize it with zero) + var sum = mf(row[0], bdata[0]); + // loop matrix a columns + for (var j = 1; j < acolumns; j++) { + // multiply & accumulate + sum = af(sum, mf(row[j], bdata[j])); + } + c[i] = sum; + } + + // return matrix + return new DenseMatrix({ + data: c, + size: [arows], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b DenseMatrix (NxC) + * + * @return {Matrix} DenseMatrix (MxC) + */ + var _multiplyDenseMatrixDenseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + // rows & columns + var arows = asize[0]; + var acolumns = asize[1]; + var bcolumns = bsize[1]; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + } + + // result + var c = []; + + // loop matrix a rows + for (var i = 0; i < arows; i++) { + // current row + var row = adata[i]; + // initialize row array + c[i] = []; + // loop matrix b columns + for (var j = 0; j < bcolumns; j++) { + // sum (avoid initializing sum to zero) + var sum = mf(row[0], bdata[0][j]); + // loop matrix a columns + for (var x = 1; x < acolumns; x++) { + // multiply & accumulate + sum = af(sum, mf(row[x], bdata[x][j])); + } + c[i][j] = sum; + } + } + + // return matrix + return new DenseMatrix({ + data: c, + size: [arows, bcolumns], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b SparseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplyDenseMatrixSparseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b sparse + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + // validate b matrix + if (!bvalues) + throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix'); + // rows & columns + var arows = asize[0]; + var bcolumns = bsize[1]; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + // equalScalar signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + } + + // result + var cvalues = []; + var cindex = []; + var cptr = []; + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // indeces in column jb + var kb0 = bptr[jb]; + var kb1 = bptr[jb + 1]; + // do not process column jb if no data exists + if (kb1 > kb0) { + // last row mark processed + var last = 0; + // loop a rows + for (var i = 0; i < arows; i++) { + // column mark + var mark = i + 1; + // C[i, jb] + var cij; + // values in b column j + for (var kb = kb0; kb < kb1; kb++) { + // row + var ib = bindex[kb]; + // check value has been initialized + if (last !== mark) { + // first value in column jb + cij = mf(adata[i][ib], bvalues[kb]); + // update mark + last = mark; + } + else { + // accumulate value + cij = af(cij, mf(adata[i][ib], bvalues[kb])); + } + } + // check column has been processed and value != 0 + if (last === mark && !eq(cij, zero)) { + // push row & value + cindex.push(i); + cvalues.push(cij); + } + } + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} SparseMatrix (M, 1) + */ + var _multiplySparseMatrixVector = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // validate a matrix + if (!avalues) + throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = a._size[0]; + var brows = b._size[0]; + // result + var cvalues = []; + var cindex = []; + var cptr = []; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + // equalScalar signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + } + + // workspace + var x = []; + // vector with marks indicating a value x[i] exists in a given column + var w = []; + + // update ptr + cptr[0] = 0; + // rows in b + for (var ib = 0; ib < brows; ib++) { + // b[ib] + var vbi = bdata[ib]; + // check b[ib] != 0, avoid loops + if (!eq(vbi, zero)) { + // A values & index in ib column + for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // a row + var ia = aindex[ka]; + // check value exists in current j + if (!w[ia]) { + // ia is new entry in j + w[ia] = true; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(vbi, avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(vbi, avalues[ka])); + } + } + } + } + // copy values from x to column jb of c + for (var p1 = cindex.length, p = 0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + // update ptr + cptr[1] = cindex.length; + + // return sparse matrix + return new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, 1], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b DenseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplySparseMatrixDenseMatrix = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // validate a matrix + if (!avalues) + throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = a._size[0]; + var brows = b._size[0]; + var bcolumns = b._size[1]; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + // equalScalar signature to use + var eq = equalScalar; + // zero value + var zero = 0; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + } + + // result + var cvalues = []; + var cindex = []; + var cptr = []; + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + + // workspace + var x = []; + // vector with marks indicating a value x[i] exists in a given column + var w = []; + + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // mark in workspace for current column + var mark = jb + 1; + // rows in jb + for (var ib = 0; ib < brows; ib++) { + // b[ib, jb] + var vbij = bdata[ib][jb]; + // check b[ib, jb] != 0, avoid loops + if (!eq(vbij, zero)) { + // A values & index in ib column + for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // a row + var ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(vbij, avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(vbij, avalues[ka])); + } + } + } + } + // copy values from x to column jb of c + for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b SparseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplySparseMatrixSparseMatrix = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // b sparse + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bdt = b._datatype; + + // rows & columns + var arows = a._size[0]; + var bcolumns = b._size[1]; + // flag indicating both matrices (a & b) contain data + var values = avalues && bvalues; + + // datatype + var dt; + // addScalar signature to use + var af = addScalar; + // multiplyScalar signature to use + var mf = multiplyScalar; + + // process data types + if (adt && bdt && adt === bdt && typeof adt === 'string') { + // datatype + dt = adt; + // find signatures that matches (dt, dt) + af = typed.find(addScalar, [dt, dt]); + mf = typed.find(multiplyScalar, [dt, dt]); + } + + // result + var cvalues = values ? [] : undefined; + var cindex = []; + var cptr = []; + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + + // workspace + var x = values ? [] : undefined; + // vector with marks indicating a value x[i] exists in a given column + var w = []; + // variables + var ka, ka0, ka1, kb, kb0, kb1, ia, ib; + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // mark in workspace for current column + var mark = jb + 1; + // B values & index in j + for (kb0 = bptr[jb], kb1 = bptr[jb + 1], kb = kb0; kb < kb1; kb++) { + // b row + ib = bindex[kb]; + // check we need to process values + if (values) { + // loop values in a[:,ib] + for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // row + ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(bvalues[kb], avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(bvalues[kb], avalues[ka])); + } + } + } + else { + // loop values in a[:,ib] + for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // row + ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + } + } + } + } + // check we need to process matrix values (pattern matrix) + if (values) { + // copy values from x to column jb of c + for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // return sparse matrix + return c; + }; + + multiply.toTex = { + 2: '\\left(${args[0]}' + latex.operators['multiply'] + '${args[1]}\\right)' + }; + + return multiply; + } + + exports.name = 'multiply'; + exports.factory = factory; + + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked NZ times (number of nonzero items in S). + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {Function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} SparseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm11 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + var adt = s._datatype; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string') { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // convert b to the same datatype + b = typed.convert(b, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = []; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // loop columns + for (var j = 0; j < columns; j++) { + // initialize ptr + cptr[j] = cindex.length; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var i = aindex[k]; + // invoke callback + var v = inverse ? cf(b, avalues[k]) : cf(avalues[k], b); + // check value is zero + if (!eq(v, zero)) { + // push index & value + cindex.push(i); + cvalues.push(v); + } + } + } + // update ptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm11; + } + + exports.name = 'algorithm11'; + exports.factory = factory; + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the absolute value of a number. For matrices, the function is + * evaluated element wise. + * + * Syntax: + * + * math.abs(x) + * + * Examples: + * + * math.abs(3.5); // returns number 3.5 + * math.abs(-4.2); // returns number 4.2 + * + * math.abs([3, -5, -1, 0, 2]); // returns Array [3, 5, 1, 0, 2] + * + * See also: + * + * sign + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x + * A number or matrix for which to get the absolute value + * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} + * Absolute value of `x` + */ + var abs = typed('abs', { + 'number': Math.abs, + + 'Complex': function (x) { + return x.abs(); + }, + + 'BigNumber': function (x) { + return x.abs(); + }, + + 'Fraction': function (x) { + return x.abs(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since abs(0) = 0 + return deepMap(x, abs, true); + }, + + 'Unit': function(x) { + return x.abs(); + } + }); + + abs.toTex = {1: '\\left|${args[0]}\\right|'}; + + return abs; + } + + exports.name = 'abs'; + exports.factory = factory; + + +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var equalScalar = load(__webpack_require__(48)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether two values are equal. + * + * The function tests whether the relative difference between x and y is + * smaller than the configured epsilon. The function cannot be used to + * compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * In case of complex numbers, x.re must equal y.re, and x.im must equal y.im. + * + * Values `null` and `undefined` are compared strictly, thus `null` is only + * equal to `null` and nothing else, and `undefined` is only equal to + * `undefined` and nothing else. + * + * Syntax: + * + * math.equal(x, y) + * + * Examples: + * + * math.equal(2 + 2, 3); // returns false + * math.equal(2 + 2, 4); // returns true + * + * var a = math.unit('50 cm'); + * var b = math.unit('5 m'); + * math.equal(a, b); // returns true + * + * var c = [2, 5, 1]; + * var d = [2, 7, 1]; + * + * math.equal(c, d); // returns [true, false, true] + * math.deepEqual(c, d); // returns false + * + * math.equal(0, null); // returns false + * + * See also: + * + * unequal, smaller, smallerEq, larger, largerEq, compare, deepEqual + * + * @param {number | BigNumber | boolean | Complex | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | boolean | Complex | Unit | string | Array | Matrix} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the compared values are equal, else returns false + */ + var equal = typed('equal', { + + 'any, any': function (x, y) { + // strict equality for null and undefined? + if (x === null) { return y === null; } + if (y === null) { return x === null; } + if (x === undefined) { return y === undefined; } + if (y === undefined) { return x === undefined; } + + return equalScalar(x, y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, equalScalar); + break; + default: + // sparse + dense + c = algorithm03(y, x, equalScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, equalScalar, false); + break; + default: + // dense + dense + c = algorithm13(x, y, equalScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return equal(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return equal(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return equal(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, equalScalar, false); + break; + default: + c = algorithm14(x, y, equalScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, equalScalar, true); + break; + default: + c = algorithm14(y, x, equalScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, equalScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, equalScalar, true).valueOf(); + } + }); + + equal.toTex = { + 2: '\\left(${args[0]}' + latex.operators['equal'] + '${args[1]}\\right)' + }; + + return equal; + } + + exports.name = 'equal'; + exports.factory = factory; + + +/***/ }, +/* 88 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Test whether a value is an numeric value. + * + * The function is evaluated element-wise in case of Array or Matrix input. + * + * Syntax: + * + * math.isNumeric(x) + * + * Examples: + * + * math.isNumeric(2); // returns true + * math.isNumeric(0); // returns true + * math.isNumeric(math.bignumber(500)); // returns true + * math.isNumeric(math.fraction(4)); // returns true + * math.isNumeric(math.complex('2-4i'); // returns false + * math.isNumeric('3'); // returns false + * math.isNumeric([2.3, 'foo', false]); // returns [true, false, true] + * + * See also: + * + * isZero, isPositive, isNegative, isInteger + * + * @param {*} x Value to be tested + * @return {boolean} Returns true when `x` is a `number`, `BigNumber`, + * `Fraction`, or `boolean`. Returns false for other types. + * Throws an error in case of unknown types. + */ + var isNumeric = typed('isNumeric', { + 'number | BigNumber | Fraction | boolean': function () { + return true; + }, + + 'Complex | Unit | string': function () { + return false; + }, + + 'Array | Matrix': function (x) { + return deepMap(x, isNumeric); + } + }); + + return isNumeric; + } + + exports.name = 'isNumeric'; + exports.factory = factory; + + +/***/ }, +/* 89 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var string = __webpack_require__(23); + + function factory (type, config, load, typed) { + /** + * Format a value of any type into a string. + * + * Syntax: + * + * math.format(value) + * math.format(value, options) + * math.format(value, precision) + * math.format(value, callback) + * + * Where: + * + * - `value: *` + * The value to be formatted + * - `options: Object` + * An object with formatting options. Available options: + * - `notation: string` + * Number notation. Choose from: + * - 'fixed' + * Always use regular number notation. + * For example '123.40' and '14000000' + * - 'exponential' + * Always use exponential notation. + * For example '1.234e+2' and '1.4e+7' + * - 'engineering' + * Always use engineering notation. + * For example '123.4e+0' and '14.0e+6' + * - 'auto' (default) + * Regular number notation for numbers having an absolute value between + * `lower` and `upper` bounds, and uses exponential notation elsewhere. + * Lower bound is included, upper bound is excluded. + * For example '123.4' and '1.4e7'. + * - `precision: number` + * A number between 0 and 16 to round the digits of the number. In case + * of notations 'exponential' and 'auto', `precision` defines the total + * number of significant digits returned and is undefined by default. + * In case of notation 'fixed', `precision` defines the number of + * significant digits after the decimal point, and is 0 by default. + * - `exponential: Object` + * An object containing two parameters, {number} lower and {number} upper, + * used by notation 'auto' to determine when to return exponential + * notation. Default values are `lower=1e-3` and `upper=1e5`. Only + * applicable for notation `auto`. + * - `fraction: string`. Available values: 'ratio' (default) or 'decimal'. + * For example `format(fraction(1, 3))` will output '1/3' when 'ratio' is + * configured, and will output `0.(3)` when 'decimal' is configured. + * - `callback: function` + * A custom formatting function, invoked for all numeric elements in `value`, + * for example all elements of a matrix, or the real and imaginary + * parts of a complex number. This callback can be used to override the + * built-in numeric notation with any type of formatting. Function `callback` + * is called with `value` as parameter and must return a string. + * + * When `value` is an Object: + * + * - When the object contains a property `format` being a function, this function + * is invoked as `value.format(options)` and the result is returned. + * - When the object has its own `toString` method, this method is invoked + * and the result is returned. + * - In other cases the function will loop over all object properties and + * return JSON object notation like '{"a": 2, "b": 3}'. + * + * When value is a function: + * + * - When the function has a property `syntax`, it returns this + * syntax description. + * - In other cases, a string `'function'` is returned. + * + * Examples: + * + * math.format(6.4); // returns '6.4' + * math.format(1240000); // returns '1.24e6' + * math.format(1/3); // returns '0.3333333333333333' + * math.format(1/3, 3); // returns '0.333' + * math.format(21385, 2); // returns '21000' + * math.format(12.071, {notation: 'fixed'}); // returns '12' + * math.format(2.3, {notation: 'fixed', precision: 2}); // returns '2.30' + * math.format(52.8, {notation: 'exponential'}); // returns '5.28e+1' + * math.format(12400, {notation: 'engineering'}); // returns '12.400e+3' + * + * function formatCurrency(value) { + * // return currency notation with two digits: + * return '$' + value.toFixed(2); + * + * // you could also use math.format inside the callback: + * // return '$' + math.format(value, {notation: 'fixed', precision: 2}); + * } + * math.format([2.1, 3, 0.016], formatCurrency}; // returns '[$2.10, $3.00, $0.02]' + * + * See also: + * + * print + * + * @param {*} value Value to be stringified + * @param {Object | Function | number} [options] Formatting options + * @return {string} The formatted value + */ + var format = typed('format', { + 'any': string.format, + 'any, Object | function | number': string.format + }); + + format.toTex = undefined; // use default template + + return format; + } + + exports.name = 'format'; + exports.factory = factory; + + +/***/ }, +/* 90 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var types = __webpack_require__(41); + + function factory (type, config, load, typed) { + /** + * Determine the type of a variable. + * + * Function `typeof` recognizes the following types of objects: + * + * Object | Returns | Example + * ---------------------- | ------------- | ------------------------------------------ + * null | `'null'` | `math.typeof(null)` + * number | `'number'` | `math.typeof(3.5)` + * boolean | `'boolean'` | `math.typeof (true)` + * string | `'string'` | `math.typeof ('hello world')` + * Array | `'Array'` | `math.typeof ([1, 2, 3])` + * Date | `'Date'` | `math.typeof (new Date())` + * Function | `'Function'` | `math.typeof (function () {})` + * Object | `'Object'` | `math.typeof ({a: 2, b: 3})` + * RegExp | `'RegExp'` | `math.typeof (/a regexp/)` + * undefined | `'undefined'` | `math.typeof(undefined)` + * math.type.BigNumber | `'BigNumber'` | `math.typeof (math.bignumber('2.3e500'))` + * math.type.Chain | `'Chain'` | `math.typeof (math.chain(2))` + * math.type.Complex | `'Complex'` | `math.typeof (math.complex(2, 3))` + * math.type.Fraction | `'Fraction'` | `math.typeof (math.fraction(1, 3))` + * math.type.Help | `'Help'` | `math.typeof (math.help('sqrt'))` + * math.type.Index | `'Index'` | `math.typeof (math.index(1, 3))` + * math.type.Matrix | `'Matrix'` | `math.typeof (math.matrix([[1,2], [3, 4]]))` + * math.type.Range | `'Range'` | `math.typeof (math.range(0, 10))` + * math.type.Unit | `'Unit'` | `math.typeof (math.unit('45 deg'))` + * + * Syntax: + * + * math.typeof(x) + * + * Examples: + * + * math.typeof(3.5); // returns 'number' + * math.typeof(math.complex('2-4i')); // returns 'Complex' + * math.typeof(math.unit('45 deg')); // returns 'Unit' + * math.typeof('hello world'); // returns 'string' + * + * @param {*} x The variable for which to test the type. + * @return {string} Returns the name of the type. Primitive types are lower case, + * non-primitive types are upper-camel-case. + * For example 'number', 'string', 'Array', 'Date'. + */ + var _typeof = typed('_typeof', { + 'any': function (x) { + // JavaScript types + var t = types.type(x); + + // math.js types + if (t === 'Object') { + if (x.isBigNumber === true) return 'BigNumber'; + if (x.isComplex === true) return 'Complex'; + if (x.isFraction === true) return 'Fraction'; + if (x.isMatrix === true) return 'Matrix'; + if (x.isUnit === true) return 'Unit'; + if (x.isIndex === true) return 'Index'; + if (x.isRange === true) return 'Range'; + if (x.isChain === true) return 'Chain'; + if (x.isHelp === true) return 'Help'; + } + + return t; + } + }); + + _typeof.toTex = undefined; // use default template + + return _typeof; + } + + exports.name = 'typeof'; + exports.factory = factory; + + +/***/ }, +/* 91 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Create a unit. Depending on the passed arguments, the function + * will create and return a new math.type.Unit object. + * When a matrix is provided, all elements will be converted to units. + * + * Syntax: + * + * math.unit(unit : string) + * math.unit(value : number, unit : string) + * + * Examples: + * + * var a = math.unit(5, 'cm'); // returns Unit 50 mm + * var b = math.unit('23 kg'); // returns Unit 23 kg + * a.to('m'); // returns Unit 0.05 m + * + * See also: + * + * bignumber, boolean, complex, index, matrix, number, string + * + * @param {* | Array | Matrix} args A number and unit. + * @return {Unit | Array | Matrix} The created unit + */ + + var unit = typed('unit', { + 'Unit': function (x) { + return x.clone(); + }, + + 'string': function (x) { + if (type.Unit.isValuelessUnit(x)) { + return new type.Unit(null, x); // a pure unit + } + + return type.Unit.parse(x); // a unit with value, like '5cm' + }, + + 'number | BigNumber | Fraction | Complex, string': function (value, unit) { + return new type.Unit(value, unit); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, unit); + } + }); + + unit.toTex = { + 1: '\\left(${args[0]}\\right)', + 2: '\\left(\\left(${args[0]}\\right)${args[1]}\\right)' + }; + + return unit; + } + + exports.name = 'unit'; + exports.factory = factory; + + +/***/ }, +/* 92 */ +/***/ function(module, exports, __webpack_require__) { + + var lazy = __webpack_require__(3).lazy; + + + function factory (type, config, load, typed, math) { + + // helper function to create a unit with a fixed prefix + function fixedUnit(str) { + var unit = type.Unit.parse(str); + unit.fixPrefix = true; + return unit; + } + + // Source: http://www.wikiwand.com/en/Physical_constant + + // Universal constants + lazy(math, 'speedOfLight', function () {return fixedUnit('299792458 m s^-1')}); + lazy(math, 'gravitationConstant', function () {return fixedUnit('6.6738480e-11 m^3 kg^-1 s^-2')}); + lazy(math, 'planckConstant', function () {return fixedUnit('6.626069311e-34 J s')}); + lazy(math, 'reducedPlanckConstant',function () {return fixedUnit('1.05457172647e-34 J s')}); + + // Electromagnetic constants + lazy(math, 'magneticConstant', function () {return fixedUnit('1.2566370614e-6 N A^-2')}); + lazy(math, 'electricConstant', function () {return fixedUnit('8.854187817e-12 F m^-1')}); + lazy(math, 'vacuumImpedance', function () {return fixedUnit('376.730313461 ohm')}); + lazy(math, 'coulomb', function () {return fixedUnit('8.9875517873681764e9 N m^2 C^-2')}); + lazy(math, 'elementaryCharge', function () {return fixedUnit('1.60217656535e-19 C')}); + lazy(math, 'bohrMagneton', function () {return fixedUnit('9.2740096820e-24 J T^-1')}); + lazy(math, 'conductanceQuantum', function () {return fixedUnit('7.748091734625e-5 S')}); + lazy(math, 'inverseConductanceQuantum', function () {return fixedUnit('12906.403721742 ohm')}); + lazy(math, 'magneticFluxQuantum', function () {return fixedUnit('2.06783375846e-15 Wb')}); + lazy(math, 'nuclearMagneton', function () {return fixedUnit('5.0507835311e-27 J T^-1')}); + lazy(math, 'klitzing', function () {return fixedUnit('25812.807443484 ohm')}); + //lazy(math, 'josephson', function () {return fixedUnit('4.8359787011e-14 Hz V^-1')}); // TODO: support for Hz needed + + // Atomic and nuclear constants + lazy(math, 'bohrRadius', function () {return fixedUnit('5.291772109217e-11 m')}); + lazy(math, 'classicalElectronRadius', function () {return fixedUnit('2.817940326727e-15 m')}); + lazy(math, 'electronMass', function () {return fixedUnit('9.1093829140e-31 kg')}); + lazy(math, 'fermiCoupling', function () {return fixedUnit('1.1663645e-5 GeV^-2')}); + lazy(math, 'fineStructure', function () {return 7.297352569824e-3}); + lazy(math, 'hartreeEnergy', function () {return fixedUnit('4.3597443419e-18 J')}); + lazy(math, 'protonMass', function () {return fixedUnit('1.67262177774e-27 kg')}); + lazy(math, 'deuteronMass', function () {return fixedUnit('3.3435830926e-27 kg')}); + lazy(math, 'neutronMass', function () {return fixedUnit('1.6749271613e-27 kg')}); + lazy(math, 'quantumOfCirculation', function () {return fixedUnit('3.636947552024e-4 m^2 s^-1')}); + lazy(math, 'rydberg', function () {return fixedUnit('10973731.56853955 m^-1')}); + lazy(math, 'thomsonCrossSection', function () {return fixedUnit('6.65245873413e-29 m^2')}); + lazy(math, 'weakMixingAngle', function () {return 0.222321}); + lazy(math, 'efimovFactor', function () {return 22.7}); + + // Physico-chemical constants + lazy(math, 'atomicMass', function () {return fixedUnit('1.66053892173e-27 kg')}); + lazy(math, 'avogadro', function () {return fixedUnit('6.0221412927e23 mol^-1')}); + lazy(math, 'boltzmann', function () {return fixedUnit('1.380648813e-23 J K^-1')}); + lazy(math, 'faraday', function () {return fixedUnit('96485.336521 C mol^-1')}); + lazy(math, 'firstRadiation', function () {return fixedUnit('3.7417715317e-16 W m^2')}); + // lazy(math, 'spectralRadiance', function () {return fixedUnit('1.19104286953e-16 W m^2 sr^-1')}); // TODO spectralRadiance + lazy(math, 'loschmidt', function () {return fixedUnit('2.686780524e25 m^-3')}); + lazy(math, 'gasConstant', function () {return fixedUnit('8.314462175 J K^-1 mol^-1')}); + lazy(math, 'molarPlanckConstant', function () {return fixedUnit('3.990312717628e-10 J s mol^-1')}); + lazy(math, 'molarVolume', function () {return fixedUnit('2.241396820e-10 m^3 mol^-1')}); + lazy(math, 'sackurTetrode', function () {return -1.164870823}); + lazy(math, 'secondRadiation', function () {return fixedUnit('1.438777013e-2 m K')}); + lazy(math, 'stefanBoltzmann', function () {return fixedUnit('5.67037321e-8 W m^-2 K^-4')}); + lazy(math, 'wienDisplacement', function () {return fixedUnit('2.897772126e-3 m K')}); + + // Adopted values + lazy(math, 'molarMass', function () {return fixedUnit('1e-3 kg mol^-1')}); + lazy(math, 'molarMassC12', function () {return fixedUnit('1.2e-2 kg mol^-1')}); + lazy(math, 'gravity', function () {return fixedUnit('9.80665 m s^-2')}); + // atm is defined in Unit.js + + // Natural units + lazy(math, 'planckLength', function () {return fixedUnit('1.61619997e-35 m')}); + lazy(math, 'planckMass', function () {return fixedUnit('2.1765113e-8 kg')}); + lazy(math, 'planckTime', function () {return fixedUnit('5.3910632e-44 s')}); + lazy(math, 'planckCharge', function () {return fixedUnit('1.87554595641e-18 C')}); + lazy(math, 'planckTemperature', function () {return fixedUnit('1.41683385e+32 K')}); + + } + + exports.factory = factory; + exports.lazy = false; // no lazy loading of constants, the constants themselves are lazy when needed + exports.math = true; // request access to the math namespace + + +/***/ }, +/* 93 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(3); + var bigConstants = __webpack_require__(76); + + function factory (type, config, load, typed, math) { + // listen for changed in the configuration, automatically reload + // constants when needed + math.on('config', function (curr, prev) { + if (curr.number !== prev.number) { + factory(type, config, load, typed, math); + } + }); + + math['true'] = true; + math['false'] = false; + math['null'] = null; + math['uninitialized'] = __webpack_require__(40).UNINITIALIZED; + + if (config.number === 'BigNumber') { + math['Infinity'] = new type.BigNumber(Infinity); + math['NaN'] = new type.BigNumber(NaN); + + object.lazy(math, 'pi', function () {return bigConstants.pi(type.BigNumber)}); + object.lazy(math, 'tau', function () {return bigConstants.tau(type.BigNumber)}); + object.lazy(math, 'e', function () {return bigConstants.e(type.BigNumber)}); + object.lazy(math, 'phi', function () {return bigConstants.phi(type.BigNumber)}); // golden ratio, (1+sqrt(5))/2 + + // uppercase constants (for compatibility with built-in Math) + object.lazy(math, 'E', function () {return math.e;}); + object.lazy(math, 'LN2', function () {return new type.BigNumber(2).ln();}); + object.lazy(math, 'LN10', function () {return new type.BigNumber(10).ln()}); + object.lazy(math, 'LOG2E', function () {return new type.BigNumber(1).div(new type.BigNumber(2).ln());}); + object.lazy(math, 'LOG10E', function () {return new type.BigNumber(1).div(new type.BigNumber(10).ln())}); + object.lazy(math, 'PI', function () {return math.pi}); + object.lazy(math, 'SQRT1_2', function () {return new type.BigNumber('0.5').sqrt()}); + object.lazy(math, 'SQRT2', function () {return new type.BigNumber(2).sqrt()}); + } + else { + math['Infinity'] = Infinity; + math['NaN'] = NaN; + + math.pi = Math.PI; + math.tau = Math.PI * 2; + math.e = Math.E; + math.phi = 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2 + + // uppercase constants (for compatibility with built-in Math) + math.E = math.e; + math.LN2 = Math.LN2; + math.LN10 = Math.LN10; + math.LOG2E = Math.LOG2E; + math.LOG10E = Math.LOG10E; + math.PI = math.pi; + math.SQRT1_2 = Math.SQRT1_2; + math.SQRT2 = Math.SQRT2; + } + + // complex i + math.i = type.Complex.I; + + // meta information + math.version = __webpack_require__(94); + } + + exports.factory = factory; + exports.lazy = false; // no lazy loading of constants, the constants themselves are lazy when needed + exports.math = true; // request access to the math namespace + +/***/ }, +/* 94 */ +/***/ function(module, exports) { + + module.exports = '3.2.1'; + // Note: This file is automatically generated when building math.js. + // Changes made in this file will be overwritten. + + +/***/ }, +/* 95 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(96), + __webpack_require__(268), + __webpack_require__(297), + __webpack_require__(299), + + __webpack_require__(325), + __webpack_require__(270), + __webpack_require__(296) + ]; + + +/***/ }, +/* 96 */ +/***/ function(module, exports, __webpack_require__) { + + function factory (construction, config, load, typed) { + var docs = {}; + + + // construction functions + docs.bignumber = __webpack_require__(97); + docs['boolean'] = __webpack_require__(98); + docs.complex = __webpack_require__(99); + docs.fraction = __webpack_require__(100); + docs.index = __webpack_require__(101); + docs.matrix = __webpack_require__(102); + docs.number = __webpack_require__(103); + docs.sparse = __webpack_require__(104); + docs.string = __webpack_require__(105); + docs.unit = __webpack_require__(106); + + // constants + docs.e = __webpack_require__(107); + docs.E = __webpack_require__(107); + docs['false'] = __webpack_require__(108); + docs.i = __webpack_require__(109); + docs['Infinity'] = __webpack_require__(110); + docs.LN2 = __webpack_require__(111); + docs.LN10 = __webpack_require__(112); + docs.LOG2E = __webpack_require__(113); + docs.LOG10E = __webpack_require__(114); + docs.NaN = __webpack_require__(115); + docs['null'] = __webpack_require__(116); + docs.pi = __webpack_require__(117); + docs.PI = __webpack_require__(117); + docs.phi = __webpack_require__(118); + docs.SQRT1_2 = __webpack_require__(119); + docs.SQRT2 = __webpack_require__(120); + docs.tau = __webpack_require__(121); + docs['true'] = __webpack_require__(122); + docs.version = __webpack_require__(123); + + // physical constants + // TODO: more detailed docs for physical constants + docs.speedOfLight = {description: 'Speed of light in vacuum', examples: ['speedOfLight']}; + docs.gravitationConstant = {description: 'Newtonian constant of gravitation', examples: ['gravitationConstant']}; + docs.planckConstant = {description: 'Planck constant', examples: ['planckConstant']}; + docs.reducedPlanckConstant = {description: 'Reduced Planck constant', examples: ['reducedPlanckConstant']}; + + docs.magneticConstant = {description: 'Magnetic constant (vacuum permeability)', examples: ['magneticConstant']}; + docs.electricConstant = {description: 'Electric constant (vacuum permeability)', examples: ['electricConstant']}; + docs.vacuumImpedance = {description: 'Characteristic impedance of vacuum', examples: ['vacuumImpedance']}; + docs.coulomb = {description: 'Coulomb\'s constant', examples: ['coulomb']}; + docs.elementaryCharge = {description: 'Elementary charge', examples: ['elementaryCharge']}; + docs.bohrMagneton = {description: 'Borh magneton', examples: ['bohrMagneton']}; + docs.conductanceQuantum = {description: 'Conductance quantum', examples: ['conductanceQuantum']}; + docs.inverseConductanceQuantum = {description: 'Inverse conductance quantum', examples: ['inverseConductanceQuantum']}; + //docs.josephson = {description: 'Josephson constant', examples: ['josephson']}; + docs.magneticFluxQuantum = {description: 'Magnetic flux quantum', examples: ['magneticFluxQuantum']}; + docs.nuclearMagneton = {description: 'Nuclear magneton', examples: ['nuclearMagneton']}; + docs.klitzing = {description: 'Von Klitzing constant', examples: ['klitzing']}; + + docs.bohrRadius = {description: 'Borh radius', examples: ['bohrRadius']}; + docs.classicalElectronRadius = {description: 'Classical electron radius', examples: ['classicalElectronRadius']}; + docs.electronMass = {description: 'Electron mass', examples: ['electronMass']}; + docs.fermiCoupling = {description: 'Fermi coupling constant', examples: ['fermiCoupling']}; + docs.fineStructure = {description: 'Fine-structure constant', examples: ['fineStructure']}; + docs.hartreeEnergy = {description: 'Hartree energy', examples: ['hartreeEnergy']}; + docs.protonMass = {description: 'Proton mass', examples: ['protonMass']}; + docs.deuteronMass = {description: 'Deuteron Mass', examples: ['deuteronMass']}; + docs.neutronMass = {description: 'Neutron mass', examples: ['neutronMass']}; + docs.quantumOfCirculation = {description: 'Quantum of circulation', examples: ['quantumOfCirculation']}; + docs.rydberg = {description: 'Rydberg constant', examples: ['rydberg']}; + docs.thomsonCrossSection = {description: 'Thomson cross section', examples: ['thomsonCrossSection']}; + docs.weakMixingAngle = {description: 'Weak mixing angle', examples: ['weakMixingAngle']}; + docs.efimovFactor = {description: 'Efimov factor', examples: ['efimovFactor']}; + + docs.atomicMass = {description: 'Atomic mass constant', examples: ['atomicMass']}; + docs.avogadro = {description: 'Avogadro\'s number', examples: ['avogadro']}; + docs.boltzmann = {description: 'Boltzmann constant', examples: ['boltzmann']}; + docs.faraday = {description: 'Faraday constant', examples: ['faraday']}; + docs.firstRadiation = {description: 'First radiation constant', examples: ['firstRadiation']}; + docs.loschmidt = {description: 'Loschmidt constant at T=273.15 K and p=101.325 kPa', examples: ['loschmidt']}; + docs.gasConstant = {description: 'Gas constant', examples: ['gasConstant']}; + docs.molarPlanckConstant = {description: 'Molar Planck constant', examples: ['molarPlanckConstant']}; + docs.molarVolume = {description: 'Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa', examples: ['molarVolume']}; + docs.sackurTetrode = {description: 'Sackur-Tetrode constant at T=1 K and p=101.325 kPa', examples: ['sackurTetrode']}; + docs.secondRadiation = {description: 'Second radiation constant', examples: ['secondRadiation']}; + docs.stefanBoltzmann = {description: 'Stefan-Boltzmann constant', examples: ['stefanBoltzmann']}; + docs.wienDisplacement = {description: 'Wien displacement law constant', examples: ['wienDisplacement']}; + //docs.spectralRadiance = {description: 'First radiation constant for spectral radiance', examples: ['spectralRadiance']}; + + docs.molarMass = {description: 'Molar mass constant', examples: ['molarMass']}; + docs.molarMassC12 = {description: 'Molar mass constant of carbon-12', examples: ['molarMassC12']}; + docs.gravity = {description: 'Standard acceleration of gravity (standard acceleration of free-fall on Earth)', examples: ['gravity']}; + + docs.planckLength = {description: 'Planck length', examples: ['planckLength']}; + docs.planckMass = {description: 'Planck mass', examples: ['planckMass']}; + docs.planckTime = {description: 'Planck time', examples: ['planckTime']}; + docs.planckCharge = {description: 'Planck charge', examples: ['planckCharge']}; + docs.planckTemperature = {description: 'Planck temperature', examples: ['planckTemperature']}; + + // functions - algebra + docs.lsolve = __webpack_require__(124); + docs.lup = __webpack_require__(125); + docs.lusolve = __webpack_require__(126); + docs.slu = __webpack_require__(127); + docs.usolve = __webpack_require__(128); + + // functions - arithmetic + docs.abs = __webpack_require__(129); + docs.add = __webpack_require__(130); + docs.cbrt = __webpack_require__(131); + docs.ceil = __webpack_require__(132); + docs.cube = __webpack_require__(133); + docs.divide = __webpack_require__(134); + docs.dotDivide = __webpack_require__(135); + docs.dotMultiply = __webpack_require__(136); + docs.dotPow = __webpack_require__(137); + docs.exp = __webpack_require__(138); + docs.fix = __webpack_require__(139); + docs.floor = __webpack_require__(140); + docs.gcd = __webpack_require__(141); + docs.hypot = __webpack_require__(142); + docs.lcm = __webpack_require__(143); + docs.log = __webpack_require__(144); + docs.log10 = __webpack_require__(145); + docs.mod = __webpack_require__(146); + docs.multiply = __webpack_require__(147); + docs.norm = __webpack_require__(148); + docs.nthRoot = __webpack_require__(149); + docs.pow = __webpack_require__(150); + docs.round = __webpack_require__(151); + docs.sign = __webpack_require__(152); + docs.sqrt = __webpack_require__(153); + docs.square = __webpack_require__(154); + docs.subtract = __webpack_require__(155); + docs.unaryMinus = __webpack_require__(156); + docs.unaryPlus = __webpack_require__(157); + docs.xgcd = __webpack_require__(158); + + // functions - bitwise + docs.bitAnd = __webpack_require__(159); + docs.bitNot = __webpack_require__(160); + docs.bitOr = __webpack_require__(161); + docs.bitXor = __webpack_require__(162); + docs.leftShift = __webpack_require__(163); + docs.rightArithShift = __webpack_require__(164); + docs.rightLogShift = __webpack_require__(165); + + // functions - combinatorics + docs.bellNumbers = __webpack_require__(166); + docs.catalan = __webpack_require__(167); + docs.composition = __webpack_require__(168); + docs.stirlingS2 = __webpack_require__(169); + + // functions - core + docs['config'] = __webpack_require__(170); + docs['import'] = __webpack_require__(171); + docs['typed'] = __webpack_require__(172); + + // functions - complex + docs.arg = __webpack_require__(173); + docs.conj = __webpack_require__(174); + docs.re = __webpack_require__(175); + docs.im = __webpack_require__(176); + + // functions - expression + docs['eval'] = __webpack_require__(177); + docs.help = __webpack_require__(178); + + // functions - geometry + docs.distance = __webpack_require__(179); + docs.intersect = __webpack_require__(180); + + // functions - logical + docs['and'] = __webpack_require__(181); + docs['not'] = __webpack_require__(182); + docs['or'] = __webpack_require__(183); + docs['xor'] = __webpack_require__(184); + + // functions - matrix + docs['concat'] = __webpack_require__(185); + docs.cross = __webpack_require__(186); + docs.det = __webpack_require__(187); + docs.diag = __webpack_require__(188); + docs.dot = __webpack_require__(189); + docs.eye = __webpack_require__(190); + docs.filter = __webpack_require__(191); + docs.flatten = __webpack_require__(192); + docs.forEach = __webpack_require__(193); + docs.inv = __webpack_require__(194); + docs.map = __webpack_require__(195); + docs.ones = __webpack_require__(196); + docs.partitionSelect = __webpack_require__(197); + docs.range = __webpack_require__(198); + docs.resize = __webpack_require__(199); + docs.size = __webpack_require__(200); + docs.sort = __webpack_require__(201); + docs.squeeze = __webpack_require__(202); + docs.subset = __webpack_require__(203); + docs.trace = __webpack_require__(204); + docs.transpose = __webpack_require__(205); + docs.zeros = __webpack_require__(206); + + // functions - probability + docs.combinations = __webpack_require__(207); + //docs.distribution = require('./function/probability/distribution'); + docs.factorial = __webpack_require__(208); + docs.gamma = __webpack_require__(209); + docs.kldivergence = __webpack_require__(210); + docs.multinomial = __webpack_require__(211); + docs.permutations = __webpack_require__(212); + docs.pickRandom = __webpack_require__(213); + docs.random = __webpack_require__(214); + docs.randomInt = __webpack_require__(215); + + // functions - relational + docs.compare = __webpack_require__(216); + docs.deepEqual = __webpack_require__(217); + docs['equal'] = __webpack_require__(218); + docs.larger = __webpack_require__(219); + docs.largerEq = __webpack_require__(220); + docs.smaller = __webpack_require__(221); + docs.smallerEq = __webpack_require__(222); + docs.unequal = __webpack_require__(223); + + // functions - statistics + docs.max = __webpack_require__(224); + docs.mean = __webpack_require__(225); + docs.median = __webpack_require__(226); + docs.min = __webpack_require__(227); + docs.mode = __webpack_require__(228); + docs.prod = __webpack_require__(229); + docs.quantileSeq = __webpack_require__(230); + docs.std = __webpack_require__(231); + docs.sum = __webpack_require__(232); + docs['var'] = __webpack_require__(233); + + // functions - trigonometry + docs.acos = __webpack_require__(234); + docs.acosh = __webpack_require__(235); + docs.acot = __webpack_require__(236); + docs.acoth = __webpack_require__(237); + docs.acsc = __webpack_require__(238); + docs.acsch = __webpack_require__(239); + docs.asec = __webpack_require__(240); + docs.asech = __webpack_require__(241); + docs.asin = __webpack_require__(242); + docs.asinh = __webpack_require__(243); + docs.atan = __webpack_require__(244); + docs.atanh = __webpack_require__(245); + docs.atan2 = __webpack_require__(246); + docs.cos = __webpack_require__(247); + docs.cosh = __webpack_require__(248); + docs.cot = __webpack_require__(249); + docs.coth = __webpack_require__(250); + docs.csc = __webpack_require__(251); + docs.csch = __webpack_require__(252); + docs.sec = __webpack_require__(253); + docs.sech = __webpack_require__(254); + docs.sin = __webpack_require__(255); + docs.sinh = __webpack_require__(256); + docs.tan = __webpack_require__(257); + docs.tanh = __webpack_require__(258); + + // functions - units + docs.to = __webpack_require__(259); + + // functions - utils + docs.clone = __webpack_require__(260); + docs.format = __webpack_require__(261); + docs.isInteger = __webpack_require__(262); + docs.isNegative = __webpack_require__(263); + docs.isNumeric = __webpack_require__(264); + docs.isPositive = __webpack_require__(265); + docs.isZero = __webpack_require__(266); + // docs.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects. + docs['typeof'] = __webpack_require__(267); + + return docs; + } + + exports.name = 'docs'; + exports.path = 'expression'; + exports.factory = factory; + + +/***/ }, +/* 97 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bignumber', + 'category': 'Construction', + 'syntax': [ + 'bignumber(x)' + ], + 'description': + 'Create a big number from a number or string.', + 'examples': [ + '0.1 + 0.2', + 'bignumber(0.1) + bignumber(0.2)', + 'bignumber("7.2")', + 'bignumber("7.2e500")', + 'bignumber([0.1, 0.2, 0.3])' + ], + 'seealso': [ + 'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit' + ] + }; + + +/***/ }, +/* 98 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'boolean', + 'category': 'Construction', + 'syntax': [ + 'x', + 'boolean(x)' + ], + 'description': + 'Convert a string or number into a boolean.', + 'examples': [ + 'boolean(0)', + 'boolean(1)', + 'boolean(3)', + 'boolean("true")', + 'boolean("false")', + 'boolean([1, 0, 1, 1])' + ], + 'seealso': [ + 'bignumber', 'complex', 'index', 'matrix', 'number', 'string', 'unit' + ] + }; + + +/***/ }, +/* 99 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'complex', + 'category': 'Construction', + 'syntax': [ + 'complex()', + 'complex(re, im)', + 'complex(string)' + ], + 'description': + 'Create a complex number.', + 'examples': [ + 'complex()', + 'complex(2, 3)', + 'complex("7 - 2i")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'index', 'matrix', 'number', 'string', 'unit' + ] + }; + + +/***/ }, +/* 100 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'fraction', + 'category': 'Construction', + 'syntax': [ + 'fraction(num)', + 'fraction(num,den)' + ], + 'description': + 'Create a fraction from a number or from a numerator and denominator.', + 'examples': [ + 'fraction(0.125)', + 'fraction(1, 3) + fraction(2, 5)' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'string', 'unit' + ] + }; + + +/***/ }, +/* 101 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'index', + 'category': 'Construction', + 'syntax': [ + '[start]', + '[start:end]', + '[start:step:end]', + '[start1, start 2, ...]', + '[start1:end1, start2:end2, ...]', + '[start1:step1:end1, start2:step2:end2, ...]' + ], + 'description': + 'Create an index to get or replace a subset of a matrix', + 'examples': [ + '[]', + '[1, 2, 3]', + 'A = [1, 2, 3; 4, 5, 6]', + 'A[1, :]', + 'A[1, 2] = 50', + 'A[0:2, 0:2] = ones(2, 2)' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'matrix,', 'number', 'range', 'string', 'unit' + ] + }; + + +/***/ }, +/* 102 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'matrix', + 'category': 'Construction', + 'syntax': [ + '[]', + '[a1, b1, ...; a2, b2, ...]', + 'matrix()', + 'matrix("dense")', + 'matrix([...])' + ], + 'description': + 'Create a matrix.', + 'examples': [ + '[]', + '[1, 2, 3]', + '[1, 2, 3; 4, 5, 6]', + 'matrix()', + 'matrix([3, 4])', + 'matrix([3, 4; 5, 6], "sparse")', + 'matrix([3, 4; 5, 6], "sparse", "number")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'sparse' + ] + }; + + +/***/ }, +/* 103 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'number', + 'category': 'Construction', + 'syntax': [ + 'x', + 'number(x)' + ], + 'description': + 'Create a number or convert a string or boolean into a number.', + 'examples': [ + '2', + '2e3', + '4.05', + 'number(2)', + 'number("7.2")', + 'number(true)', + 'number([true, false, true, true])', + 'number("52cm", "m")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'fraction', 'index', 'matrix', 'string', 'unit' + ] + }; + + +/***/ }, +/* 104 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sparse', + 'category': 'Construction', + 'syntax': [ + 'sparse()', + 'sparse([a1, b1, ...; a1, b2, ...])', + 'sparse([a1, b1, ...; a1, b2, ...], "number")' + ], + 'description': + 'Create a sparse matrix.', + 'examples': [ + 'sparse()', + 'sparse([3, 4; 5, 6])', + 'sparse([3, 0; 5, 0], "number")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'matrix' + ] + }; + + +/***/ }, +/* 105 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'string', + 'category': 'Construction', + 'syntax': [ + '"text"', + 'string(x)' + ], + 'description': + 'Create a string or convert a value to a string', + 'examples': [ + '"Hello World!"', + 'string(4.2)', + 'string(3 + 2i)' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'unit' + ] + }; + + +/***/ }, +/* 106 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'unit', + 'category': 'Construction', + 'syntax': [ + 'value unit', + 'unit(value, unit)', + 'unit(string)' + ], + 'description': + 'Create a unit.', + 'examples': [ + '5.5 mm', + '3 inch', + 'unit(7.1, "kilogram")', + 'unit("23 deg")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'number', 'string' + ] + }; + + +/***/ }, +/* 107 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'e', + 'category': 'Constants', + 'syntax': [ + 'e' + ], + 'description': 'Euler\'s number, the base of the natural logarithm. Approximately equal to 2.71828', + 'examples': [ + 'e', + 'e ^ 2', + 'exp(2)', + 'log(e)' + ], + 'seealso': ['exp'] + }; + + +/***/ }, +/* 108 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'false', + 'category': 'Constants', + 'syntax': [ + 'false' + ], + 'description': 'Boolean value false', + 'examples': [ + 'false' + ], + 'seealso': ['true'] + }; + + +/***/ }, +/* 109 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'i', + 'category': 'Constants', + 'syntax': [ + 'i' + ], + 'description': 'Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.', + 'examples': [ + 'i', + 'i * i', + 'sqrt(-1)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 110 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'Infinity', + 'category': 'Constants', + 'syntax': [ + 'Infinity' + ], + 'description': 'Infinity, a number which is larger than the maximum number that can be handled by a floating point number.', + 'examples': [ + 'Infinity', + '1 / 0' + ], + 'seealso': [] + }; + + +/***/ }, +/* 111 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'LN2', + 'category': 'Constants', + 'syntax': [ + 'LN2' + ], + 'description': 'Returns the natural logarithm of 2, approximately equal to 0.693', + 'examples': [ + 'LN2', + 'log(2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 112 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'LN10', + 'category': 'Constants', + 'syntax': [ + 'LN10' + ], + 'description': 'Returns the natural logarithm of 10, approximately equal to 2.302', + 'examples': [ + 'LN10', + 'log(10)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 113 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'LOG2E', + 'category': 'Constants', + 'syntax': [ + 'LOG2E' + ], + 'description': 'Returns the base-2 logarithm of E, approximately equal to 1.442', + 'examples': [ + 'LOG2E', + 'log(e, 2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 114 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'LOG10E', + 'category': 'Constants', + 'syntax': [ + 'LOG10E' + ], + 'description': 'Returns the base-10 logarithm of E, approximately equal to 0.434', + 'examples': [ + 'LOG10E', + 'log(e, 10)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 115 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'NaN', + 'category': 'Constants', + 'syntax': [ + 'NaN' + ], + 'description': 'Not a number', + 'examples': [ + 'NaN', + '0 / 0' + ], + 'seealso': [] + }; + + +/***/ }, +/* 116 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'null', + 'category': 'Constants', + 'syntax': [ + 'null' + ], + 'description': 'Value null', + 'examples': [ + 'null' + ], + 'seealso': ['true', 'false'] + }; + + +/***/ }, +/* 117 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'pi', + 'category': 'Constants', + 'syntax': [ + 'pi' + ], + 'description': 'The number pi is a mathematical constant that is the ratio of a circle\'s circumference to its diameter, and is approximately equal to 3.14159', + 'examples': [ + 'pi', + 'sin(pi/2)' + ], + 'seealso': ['tau'] + }; + + +/***/ }, +/* 118 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'phi', + 'category': 'Constants', + 'syntax': [ + 'phi' + ], + 'description': 'Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...', + 'examples': [ + 'tau' + ], + 'seealso': [] + }; + + +/***/ }, +/* 119 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'SQRT1_2', + 'category': 'Constants', + 'syntax': [ + 'SQRT1_2' + ], + 'description': 'Returns the square root of 1/2, approximately equal to 0.707', + 'examples': [ + 'SQRT1_2', + 'sqrt(1/2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 120 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'SQRT2', + 'category': 'Constants', + 'syntax': [ + 'SQRT2' + ], + 'description': 'Returns the square root of 2, approximately equal to 1.414', + 'examples': [ + 'SQRT2', + 'sqrt(2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 121 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'tau', + 'category': 'Constants', + 'syntax': [ + 'tau' + ], + 'description': 'Tau is the ratio constant of a circle\'s circumference to radius, equal to 2 * pi, approximately 6.2832.', + 'examples': [ + 'tau', + '2 * pi' + ], + 'seealso': ['pi'] + }; + + +/***/ }, +/* 122 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'true', + 'category': 'Constants', + 'syntax': [ + 'true' + ], + 'description': 'Boolean value true', + 'examples': [ + 'true' + ], + 'seealso': ['false'] + }; + + +/***/ }, +/* 123 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'version', + 'category': 'Constants', + 'syntax': [ + 'version' + ], + 'description': 'A string with the version number of math.js', + 'examples': [ + 'version' + ], + 'seealso': [] + }; + + +/***/ }, +/* 124 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'lsolve', + 'category': 'Algebra', + 'syntax': [ + 'x=lsolve(L, b)' + ], + 'description': + 'Solves the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.', + 'examples': [ + 'a = [-2, 3; 2, 1]', + 'b = [11, 9]', + 'x = lsolve(a, b)' + ], + 'seealso': [ + 'lup', 'lusolve', 'usolve', 'matrix', 'sparse' + ] + }; + + +/***/ }, +/* 125 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'lup', + 'category': 'Algebra', + 'syntax': [ + 'lup(m)' + ], + 'description': + 'Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U', + 'examples': [ + 'lup([[2, 1], [1, 4]])', + 'lup(matrix([[2, 1], [1, 4]]))', + 'lup(sparse([[2, 1], [1, 4]]))' + ], + 'seealso': [ + 'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'slu' + ] + }; + + +/***/ }, +/* 126 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'lusolve', + 'category': 'Algebra', + 'syntax': [ + 'x=lusolve(A, b)', + 'x=lusolve(lu, b)' + ], + 'description': 'Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.', + 'examples': [ + 'a = [-2, 3; 2, 1]', + 'b = [11, 9]', + 'x = lusolve(a, b)' + ], + 'seealso': [ + 'lup', 'slu', 'lsolve', 'usolve', 'matrix', 'sparse' + ] + }; + + +/***/ }, +/* 127 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'slu', + 'category': 'Algebra', + 'syntax': [ + 'slu(A, order, threshold)' + ], + 'description': 'Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U', + 'examples': [ + 'slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)' + ], + 'seealso': [ + 'lusolve', 'lsolve', 'usolve', 'matrix', 'sparse', 'lup' + ] + }; + + +/***/ }, +/* 128 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'usolve', + 'category': 'Algebra', + 'syntax': [ + 'x=usolve(U, b)' + ], + 'description': + 'Solves the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.', + 'examples': [ + 'x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])' + ], + 'seealso': [ + 'lup', 'lusolve', 'lsolve', 'matrix', 'sparse' + ] + }; + + +/***/ }, +/* 129 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'abs', + 'category': 'Arithmetic', + 'syntax': [ + 'abs(x)' + ], + 'description': 'Compute the absolute value.', + 'examples': [ + 'abs(3.5)', + 'abs(-4.2)' + ], + 'seealso': ['sign'] + }; + + +/***/ }, +/* 130 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'add', + 'category': 'Operators', + 'syntax': [ + 'x + y', + 'add(x, y)' + ], + 'description': 'Add two values.', + 'examples': [ + 'a = 2.1 + 3.6', + 'a - 3.6', + '3 + 2i', + '3 cm + 2 inch', + '"2.3" + "4"' + ], + 'seealso': [ + 'subtract' + ] + }; + + +/***/ }, +/* 131 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cbrt', + 'category': 'Arithmetic', + 'syntax': [ + 'cbrt(x)', + 'cbrt(x, allRoots)' + ], + 'description': + 'Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned', + 'examples': [ + 'cbrt(64)', + 'cube(4)', + 'cbrt(-8)', + 'cbrt(2 + 3i)', + 'cbrt(8i)', + 'cbrt(8i, true)', + 'cbrt(27 m^3)' + ], + 'seealso': [ + 'square', + 'sqrt', + 'cube', + 'multiply' + ] + }; + + +/***/ }, +/* 132 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'ceil', + 'category': 'Arithmetic', + 'syntax': [ + 'ceil(x)' + ], + 'description': + 'Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.', + 'examples': [ + 'ceil(3.2)', + 'ceil(3.8)', + 'ceil(-4.2)' + ], + 'seealso': ['floor', 'fix', 'round'] + }; + + +/***/ }, +/* 133 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cube', + 'category': 'Arithmetic', + 'syntax': [ + 'cube(x)' + ], + 'description': 'Compute the cube of a value. The cube of x is x * x * x.', + 'examples': [ + 'cube(2)', + '2^3', + '2 * 2 * 2' + ], + 'seealso': [ + 'multiply', + 'square', + 'pow' + ] + }; + + +/***/ }, +/* 134 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'divide', + 'category': 'Operators', + 'syntax': [ + 'x / y', + 'divide(x, y)' + ], + 'description': 'Divide two values.', + 'examples': [ + 'a = 2 / 3', + 'a * 3', + '4.5 / 2', + '3 + 4 / 2', + '(3 + 4) / 2', + '18 km / 4.5' + ], + 'seealso': [ + 'multiply' + ] + }; + + +/***/ }, +/* 135 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'dotDivide', + 'category': 'Operators', + 'syntax': [ + 'x ./ y', + 'dotDivide(x, y)' + ], + 'description': 'Divide two values element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'b = [2, 1, 1; 3, 2, 5]', + 'a ./ b' + ], + 'seealso': [ + 'multiply', + 'dotMultiply', + 'divide' + ] + }; + + +/***/ }, +/* 136 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'dotMultiply', + 'category': 'Operators', + 'syntax': [ + 'x .* y', + 'dotMultiply(x, y)' + ], + 'description': 'Multiply two values element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'b = [2, 1, 1; 3, 2, 5]', + 'a .* b' + ], + 'seealso': [ + 'multiply', + 'divide', + 'dotDivide' + ] + }; + + +/***/ }, +/* 137 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'dotpow', + 'category': 'Operators', + 'syntax': [ + 'x .^ y', + 'dotpow(x, y)' + ], + 'description': + 'Calculates the power of x to y element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'a .^ 2' + ], + 'seealso': [ + 'pow' + ] + }; + + +/***/ }, +/* 138 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'exp', + 'category': 'Arithmetic', + 'syntax': [ + 'exp(x)' + ], + 'description': 'Calculate the exponent of a value.', + 'examples': [ + 'exp(1.3)', + 'e ^ 1.3', + 'log(exp(1.3))', + 'x = 2.4', + '(exp(i*x) == cos(x) + i*sin(x)) # Euler\'s formula' + ], + 'seealso': [ + 'pow', + 'log' + ] + }; + + +/***/ }, +/* 139 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'fix', + 'category': 'Arithmetic', + 'syntax': [ + 'fix(x)' + ], + 'description': + 'Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.', + 'examples': [ + 'fix(3.2)', + 'fix(3.8)', + 'fix(-4.2)', + 'fix(-4.8)' + ], + 'seealso': ['ceil', 'floor', 'round'] + }; + + +/***/ }, +/* 140 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'floor', + 'category': 'Arithmetic', + 'syntax': [ + 'floor(x)' + ], + 'description': + 'Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.', + 'examples': [ + 'floor(3.2)', + 'floor(3.8)', + 'floor(-4.2)' + ], + 'seealso': ['ceil', 'fix', 'round'] + }; + + +/***/ }, +/* 141 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'gcd', + 'category': 'Arithmetic', + 'syntax': [ + 'gcd(a, b)', + 'gcd(a, b, c, ...)' + ], + 'description': 'Compute the greatest common divisor.', + 'examples': [ + 'gcd(8, 12)', + 'gcd(-4, 6)', + 'gcd(25, 15, -10)' + ], + 'seealso': [ 'lcm', 'xgcd' ] + }; + + +/***/ }, +/* 142 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'hypot', + 'category': 'Arithmetic', + 'syntax': [ + 'hypot(a, b, c, ...)', + 'hypot([a, b, c, ...])' + ], + 'description': 'Calculate the hypotenusa of a list with values. ', + 'examples': [ + 'hypot(3, 4)', + 'sqrt(3^2 + 4^2)', + 'hypot(-2)', + 'hypot([3, 4, 5])' + ], + 'seealso': [ 'abs', 'norm' ] + }; + + +/***/ }, +/* 143 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'lcm', + 'category': 'Arithmetic', + 'syntax': [ + 'lcm(x, y)' + ], + 'description': 'Compute the least common multiple.', + 'examples': [ + 'lcm(4, 6)', + 'lcm(6, 21)', + 'lcm(6, 21, 5)' + ], + 'seealso': [ 'gcd' ] + }; + + +/***/ }, +/* 144 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'log', + 'category': 'Arithmetic', + 'syntax': [ + 'log(x)', + 'log(x, base)' + ], + 'description': 'Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).', + 'examples': [ + 'log(3.5)', + 'a = log(2.4)', + 'exp(a)', + '10 ^ 4', + 'log(10000, 10)', + 'log(10000) / log(10)', + 'b = log(1024, 2)', + '2 ^ b' + ], + 'seealso': [ + 'exp', + 'log10' + ] + }; + +/***/ }, +/* 145 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'log10', + 'category': 'Arithmetic', + 'syntax': [ + 'log10(x)' + ], + 'description': 'Compute the 10-base logarithm of a value.', + 'examples': [ + 'log10(0.00001)', + 'log10(10000)', + '10 ^ 4', + 'log(10000) / log(10)', + 'log(10000, 10)' + ], + 'seealso': [ + 'exp', + 'log' + ] + }; + + +/***/ }, +/* 146 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'mod', + 'category': 'Operators', + 'syntax': [ + 'x % y', + 'x mod y', + 'mod(x, y)' + ], + 'description': + 'Calculates the modulus, the remainder of an integer division.', + 'examples': [ + '7 % 3', + '11 % 2', + '10 mod 4', + 'function isOdd(x) = x % 2', + 'isOdd(2)', + 'isOdd(3)' + ], + 'seealso': ['divide'] + }; + + +/***/ }, +/* 147 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'multiply', + 'category': 'Operators', + 'syntax': [ + 'x * y', + 'multiply(x, y)' + ], + 'description': 'multiply two values.', + 'examples': [ + 'a = 2.1 * 3.4', + 'a / 3.4', + '2 * 3 + 4', + '2 * (3 + 4)', + '3 * 2.1 km' + ], + 'seealso': [ + 'divide' + ] + }; + + +/***/ }, +/* 148 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'norm', + 'category': 'Arithmetic', + 'syntax': [ + 'norm(x)', + 'norm(x, p)' + ], + 'description': 'Calculate the norm of a number, vector or matrix.', + 'examples': [ + 'abs(-3.5)', + 'norm(-3.5)', + 'norm(3 - 4i))', + 'norm([1, 2, -3], Infinity)', + 'norm([1, 2, -3], -Infinity)', + 'norm([3, 4], 2)', + 'norm([[1, 2], [3, 4]], 1)', + 'norm([[1, 2], [3, 4]], \'inf\')', + 'norm([[1, 2], [3, 4]], \'fro\')' + ] + }; + + +/***/ }, +/* 149 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'nthRoot', + 'category': 'Arithmetic', + 'syntax': [ + 'nthRoot(a)', + 'nthRoot(a, root)' + ], + 'description': 'Calculate the nth root of a value. ' + + 'The principal nth root of a positive real number A, ' + + 'is the positive real solution of the equation "x^root = A".', + 'examples': [ + '4 ^ 3', + 'nthRoot(64, 3)', + 'nthRoot(9, 2)', + 'sqrt(9)' + ], + 'seealso': [ + 'sqrt', + 'pow' + ] + }; + +/***/ }, +/* 150 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'pow', + 'category': 'Operators', + 'syntax': [ + 'x ^ y', + 'pow(x, y)' + ], + 'description': + 'Calculates the power of x to y, x^y.', + 'examples': [ + '2^3 = 8', + '2*2*2', + '1 + e ^ (pi * i)' + ], + 'seealso': [ 'multiply' ] + }; + + +/***/ }, +/* 151 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'round', + 'category': 'Arithmetic', + 'syntax': [ + 'round(x)', + 'round(x, n)' + ], + 'description': + 'round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.', + 'examples': [ + 'round(3.2)', + 'round(3.8)', + 'round(-4.2)', + 'round(-4.8)', + 'round(pi, 3)', + 'round(123.45678, 2)' + ], + 'seealso': ['ceil', 'floor', 'fix'] + }; + + +/***/ }, +/* 152 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sign', + 'category': 'Arithmetic', + 'syntax': [ + 'sign(x)' + ], + 'description': + 'Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.', + 'examples': [ + 'sign(3.5)', + 'sign(-4.2)', + 'sign(0)' + ], + 'seealso': [ + 'abs' + ] + }; + + +/***/ }, +/* 153 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sqrt', + 'category': 'Arithmetic', + 'syntax': [ + 'sqrt(x)' + ], + 'description': + 'Compute the square root value. If x = y * y, then y is the square root of x.', + 'examples': [ + 'sqrt(25)', + '5 * 5', + 'sqrt(-1)' + ], + 'seealso': [ + 'square', + 'multiply' + ] + }; + + +/***/ }, +/* 154 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'square', + 'category': 'Arithmetic', + 'syntax': [ + 'square(x)' + ], + 'description': + 'Compute the square of a value. The square of x is x * x.', + 'examples': [ + 'square(3)', + 'sqrt(9)', + '3^2', + '3 * 3' + ], + 'seealso': [ + 'multiply', + 'pow', + 'sqrt', + 'cube' + ] + }; + + +/***/ }, +/* 155 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'subtract', + 'category': 'Operators', + 'syntax': [ + 'x - y', + 'subtract(x, y)' + ], + 'description': 'subtract two values.', + 'examples': [ + 'a = 5.3 - 2', + 'a + 2', + '2/3 - 1/6', + '2 * 3 - 3', + '2.1 km - 500m' + ], + 'seealso': [ + 'add' + ] + }; + + +/***/ }, +/* 156 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'unaryMinus', + 'category': 'Operators', + 'syntax': [ + '-x', + 'unaryMinus(x)' + ], + 'description': + 'Inverse the sign of a value. Converts booleans and strings to numbers.', + 'examples': [ + '-4.5', + '-(-5.6)', + '-"22"' + ], + 'seealso': [ + 'add', 'subtract', 'unaryPlus' + ] + }; + + +/***/ }, +/* 157 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'unaryPlus', + 'category': 'Operators', + 'syntax': [ + '+x', + 'unaryPlus(x)' + ], + 'description': + 'Converts booleans and strings to numbers.', + 'examples': [ + '+true', + '+"2"' + ], + 'seealso': [ + 'add', 'subtract', 'unaryMinus' + ] + }; + + +/***/ }, +/* 158 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'xgcd', + 'category': 'Arithmetic', + 'syntax': [ + 'xgcd(a, b)' + ], + 'description': 'Calculate the extended greatest common divisor for two values', + 'examples': [ + 'xgcd(8, 12)', + 'gcd(8, 12)', + 'xgcd(36163, 21199)' + ], + 'seealso': [ 'gcd', 'lcm' ] + }; + + +/***/ }, +/* 159 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bitAnd', + 'category': 'Bitwise', + 'syntax': [ + 'x & y', + 'bitAnd(x, y)' + ], + 'description': 'Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0', + 'examples': [ + '5 & 3', + 'bitAnd(53, 131)', + '[1, 12, 31] & 42' + ], + 'seealso': [ + 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 160 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bitNot', + 'category': 'Bitwise', + 'syntax': [ + '~x', + 'bitNot(x)' + ], + 'description': 'Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.', + 'examples': [ + '~1', + '~2', + 'bitNot([2, -3, 4])' + ], + 'seealso': [ + 'bitAnd', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 161 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bitOr', + 'category': 'Bitwise', + 'syntax': [ + 'x | y', + 'bitOr(x, y)' + ], + 'description': 'Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.', + 'examples': [ + '5 | 3', + 'bitOr([1, 2, 3], 4)' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 162 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bitXor', + 'category': 'Bitwise', + 'syntax': [ + 'bitXor(x, y)' + ], + 'description': 'Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.', + 'examples': [ + 'bitOr(1, 2)', + 'bitXor([2, 3, 4], 4)' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 163 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'leftShift', + 'category': 'Bitwise', + 'syntax': [ + 'x << y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise left logical shift of a value x by y number of bits.', + 'examples': [ + '4 << 1', + '8 >> 1' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 164 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'rightArithShift', + 'category': 'Bitwise', + 'syntax': [ + 'x >> y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise right arithmetic shift of a value x by y number of bits.', + 'examples': [ + '8 >> 1', + '4 << 1', + '-12 >> 2' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 165 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'rightLogShift', + 'category': 'Bitwise', + 'syntax': [ + 'x >> y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise right logical shift of a value x by y number of bits.', + 'examples': [ + '8 >>> 1', + '4 << 1', + '-12 >>> 2' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift' + ] + }; + + +/***/ }, +/* 166 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'bellNumbers', + 'category': 'Combinatorics', + 'syntax': [ + 'bellNumbers(n)' + ], + 'description': 'The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.', + 'examples': [ + 'bellNumbers(3)', + 'bellNumbers(8)' + ], + 'seealso': ['stirlingS2'] + }; + +/***/ }, +/* 167 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'catalan', + 'category': 'Combinatorics', + 'syntax': [ + 'catalan(n)' + ], + 'description': 'The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.', + 'examples': [ + 'catalan(3)', + 'catalan(8)' + ], + 'seealso': ['bellNumbers'] + }; + +/***/ }, +/* 168 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'composition', + 'category': 'Combinatorics', + 'syntax': [ + 'composition(n, k)' + ], + 'description': 'The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.', + 'examples': [ + 'composition(5, 3)' + ], + 'seealso': ['combinations'] + }; + +/***/ }, +/* 169 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'stirlingS2', + 'category': 'Combinatorics', + 'syntax': [ + 'stirlingS2(n, k)' + ], + 'description': 'he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.', + 'examples': [ + 'stirlingS2(5, 3)' + ], + 'seealso': ['bellNumbers'] + }; + + +/***/ }, +/* 170 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'config', + 'category': 'Core', + 'syntax': [ + 'config()', + 'config(options)' + ], + 'description': 'Get configuration or change configuration.', + 'examples': [ + 'config()', + '1/3 + 1/4', + 'config({number: "Fraction"})', + '1/3 + 1/4' + ], + 'seealso': [] + }; + + +/***/ }, +/* 171 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'import', + 'category': 'Core', + 'syntax': [ + 'import(functions)', + 'import(functions, options)' + ], + 'description': 'Import functions or constants from an object.', + 'examples': [ + 'import({myFn: f(x)=x^2, myConstant: 32 })', + 'myFn(2)', + 'myConstant' + ], + 'seealso': [] + }; + + +/***/ }, +/* 172 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'typed', + 'category': 'Core', + 'syntax': [ + 'typed(signatures)', + 'typed(name, signatures)' + ], + 'description': 'Create a typed function.', + 'examples': [ + 'double = typed({ "number, number": f(x)=x+x })', + 'double(2)', + 'double("hello")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 173 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'arg', + 'category': 'Complex', + 'syntax': [ + 'arg(x)' + ], + 'description': + 'Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).', + 'examples': [ + 'arg(2 + 2i)', + 'atan2(3, 2)', + 'arg(2 + 3i)' + ], + 'seealso': [ + 're', + 'im', + 'conj', + 'abs' + ] + }; + + +/***/ }, +/* 174 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'conj', + 'category': 'Complex', + 'syntax': [ + 'conj(x)' + ], + 'description': + 'Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.', + 'examples': [ + 'conj(2 + 3i)', + 'conj(2 - 3i)', + 'conj(-5.2i)' + ], + 'seealso': [ + 're', + 'im', + 'abs', + 'arg' + ] + }; + + +/***/ }, +/* 175 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 're', + 'category': 'Complex', + 'syntax': [ + 're(x)' + ], + 'description': 'Get the real part of a complex number.', + 'examples': [ + 're(2 + 3i)', + 'im(2 + 3i)', + 're(-5.2i)', + 're(2.4)' + ], + 'seealso': [ + 'im', + 'conj', + 'abs', + 'arg' + ] + }; + + +/***/ }, +/* 176 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'im', + 'category': 'Complex', + 'syntax': [ + 'im(x)' + ], + 'description': 'Get the imaginary part of a complex number.', + 'examples': [ + 'im(2 + 3i)', + 're(2 + 3i)', + 'im(-5.2i)', + 'im(2.4)' + ], + 'seealso': [ + 're', + 'conj', + 'abs', + 'arg' + ] + }; + + +/***/ }, +/* 177 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'eval', + 'category': 'Expression', + 'syntax': [ + 'eval(expression)', + 'eval([expr1, expr2, expr3, ...])' + ], + 'description': 'Evaluate an expression or an array with expressions.', + 'examples': [ + 'eval("2 + 3")', + 'eval("sqrt(" + 4 + ")")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 178 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'help', + 'category': 'Expression', + 'syntax': [ + 'help(object)', + 'help(string)' + ], + 'description': 'Display documentation on a function or data type.', + 'examples': [ + 'help(sqrt)', + 'help("complex")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 179 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'distance', + 'category': 'Geometry', + 'syntax': [ + 'distance([x1, y1], [x2, y2])', + 'distance([[x1, y1], [x2, y2])' + ], + 'description': 'Calculates the Euclidean distance between two points.', + 'examples': [ + 'distance([0,0], [4,4])', + 'distance([[0,0], [4,4]])' + ], + 'seealso': [] + }; + + +/***/ }, +/* 180 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'intersect', + 'category': 'Geometry', + 'syntax': [ + 'intersect(expr1, expr2, expr3, expr4)', + 'intersect(expr1, expr2, expr3)' + ], + 'description': 'Computes the intersection point of lines and/or planes.', + 'examples': [ + 'intersect([0, 0], [10, 10], [10, 0], [0, 10])', + 'intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])' + ], + 'seealso': [] + }; + + +/***/ }, +/* 181 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'and', + 'category': 'Logical', + 'syntax': [ + 'x and y', + 'and(x, y)' + ], + 'description': 'Logical and. Test whether two values are both defined with a nonzero/nonempty value.', + 'examples': [ + 'true and false', + 'true and true', + '2 and 4' + ], + 'seealso': [ + 'not', 'or', 'xor' + ] + }; + + +/***/ }, +/* 182 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'not', + 'category': 'Logical', + 'syntax': [ + 'not x', + 'not(x)' + ], + 'description': 'Logical not. Flips the boolean value of given argument.', + 'examples': [ + 'not true', + 'not false', + 'not 2', + 'not 0' + ], + 'seealso': [ + 'and', 'or', 'xor' + ] + }; + + +/***/ }, +/* 183 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'or', + 'category': 'Logical', + 'syntax': [ + 'x or y', + 'or(x, y)' + ], + 'description': 'Logical or. Test if at least one value is defined with a nonzero/nonempty value.', + 'examples': [ + 'true or false', + 'false or false', + '0 or 4' + ], + 'seealso': [ + 'not', 'and', 'xor' + ] + }; + + +/***/ }, +/* 184 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'xor', + 'category': 'Logical', + 'syntax': [ + 'x or y', + 'or(x, y)' + ], + 'description': 'Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.', + 'examples': [ + 'true xor false', + 'false xor false', + 'true xor true', + '0 or 4' + ], + 'seealso': [ + 'not', 'and', 'or' + ] + }; + + +/***/ }, +/* 185 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'concat', + 'category': 'Matrix', + 'syntax': [ + 'concat(A, B, C, ...)', + 'concat(A, B, C, ..., dim)' + ], + 'description': 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.', + 'examples': [ + 'A = [1, 2; 5, 6]', + 'B = [3, 4; 7, 8]', + 'concat(A, B)', + 'concat(A, B, 1)', + 'concat(A, B, 2)' + ], + 'seealso': [ + 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 186 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cross', + 'category': 'Matrix', + 'syntax': [ + 'cross(A, B)' + ], + 'description': 'Calculate the cross product for two vectors in three dimensional space.', + 'examples': [ + 'cross([1, 1, 0], [0, 1, 1])', + 'cross([3, -3, 1], [4, 9, 2])', + 'cross([2, 3, 4], [5, 6, 7])' + ], + 'seealso': [ + 'multiply', + 'dot' + ] + }; + + +/***/ }, +/* 187 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'det', + 'category': 'Matrix', + 'syntax': [ + 'det(x)' + ], + 'description': 'Calculate the determinant of a matrix', + 'examples': [ + 'det([1, 2; 3, 4])', + 'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])' + ], + 'seealso': [ + 'concat', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 188 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'diag', + 'category': 'Matrix', + 'syntax': [ + 'diag(x)', + 'diag(x, k)' + ], + 'description': 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.', + 'examples': [ + 'diag(1:3)', + 'diag(1:3, 1)', + 'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]', + 'diag(a)' + ], + 'seealso': [ + 'concat', 'det', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 189 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'dot', + 'category': 'Matrix', + 'syntax': [ + 'dot(A, B)' + ], + 'description': 'Calculate the dot product of two vectors. ' + + 'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' + + 'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn', + 'examples': [ + 'dot([2, 4, 1], [2, 2, 3])', + '[2, 4, 1] * [2, 2, 3]' + ], + 'seealso': [ + 'multiply', + 'cross' + ] + }; + + +/***/ }, +/* 190 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'eye', + 'category': 'Matrix', + 'syntax': [ + 'eye(n)', + 'eye(m, n)', + 'eye([m, n])', + 'eye' + ], + 'description': 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.', + 'examples': [ + 'eye(3)', + 'eye(3, 5)', + 'a = [1, 2, 3; 4, 5, 6]', + 'eye(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 191 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'filter', + 'category': 'Matrix', + 'syntax': [ + 'filter(x, test)' + ], + 'description': 'Filter items in a matrix.', + 'examples': [ + 'isPositive(x) = x > 0', + 'filter([6, -2, -1, 4, 3], isPositive)', + 'filter([6, -2, 0, 1, 0], x != 0)' + ], + 'seealso': ['sort', 'map', 'forEach'] + }; + + +/***/ }, +/* 192 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'flatten', + 'category': 'Matrix', + 'syntax': [ + 'flatten(x)' + ], + 'description': 'Flatten a multi dimensional matrix into a single dimensional matrix.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'size(a)', + 'b = flatten(a)', + 'size(b)' + ], + 'seealso': [ + 'concat', 'resize', 'size', 'squeeze' + ] + }; + + +/***/ }, +/* 193 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'forEach', + 'category': 'Matrix', + 'syntax': [ + 'forEach(x, callback)' + ], + 'description': 'Iterates over all elements of a matrix/array, and executes the given callback function.', + 'examples': [ + 'forEach([1, 2, 3], function(val) { console.log(val) })' + ], + 'seealso': ['map', 'sort', 'filter'] + }; + + +/***/ }, +/* 194 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'inv', + 'category': 'Matrix', + 'syntax': [ + 'inv(x)' + ], + 'description': 'Calculate the inverse of a matrix', + 'examples': [ + 'inv([1, 2; 3, 4])', + 'inv(4)', + '1 / 4' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 195 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'map', + 'category': 'Matrix', + 'syntax': [ + 'map(x, callback)' + ], + 'description': 'Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.', + 'examples': [ + 'map([1, 2, 3], function(val) { return value * value })' + ], + 'seealso': ['filter', 'forEach'] + }; + + +/***/ }, +/* 196 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'ones', + 'category': 'Matrix', + 'syntax': [ + 'ones(m)', + 'ones(m, n)', + 'ones(m, n, p, ...)', + 'ones([m])', + 'ones([m, n])', + 'ones([m, n, p, ...])', + 'ones' + ], + 'description': 'Create a matrix containing ones.', + 'examples': [ + 'ones(3)', + 'ones(3, 5)', + 'ones([2,3]) * 4.5', + 'a = [1, 2, 3; 4, 5, 6]', + 'ones(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 197 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'partitionSelect', + 'category': 'Matrix', + 'syntax': [ + 'partitionSelect(x, k)', + 'partitionSelect(x, k, compare)' + ], + 'description': 'Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.', + 'examples': [ + 'partitionSelect([5, 10, 1], 2)', + 'partitionSelect(["C", "B", "A", "D"], 1)' + ], + 'seealso': ['sort'] + }; + + +/***/ }, +/* 198 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'range', + 'category': 'Type', + 'syntax': [ + 'start:end', + 'start:step:end', + 'range(start, end)', + 'range(start, end, step)', + 'range(string)' + ], + 'description': + 'Create a range. Lower bound of the range is included, upper bound is excluded.', + 'examples': [ + '1:5', + '3:-1:-3', + 'range(3, 7)', + 'range(0, 12, 2)', + 'range("4:10")', + 'a = [1, 2, 3, 4; 5, 6, 7, 8]', + 'a[1:2, 1:2]' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 199 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'resize', + 'category': 'Matrix', + 'syntax': [ + 'resize(x, size)', + 'resize(x, size, defaultValue)' + ], + 'description': 'Resize a matrix.', + 'examples': [ + 'resize([1,2,3,4,5], [3])', + 'resize([1,2,3], [5])', + 'resize([1,2,3], [5], -1)', + 'resize(2, [2, 3])', + 'resize("hello", [8], "!")' + ], + 'seealso': [ + 'size', 'subset', 'squeeze' + ] + }; + + +/***/ }, +/* 200 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'size', + 'category': 'Matrix', + 'syntax': [ + 'size(x)' + ], + 'description': 'Calculate the size of a matrix.', + 'examples': [ + 'size(2.3)', + 'size("hello world")', + 'a = [1, 2; 3, 4; 5, 6]', + 'size(a)', + 'size(1:6)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 201 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sort', + 'category': 'Matrix', + 'syntax': [ + 'sort(x)', + 'sort(x, compare)' + ], + 'description': 'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.', + 'examples': [ + 'sort([5, 10, 1])', + 'sort(["C", "B", "A", "D"])', + 'sortByLength(a, b) = size(a)[1] - size(b)[1]', + 'sort(["Langdon", "Tom", "Sara"], sortByLength)' + ], + 'seealso': ['map', 'filter', 'forEach'] + }; + + +/***/ }, +/* 202 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'squeeze', + 'category': 'Matrix', + 'syntax': [ + 'squeeze(x)' + ], + 'description': 'Remove inner and outer singleton dimensions from a matrix.', + 'examples': [ + 'a = zeros(3,2,1)', + 'size(squeeze(a))', + 'b = zeros(1,1,3)', + 'size(squeeze(b))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 203 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'subset', + 'category': 'Matrix', + 'syntax': [ + 'value(index)', + 'value(index) = replacement', + 'subset(value, [index])', + 'subset(value, [index], replacement)' + ], + 'description': 'Get or set a subset of a matrix or string. ' + + 'Indexes are one-based. ' + + 'Both the ranges lower-bound and upper-bound are included.', + 'examples': [ + 'd = [1, 2; 3, 4]', + 'e = []', + 'e[1, 1:2] = [5, 6]', + 'e[2, :] = [7, 8]', + 'f = d * e', + 'f[2, 1]', + 'f[:, 1]' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 204 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'trace', + 'category': 'Matrix', + 'syntax': [ + 'trace(A)' + ], + 'description': 'Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.', + 'examples': [ + 'A = [1, 2, 3; -1, 2, 3; 2, 0, 3]', + 'trace(A)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 205 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'transpose', + 'category': 'Matrix', + 'syntax': [ + 'x\'', + 'transpose(x)' + ], + 'description': 'Transpose a matrix', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'a\'', + 'transpose(a)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros' + ] + }; + + +/***/ }, +/* 206 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'zeros', + 'category': 'Matrix', + 'syntax': [ + 'zeros(m)', + 'zeros(m, n)', + 'zeros(m, n, p, ...)', + 'zeros([m])', + 'zeros([m, n])', + 'zeros([m, n, p, ...])', + 'zeros' + ], + 'description': 'Create a matrix containing zeros.', + 'examples': [ + 'zeros(3)', + 'zeros(3, 5)', + 'a = [1, 2, 3; 4, 5, 6]', + 'zeros(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose' + ] + }; + + +/***/ }, +/* 207 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'combinations', + 'category': 'Probability', + 'syntax': [ + 'combinations(n, k)' + ], + 'description': 'Compute the number of combinations of n items taken k at a time', + 'examples': [ + 'combinations(7, 5)' + ], + 'seealso': ['permutations', 'factorial'] + }; + + +/***/ }, +/* 208 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'factorial', + 'category': 'Probability', + 'syntax': [ + 'kldivergence(x, y)' + ], + 'description': 'Compute the factorial of a value', + 'examples': [ + '5!', + '5 * 4 * 3 * 2 * 1', + '3!' + ], + 'seealso': ['combinations', 'permutations', 'gamma'] + }; + + +/***/ }, +/* 209 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'gamma', + 'category': 'Probability', + 'syntax': [ + 'gamma(n)' + ], + 'description': 'Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.', + 'examples': [ + 'gamma(4)', + '3!', + 'gamma(1/2)', + 'sqrt(pi)' + ], + 'seealso': ['factorial'] + }; + + +/***/ }, +/* 210 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'kldivergence', + 'category': 'Probability', + 'syntax': [ + 'n!', + 'factorial(n)' + ], + 'description': 'Calculate the Kullback-Leibler (KL) divergence between two distributions.', + 'examples': [ + 'math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])' + ], + 'seealso': [] + }; + + +/***/ }, +/* 211 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'multinomial', + 'category': 'Probability', + 'syntax': [ + 'multinomial(A)' + ], + 'description': 'Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai <= 0.', + 'examples': [ + 'multinomial([1, 2, 1])' + ], + 'seealso': ['combinations', 'factorial'] + }; + +/***/ }, +/* 212 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'permutations', + 'category': 'Probability', + 'syntax': [ + 'permutations(n)', + 'permutations(n, k)' + ], + 'description': 'Compute the number of permutations of n items taken k at a time', + 'examples': [ + 'permutations(5)', + 'permutations(5, 3)' + ], + 'seealso': ['combinations', 'factorial'] + }; + + +/***/ }, +/* 213 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'pickRandom', + 'category': 'Probability', + 'syntax': [ + 'pickRandom(array)' + ], + 'description': + 'Pick a random entry from a given array.', + 'examples': [ + 'pickRandom(0:10)', + 'pickRandom([1, 3, 1, 6])' + ], + 'seealso': ['random', 'randomInt'] + }; + + +/***/ }, +/* 214 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'random', + 'category': 'Probability', + 'syntax': [ + 'random()', + 'random(max)', + 'random(min, max)', + 'random(size)', + 'random(size, max)', + 'random(size, min, max)' + ], + 'description': + 'Return a random number.', + 'examples': [ + 'random()', + 'random(10, 20)', + 'random([2, 3])' + ], + 'seealso': ['pickRandom', 'randomInt'] + }; + + +/***/ }, +/* 215 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'randInt', + 'category': 'Probability', + 'syntax': [ + 'randInt(max)', + 'randInt(min, max)', + 'randInt(size)', + 'randInt(size, max)', + 'randInt(size, min, max)' + ], + 'description': + 'Return a random integer number', + 'examples': [ + 'randInt(10, 20)', + 'randInt([2, 3], 10)' + ], + 'seealso': ['pickRandom', 'random'] + }; + +/***/ }, +/* 216 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'compare', + 'category': 'Relational', + 'syntax': [ + 'compare(x, y)' + ], + 'description': + 'Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.', + 'examples': [ + 'compare(2, 3)', + 'compare(3, 2)', + 'compare(2, 2)', + 'compare(5cm, 40mm)', + 'compare(2, [1, 2, 3])' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq' + ] + }; + + +/***/ }, +/* 217 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'deepEqual', + 'category': 'Relational', + 'syntax': [ + 'deepEqual(x, y)' + ], + 'description': + 'Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.', + 'examples': [ + '[1,3,4] == [1,3,4]', + '[1,3,4] == [1,3]' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 218 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'equal', + 'category': 'Relational', + 'syntax': [ + 'x == y', + 'equal(x, y)' + ], + 'description': + 'Check equality of two values. Returns true if the values are equal, and false if not.', + 'examples': [ + '2+2 == 3', + '2+2 == 4', + 'a = 3.2', + 'b = 6-2.8', + 'a == b', + '50cm == 0.5m' + ], + 'seealso': [ + 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' + ] + }; + + +/***/ }, +/* 219 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'larger', + 'category': 'Relational', + 'syntax': [ + 'x > y', + 'larger(x, y)' + ], + 'description': + 'Check if value x is larger than y. Returns true if x is larger than y, and false if not.', + 'examples': [ + '2 > 3', + '5 > 2*2', + 'a = 3.3', + 'b = 6-2.8', + '(a > b)', + '(b < a)', + '5 cm > 2 inch' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 220 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'largerEq', + 'category': 'Relational', + 'syntax': [ + 'x >= y', + 'largerEq(x, y)' + ], + 'description': + 'Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.', + 'examples': [ + '2 > 1+1', + '2 >= 1+1', + 'a = 3.2', + 'b = 6-2.8', + '(a > b)' + ], + 'seealso': [ + 'equal', 'unequal', 'smallerEq', 'smaller', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 221 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'smaller', + 'category': 'Relational', + 'syntax': [ + 'x < y', + 'smaller(x, y)' + ], + 'description': + 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.', + 'examples': [ + '2 < 3', + '5 < 2*2', + 'a = 3.3', + 'b = 6-2.8', + '(a < b)', + '5 cm < 2 inch' + ], + 'seealso': [ + 'equal', 'unequal', 'larger', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 222 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'smallerEq', + 'category': 'Relational', + 'syntax': [ + 'x <= y', + 'smallerEq(x, y)' + ], + 'description': + 'Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.', + 'examples': [ + '2 < 1+1', + '2 <= 1+1', + 'a = 3.2', + 'b = 6-2.8', + '(a < b)' + ], + 'seealso': [ + 'equal', 'unequal', 'larger', 'smaller', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 223 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'unequal', + 'category': 'Relational', + 'syntax': [ + 'x != y', + 'unequal(x, y)' + ], + 'description': + 'Check unequality of two values. Returns true if the values are unequal, and false if they are equal.', + 'examples': [ + '2+2 != 3', + '2+2 != 4', + 'a = 3.2', + 'b = 6-2.8', + 'a != b', + '50cm != 0.5m', + '5 cm != 2 inch' + ], + 'seealso': [ + 'equal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' + ] + }; + + +/***/ }, +/* 224 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'max', + 'category': 'Statistics', + 'syntax': [ + 'max(a, b, c, ...)', + 'max(A)', + 'max(A, dim)' + ], + 'description': 'Compute the maximum value of a list of values.', + 'examples': [ + 'max(2, 3, 4, 1)', + 'max([2, 3, 4, 1])', + 'max([2, 5; 4, 3])', + 'max([2, 5; 4, 3], 1)', + 'max([2, 5; 4, 3], 2)', + 'max(2.7, 7.1, -4.5, 2.0, 4.1)', + 'min(2.7, 7.1, -4.5, 2.0, 4.1)' + ], + 'seealso': [ + 'mean', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 225 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'mean', + 'category': 'Statistics', + 'syntax': [ + 'mean(a, b, c, ...)', + 'mean(A)', + 'mean(A, dim)' + ], + 'description': 'Compute the arithmetic mean of a list of values.', + 'examples': [ + 'mean(2, 3, 4, 1)', + 'mean([2, 3, 4, 1])', + 'mean([2, 5; 4, 3])', + 'mean([2, 5; 4, 3], 1)', + 'mean([2, 5; 4, 3], 2)', + 'mean([1.0, 2.7, 3.2, 4.0])' + ], + 'seealso': [ + 'max', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 226 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'median', + 'category': 'Statistics', + 'syntax': [ + 'median(a, b, c, ...)', + 'median(A)' + ], + 'description': 'Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.', + 'examples': [ + 'median(5, 2, 7)', + 'median([3, -1, 5, 7])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 227 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'min', + 'category': 'Statistics', + 'syntax': [ + 'min(a, b, c, ...)', + 'min(A)', + 'min(A, dim)' + ], + 'description': 'Compute the minimum value of a list of values.', + 'examples': [ + 'min(2, 3, 4, 1)', + 'min([2, 3, 4, 1])', + 'min([2, 5; 4, 3])', + 'min([2, 5; 4, 3], 1)', + 'min([2, 5; 4, 3], 2)', + 'min(2.7, 7.1, -4.5, 2.0, 4.1)', + 'max(2.7, 7.1, -4.5, 2.0, 4.1)' + ], + 'seealso': [ + 'max', + 'mean', + 'median', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 228 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'mode', + 'category': 'Statistics', + 'syntax': [ + 'mode(a, b, c, ...)', + 'mode(A)', + 'mode(A, a, b, B, c, ...)' + ], + 'description': 'Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.', + 'examples': [ + 'mode(5, 2, 7)', + 'mode([3, -1, 5, 7])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 229 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'prod', + 'category': 'Statistics', + 'syntax': [ + 'prod(a, b, c, ...)', + 'prod(A)' + ], + 'description': 'Compute the product of all values.', + 'examples': [ + 'prod(2, 3, 4)', + 'prod([2, 3, 4])', + 'prod([2, 5; 4, 3])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 230 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'quantileSeq', + 'category': 'Statistics', + 'syntax': [ + 'quantileSeq(A, prob[, sorted])', + 'quantileSeq(A, [prob1, prob2, ...][, sorted])', + 'quantileSeq(A, N[, sorted])' + ], + 'description': 'Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.', + 'examples': [ + 'quantileSeq([3, -1, 5, 7], 0.5)', + 'quantileSeq([3, -1, 5, 7], [1/3, 2/3])', + 'quantileSeq([3, -1, 5, 7], 2)', + 'quantileSeq([-1, 3, 5, 7], 0.5, true)' + ], + 'seealso': [ + 'mean', + 'median', + 'min', + 'max', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + +/***/ }, +/* 231 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'std', + 'category': 'Statistics', + 'syntax': [ + 'std(a, b, c, ...)', + 'std(A)', + 'std(A, normalization)' + ], + 'description': 'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', + 'examples': [ + 'std(2, 4, 6)', + 'std([2, 4, 6, 8])', + 'std([2, 4, 6, 8], "uncorrected")', + 'std([2, 4, 6, 8], "biased")', + 'std([1, 2, 3; 4, 5, 6])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'prod', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 232 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sum', + 'category': 'Statistics', + 'syntax': [ + 'sum(a, b, c, ...)', + 'sum(A)' + ], + 'description': 'Compute the sum of all values.', + 'examples': [ + 'sum(2, 3, 4, 1)', + 'sum([2, 3, 4, 1])', + 'sum([2, 5; 4, 3])' + ], + 'seealso': [ + 'max', + 'mean', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 233 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'var', + 'category': 'Statistics', + 'syntax': [ + 'var(a, b, c, ...)', + 'var(A)', + 'var(A, normalization)' + ], + 'description': 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', + 'examples': [ + 'var(2, 4, 6)', + 'var([2, 4, 6, 8])', + 'var([2, 4, 6, 8], "uncorrected")', + 'var([2, 4, 6, 8], "biased")', + 'var([1, 2, 3; 4, 5, 6])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'prod', + 'std', + 'sum' + ] + }; + + +/***/ }, +/* 234 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acos', + 'category': 'Trigonometry', + 'syntax': [ + 'acos(x)' + ], + 'description': 'Compute the inverse cosine of a value in radians.', + 'examples': [ + 'acos(0.5)', + 'acos(cos(2.3))' + ], + 'seealso': [ + 'cos', + 'atan', + 'asin' + ] + }; + + +/***/ }, +/* 235 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acosh', + 'category': 'Trigonometry', + 'syntax': [ + 'acosh(x)' + ], + 'description': 'Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.', + 'examples': [ + 'acosh(1.5)' + ], + 'seealso': [ + 'cosh', + 'asinh', + 'atanh' + ] + }; + +/***/ }, +/* 236 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acot', + 'category': 'Trigonometry', + 'syntax': [ + 'acot(x)' + ], + 'description': 'Calculate the inverse cotangent of a value.', + 'examples': [ + 'acot(0.5)', + 'acot(cot(0.5))', + 'acot(2)' + ], + 'seealso': [ + 'cot', + 'atan' + ] + }; + + +/***/ }, +/* 237 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acoth', + 'category': 'Trigonometry', + 'syntax': [ + 'acoth(x)' + ], + 'description': 'Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.', + 'examples': [ + 'acoth(0.5)' + ], + 'seealso': [ + 'acsch', + 'asech' + ] + }; + +/***/ }, +/* 238 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acsc', + 'category': 'Trigonometry', + 'syntax': [ + 'acsc(x)' + ], + 'description': 'Calculate the inverse cotangent of a value.', + 'examples': [ + 'acsc(0.5)', + 'acsc(csc(0.5))', + 'acsc(2)' + ], + 'seealso': [ + 'csc', + 'asin', + 'asec' + ] + }; + + +/***/ }, +/* 239 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'acsch', + 'category': 'Trigonometry', + 'syntax': [ + 'acsch(x)' + ], + 'description': 'Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.', + 'examples': [ + 'acsch(0.5)' + ], + 'seealso': [ + 'asech', + 'acoth' + ] + }; + + +/***/ }, +/* 240 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'asec', + 'category': 'Trigonometry', + 'syntax': [ + 'asec(x)' + ], + 'description': 'Calculate the inverse secant of a value.', + 'examples': [ + 'asec(0.5)', + 'asec(sec(0.5))', + 'asec(2)' + ], + 'seealso': [ + 'acos', + 'acot', + 'acsc' + ] + }; + + +/***/ }, +/* 241 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'asech', + 'category': 'Trigonometry', + 'syntax': [ + 'asech(x)' + ], + 'description': 'Calculate the inverse secant of a value.', + 'examples': [ + 'asech(0.5)' + ], + 'seealso': [ + 'acsch', + 'acoth' + ] + }; + + +/***/ }, +/* 242 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'asin', + 'category': 'Trigonometry', + 'syntax': [ + 'asin(x)' + ], + 'description': 'Compute the inverse sine of a value in radians.', + 'examples': [ + 'asin(0.5)', + 'asin(sin(2.3))' + ], + 'seealso': [ + 'sin', + 'acos', + 'atan' + ] + }; + + +/***/ }, +/* 243 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'asinh', + 'category': 'Trigonometry', + 'syntax': [ + 'asinh(x)' + ], + 'description': 'Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.', + 'examples': [ + 'asinh(0.5)' + ], + 'seealso': [ + 'acosh', + 'atanh' + ] + }; + + +/***/ }, +/* 244 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'atan', + 'category': 'Trigonometry', + 'syntax': [ + 'atan(x)' + ], + 'description': 'Compute the inverse tangent of a value in radians.', + 'examples': [ + 'atan(0.5)', + 'atan(tan(2.3))' + ], + 'seealso': [ + 'tan', + 'acos', + 'asin' + ] + }; + + +/***/ }, +/* 245 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'atanh', + 'category': 'Trigonometry', + 'syntax': [ + 'atanh(x)' + ], + 'description': 'Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.', + 'examples': [ + 'atanh(0.5)' + ], + 'seealso': [ + 'acosh', + 'asinh' + ] + }; + + +/***/ }, +/* 246 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'atan2', + 'category': 'Trigonometry', + 'syntax': [ + 'atan2(y, x)' + ], + 'description': + 'Computes the principal value of the arc tangent of y/x in radians.', + 'examples': [ + 'atan2(2, 2) / pi', + 'angle = 60 deg in rad', + 'x = cos(angle)', + 'y = sin(angle)', + 'atan2(y, x)' + ], + 'seealso': [ + 'sin', + 'cos', + 'tan' + ] + }; + + +/***/ }, +/* 247 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cos', + 'category': 'Trigonometry', + 'syntax': [ + 'cos(x)' + ], + 'description': 'Compute the cosine of x in radians.', + 'examples': [ + 'cos(2)', + 'cos(pi / 4) ^ 2', + 'cos(180 deg)', + 'cos(60 deg)', + 'sin(0.2)^2 + cos(0.2)^2' + ], + 'seealso': [ + 'acos', + 'sin', + 'tan' + ] + }; + + +/***/ }, +/* 248 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cosh', + 'category': 'Trigonometry', + 'syntax': [ + 'cosh(x)' + ], + 'description': 'Compute the hyperbolic cosine of x in radians.', + 'examples': [ + 'cosh(0.5)' + ], + 'seealso': [ + 'sinh', + 'tanh', + 'coth' + ] + }; + + +/***/ }, +/* 249 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'cot', + 'category': 'Trigonometry', + 'syntax': [ + 'cot(x)' + ], + 'description': 'Compute the cotangent of x in radians. Defined as 1/tan(x)', + 'examples': [ + 'cot(2)', + '1 / tan(2)' + ], + 'seealso': [ + 'sec', + 'csc', + 'tan' + ] + }; + + +/***/ }, +/* 250 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'coth', + 'category': 'Trigonometry', + 'syntax': [ + 'coth(x)' + ], + 'description': 'Compute the hyperbolic cotangent of x in radians.', + 'examples': [ + 'coth(2)', + '1 / tanh(2)' + ], + 'seealso': [ + 'sech', + 'csch', + 'tanh' + ] + }; + + +/***/ }, +/* 251 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'csc', + 'category': 'Trigonometry', + 'syntax': [ + 'csc(x)' + ], + 'description': 'Compute the cosecant of x in radians. Defined as 1/sin(x)', + 'examples': [ + 'csc(2)', + '1 / sin(2)' + ], + 'seealso': [ + 'sec', + 'cot', + 'sin' + ] + }; + + +/***/ }, +/* 252 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'csch', + 'category': 'Trigonometry', + 'syntax': [ + 'csch(x)' + ], + 'description': 'Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)', + 'examples': [ + 'csch(2)', + '1 / sinh(2)' + ], + 'seealso': [ + 'sech', + 'coth', + 'sinh' + ] + }; + + +/***/ }, +/* 253 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sec', + 'category': 'Trigonometry', + 'syntax': [ + 'sec(x)' + ], + 'description': 'Compute the secant of x in radians. Defined as 1/cos(x)', + 'examples': [ + 'sec(2)', + '1 / cos(2)' + ], + 'seealso': [ + 'cot', + 'csc', + 'cos' + ] + }; + + +/***/ }, +/* 254 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sech', + 'category': 'Trigonometry', + 'syntax': [ + 'sech(x)' + ], + 'description': 'Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)', + 'examples': [ + 'sech(2)', + '1 / cosh(2)' + ], + 'seealso': [ + 'coth', + 'csch', + 'cosh' + ] + }; + + +/***/ }, +/* 255 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sin', + 'category': 'Trigonometry', + 'syntax': [ + 'sin(x)' + ], + 'description': 'Compute the sine of x in radians.', + 'examples': [ + 'sin(2)', + 'sin(pi / 4) ^ 2', + 'sin(90 deg)', + 'sin(30 deg)', + 'sin(0.2)^2 + cos(0.2)^2' + ], + 'seealso': [ + 'asin', + 'cos', + 'tan' + ] + }; + + +/***/ }, +/* 256 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'sinh', + 'category': 'Trigonometry', + 'syntax': [ + 'sinh(x)' + ], + 'description': 'Compute the hyperbolic sine of x in radians.', + 'examples': [ + 'sinh(0.5)' + ], + 'seealso': [ + 'cosh', + 'tanh' + ] + }; + + +/***/ }, +/* 257 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'tan', + 'category': 'Trigonometry', + 'syntax': [ + 'tan(x)' + ], + 'description': 'Compute the tangent of x in radians.', + 'examples': [ + 'tan(0.5)', + 'sin(0.5) / cos(0.5)', + 'tan(pi / 4)', + 'tan(45 deg)' + ], + 'seealso': [ + 'atan', + 'sin', + 'cos' + ] + }; + + +/***/ }, +/* 258 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'tanh', + 'category': 'Trigonometry', + 'syntax': [ + 'tanh(x)' + ], + 'description': 'Compute the hyperbolic tangent of x in radians.', + 'examples': [ + 'tanh(0.5)', + 'sinh(0.5) / cosh(0.5)' + ], + 'seealso': [ + 'sinh', + 'cosh' + ] + }; + + +/***/ }, +/* 259 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'to', + 'category': 'Units', + 'syntax': [ + 'x to unit', + 'to(x, unit)' + ], + 'description': 'Change the unit of a value.', + 'examples': [ + '5 inch to cm', + '3.2kg to g', + '16 bytes in bits' + ], + 'seealso': [] + }; + + +/***/ }, +/* 260 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'clone', + 'category': 'Utils', + 'syntax': [ + 'clone(x)' + ], + 'description': 'Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices', + 'examples': [ + 'clone(3.5)', + 'clone(2 - 4i)', + 'clone(45 deg)', + 'clone([1, 2; 3, 4])', + 'clone("hello world")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 261 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'format', + 'category': 'Utils', + 'syntax': [ + 'format(value)', + 'format(value, precision)' + ], + 'description': 'Format a value of any type as string.', + 'examples': [ + 'format(2.3)', + 'format(3 - 4i)', + 'format([])', + 'format(pi, 3)' + ], + 'seealso': ['print'] + }; + + +/***/ }, +/* 262 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'isInteger', + 'category': 'Utils', + 'syntax': [ + 'isInteger(x)' + ], + 'description': 'Test whether a value is an integer number.', + 'examples': [ + 'isInteger(2)', + 'isInteger(3.5)', + 'isInteger([3, 0.5, -2])' + ], + 'seealso': ['isNegative', 'isNumeric', 'isPositive', 'isZero'] + }; + + +/***/ }, +/* 263 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'isNegative', + 'category': 'Utils', + 'syntax': [ + 'isNegative(x)' + ], + 'description': 'Test whether a value is negative: smaller than zero.', + 'examples': [ + 'isNegative(2)', + 'isNegative(0)', + 'isNegative(-4)', + 'isNegative([3, 0.5, -2])' + ], + 'seealso': ['isInteger', 'isNumeric', 'isPositive', 'isZero'] + }; + + +/***/ }, +/* 264 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'isNumeric', + 'category': 'Utils', + 'syntax': [ + 'isNumeric(x)' + ], + 'description': 'Test whether a value is a numeric value. ' + + 'Returns true when the input is a number, BigNumber, Fraction, or boolean.', + 'examples': [ + 'isNumeric(2)', + 'isNumeric(0)', + 'isNumeric(bignumber(500))', + 'isNumeric(fraction(0.125))', + 'isNumeric("3")', + 'isNumeric(2 + 3i)', + 'isNumeric([2.3, "foo", false])' + ], + 'seealso': ['isInteger', 'isZero', 'isNegative', 'isPositive'] + }; + + +/***/ }, +/* 265 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'isPositive', + 'category': 'Utils', + 'syntax': [ + 'isPositive(x)' + ], + 'description': 'Test whether a value is positive: larger than zero.', + 'examples': [ + 'isPositive(2)', + 'isPositive(0)', + 'isPositive(-4)', + 'isPositive([3, 0.5, -2])' + ], + 'seealso': ['isInteger', 'isNumeric', 'isNegative', 'isZero'] + }; + + +/***/ }, +/* 266 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'isZero', + 'category': 'Utils', + 'syntax': [ + 'isZero(x)' + ], + 'description': 'Test whether a value is zero.', + 'examples': [ + 'isZero(2)', + 'isZero(0)', + 'isZero(-4)', + 'isZero([3, 0, -2, 0])' + ], + 'seealso': ['isInteger', 'isNumeric', 'isNegative', 'isPositive'] + }; + + +/***/ }, +/* 267 */ +/***/ function(module, exports) { + + module.exports = { + 'name': 'typeof', + 'category': 'Utils', + 'syntax': [ + 'typeof(x)' + ], + 'description': 'Get the type of a variable.', + 'examples': [ + 'typeof(3.5)', + 'typeof(2 - 4i)', + 'typeof(45 deg)', + 'typeof("hello world")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 268 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(269), + __webpack_require__(292), + __webpack_require__(293), + __webpack_require__(294), + __webpack_require__(295) + ]; + + +/***/ }, +/* 269 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var parse = load(__webpack_require__(270)); + + /** + * Parse and compile an expression. + * Returns a an object with a function `eval([scope])` to evaluate the + * compiled expression. + * + * Syntax: + * + * math.compile(expr) // returns one node + * math.compile([expr1, expr2, expr3, ...]) // returns an array with nodes + * + * Examples: + * + * var code = math.compile('sqrt(3^2 + 4^2)'); + * code.eval(); // 5 + * + * var scope = {a: 3, b: 4} + * var code = math.compile('a * b'); // 12 + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 + * + * var nodes = math.compile(['a = 3', 'b = 4', 'a * b']); + * nodes[2].eval(); // 12 + * + * See also: + * + * parse, eval + * + * @param {string | string[] | Array | Matrix} expr + * The expression to be compiled + * @return {{eval: Function} | Array.<{eval: Function}>} code + * An object with the compiled expression + * @throws {Error} + */ + return typed('compile', { + 'string': function (expr) { + return parse(expr).compile(); + }, + + 'Array | Matrix': function (expr) { + return deepMap(expr, function (entry) { + return parse(entry).compile(); + }); + } + }); + } + + exports.name = 'compile'; + exports.factory = factory; + + +/***/ }, +/* 270 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var ArgumentsError = __webpack_require__(11); + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var AccessorNode = load(__webpack_require__(271)); + var ArrayNode = load(__webpack_require__(277)); + var AssignmentNode = load(__webpack_require__(278)); + var BlockNode = load(__webpack_require__(281)); + var ConditionalNode = load(__webpack_require__(282)); + var ConstantNode = load(__webpack_require__(283)); + var FunctionAssignmentNode = load(__webpack_require__(284)); + var IndexNode = load(__webpack_require__(285)); + var ObjectNode = load(__webpack_require__(288)); + var OperatorNode = load(__webpack_require__(289)); + var ParenthesisNode = load(__webpack_require__(291)); + var FunctionNode = load(__webpack_require__(290)); + var RangeNode = load(__webpack_require__(286)); + var SymbolNode = load(__webpack_require__(287)); + + + /** + * Parse an expression. Returns a node tree, which can be evaluated by + * invoking node.eval(); + * + * Syntax: + * + * parse(expr) + * parse(expr, options) + * parse([expr1, expr2, expr3, ...]) + * parse([expr1, expr2, expr3, ...], options) + * + * Example: + * + * var node = parse('sqrt(3^2 + 4^2)'); + * node.compile(math).eval(); // 5 + * + * var scope = {a:3, b:4} + * var node = parse('a * b'); // 12 + * var code = node.compile(math); + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 + * + * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); + * nodes[2].compile(math).eval(); // 12 + * + * @param {string | string[] | Matrix} expr + * @param {{nodes: Object}} [options] Available options: + * - `nodes` a set of custom nodes + * @return {Node | Node[]} node + * @throws {Error} + */ + function parse (expr, options) { + if (arguments.length != 1 && arguments.length != 2) { + throw new ArgumentsError('parse', arguments.length, 1, 2); + } + + // pass extra nodes + extra_nodes = (options && options.nodes) ? options.nodes : {}; + + if (typeof expr === 'string') { + // parse a single expression + expression = expr; + return parseStart(); + } + else if (Array.isArray(expr) || expr instanceof type.Matrix) { + // parse an array or matrix with expressions + return deepMap(expr, function (elem) { + if (typeof elem !== 'string') throw new TypeError('String expected'); + + expression = elem; + return parseStart(); + }); + } + else { + // oops + throw new TypeError('String or matrix expected'); + } + } + + // token types enumeration + var TOKENTYPE = { + NULL : 0, + DELIMITER : 1, + NUMBER : 2, + SYMBOL : 3, + UNKNOWN : 4 + }; + + // map with all delimiters + var DELIMITERS = { + ',': true, + '(': true, + ')': true, + '[': true, + ']': true, + '{': true, + '}': true, + '\"': true, + ';': true, + + '+': true, + '-': true, + '*': true, + '.*': true, + '/': true, + './': true, + '%': true, + '^': true, + '.^': true, + '~': true, + '!': true, + '&': true, + '|': true, + '^|': true, + '\'': true, + '=': true, + ':': true, + '?': true, + + '==': true, + '!=': true, + '<': true, + '>': true, + '<=': true, + '>=': true, + + '<<': true, + '>>': true, + '>>>': true + }; + + // map with all named delimiters + var NAMED_DELIMITERS = { + 'mod': true, + 'to': true, + 'in': true, + 'and': true, + 'xor': true, + 'or': true, + 'not': true + }; + + var extra_nodes = {}; // current extra nodes + var expression = ''; // current expression + var index = 0; // current index in expr + var c = ''; // current token character in expr + var token = ''; // current token + var token_type = TOKENTYPE.NULL; // type of the token + var nesting_level = 0; // level of nesting inside parameters, used to ignore newline characters + var conditional_level = null; // when a conditional is being parsed, the level of the conditional is stored here + + /** + * Get the first character from the expression. + * The character is stored into the char c. If the end of the expression is + * reached, the function puts an empty string in c. + * @private + */ + function first() { + index = 0; + c = expression.charAt(0); + nesting_level = 0; + conditional_level = null; + } + + /** + * Get the next character from the expression. + * The character is stored into the char c. If the end of the expression is + * reached, the function puts an empty string in c. + * @private + */ + function next() { + index++; + c = expression.charAt(index); + } + + /** + * Preview the next character from the expression. + * @return {string} cNext + * @private + */ + function nextPreview() { + return expression.charAt(index + 1); + } + + /** + * Preview the second next character from the expression. + * @return {string} cNext + * @private + */ + function nextNextPreview() { + return expression.charAt(index + 2); + } + + /** + * Get next token in the current string expr. + * The token and token type are available as token and token_type + * @private + */ + function getToken() { + token_type = TOKENTYPE.NULL; + token = ''; + + // skip over whitespaces + // space, tab, and newline when inside parameters + while (c == ' ' || c == '\t' || (c == '\n' && nesting_level)) { + // TODO: also take '\r' carriage return as newline? Or does that give problems on mac? + next(); + } + + // skip comment + if (c == '#') { + while (c != '\n' && c != '') { + next(); + } + } + + // check for end of expression + if (c == '') { + // token is still empty + token_type = TOKENTYPE.DELIMITER; + return; + } + + // check for new line character + if (c == '\n' && !nesting_level) { + token_type = TOKENTYPE.DELIMITER; + token = c; + next(); + return; + } + + // check for delimiters consisting of 3 characters + var c2 = c + nextPreview(); + var c3 = c2 + nextNextPreview(); + if (c3.length == 3 && DELIMITERS[c3]) { + token_type = TOKENTYPE.DELIMITER; + token = c3; + next(); + next(); + next(); + return; + } + + // check for delimiters consisting of 2 characters + if (c2.length == 2 && DELIMITERS[c2]) { + token_type = TOKENTYPE.DELIMITER; + token = c2; + next(); + next(); + return; + } + + // check for delimiters consisting of 1 character + if (DELIMITERS[c]) { + token_type = TOKENTYPE.DELIMITER; + token = c; + next(); + return; + } + + // check for a number + if (isDigitDot(c)) { + token_type = TOKENTYPE.NUMBER; + + // get number, can have a single dot + if (c == '.') { + token += c; + next(); + + if (!isDigit(c)) { + // this is no legal number, it is just a dot (can be dot notation) + token_type = TOKENTYPE.UNKNOWN; + } + } + else { + while (isDigit(c)) { + token += c; + next(); + } + if (c == '.') { + token += c; + next(); + } + } + while (isDigit(c)) { + token += c; + next(); + } + + // check for exponential notation like "2.3e-4", "1.23e50" or "2e+4" + c2 = nextPreview(); + if (c == 'E' || c == 'e') { + if (isDigit(c2) || c2 == '-' || c2 == '+') { + token += c; + next(); + + if (c == '+' || c == '-') { + token += c; + next(); + } + + // Scientific notation MUST be followed by an exponent + if (!isDigit(c)) { + throw createSyntaxError('Digit expected, got "' + c + '"'); + } + + while (isDigit(c)) { + token += c; + next(); + } + + if (c == '.') { + throw createSyntaxError('Digit expected, got "' + c + '"'); + } + } + else if (c2 == '.') { + next(); + throw createSyntaxError('Digit expected, got "' + c + '"'); + } + } + + return; + } + + // check for variables, functions, named operators + if (currentIsAlpha()) { + while (currentIsAlpha() || isDigit(c)) { + token += c; + next(); + } + + if (NAMED_DELIMITERS.hasOwnProperty(token)) { + token_type = TOKENTYPE.DELIMITER; + } + else { + token_type = TOKENTYPE.SYMBOL; + } + + return; + } + + // something unknown is found, wrong characters -> a syntax error + token_type = TOKENTYPE.UNKNOWN; + while (c != '') { + token += c; + next(); + } + throw createSyntaxError('Syntax error in part "' + token + '"'); + } + + /** + * Get next token and skip newline tokens + */ + function getTokenSkipNewline () { + do { + getToken(); + } + while (token == '\n'); + } + + /** + * Open parameters. + * New line characters will be ignored until closeParams() is called + */ + function openParams() { + nesting_level++; + } + + /** + * Close parameters. + * New line characters will no longer be ignored + */ + function closeParams() { + nesting_level--; + } + + /** + * Checks whether the current character `c` is a valid alpha character: + * + * - A latin letter (upper or lower case) Ascii: a-z, A-Z + * - A underscore Ascii: _ + * - A latin letter with accents Unicode: \u00C0 - \u02AF + * - A greek letter Unicode: \u0370 - \u03FF + * - A mathematical alphanumeric symbol Unicode: \u{1D400} - \u{1D7FF} excluding invalid code points + * + * @return {boolean} + * @private + */ + function currentIsAlpha () { + // http://unicode-table.com/en/ + // http://www.wikiwand.com/en/Mathematical_operators_and_symbols_in_Unicode + // + // Note: In ES6 will be unicode aware: + // http://stackoverflow.com/questions/280712/javascript-unicode-regexes + // https://mathiasbynens.be/notes/es6-unicode-regex + var cPrev = expression.charAt(index - 1); + var cNext = expression.charAt(index + 1); + + var isValidLatinOrGreek = function (p) { + return /^[a-zA-Z_\u00C0-\u02AF\u0370-\u03FF]$/.test(p); + }; + + var isValidMathSymbol = function (high, low) { + return /^[\uD835]$/.test(high) && + /^[\uDC00-\uDFFF]$/.test(low) && + /^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(low); + }; + + return isValidLatinOrGreek(c) + || isValidMathSymbol(c, cNext) + || isValidMathSymbol(cPrev, c); + } + + /** + * checks if the given char c is a digit or dot + * @param {string} c a string with one character + * @return {boolean} + * @private + */ + function isDigitDot (c) { + return ((c >= '0' && c <= '9') || c == '.'); + } + + /** + * checks if the given char c is a digit + * @param {string} c a string with one character + * @return {boolean} + * @private + */ + function isDigit (c) { + return (c >= '0' && c <= '9'); + } + + /** + * Start of the parse levels below, in order of precedence + * @return {Node} node + * @private + */ + function parseStart () { + // get the first character in expression + first(); + + getToken(); + + var node = parseBlock(); + + // check for garbage at the end of the expression + // an expression ends with a empty character '' and token_type DELIMITER + if (token != '') { + if (token_type == TOKENTYPE.DELIMITER) { + // user entered a not existing operator like "//" + + // TODO: give hints for aliases, for example with "<>" give as hint " did you mean != ?" + throw createError('Unexpected operator ' + token); + } + else { + throw createSyntaxError('Unexpected part "' + token + '"'); + } + } + + return node; + } + + /** + * Parse a block with expressions. Expressions can be separated by a newline + * character '\n', or by a semicolon ';'. In case of a semicolon, no output + * of the preceding line is returned. + * @return {Node} node + * @private + */ + function parseBlock () { + var node; + var blocks = []; + var visible; + + if (token == '') { + // empty expression + return new ConstantNode('undefined', 'undefined'); + } + + if (token != '\n' && token != ';') { + node = parseAssignment(); + } + + // TODO: simplify this loop + while (token == '\n' || token == ';') { + if (blocks.length == 0 && node) { + visible = (token != ';'); + blocks.push({ + node: node, + visible: visible + }); + } + + getToken(); + if (token != '\n' && token != ';' && token != '') { + node = parseAssignment(); + + visible = (token != ';'); + blocks.push({ + node: node, + visible: visible + }); + } + } + + if (blocks.length > 0) { + return new BlockNode(blocks); + } + else { + return node; + } + } + + /** + * Assignment of a function or variable, + * - can be a variable like 'a=2.3' + * - or a updating an existing variable like 'matrix(2,3:5)=[6,7,8]' + * - defining a function like 'f(x) = x^2' + * @return {Node} node + * @private + */ + function parseAssignment () { + var name, args, value, valid; + + var node = parseConditional(); + + if (token == '=') { + if (node && node.isSymbolNode) { + // parse a variable assignment like 'a = 2/3' + name = node.name; + getTokenSkipNewline(); + value = parseAssignment(); + return new AssignmentNode(new SymbolNode(name), value); + } + else if (node && node.isAccessorNode) { + // parse a matrix subset assignment like 'A[1,2] = 4' + getTokenSkipNewline(); + value = parseAssignment(); + return new AssignmentNode(node.object, node.index, value); + } + else if (node && node.isFunctionNode) { + // parse function assignment like 'f(x) = x^2' + valid = true; + args = []; + + name = node.name; + node.args.forEach(function (arg, index) { + if (arg && arg.isSymbolNode) { + args[index] = arg.name; + } + else { + valid = false; + } + }); + + if (valid) { + getTokenSkipNewline(); + value = parseAssignment(); + return new FunctionAssignmentNode(name, args, value); + } + } + + throw createSyntaxError('Invalid left hand side of assignment operator ='); + } + + return node; + } + + /** + * conditional operation + * + * condition ? truePart : falsePart + * + * Note: conditional operator is right-associative + * + * @return {Node} node + * @private + */ + function parseConditional () { + var node = parseLogicalOr(); + + while (token == '?') { + // set a conditional level, the range operator will be ignored as long + // as conditional_level == nesting_level. + var prev = conditional_level; + conditional_level = nesting_level; + getTokenSkipNewline(); + + var condition = node; + var trueExpr = parseAssignment(); + + if (token != ':') throw createSyntaxError('False part of conditional expression expected'); + + conditional_level = null; + getTokenSkipNewline(); + + var falseExpr = parseAssignment(); // Note: check for conditional operator again, right associativity + + node = new ConditionalNode(condition, trueExpr, falseExpr); + + // restore the previous conditional level + conditional_level = prev; + } + + return node; + } + + /** + * logical or, 'x or y' + * @return {Node} node + * @private + */ + function parseLogicalOr() { + var node = parseLogicalXor(); + + while (token == 'or') { + getTokenSkipNewline(); + node = new OperatorNode('or', 'or', [node, parseLogicalXor()]); + } + + return node; + } + + /** + * logical exclusive or, 'x xor y' + * @return {Node} node + * @private + */ + function parseLogicalXor() { + var node = parseLogicalAnd(); + + while (token == 'xor') { + getTokenSkipNewline(); + node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd()]); + } + + return node; + } + + /** + * logical and, 'x and y' + * @return {Node} node + * @private + */ + function parseLogicalAnd() { + var node = parseBitwiseOr(); + + while (token == 'and') { + getTokenSkipNewline(); + node = new OperatorNode('and', 'and', [node, parseBitwiseOr()]); + } + + return node; + } + + /** + * bitwise or, 'x | y' + * @return {Node} node + * @private + */ + function parseBitwiseOr() { + var node = parseBitwiseXor(); + + while (token == '|') { + getTokenSkipNewline(); + node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor()]); + } + + return node; + } + + /** + * bitwise exclusive or (xor), 'x ^| y' + * @return {Node} node + * @private + */ + function parseBitwiseXor() { + var node = parseBitwiseAnd(); + + while (token == '^|') { + getTokenSkipNewline(); + node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd()]); + } + + return node; + } + + /** + * bitwise and, 'x & y' + * @return {Node} node + * @private + */ + function parseBitwiseAnd () { + var node = parseRelational(); + + while (token == '&') { + getTokenSkipNewline(); + node = new OperatorNode('&', 'bitAnd', [node, parseRelational()]); + } + + return node; + } + + /** + * relational operators + * @return {Node} node + * @private + */ + function parseRelational () { + var node, operators, name, fn, params; + + node = parseShift(); + + operators = { + '==': 'equal', + '!=': 'unequal', + '<': 'smaller', + '>': 'larger', + '<=': 'smallerEq', + '>=': 'largerEq' + }; + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseShift()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift + * @return {Node} node + * @private + */ + function parseShift () { + var node, operators, name, fn, params; + + node = parseConversion(); + + operators = { + '<<' : 'leftShift', + '>>' : 'rightArithShift', + '>>>' : 'rightLogShift' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseConversion()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * conversion operators 'to' and 'in' + * @return {Node} node + * @private + */ + function parseConversion () { + var node, operators, name, fn, params; + + node = parseRange(); + + operators = { + 'to' : 'to', + 'in' : 'to' // alias of 'to' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + + if (name === 'in' && token === '') { + // end of expression -> this is the unit 'in' ('inch') + node = new OperatorNode('*', 'multiply', [node, new SymbolNode('in')], true); + } + else { + // operator 'a to b' or 'a in b' + params = [node, parseRange()]; + node = new OperatorNode(name, fn, params); + } + } + + return node; + } + + /** + * parse range, "start:end", "start:step:end", ":", "start:", ":end", etc + * @return {Node} node + * @private + */ + function parseRange () { + var node, params = []; + + if (token == ':') { + // implicit start=1 (one-based) + node = new ConstantNode('1', 'number'); + } + else { + // explicit start + node = parseAddSubtract(); + } + + if (token == ':' && (conditional_level !== nesting_level)) { + // we ignore the range operator when a conditional operator is being processed on the same level + params.push(node); + + // parse step and end + while (token == ':' && params.length < 3) { + getTokenSkipNewline(); + + if (token == ')' || token == ']' || token == ',' || token == '') { + // implicit end + params.push(new SymbolNode('end')); + } + else { + // explicit end + params.push(parseAddSubtract()); + } + } + + if (params.length == 3) { + // params = [start, step, end] + node = new RangeNode(params[0], params[2], params[1]); // start, end, step + } + else { // length == 2 + // params = [start, end] + node = new RangeNode(params[0], params[1]); // start, end + } + } + + return node; + } + + /** + * add or subtract + * @return {Node} node + * @private + */ + function parseAddSubtract () { + var node, operators, name, fn, params; + + node = parseMultiplyDivide(); + + operators = { + '+': 'add', + '-': 'subtract' + }; + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseMultiplyDivide()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * multiply, divide, modulus + * @return {Node} node + * @private + */ + function parseMultiplyDivide () { + var node, last, operators, name, fn; + + node = parseUnary(); + last = node; + + operators = { + '*': 'multiply', + '.*': 'dotMultiply', + '/': 'divide', + './': 'dotDivide', + '%': 'mod', + 'mod': 'mod' + }; + + while (true) { + if (token in operators) { + // explicit operators + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + + last = parseUnary(); + node = new OperatorNode(name, fn, [node, last]); + } + else if ((token_type == TOKENTYPE.SYMBOL) || + (token == 'in' && (node && node.isConstantNode)) || + (token_type == TOKENTYPE.NUMBER && !last.isConstantNode) || + (token == '(')) { + // parse implicit multiplication + // + // symbol: implicit multiplication like '2a', '(2+3)a', 'a b' + // number: implicit multiplication like '(2+3)2' + // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)' + last = parseUnary(); + node = new OperatorNode('*', 'multiply', [node, last], true /*implicit*/); + } + else { + break; + } + } + + return node; + } + + /** + * Unary plus and minus, and logical and bitwise not + * @return {Node} node + * @private + */ + function parseUnary () { + var name, params; + var fn = { + '-': 'unaryMinus', + '+': 'unaryPlus', + '~': 'bitNot', + 'not': 'not' + }[token]; + + if (fn) { + name = token; + + getTokenSkipNewline(); + params = [parseUnary()]; + + return new OperatorNode(name, fn, params); + } + + return parsePow(); + } + + /** + * power + * Note: power operator is right associative + * @return {Node} node + * @private + */ + function parsePow () { + var node, name, fn, params; + + node = parseLeftHandOperators(); + + if (token == '^' || token == '.^') { + name = token; + fn = (name == '^') ? 'pow' : 'dotPow'; + + getTokenSkipNewline(); + params = [node, parseUnary()]; // Go back to unary, we can have '2^-3' + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * Left hand operators: factorial x!, transpose x' + * @return {Node} node + * @private + */ + function parseLeftHandOperators () { + var node, operators, name, fn, params; + + node = parseCustomNodes(); + + operators = { + '!': 'factorial', + '\'': 'transpose' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getToken(); + params = [node]; + + node = new OperatorNode(name, fn, params); + node = parseAccessors(node); + } + + return node; + } + + /** + * Parse a custom node handler. A node handler can be used to process + * nodes in a custom way, for example for handling a plot. + * + * A handler must be passed as second argument of the parse function. + * - must extend math.expression.node.Node + * - must contain a function _compile(defs: Object) : string + * - must contain a function find(filter: Object) : Node[] + * - must contain a function toString() : string + * - the constructor is called with a single argument containing all parameters + * + * For example: + * + * nodes = { + * 'plot': PlotHandler + * }; + * + * The constructor of the handler is called as: + * + * node = new PlotHandler(params); + * + * The handler will be invoked when evaluating an expression like: + * + * node = math.parse('plot(sin(x), x)', nodes); + * + * @return {Node} node + * @private + */ + function parseCustomNodes () { + var params = [], handler; + + if (token_type == TOKENTYPE.SYMBOL && extra_nodes[token]) { + handler = extra_nodes[token]; + + getToken(); + + // parse parameters + if (token == '(') { + params = []; + + openParams(); + getToken(); + + if (token != ')') { + params.push(parseAssignment()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseAssignment()); + } + } + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + } + + // create a new node handler + //noinspection JSValidateTypes + return new handler(params); + } + + return parseSymbol(); + } + + /** + * parse symbols: functions, variables, constants, units + * @return {Node} node + * @private + */ + function parseSymbol () { + var node, name; + + if (token_type == TOKENTYPE.SYMBOL || + (token_type == TOKENTYPE.DELIMITER && token in NAMED_DELIMITERS)) { + name = token; + + getToken(); + + // parse function parameters and matrix index + node = new SymbolNode(name); + node = parseAccessors(node); + return node; + } + + return parseString(); + } + + /** + * parse accessors: + * - function invocation in round brackets (...), for example sqrt(2) + * - index enclosed in square brackets [...], for example A[2,3] + * - dot notation for properties, like foo.bar + * @param {Node} node Node on which to apply the parameters. If there + * are no parameters in the expression, the node + * itself is returned + * @param {string[]} [types] Filter the types of notations + * can be ['(', '[', '.'] + * @return {Node} node + * @private + */ + function parseAccessors (node, types) { + var params; + + while ((token == '(' || token == '[' || token == '.') && + (!types || types.indexOf(token) !== -1)) { + params = []; + + if (token == '(') { + if (node.isSymbolNode || node.isAccessorNode) { + // function invocation like fn(2, 3) + openParams(); + getToken(); + + if (token != ')') { + params.push(parseAssignment()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseAssignment()); + } + } + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + + node = new FunctionNode(node, params); + } + else { + // implicit multiplication like (2+3)(4+5) + // don't parse it here but let it be handled by parseMultiplyDivide + // with correct precedence + return node; + } + } + else if (token == '[') { + // index notation like variable[2, 3] + openParams(); + getToken(); + + if (token != ']') { + params.push(parseAssignment()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseAssignment()); + } + } + + if (token != ']') { + throw createSyntaxError('Parenthesis ] expected'); + } + closeParams(); + getToken(); + + node = new AccessorNode(node, new IndexNode(params)); + } + else { + // dot notation like variable.prop + getToken(); + + if (token_type != TOKENTYPE.SYMBOL) { + throw createSyntaxError('Property name expected after dot'); + } + params.push(new ConstantNode(token)); + getToken(); + + var dotNotation = true; + node = new AccessorNode(node, new IndexNode(params, dotNotation)); + } + } + + return node; + } + + /** + * parse a string. + * A string is enclosed by double quotes + * @return {Node} node + * @private + */ + function parseString () { + var node, str; + + if (token == '"') { + str = parseStringToken(); + + // create constant + node = new ConstantNode(str, 'string'); + + // parse index parameters + node = parseAccessors(node); + + return node; + } + + return parseMatrix(); + } + + /** + * Parse a string surrounded by double quotes "..." + * @return {string} + */ + function parseStringToken () { + var str = ''; + + while (c != '' && c != '\"') { + if (c == '\\') { + // escape character + str += c; + next(); + } + + str += c; + next(); + } + + getToken(); + if (token != '"') { + throw createSyntaxError('End of string " expected'); + } + getToken(); + + return str; + } + + /** + * parse the matrix + * @return {Node} node + * @private + */ + function parseMatrix () { + var array, params, rows, cols; + + if (token == '[') { + // matrix [...] + openParams(); + getToken(); + + if (token != ']') { + // this is a non-empty matrix + var row = parseRow(); + + if (token == ';') { + // 2 dimensional array + rows = 1; + params = [row]; + + // the rows of the matrix are separated by dot-comma's + while (token == ';') { + getToken(); + + params[rows] = parseRow(); + rows++; + } + + if (token != ']') { + throw createSyntaxError('End of matrix ] expected'); + } + closeParams(); + getToken(); + + // check if the number of columns matches in all rows + cols = params[0].items.length; + for (var r = 1; r < rows; r++) { + if (params[r].items.length != cols) { + throw createError('Column dimensions mismatch ' + + '(' + params[r].items.length + ' != ' + cols + ')'); + } + } + + array = new ArrayNode(params); + } + else { + // 1 dimensional vector + if (token != ']') { + throw createSyntaxError('End of matrix ] expected'); + } + closeParams(); + getToken(); + + array = row; + } + } + else { + // this is an empty matrix "[ ]" + closeParams(); + getToken(); + array = new ArrayNode([]); + } + + return parseAccessors(array); + } + + return parseObject(); + } + + /** + * Parse a single comma-separated row from a matrix, like 'a, b, c' + * @return {ArrayNode} node + */ + function parseRow () { + var params = [parseAssignment()]; + var len = 1; + + while (token == ',') { + getToken(); + + // parse expression + params[len] = parseAssignment(); + len++; + } + + return new ArrayNode(params); + } + + /** + * parse an object, enclosed in angle brackets{...}, for example {value: 2} + * @return {Node} node + * @private + */ + function parseObject () { + if (token == '{') { + var key; + + var properties = {}; + do { + getToken(); + + if (token != '}') { + // parse key + if (token == '"') { + key = parseStringToken(); + } + else if (token_type == TOKENTYPE.SYMBOL) { + key = token; + getToken(); + } + else { + throw createSyntaxError('Symbol or string expected as object key'); + } + + // parse key/value separator + if (token != ':') { + throw createSyntaxError('Colon : expected after object key'); + } + getToken(); + + // parse key + properties[key] = parseAssignment(); + } + } + while (token == ','); + + if (token != '}') { + throw createSyntaxError('Comma , or bracket } expected after object value'); + } + getToken(); + + var node = new ObjectNode(properties); + + // parse index parameters + node = parseAccessors(node); + + return node; + } + + return parseNumber(); + } + + /** + * parse a number + * @return {Node} node + * @private + */ + function parseNumber () { + var number; + + if (token_type == TOKENTYPE.NUMBER) { + // this is a number + number = token; + getToken(); + + return new ConstantNode(number, 'number'); + } + + return parseParentheses(); + } + + /** + * parentheses + * @return {Node} node + * @private + */ + function parseParentheses () { + var node; + + // check if it is a parenthesized expression + if (token == '(') { + // parentheses (...) + openParams(); + getToken(); + + node = parseAssignment(); // start again + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + + node = new ParenthesisNode(node); + node = parseAccessors(node); + return node; + } + + return parseEnd(); + } + + /** + * Evaluated when the expression is not yet ended but expected to end + * @return {Node} res + * @private + */ + function parseEnd () { + if (token == '') { + // syntax error or unexpected end of expression + throw createSyntaxError('Unexpected end of expression'); + } else { + throw createSyntaxError('Value expected'); + } + } + + /** + * Shortcut for getting the current row value (one based) + * Returns the line of the currently handled expression + * @private + */ + /* TODO: implement keeping track on the row number + function row () { + return null; + } + */ + + /** + * Shortcut for getting the current col value (one based) + * Returns the column (position) where the last token starts + * @private + */ + function col () { + return index - token.length + 1; + } + + /** + * Create an error + * @param {string} message + * @return {SyntaxError} instantiated error + * @private + */ + function createSyntaxError (message) { + var c = col(); + var error = new SyntaxError(message + ' (char ' + c + ')'); + error['char'] = c; + + return error; + } + + /** + * Create an error + * @param {string} message + * @return {Error} instantiated error + * @private + */ + function createError (message) { + var c = col(); + var error = new SyntaxError(message + ' (char ' + c + ')'); + error['char'] = c; + + return error; + } + + return parse; + }; + + exports.name = 'parse'; + exports.path = 'expression'; + exports.factory = factory; + + +/***/ }, +/* 271 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + var access = load(__webpack_require__(274)); + + /** + * @constructor AccessorNode + * @extends {Node} + * Access an object property or get a matrix subset + * + * @param {Node} object The object from which to retrieve + * a property or subset. + * @param {IndexNode} index IndexNode containing ranges + */ + function AccessorNode(object, index) { + if (!(this instanceof AccessorNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (!(object && object.isNode)) { + throw new TypeError('Node expected for parameter "object"'); + } + if (!(index && index.isIndexNode)) { + throw new TypeError('IndexNode expected for parameter "index"'); + } + + this.object = object || null; + this.index = index; + + // readonly property name + Object.defineProperty(this, 'name', { + get: function () { + if (this.index) { + return (this.index.isObjectProperty()) + ? this.index.getObjectProperty() + : ''; + } + else { + return this.object.name || ''; + } + }.bind(this), + set: function () { + throw new Error('Cannot assign a new name, name is read-only'); + } + }); + } + + AccessorNode.prototype = new Node(); + + AccessorNode.prototype.type = 'AccessorNode'; + + AccessorNode.prototype.isAccessorNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + AccessorNode.prototype._compile = function (defs, args) { + defs.access = access; + + var object = this.object._compile(defs, args); + var index = this.index._compile(defs, args); + + if (this.index.isObjectProperty()) { + return object + '["' + this.index.getObjectProperty() + '"]'; + } + else if (this.index.needsSize()) { + // if some parameters use the 'end' parameter, we need to calculate the size + return '(function () {' + + ' var object = ' + object + ';' + + ' var size = math.size(object).valueOf();' + + ' return access(object, ' + index + ');' + + '})()'; + } + else { + return 'access(' + object + ', ' + index + ')'; + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + AccessorNode.prototype.forEach = function (callback) { + callback(this.object, 'object', this); + callback(this.index, 'index', this); + }; + + /** + * Create a new AccessorNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {AccessorNode} Returns a transformed copy of the node + */ + AccessorNode.prototype.map = function (callback) { + return new AccessorNode( + this._ifNode(callback(this.object, 'object', this)), + this._ifNode(callback(this.index, 'index', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {AccessorNode} + */ + AccessorNode.prototype.clone = function () { + return new AccessorNode(this.object, this.index); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} + */ + AccessorNode.prototype._toString = function (options) { + var object = this.object.toString(options); + if (needParenthesis(this.object)) { + object = '(' + object + ')'; + } + + return object + this.index.toString(options); + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} + */ + AccessorNode.prototype._toTex = function (options) { + var object = this.object.toTex(options); + if (needParenthesis(this.object)) { + object = '\\left(' + object + '\\right)'; + } + + return object + this.index.toTex(options); + }; + + /** + * Are parenthesis needed? + * @private + */ + function needParenthesis(node) { + // TODO: maybe make a method on the nodes which tells whether they need parenthesis? + return !(node.isAccessorNode || node.isArrayNode || node.isConstantNode + || node.isFunctionNode || node.isObjectNode || node.isParenthesisNode + || node.isSymbolNode); + } + + return AccessorNode; + } + + exports.name = 'AccessorNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 272 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var keywords = __webpack_require__(273); + var extend = __webpack_require__(3).extend; + + function factory (type, config, load, typed, math) { + /** + * Node + */ + function Node() { + if (!(this instanceof Node)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + } + + /** + * Evaluate the node + * @param {Object} [scope] Scope to read/write variables + * @return {*} Returns the result + */ + Node.prototype.eval = function(scope) { + return this.compile().eval(scope); + }; + + Node.prototype.type = 'Node'; + + Node.prototype.isNode = true; + + /** + * Compile the node to javascript code + * @return {{eval: function}} expr Returns an object with a function 'eval', + * which can be invoked as expr.eval([scope]), + * where scope is an optional object with + * variables. + */ + Node.prototype.compile = function () { + // TODO: calling compile(math) is deprecated since version 2.0.0. Remove this warning some day + if (arguments.length > 0) { + throw new Error('Calling compile(math) is deprecated. Call the function as compile() instead.'); + } + + // definitions globally available inside the closure of the compiled expressions + var defs = { + math: math.expression.transform, + args: {}, // can be filled with names of FunctionAssignment arguments + _validateScope: _validateScope + }; + + // will be used to put local function arguments + var args = {}; + + var code = this._compile(defs, args); + + var defsCode = Object.keys(defs).map(function (name) { + return ' var ' + name + ' = defs["' + name + '"];'; + }); + + var factoryCode = + defsCode.join(' ') + + 'return {' + + ' "eval": function (scope) {' + + ' if (scope) _validateScope(scope);' + + ' scope = scope || {};' + + ' return ' + code + ';' + + ' }' + + '};'; + + var factory = new Function('defs', factoryCode); + return factory(defs); + }; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * and constants globally available inside the closure + * of the compiled expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + Node.prototype._compile = function (defs, args) { + // must be implemented by each of the Node implementations + throw new Error('Cannot compile a Node interface'); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + Node.prototype.forEach = function (callback) { + // must be implemented by each of the Node implementations + throw new Error('Cannot run forEach on a Node interface'); + }; + + /** + * Create a new Node having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {OperatorNode} Returns a transformed copy of the node + */ + Node.prototype.map = function (callback) { + // must be implemented by each of the Node implementations + throw new Error('Cannot run map on a Node interface'); + }; + + /** + * Validate whether an object is a Node, for use with map + * @param {Node} node + * @returns {Node} Returns the input if it's a node, else throws an Error + * @protected + */ + Node.prototype._ifNode = function (node) { + if (!(node && node.isNode)) { + throw new TypeError('Callback function must return a Node'); + } + + return node; + }; + + /** + * Recursively traverse all nodes in a node tree. Executes given callback for + * this node and each of its child nodes. + * @param {function(node: Node, path: string, parent: Node)} callback + * A callback called for every node in the node tree. + */ + Node.prototype.traverse = function (callback) { + // execute callback for itself + callback(this, null, null); + + // recursively traverse over all childs of a node + function _traverse(node, callback) { + node.forEach(function (child, path, parent) { + callback(child, path, parent); + _traverse(child, callback); + }); + } + + _traverse(this, callback); + }; + + /** + * Recursively transform a node tree via a transform function. + * + * For example, to replace all nodes of type SymbolNode having name 'x' with a + * ConstantNode with value 2: + * + * var res = Node.transform(function (node, path, parent) { + * if (node && node.isSymbolNode) && (node.name == 'x')) { + * return new ConstantNode(2); + * } + * else { + * return node; + * } + * }); + * + * @param {function(node: Node, path: string, parent: Node) : Node} callback + * A mapping function accepting a node, and returning + * a replacement for the node or the original node. + * Signature: callback(node: Node, index: string, parent: Node) : Node + * @return {Node} Returns the original node or its replacement + */ + Node.prototype.transform = function (callback) { + // traverse over all childs + function _transform (node, callback) { + return node.map(function(child, path, parent) { + var replacement = callback(child, path, parent); + return _transform(replacement, callback); + }); + } + + var replacement = callback(this, null, null); + return _transform(replacement, callback); + }; + + /** + * Find any node in the node tree matching given filter function. For example, to + * find all nodes of type SymbolNode having name 'x': + * + * var results = Node.filter(function (node) { + * return (node && node.isSymbolNode) && (node.name == 'x'); + * }); + * + * @param {function(node: Node, path: string, parent: Node) : Node} callback + * A test function returning true when a node matches, and false + * otherwise. Function signature: + * callback(node: Node, index: string, parent: Node) : boolean + * @return {Node[]} nodes An array with nodes matching given filter criteria + */ + Node.prototype.filter = function (callback) { + var nodes = []; + + this.traverse(function (node, path, parent) { + if (callback(node, path, parent)) { + nodes.push(node); + } + }); + + return nodes; + }; + + // TODO: deprecated since version 1.1.0, remove this some day + Node.prototype.find = function () { + throw new Error('Function Node.find is deprecated. Use Node.filter instead.'); + }; + + // TODO: deprecated since version 1.1.0, remove this some day + Node.prototype.match = function () { + throw new Error('Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.'); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {Node} + */ + Node.prototype.clone = function () { + // must be implemented by each of the Node implementations + throw new Error('Cannot clone a Node interface'); + }; + + /** + /** + * Get string representation. (wrapper function) + * + * This function can get an object of the following form: + * { + * handler: //This can be a callback function of the form + * // "function callback(node, options)"or + * // a map that maps function names (used in FunctionNodes) + * // to callbacks + * parenthesis: "keep" //the parenthesis option (This is optional) + * } + * + * @param {Object} [options] + * @return {string} + */ + Node.prototype.toString = function (options) { + var customString; + if (options && typeof options == "object") { + switch (typeof options.handler) { + case 'object': + case 'undefined': + break; + case 'function': + customString = options.handler(this, options); + break; + default: + throw new TypeError('Object or function expected as callback'); + } + } + + if (typeof customString !== 'undefined') { + return customString; + } + + return this._toString(options); + }; + + /** + * Internal function to generate the string output. + * This has to be implemented by every Node + * + * @throws {Error} + */ + Node.prototype._toString = function () { + //must be implemented by each of the Node implementations + throw new Error('_toString not implemented for ' + this.type); + }; + + /** + * Get LaTeX representation. (wrapper function) + * + * This function can get an object of the following form: + * { + * handler: //This can be a callback function of the form + * // "function callback(node, options)"or + * // a map that maps function names (used in FunctionNodes) + * // to callbacks + * parenthesis: "keep" //the parenthesis option (This is optional) + * } + * + * @param {Object} [options] + * @return {string} + */ + Node.prototype.toTex = function (options) { + var customTex; + if (options && typeof options == 'object') { + switch (typeof options.handler) { + case 'object': + case 'undefined': + break; + case 'function': + customTex = options.handler(this, options); + break; + default: + throw new TypeError('Object or function expected as callback'); + } + } + + if (typeof customTex !== 'undefined') { + return customTex; + } + + return this._toTex(options); + }; + + /** + * Internal function to generate the LaTeX output. + * This has to be implemented by every Node + * + * @param {Object} [options] + * @throws {Error} + */ + Node.prototype._toTex = function (options) { + //must be implemented by each of the Node implementations + throw new Error('_toTex not implemented for ' + this.type); + }; + + /** + * Get identifier. + * @return {string} + */ + Node.prototype.getIdentifier = function () { + return this.type; + }; + + /** + * Get the content of the current Node. + * @return {Node} node + **/ + Node.prototype.getContent = function () { + return this; + }; + + /** + * Validate the symbol names of a scope. + * Throws an error when the scope contains an illegal symbol. + * @param {Object} scope + */ + function _validateScope(scope) { + for (var symbol in scope) { + if (scope.hasOwnProperty(symbol)) { + if (symbol in keywords) { + throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword'); + } + } + } + } + + return Node; + } + + exports.name = 'Node'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 273 */ +/***/ function(module, exports) { + + 'use strict'; + + // Reserved keywords not allowed to use in the parser + module.exports = { + end: true + }; + + +/***/ }, +/* 274 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(275).transform; + + function factory (type, config, load, typed) { + var subset = load(__webpack_require__(276)); + var matrix = load(__webpack_require__(52)); + + /** + * Retrieve part of an object: + * + * - Retrieve a property from an object + * - Retrieve a part of a string + * - Retrieve a matrix subset + * + * @param {Object | Array | Matrix | string} object + * @param {Index} index + * @return {Object | Array | Matrix | string} Returns the subset + */ + return function access(object, index) { + try { + if (Array.isArray(object)) { + return matrix(object).subset(index).valueOf(); + } + else if (object && typeof object.subset === 'function') { // Matrix + return object.subset(index); + } + else if (typeof object === 'string') { + // TODO: move getStringSubset into a separate util file, use that + return subset(object, index); + } + else if (typeof object === 'object') { + if (!index.isObjectProperty()) { + throw TypeError('Cannot apply a numeric index as object property'); + } + return object[index.getObjectProperty()]; + } + else { + throw new TypeError('Cannot apply index: unsupported type of object'); + } + } + catch (err) { + throw errorTransform(err); + } + } + } + + exports.factory = factory; + + +/***/ }, +/* 275 */ +/***/ function(module, exports, __webpack_require__) { + + var IndexError = __webpack_require__(43); + + /** + * Transform zero-based indices to one-based indices in errors + * @param {Error} err + * @returns {Error} Returns the transformed error + */ + exports.transform = function (err) { + if (err && err.isIndexError) { + return new IndexError( + err.index + 1, + err.min + 1, + err.max !== undefined ? err.max + 1 : undefined); + } + + return err; + }; + + +/***/ }, +/* 276 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var validateIndex = __webpack_require__(40).validateIndex; + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Get or set a subset of a matrix or string. + * + * Syntax: + * math.subset(value, index) // retrieve a subset + * math.subset(value, index, replacement [, defaultValue]) // replace a subset + * + * Examples: + * + * // get a subset + * var d = [[1, 2], [3, 4]]; + * math.subset(d, math.index(1, 0)); // returns 3 + * math.subset(d, math.index([0, 2], 1)); // returns [[2], [4]] + * + * // replace a subset + * var e = []; + * var f = math.subset(e, math.index(0, [0, 2]), [5, 6]); // f = [[5, 6]] + * var g = math.subset(f, math.index(1, 1), 7, 0); // g = [[5, 6], [0, 7]] + * + * See also: + * + * size, resize, squeeze, index + * + * @param {Array | Matrix | string} matrix An array, matrix, or string + * @param {Index} index An index containing ranges for each + * dimension + * @param {*} [replacement] An array, matrix, or scalar. + * If provided, the subset is replaced with replacement. + * If not provided, the subset is returned + * @param {*} [defaultValue=undefined] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * math.matrix elements will be left undefined. + * @return {Array | Matrix | string} Either the retrieved subset or the updated matrix. + */ + var subset = typed('subset', { + // get subset + 'Array, Index': function (value, index) { + var m = matrix(value); + var subset = m.subset(index); // returns a Matrix + return subset && subset.valueOf(); // return an Array (like the input) + }, + + 'Matrix, Index': function (value, index) { + return value.subset(index); + }, + + 'Object, Index': _getObjectProperty, + + 'string, Index': _getSubstring, + + // set subset + 'Array, Index, any': function (value, index, replacement) { + return matrix(clone(value)) + .subset(index, replacement, undefined) + .valueOf(); + }, + + 'Array, Index, any, any': function (value, index, replacement, defaultValue) { + return matrix(clone(value)) + .subset(index, replacement, defaultValue) + .valueOf(); + }, + + 'Matrix, Index, any': function (value, index, replacement) { + return value.clone().subset(index, replacement); + }, + + 'Matrix, Index, any, any': function (value, index, replacement, defaultValue) { + return value.clone().subset(index, replacement, defaultValue); + }, + + 'string, Index, string': _setSubstring, + 'string, Index, string, string': _setSubstring, + 'Object, Index, any': _setObjectProperty + }); + + subset.toTex = undefined; // use default template + + return subset; + + /** + * Retrieve a subset of a string + * @param {string} str string from which to get a substring + * @param {Index} index An index containing ranges for each dimension + * @returns {string} substring + * @private + */ + function _getSubstring(str, index) { + if (!index || index.isIndex !== true) { + // TODO: better error message + throw new TypeError('Index expected'); + } + if (index.size().length != 1) { + throw new DimensionError(index.size().length, 1); + } + + // validate whether the range is out of range + var strLen = str.length; + validateIndex(index.min()[0], strLen); + validateIndex(index.max()[0], strLen); + + var range = index.dimension(0); + + var substr = ''; + range.forEach(function (v) { + substr += str.charAt(v); + }); + + return substr; + } + + /** + * Replace a substring in a string + * @param {string} str string to be replaced + * @param {Index} index An index containing ranges for each dimension + * @param {string} replacement Replacement string + * @param {string} [defaultValue] Default value to be uses when resizing + * the string. is ' ' by default + * @returns {string} result + * @private + */ + function _setSubstring(str, index, replacement, defaultValue) { + if (!index || index.isIndex !== true) { + // TODO: better error message + throw new TypeError('Index expected'); + } + if (index.size().length != 1) { + throw new DimensionError(index.size().length, 1); + } + if (defaultValue !== undefined) { + if (typeof defaultValue !== 'string' || defaultValue.length !== 1) { + throw new TypeError('Single character expected as defaultValue'); + } + } + else { + defaultValue = ' '; + } + + var range = index.dimension(0); + var len = range.size()[0]; + + if (len != replacement.length) { + throw new DimensionError(range.size()[0], replacement.length); + } + + // validate whether the range is out of range + var strLen = str.length; + validateIndex(index.min()[0]); + validateIndex(index.max()[0]); + + // copy the string into an array with characters + var chars = []; + for (var i = 0; i < strLen; i++) { + chars[i] = str.charAt(i); + } + + range.forEach(function (v, i) { + chars[v] = replacement.charAt(i[0]); + }); + + // initialize undefined characters with a space + if (chars.length > strLen) { + for (i = strLen - 1, len = chars.length; i < len; i++) { + if (!chars[i]) { + chars[i] = defaultValue; + } + } + } + + return chars.join(''); + } + } + + /** + * Retrieve a property from an object + * @param {Object} object + * @param {Index} index + * @return {*} Returns the value of the property + * @private + */ + function _getObjectProperty (object, index) { + if (index.size().length !== 1) { + throw new DimensionError(index.size(), 1); + } + + var key = index.dimension(0); + if (typeof key !== 'string') { + throw new TypeError('String expected as index to retrieve an object property'); + } + + return object[key]; + } + + /** + * Set a property on an object + * @param {Object} object + * @param {Index} index + * @param {*} replacement + * @return {*} Returns the updated object + * @private + */ + function _setObjectProperty (object, index, replacement) { + if (index.size().length !== 1) { + throw new DimensionError(index.size(), 1); + } + + var key = index.dimension(0); + if (typeof key !== 'string') { + throw new TypeError('String expected as index to retrieve an object property'); + } + + // clone the object, and apply the property to the clone + var updated = clone(object); + updated[key] = replacement; + + return updated; + } + + exports.name = 'subset'; + exports.factory = factory; + + +/***/ }, +/* 277 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * @constructor ArrayNode + * @extends {Node} + * Holds an 1-dimensional array with items + * @param {Node[]} [items] 1 dimensional array with items + */ + function ArrayNode(items) { + if (!(this instanceof ArrayNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.items = items || []; + + // validate input + if (!Array.isArray(this.items) + || !this.items.every(function (item) {return item && item.isNode;})) { + throw new TypeError('Array containing Nodes expected'); + } + + // TODO: deprecated since v3, remove some day + var deprecated = function () { + throw new Error('Property `ArrayNode.nodes` is deprecated, use `ArrayNode.items` instead'); + }; + Object.defineProperty(this, 'nodes', { get: deprecated, set: deprecated }); + } + + ArrayNode.prototype = new Node(); + + ArrayNode.prototype.type = 'ArrayNode'; + + ArrayNode.prototype.isArrayNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @private + */ + ArrayNode.prototype._compile = function (defs, args) { + var asMatrix = (defs.math.config().matrix !== 'Array'); + + var items = this.items.map(function (node) { + return node._compile(defs, args); + }); + + return (asMatrix ? 'math.matrix([' : '[') + + items.join(',') + + (asMatrix ? '])' : ']'); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ArrayNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.items.length; i++) { + var node = this.items[i]; + callback(node, 'items[' + i + ']', this); + } + }; + + /** + * Create a new ArrayNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {ArrayNode} Returns a transformed copy of the node + */ + ArrayNode.prototype.map = function (callback) { + var items = []; + for (var i = 0; i < this.items.length; i++) { + items[i] = this._ifNode(callback(this.items[i], 'items[' + i + ']', this)); + } + return new ArrayNode(items); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ArrayNode} + */ + ArrayNode.prototype.clone = function() { + return new ArrayNode(this.items.slice(0)); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + * @override + */ + ArrayNode.prototype._toString = function(options) { + var items = this.items.map(function (node) { + return node.toString(options); + }); + return '[' + items.join(', ') + ']'; + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + ArrayNode.prototype._toTex = function(options) { + var s = '\\begin{bmatrix}'; + + this.items.forEach(function(node) { + if (node.items) { + s += node.items.map(function(childNode) { + return childNode.toTex(options); + }).join('&'); + } + else { + s += node.toTex(options); + } + + // new line + s += '\\\\'; + }); + s += '\\end{bmatrix}'; + return s; + }; + + return ArrayNode; + } + + exports.name = 'ArrayNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 278 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(32); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + var ArrayNode = load(__webpack_require__(277)); + var matrix = load(__webpack_require__(52)); + var assign = load(__webpack_require__(279)); + var access = load(__webpack_require__(274)); + + var keywords = __webpack_require__(273); + var operators = __webpack_require__(280); + + /** + * @constructor AssignmentNode + * @extends {Node} + * + * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or + * replace a subset of a matrix like `A[2,2]=42`. + * + * Syntax: + * + * new AssignmentNode(symbol, value) + * new AssignmentNode(object, index, value) + * + * Usage: + * + * new AssignmentNode(new SymbolNode('a'), new ConstantNode(2)); // a=2 + * new AssignmentNode(new SymbolNode('a'), new IndexNode('b'), new ConstantNode(2)) // a.b=2 + * new AssignmentNode(new SymbolNode('a'), new IndexNode(1, 2), new ConstantNode(3)) // a[1,2]=3 + * + * @param {SymbolNode | AccessorNode} object Object on which to assign a value + * @param {IndexNode} [index=null] Index, property name or matrix + * index. Optional. If not provided + * and `object` is a SymbolNode, + * the property is assigned to the + * global scope. + * @param {Node} value The value to be assigned + */ + function AssignmentNode(object, index, value) { + if (!(this instanceof AssignmentNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.object = object; + this.index = value ? index : null; + this.value = value ? value : index; + + // validate input + if (!object || !(object.isSymbolNode || object.isAccessorNode)) { + throw new TypeError('SymbolNode or AccessorNode expected as "object"'); + } + if (object && object.isSymbolNode && object.name === 'end') { + throw new Error('Cannot assign to symbol "end"'); + } + if (this.index && !this.index.isIndexNode) { + throw new TypeError('IndexNode expected as "index"'); + } + if (!this.value || !this.value.isNode) { + throw new TypeError('Node expected as "value"'); + } + + // readonly property name + Object.defineProperty(this, 'name', { + get: function () { + if (this.index) { + return (this.index.isObjectProperty()) + ? this.index.getObjectProperty() + : ''; + } + else { + return this.object.name || ''; + } + }.bind(this), + set: function () { + throw new Error('Cannot assign a new name, name is read-only'); + } + }); + } + + AssignmentNode.prototype = new Node(); + + AssignmentNode.prototype.type = 'AssignmentNode'; + + AssignmentNode.prototype.isAssignmentNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @private + */ + AssignmentNode.prototype._compile = function (defs, args) { + defs.assign = assign; + defs.access = access; + + var size; + var object = this.object._compile(defs, args); + var index = this.index ? this.index._compile(defs, args) : null; + var value = this.value._compile(defs, args); + + if (!this.index) { + // apply a variable to the scope, for example `a=2` + if (!this.object.isSymbolNode) { + throw new TypeError('SymbolNode expected as object'); + } + + return 'scope["' + this.object.name + '"] = ' + value; + } + else if (this.index.isObjectProperty()) { + // apply an object property for example `a.b=2` + return object + '["' + this.index.getObjectProperty() + '"] = ' + value; + } + else if (this.object.isSymbolNode) { + // update a matrix subset, for example `a[2]=3` + size = this.index.needsSize() ? 'var size = math.size(object).valueOf();' : ''; + + // apply updated object to scope + return '(function () {' + + ' var object = ' + object + ';' + + ' var value = ' + value + ';' + + ' ' + size + + ' scope["' + this.object.name + '"] = assign(object, ' + index + ', value);' + + ' return value;' + + '})()'; + } + else { // this.object.isAccessorNode === true + // update a matrix subset, for example `a.b[2]=3` + size = this.index.needsSize() ? 'var size = math.size(object).valueOf();' : ''; + + // we will not use the _compile of the AccessorNode, but compile it + // ourselves here as we need the parent object of the AccessorNode: + // wee need to apply the updated object to parent object + var parentObject = this.object.object._compile(defs, args); + + if (this.object.index.isObjectProperty()) { + var parentProperty = '["' + this.object.index.getObjectProperty() + '"]'; + return '(function () {' + + ' var parent = ' + parentObject + ';' + + ' var object = parent' + parentProperty + ';' + // parentIndex is a property + ' var value = ' + value + ';' + + size + + ' parent' + parentProperty + ' = assign(object, ' + index + ', value);' + + ' return value;' + + '})()'; + } + else { + // if some parameters use the 'end' parameter, we need to calculate the size + var parentSize = this.object.index.needsSize() ? 'var size = math.size(parent).valueOf();' : ''; + var parentIndex = this.object.index._compile(defs, args); + + return '(function () {' + + ' var parent = ' + parentObject + ';' + + ' ' + parentSize + + ' var parentIndex = ' + parentIndex + ';' + + ' var object = access(parent, parentIndex);' + + ' var value = ' + value + ';' + + ' ' + size + + ' assign(parent, parentIndex, assign(object, ' + index + ', value));' + + ' return value;' + + '})()'; + } + } + }; + + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + AssignmentNode.prototype.forEach = function (callback) { + callback(this.object, 'object', this); + if (this.index) { + callback(this.index, 'index', this); + } + callback(this.value, 'value', this); + }; + + /** + * Create a new AssignmentNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {AssignmentNode} Returns a transformed copy of the node + */ + AssignmentNode.prototype.map = function (callback) { + var object = this._ifNode(callback(this.object, 'object', this)); + var index = this.index + ? this._ifNode(callback(this.index, 'index', this)) + : null; + var value = this._ifNode(callback(this.value, 'value', this)); + + return new AssignmentNode(object, index, value); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {AssignmentNode} + */ + AssignmentNode.prototype.clone = function() { + return new AssignmentNode(this.object, this.index, this.value); + }; + + /* + * Is parenthesis needed? + * @param {node} node + * @param {string} [parenthesis='keep'] + * @private + */ + function needParenthesis(node, parenthesis) { + if (!parenthesis) { + parenthesis = 'keep'; + } + + var precedence = operators.getPrecedence(node, parenthesis); + var exprPrecedence = operators.getPrecedence(node.value, parenthesis); + return (parenthesis === 'all') + || ((exprPrecedence !== null) && (exprPrecedence <= precedence)); + } + + /** + * Get string representation + * @param {Object} options + * @return {string} + */ + AssignmentNode.prototype._toString = function(options) { + var object = this.object.toString(options); + var index = this.index ? this.index.toString(options) : ''; + var value = this.value.toString(options); + if (needParenthesis(this, options && options.parenthesis)) { + value = '(' + value + ')'; + } + + return object + index + ' = ' + value; + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} + */ + AssignmentNode.prototype._toTex = function(options) { + var object = this.object.toTex(options); + var index = this.index ? this.index.toTex(options) : ''; + var value = this.value.toTex(options); + if (needParenthesis(this, options && options.parenthesis)) { + value = '\\left(' + value + '\\right)'; + } + + return object + index + ':=' + value; + }; + + return AssignmentNode; + } + + exports.name = 'AssignmentNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 279 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(275).transform; + + function factory (type, config, load, typed) { + var subset = load(__webpack_require__(276)); + var matrix = load(__webpack_require__(52)); + + /** + * Replace part of an object: + * + * - Assign a property to an object + * - Replace a part of a string + * - Replace a matrix subset + * + * @param {Object | Array | Matrix | string} object + * @param {Index} index + * @param {*} value + * @return {Object | Array | Matrix | string} Returns the original object + * except in case of a string + */ + return function assign(object, index, value) { + try { + if (Array.isArray(object)) { + return matrix(object).subset(index, value).valueOf(); + } + else if (object && typeof object.subset === 'function') { // Matrix + return object.subset(index, value); + } + else if (typeof object === 'string') { + // TODO: move setStringSubset into a separate util file, use that + return subset(object, index, value); + } + else if (typeof object === 'object') { + if (!index.isObjectProperty()) { + throw TypeError('Cannot apply a numeric index as object property'); + } + object[index.getObjectProperty()] = value; + return object; + } + else { + throw new TypeError('Cannot apply index: unsupported type of object'); + } + } + catch (err) { + throw errorTransform(err); + } + } + } + + exports.factory = factory; + + +/***/ }, +/* 280 */ +/***/ function(module, exports) { + + 'use strict' + + //list of identifiers of nodes in order of their precedence + //also contains information about left/right associativity + //and which other operator the operator is associative with + //Example: + // addition is associative with addition and subtraction, because: + // (a+b)+c=a+(b+c) + // (a+b)-c=a+(b-c) + // + // postfix operators are left associative, prefix operators + // are right associative + // + //It's also possible to set the following properties: + // latexParens: if set to false, this node doesn't need to be enclosed + // in parentheses when using LaTeX + // latexLeftParens: if set to false, this !OperatorNode's! + // left argument doesn't need to be enclosed + // in parentheses + // latexRightParens: the same for the right argument + var properties = [ + { //assignment + 'AssignmentNode': {}, + 'FunctionAssignmentNode': {} + }, + { //conditional expression + 'ConditionalNode': { + latexLeftParens: false, + latexRightParens: false, + latexParens: false + //conditionals don't need parentheses in LaTeX because + //they are 2 dimensional + } + }, + { //logical or + 'OperatorNode:or': { + associativity: 'left', + associativeWith: [] + } + + }, + { //logical xor + 'OperatorNode:xor': { + associativity: 'left', + associativeWith: [] + } + }, + { //logical and + 'OperatorNode:and': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise or + 'OperatorNode:bitOr': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise xor + 'OperatorNode:bitXor': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise and + 'OperatorNode:bitAnd': { + associativity: 'left', + associativeWith: [] + } + }, + { //relational operators + 'OperatorNode:equal': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:unequal': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:smaller': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:larger': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:smallerEq': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:largerEq': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitshift operators + 'OperatorNode:leftShift': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:rightArithShift': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:rightLogShift': { + associativity: 'left', + associativeWith: [] + } + }, + { //unit conversion + 'OperatorNode:to': { + associativity: 'left', + associativeWith: [] + } + }, + { //range + 'RangeNode': {} + }, + { //addition, subtraction + 'OperatorNode:add': { + associativity: 'left', + associativeWith: ['OperatorNode:add', 'OperatorNode:subtract'] + }, + 'OperatorNode:subtract': { + associativity: 'left', + associativeWith: [] + } + }, + { //multiply, divide, modulus + 'OperatorNode:multiply': { + associativity: 'left', + associativeWith: [ + 'OperatorNode:multiply', + 'OperatorNode:divide', + 'Operator:dotMultiply', + 'Operator:dotDivide' + ] + }, + 'OperatorNode:divide': { + associativity: 'left', + associativeWith: [], + latexLeftParens: false, + latexRightParens: false, + latexParens: false + //fractions don't require parentheses because + //they're 2 dimensional, so parens aren't needed + //in LaTeX + }, + 'OperatorNode:dotMultiply': { + associativity: 'left', + associativeWith: [ + 'OperatorNode:multiply', + 'OperatorNode:divide', + 'OperatorNode:dotMultiply', + 'OperatorNode:doDivide' + ] + }, + 'OperatorNode:dotDivide': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:mod': { + associativity: 'left', + associativeWith: [] + } + }, + { //unary prefix operators + 'OperatorNode:unaryPlus': { + associativity: 'right' + }, + 'OperatorNode:unaryMinus': { + associativity: 'right' + }, + 'OperatorNode:bitNot': { + associativity: 'right' + }, + 'OperatorNode:not': { + associativity: 'right' + } + }, + { //exponentiation + 'OperatorNode:pow': { + associativity: 'right', + associativeWith: [], + latexRightParens: false + //the exponent doesn't need parentheses in + //LaTeX because it's 2 dimensional + //(it's on top) + }, + 'OperatorNode:dotPow': { + associativity: 'right', + associativeWith: [] + } + }, + { //factorial + 'OperatorNode:factorial': { + associativity: 'left' + } + }, + { //matrix transpose + 'OperatorNode:transpose': { + associativity: 'left' + } + } + ]; + + /** + * Get the precedence of a Node. + * Higher number for higher precedence, starting with 0. + * Returns null if the precedence is undefined. + * + * @param {Node} + * @param {string} parenthesis + * @return {number|null} + */ + function getPrecedence (_node, parenthesis) { + var node = _node; + if (parenthesis !== 'keep') { + //ParenthesisNodes are only ignored when not in 'keep' mode + node = _node.getContent(); + } + var identifier = node.getIdentifier(); + for (var i = 0; i < properties.length; i++) { + if (identifier in properties[i]) { + return i; + } + } + return null; + } + + /** + * Get the associativity of an operator (left or right). + * Returns a string containing 'left' or 'right' or null if + * the associativity is not defined. + * + * @param {Node} + * @param {string} parenthesis + * @return {string|null} + * @throws {Error} + */ + function getAssociativity (_node, parenthesis) { + var node = _node; + if (parenthesis !== 'keep') { + //ParenthesisNodes are only ignored when not in 'keep' mode + node = _node.getContent(); + } + var identifier = node.getIdentifier(); + var index = getPrecedence(node, parenthesis); + if (index === null) { + //node isn't in the list + return null; + } + var property = properties[index][identifier]; + + if (property.hasOwnProperty('associativity')) { + if (property.associativity === 'left') { + return 'left'; + } + if (property.associativity === 'right') { + return 'right'; + } + //associativity is invalid + throw Error('\'' + identifier + '\' has the invalid associativity \'' + + property.associativity + '\'.'); + } + + //associativity is undefined + return null; + } + + /** + * Check if an operator is associative with another operator. + * Returns either true or false or null if not defined. + * + * @param {Node} nodeA + * @param {Node} nodeB + * @param {string} parenthesis + * @return {bool|null} + */ + function isAssociativeWith (nodeA, nodeB, parenthesis) { + var a = nodeA; + var b = nodeB; + if (parenthesis !== 'keep') { + //ParenthesisNodes are only ignored when not in 'keep' mode + var a = nodeA.getContent(); + var b = nodeB.getContent(); + } + var identifierA = a.getIdentifier(); + var identifierB = b.getIdentifier(); + var index = getPrecedence(a, parenthesis); + if (index === null) { + //node isn't in the list + return null; + } + var property = properties[index][identifierA]; + + if (property.hasOwnProperty('associativeWith') + && (property.associativeWith instanceof Array)) { + for (var i = 0; i < property.associativeWith.length; i++) { + if (property.associativeWith[i] === identifierB) { + return true; + } + } + return false; + } + + //associativeWith is not defined + return null; + } + + module.exports.properties = properties; + module.exports.getPrecedence = getPrecedence; + module.exports.getAssociativity = getAssociativity; + module.exports.isAssociativeWith = isAssociativeWith; + + +/***/ }, +/* 281 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + var ResultSet = load(__webpack_require__(72)); + + /** + * @constructor BlockNode + * @extends {Node} + * Holds a set with blocks + * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks + * An array with blocks, where a block is constructed as an Object + * with properties block, which is a Node, and visible, which is + * a boolean. The property visible is optional and is true by default + */ + function BlockNode(blocks) { + if (!(this instanceof BlockNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input, copy blocks + if (!Array.isArray(blocks)) throw new Error('Array expected'); + this.blocks = blocks.map(function (block) { + var node = block && block.node; + var visible = block && block.visible !== undefined ? block.visible : true; + + if (!(node && node.isNode)) throw new TypeError('Property "node" must be a Node'); + if (typeof visible !== 'boolean') throw new TypeError('Property "visible" must be a boolean'); + + return { + node: node, + visible: visible + } + }); + } + + BlockNode.prototype = new Node(); + + BlockNode.prototype.type = 'BlockNode'; + + BlockNode.prototype.isBlockNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + BlockNode.prototype._compile = function (defs, args) { + defs.ResultSet = ResultSet; + var blocks = this.blocks.map(function (param) { + var js = param.node._compile(defs, args); + if (param.visible) { + return 'results.push(' + js + ');'; + } + else { + return js + ';'; + } + }); + + return '(function () {' + + 'var results = [];' + + blocks.join('') + + 'return new ResultSet(results);' + + '})()'; + }; + + /** + * Execute a callback for each of the child blocks of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + BlockNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.blocks.length; i++) { + callback(this.blocks[i].node, 'blocks[' + i + '].node', this); + } + }; + + /** + * Create a new BlockNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {BlockNode} Returns a transformed copy of the node + */ + BlockNode.prototype.map = function (callback) { + var blocks = []; + for (var i = 0; i < this.blocks.length; i++) { + var block = this.blocks[i]; + var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this)); + blocks[i] = { + node: node, + visible: block.visible + }; + } + return new BlockNode(blocks); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {BlockNode} + */ + BlockNode.prototype.clone = function () { + var blocks = this.blocks.map(function (block) { + return { + node: block.node, + visible: block.visible + }; + }); + + return new BlockNode(blocks); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + * @override + */ + BlockNode.prototype._toString = function (options) { + return this.blocks.map(function (param) { + return param.node.toString(options) + (param.visible ? '' : ';'); + }).join('\n'); + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + BlockNode.prototype._toTex = function (options) { + return this.blocks.map(function (param) { + return param.node.toTex(options) + (param.visible ? '' : ';'); + }).join('\\;\\;\n'); + }; + + return BlockNode; + } + + exports.name = 'BlockNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 282 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(32); + var operators = __webpack_require__(280); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr' + * + * @param {Node} condition Condition, must result in a boolean + * @param {Node} trueExpr Expression evaluated when condition is true + * @param {Node} falseExpr Expression evaluated when condition is true + * + * @constructor ConditionalNode + * @extends {Node} + */ + function ConditionalNode(condition, trueExpr, falseExpr) { + if (!(this instanceof ConditionalNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + if (!(condition && condition.isNode)) throw new TypeError('Parameter condition must be a Node'); + if (!(trueExpr && trueExpr.isNode)) throw new TypeError('Parameter trueExpr must be a Node'); + if (!(falseExpr && falseExpr.isNode)) throw new TypeError('Parameter falseExpr must be a Node'); + + this.condition = condition; + this.trueExpr = trueExpr; + this.falseExpr = falseExpr; + } + + ConditionalNode.prototype = new Node(); + + ConditionalNode.prototype.type = 'ConditionalNode'; + + ConditionalNode.prototype.isConditionalNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + ConditionalNode.prototype._compile = function (defs, args) { + /** + * Test whether a condition is met + * @param {*} condition + * @returns {boolean} true if condition is true or non-zero, else false + */ + defs.testCondition = function (condition) { + if (typeof condition === 'number' + || typeof condition === 'boolean' + || typeof condition === 'string') { + return condition ? true : false; + } + + if (condition) { + if (condition.isBigNumber === true) { + return condition.isZero() ? false : true; + } + + if (condition.isComplex === true) { + return (condition.re || condition.im) ? true : false; + } + + if (condition.isUnit === true) { + return condition.value ? true : false; + } + } + + if (condition === null || condition === undefined) { + return false; + } + + throw new TypeError('Unsupported type of condition "' + defs.math['typeof'](condition) + '"'); + }; + + return ( + 'testCondition(' + this.condition._compile(defs, args) + ') ? ' + + '( ' + this.trueExpr._compile(defs, args) + ') : ' + + '( ' + this.falseExpr._compile(defs, args) + ')' + ); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ConditionalNode.prototype.forEach = function (callback) { + callback(this.condition, 'condition', this); + callback(this.trueExpr, 'trueExpr', this); + callback(this.falseExpr, 'falseExpr', this); + }; + + /** + * Create a new ConditionalNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {ConditionalNode} Returns a transformed copy of the node + */ + ConditionalNode.prototype.map = function (callback) { + return new ConditionalNode( + this._ifNode(callback(this.condition, 'condition', this)), + this._ifNode(callback(this.trueExpr, 'trueExpr', this)), + this._ifNode(callback(this.falseExpr, 'falseExpr', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ConditionalNode} + */ + ConditionalNode.prototype.clone = function () { + return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + */ + ConditionalNode.prototype._toString = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var precedence = operators.getPrecedence(this, parenthesis); + + //Enclose Arguments in parentheses if they are an OperatorNode + //or have lower or equal precedence + //NOTE: enclosing all OperatorNodes in parentheses is a decision + //purely based on aesthetics and readability + var condition = this.condition.toString(options); + var conditionPrecedence = operators.getPrecedence(this.condition, parenthesis); + if ((parenthesis === 'all') + || (this.condition.type === 'OperatorNode') + || ((conditionPrecedence !== null) && (conditionPrecedence <= precedence))) { + condition = '(' + condition + ')'; + } + + var trueExpr = this.trueExpr.toString(options); + var truePrecedence = operators.getPrecedence(this.trueExpr, parenthesis); + if ((parenthesis === 'all') + || (this.trueExpr.type === 'OperatorNode') + || ((truePrecedence !== null) && (truePrecedence <= precedence))) { + trueExpr = '(' + trueExpr + ')'; + } + + var falseExpr = this.falseExpr.toString(options); + var falsePrecedence = operators.getPrecedence(this.falseExpr, parenthesis); + if ((parenthesis === 'all') + || (this.falseExpr.type === 'OperatorNode') + || ((falsePrecedence !== null) && (falsePrecedence <= precedence))) { + falseExpr = '(' + falseExpr + ')'; + } + return condition + ' ? ' + trueExpr + ' : ' + falseExpr; + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + ConditionalNode.prototype._toTex = function (options) { + return '\\begin{cases} {' + + this.trueExpr.toTex(options) + '}, &\\quad{\\text{if }\\;' + + this.condition.toTex(options) + + '}\\\\{' + this.falseExpr.toTex(options) + + '}, &\\quad{\\text{otherwise}}\\end{cases}'; + }; + + return ConditionalNode; + } + + exports.name = 'ConditionalNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 283 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var getType = __webpack_require__(41).type; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * A ConstantNode holds a constant value like a number or string. A ConstantNode + * stores a stringified version of the value and uses this to compile to + * JavaScript. + * + * In case of a stringified number as input, this may be compiled to a BigNumber + * when the math instance is configured for BigNumbers. + * + * Usage: + * + * // stringified values with type + * new ConstantNode('2.3', 'number'); + * new ConstantNode('true', 'boolean'); + * new ConstantNode('hello', 'string'); + * + * // non-stringified values, type will be automatically detected + * new ConstantNode(2.3); + * new ConstantNode('hello'); + * + * @param {string | number | boolean | null | undefined} value + * When valueType is provided, value must contain + * an uninterpreted string representing the value. + * When valueType is undefined, value can be a + * number, string, boolean, null, or undefined, and + * the type will be determined automatically. + * @param {string} [valueType] The type of value. Choose from 'number', 'string', + * 'boolean', 'undefined', 'null' + * @constructor ConstantNode + * @extends {Node} + */ + function ConstantNode(value, valueType) { + if (!(this instanceof ConstantNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (valueType) { + if (typeof valueType !== 'string') { + throw new TypeError('String expected for parameter "valueType"'); + } + if (typeof value !== 'string') { + throw new TypeError('String expected for parameter "value"'); + } + + this.value = value; + this.valueType = valueType; + } + else { + // stringify the value and determine the type + this.value = value + ''; + this.valueType = getType(value); + } + + if (!SUPPORTED_TYPES[this.valueType]) { + throw new TypeError('Unsupported type of value "' + this.valueType + '"'); + } + } + + var SUPPORTED_TYPES = { + 'number': true, + 'string': true, + 'boolean': true, + 'undefined': true, + 'null': true + }; + + ConstantNode.prototype = new Node(); + + ConstantNode.prototype.type = 'ConstantNode'; + + ConstantNode.prototype.isConstantNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + ConstantNode.prototype._compile = function (defs, args) { + switch (this.valueType) { + case 'number': + // TODO: replace this with using config.number + var numConfig = defs.math.config().number; + if (numConfig === 'BigNumber') { + return 'math.bignumber("' + this.value + '")'; + } + else if (numConfig === 'Fraction') { + return 'math.fraction("' + this.value + '")'; + } + else { + // remove leading zeros like '003.2' which are not allowed by JavaScript + return this.value.replace(/^(0*)[0-9]/, function (match, zeros) { + return match.substring(zeros.length); + }); + } + + case 'string': + return '"' + this.value + '"'; + + case 'boolean': + return this.value; + + case 'undefined': + return this.value; + + case 'null': + return this.value; + + default: + // TODO: move this error to the constructor? + throw new TypeError('Unsupported type of constant "' + this.valueType + '"'); + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ConstantNode.prototype.forEach = function (callback) { + // nothing to do, we don't have childs + }; + + + /** + * Create a new ConstantNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node) : Node} callback + * @returns {ConstantNode} Returns a clone of the node + */ + ConstantNode.prototype.map = function (callback) { + return this.clone(); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ConstantNode} + */ + ConstantNode.prototype.clone = function () { + return new ConstantNode(this.value, this.valueType); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + */ + ConstantNode.prototype._toString = function (options) { + switch (this.valueType) { + case 'string': + return '"' + this.value + '"'; + + default: + return this.value; + } + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + ConstantNode.prototype._toTex = function (options) { + var value = this.value, + index; + switch (this.valueType) { + case 'string': + return '\\mathtt{"' + value + '"}'; + + case 'number': + index = value.toLowerCase().indexOf('e'); + if (index !== -1) { + return value.substring(0, index) + '\\cdot10^{' + + value.substring(index + 1) + '}'; + } + return value; + + default: + return value; + } + }; + + return ConstantNode; + } + + exports.name = 'ConstantNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 284 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var keywords = __webpack_require__(273); + var latex = __webpack_require__(32); + var operators = __webpack_require__(280); + + function isString (x) { + return typeof x === 'string'; + } + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * @constructor FunctionAssignmentNode + * @extends {Node} + * Function assignment + * + * @param {string} name Function name + * @param {string[]} params Function parameter names + * @param {Node} expr The function expression + */ + function FunctionAssignmentNode(name, params, expr) { + if (!(this instanceof FunctionAssignmentNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); + if (!Array.isArray(params) || !params.every(isString)) throw new TypeError('Array containing strings expected for parameter "params"'); + if (!(expr && expr.isNode)) throw new TypeError('Node expected for parameter "expr"'); + if (name in keywords) throw new Error('Illegal function name, "' + name + '" is a reserved keyword'); + + this.name = name; + this.params = params; + this.expr = expr; + } + + FunctionAssignmentNode.prototype = new Node(); + + FunctionAssignmentNode.prototype.type = 'FunctionAssignmentNode'; + + FunctionAssignmentNode.prototype.isFunctionAssignmentNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + FunctionAssignmentNode.prototype._compile = function (defs, args) { + // we extend the original args and add the args to the child object + var childArgs = Object.create(args); + this.params.forEach(function (variable) { + childArgs[variable] = true; + }); + + // compile the function expression with the child args + var jsExpr = this.expr._compile(defs, childArgs); + + return 'scope["' + this.name + '"] = ' + + ' (function () {' + + ' var fn = function ' + this.name + '(' + this.params.join(',') + ') {' + + ' if (arguments.length != ' + this.params.length + ') {' + + // TODO: use util.error.ArgumentsError here? + // TODO: test arguments error + ' throw new SyntaxError("Wrong number of arguments in function ' + this.name + ' (" + arguments.length + " provided, ' + this.params.length + ' expected)");' + + ' }' + + ' return ' + jsExpr + '' + + ' };' + + ' fn.syntax = "' + this.name + '(' + this.params.join(', ') + ')";' + + ' return fn;' + + ' })()'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + FunctionAssignmentNode.prototype.forEach = function (callback) { + callback(this.expr, 'expr', this); + }; + + /** + * Create a new FunctionAssignmentNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {FunctionAssignmentNode} Returns a transformed copy of the node + */ + FunctionAssignmentNode.prototype.map = function (callback) { + var expr = this._ifNode(callback(this.expr, 'expr', this)); + + return new FunctionAssignmentNode(this.name, this.params.slice(0), expr); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {FunctionAssignmentNode} + */ + FunctionAssignmentNode.prototype.clone = function () { + return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr); + }; + + /** + * Is parenthesis needed? + * @param {Node} node + * @param {Object} parenthesis + * @private + */ + function needParenthesis(node, parenthesis) { + var precedence = operators.getPrecedence(node, parenthesis); + var exprPrecedence = operators.getPrecedence(node.expr, parenthesis); + + return (parenthesis === 'all') + || ((exprPrecedence !== null) && (exprPrecedence <= precedence)); + } + + /** + * get string representation + * @param {Object} options + * @return {string} str + */ + FunctionAssignmentNode.prototype._toString = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var expr = this.expr.toString(options); + if (needParenthesis(this, parenthesis)) { + expr = '(' + expr + ')'; + } + return 'function ' + this.name + + '(' + this.params.join(', ') + ') = ' + expr; + }; + + /** + * get LaTeX representation + * @param {Object} options + * @return {string} str + */ + FunctionAssignmentNode.prototype._toTex = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var expr = this.expr.toTex(options); + if (needParenthesis(this, parenthesis)) { + expr = '\\left(' + expr + '\\right)'; + } + + return '\\mathrm{' + this.name + + '}\\left(' + this.params.map(latex.toSymbol).join(',') + '\\right):=' + expr; + }; + + return FunctionAssignmentNode; + } + exports.name = 'FunctionAssignmentNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 285 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + var RangeNode = load(__webpack_require__(286)); + var SymbolNode = load(__webpack_require__(287)); + + var Range = load(__webpack_require__(67)); + + var isArray = Array.isArray; + + /** + * @constructor IndexNode + * @extends Node + * + * Describes a subset of a matrix or an object property. + * Cannot be used on its own, needs to be used within an AccessorNode or + * AssignmentNode. + * + * @param {Node[]} dimensions + * @param {boolean} [dotNotation=false] Optional property describing whether + * this index was written using dot + * notation like `a.b`, or using bracket + * notation like `a["b"]` (default). + * Used to stringify an IndexNode. + */ + function IndexNode(dimensions, dotNotation) { + if (!(this instanceof IndexNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.dimensions = dimensions; + this.dotNotation = dotNotation || false; + + // validate input + if (!isArray(dimensions) + || !dimensions.every(function (range) {return range && range.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "dimensions"'); + } + if (this.dotNotation && !this.isObjectProperty()) { + throw new Error('dotNotation only applicable for object properties'); + } + + // TODO: deprecated since v3, remove some day + var deprecated = function () { + throw new Error('Property `IndexNode.object` is deprecated, use `IndexNode.fn` instead'); + }; + Object.defineProperty(this, 'object', { get: deprecated, set: deprecated }); + } + + IndexNode.prototype = new Node(); + + IndexNode.prototype.type = 'IndexNode'; + + IndexNode.prototype.isIndexNode = true; + + /** + * Compile all range nodes + * + * When some of the dimensions has `end` defined, the IndexNode requires + * a variable `size` to be defined in the current closure, and must contain + * the size of the matrix that's being handled. To check whether the `size` + * variable is needed, call IndexNode.needsSize(). + * + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the + * compiled expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} code + */ + IndexNode.prototype._compile = function (defs, args) { + // args can be mutated by IndexNode, when dimensions use `end` + var childArgs = Object.create(args); + + // helper function to create a Range from start, step and end + defs.range = function (start, end, step) { + return new Range( + (start && start.isBigNumber === true) ? start.toNumber() : start, + (end && end.isBigNumber === true) ? end.toNumber() : end, + (step && step.isBigNumber === true) ? step.toNumber() : step + ); + }; + + // TODO: implement support for bignumber (currently bignumbers are silently + // reduced to numbers when changing the value to zero-based) + + // TODO: Optimization: when the range values are ConstantNodes, + // we can beforehand resolve the zero-based value + + // optimization for a simple object property + var dimensions = this.dimensions.map(function (range, i) { + if (range && range.isRangeNode) { + if (range.needsEnd()) { + childArgs.end = true; + + // resolve end and create range + return '(function () {' + + 'var end = size[' + i + ']; ' + + 'return range(' + + range.start._compile(defs, childArgs) + ', ' + + range.end._compile(defs, childArgs) + ', ' + + (range.step ? range.step._compile(defs, childArgs) : '1') + + '); ' + + '})()'; + } + else { + // create range + return 'range(' + + range.start._compile(defs, childArgs) + ', ' + + range.end._compile(defs, childArgs) + ', ' + + (range.step ? range.step._compile(defs, childArgs) : '1') + + ')'; + } + } + if (range.isSymbolNode && range.name === 'end') { + childArgs.end = true; + + // resolve the parameter 'end' + return '(function () {' + + 'var end = size[' + i + ']; ' + + 'return ' + range._compile(defs, childArgs) + '; ' + + '})()' + } + else { // ConstantNode + return range._compile(defs, childArgs); + } + }); + + return 'math.index(' + dimensions.join(', ') + ')'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + IndexNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.dimensions.length; i++) { + callback(this.dimensions[i], 'dimensions[' + i + ']', this); + } + }; + + /** + * Create a new IndexNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {IndexNode} Returns a transformed copy of the node + */ + IndexNode.prototype.map = function (callback) { + var dimensions = []; + for (var i = 0; i < this.dimensions.length; i++) { + dimensions[i] = this._ifNode(callback(this.dimensions[i], 'dimensions[' + i + ']', this)); + } + + return new IndexNode(dimensions); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {IndexNode} + */ + IndexNode.prototype.clone = function () { + return new IndexNode(this.dimensions.slice(0)); + }; + + /** + * Test whether this IndexNode contains a single property name + * @return {boolean} + */ + IndexNode.prototype.isObjectProperty = function () { + return this.dimensions.length === 1 && + this.dimensions[0].isConstantNode && + this.dimensions[0].valueType === 'string'; + }; + + /** + * Returns the property name if IndexNode contains a property. + * If not, returns null. + * @return {string | null} + */ + IndexNode.prototype.getObjectProperty = function () { + return this.isObjectProperty() ? this.dimensions[0].value : null; + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + */ + IndexNode.prototype._toString = function (options) { + // format the parameters like "[1, 0:5]" + return this.dotNotation + ? ('.' + this.getObjectProperty()) + : ('[' + this.dimensions.join(', ') + ']'); + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + IndexNode.prototype._toTex = function (options) { + var dimensions = this.dimensions.map(function (range) { + return range.toTex(options); + }); + + return this.dotNotation + ? ('.' + this.getObjectProperty() + '') + : ('_{' + dimensions.join(',') + '}'); + }; + + /** + * Test whether this IndexNode needs the object size, size of the Matrix + * @return {boolean} + */ + IndexNode.prototype.needsSize = function () { + return this.dimensions.some(function (range) { + return (range.isRangeNode && range.needsEnd()) || + (range.isSymbolNode && range.name === 'end'); + }); + }; + + return IndexNode; + } + + exports.name = 'IndexNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 286 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var operators = __webpack_require__(280); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * @constructor RangeNode + * @extends {Node} + * create a range + * @param {Node} start included lower-bound + * @param {Node} end included upper-bound + * @param {Node} [step] optional step + */ + function RangeNode(start, end, step) { + if (!(this instanceof RangeNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate inputs + if (!(start && start.isNode)) throw new TypeError('Node expected'); + if (!(end && end.isNode)) throw new TypeError('Node expected'); + if (step && !(step && step.isNode)) throw new TypeError('Node expected'); + if (arguments.length > 3) throw new Error('Too many arguments'); + + this.start = start; // included lower-bound + this.end = end; // included upper-bound + this.step = step || null; // optional step + } + + RangeNode.prototype = new Node(); + + RangeNode.prototype.type = 'RangeNode'; + + RangeNode.prototype.isRangeNode = true; + + /** + * Check whether the RangeNode needs the `end` symbol to be defined. + * This end is the size of the Matrix in current dimension. + * @return {boolean} + */ + RangeNode.prototype.needsEnd = function () { + // find all `end` symbols in this RangeNode + var endSymbols = this.filter(function (node) { + return (node && node.isSymbolNode) && (node.name == 'end'); + }); + + return endSymbols.length > 0; + }; + + /** + * Compile the node to javascript code + * + * When the range has a symbol `end` defined, the RangeNode requires + * a variable `end` to be defined in the current closure, which must contain + * the length of the of the matrix that's being handled in the range's + * dimension. To check whether the `end` variable is needed, call + * RangeNode.needsEnd(). + * + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + RangeNode.prototype._compile = function (defs, args) { + return 'math.range(' + + this.start._compile(defs, args) + ', ' + + this.end._compile(defs, args) + + (this.step ? (', ' + this.step._compile(defs, args)) : '') + + ')'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + RangeNode.prototype.forEach = function (callback) { + callback(this.start, 'start', this); + callback(this.end, 'end', this); + if (this.step) { + callback(this.step, 'step', this); + } + }; + + /** + * Create a new RangeNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {RangeNode} Returns a transformed copy of the node + */ + RangeNode.prototype.map = function (callback) { + return new RangeNode( + this._ifNode(callback(this.start, 'start', this)), + this._ifNode(callback(this.end, 'end', this)), + this.step && this._ifNode(callback(this.step, 'step', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {RangeNode} + */ + RangeNode.prototype.clone = function () { + return new RangeNode(this.start, this.end, this.step && this.step); + }; + + /** + * Calculate the necessary parentheses + * @param {Node} node + * @param {string} parenthesis + * @return {Object} parentheses + * @private + */ + function calculateNecessaryParentheses(node, parenthesis) { + var precedence = operators.getPrecedence(node, parenthesis); + var parens = {}; + + var startPrecedence = operators.getPrecedence(node.start, parenthesis); + parens.start = ((startPrecedence !== null) && (startPrecedence <= precedence)) + || (parenthesis === 'all'); + + if (node.step) { + var stepPrecedence = operators.getPrecedence(node.step, parenthesis); + parens.step = ((stepPrecedence !== null) && (stepPrecedence <= precedence)) + || (parenthesis === 'all'); + } + + var endPrecedence = operators.getPrecedence(node.end, parenthesis); + parens.end = ((endPrecedence !== null) && (endPrecedence <= precedence)) + || (parenthesis === 'all'); + + return parens; + } + + /** + * Get string representation + * @param {Object} options + * @return {string} str + */ + RangeNode.prototype._toString = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var parens = calculateNecessaryParentheses(this, parenthesis); + + //format string as start:step:stop + var str; + + var start = this.start.toString(options); + if (parens.start) { + start = '(' + start + ')'; + } + str = start; + + if (this.step) { + var step = this.step.toString(options); + if (parens.step) { + step = '(' + step + ')'; + } + str += ':' + step; + } + + var end = this.end.toString(options); + if (parens.end) { + end = '(' + end + ')'; + } + str += ':' + end; + + return str; + }; + + /** + * Get LaTeX representation + * @params {Object} options + * @return {string} str + */ + RangeNode.prototype._toTex = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var parens = calculateNecessaryParentheses(this, parenthesis); + + var str = this.start.toTex(options); + if (parens.start) { + str = '\\left(' + str + '\\right)'; + } + + if (this.step) { + var step = this.step.toTex(options); + if (parens.step) { + step = '\\left(' + step + '\\right)'; + } + str += ':' + step; + } + + var end = this.end.toTex(options); + if (parens.end) { + end = '\\left(' + end + '\\right)'; + } + str += ':' + end; + + return str; + }; + + return RangeNode; + } + + exports.name = 'RangeNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 287 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(32); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(272)); + + var Unit = load(__webpack_require__(75)); + + /** + * @constructor SymbolNode + * @extends {Node} + * A symbol node can hold and resolve a symbol + * @param {string} name + * @extends {Node} + */ + function SymbolNode(name) { + if (!(this instanceof SymbolNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); + + this.name = name; + } + + SymbolNode.prototype = new Node(); + + SymbolNode.prototype.type = 'SymbolNode'; + + SymbolNode.prototype.isSymbolNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + SymbolNode.prototype._compile = function (defs, args) { + // add a function to the definitions + defs['undef'] = undef; + defs['Unit'] = Unit; + + if (args[this.name]) { + // this is a FunctionAssignment argument + // (like an x when inside the expression of a function assignment `f(x) = ...`) + return this.name; + } + else if (this.name in defs.math) { + return '("' + this.name + '" in scope ? scope["' + this.name + '"] : math["' + this.name + '"])'; + } + else { + return '(' + + '"' + this.name + '" in scope ? scope["' + this.name + '"] : ' + + (Unit.isValuelessUnit(this.name) ? + 'new Unit(null, "' + this.name + '")' : + 'undef("' + this.name + '")') + + ')'; + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + SymbolNode.prototype.forEach = function (callback) { + // nothing to do, we don't have childs + }; + + /** + * Create a new SymbolNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node) : Node} callback + * @returns {SymbolNode} Returns a clone of the node + */ + SymbolNode.prototype.map = function (callback) { + return this.clone(); + }; + + /** + * Throws an error 'Undefined symbol {name}' + * @param {string} name + */ + function undef (name) { + throw new Error('Undefined symbol ' + name); + } + + /** + * Create a clone of this node, a shallow copy + * @return {SymbolNode} + */ + SymbolNode.prototype.clone = function() { + return new SymbolNode(this.name); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + * @override + */ + SymbolNode.prototype._toString = function(options) { + return this.name; + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + * @override + */ + SymbolNode.prototype._toTex = function(options) { + var isUnit = false; + if ((typeof math[this.name] === 'undefined') && Unit.isValuelessUnit(this.name)) { + isUnit = true; + } + var symbol = latex.toSymbol(this.name, isUnit); + if (symbol[0] === '\\') { + //no space needed if the symbol starts with '\' + return symbol; + } + //the space prevents symbols from breaking stuff like '\cdot' if it's written right before the symbol + return ' ' + symbol; + }; + + return SymbolNode; + } + + exports.name = 'SymbolNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 288 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var string = __webpack_require__(23); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * @constructor ObjectNode + * @extends {Node} + * Holds an object with keys/values + * @param {Object.} [properties] array with key/value pairs + */ + function ObjectNode(properties) { + if (!(this instanceof ObjectNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.properties = properties || {}; + + // validate input + if (properties) { + if (!(typeof properties === 'object') || Object.keys(properties).some(function (key) { + return !properties[key] || !properties[key].isNode; + })) { + throw new TypeError('Object containing Nodes expected'); + } + } + } + + ObjectNode.prototype = new Node(); + + ObjectNode.prototype.type = 'ObjectNode'; + + ObjectNode.prototype.isObjectNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} code + * @private + */ + ObjectNode.prototype._compile = function (defs, args) { + var entries = []; + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + entries.push('"' + key + '": ' + this.properties[key]._compile(defs, args)); + } + } + return '{' + entries.join(', ') + '}'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ObjectNode.prototype.forEach = function (callback) { + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + callback(this.properties[key], 'properties["' + key + '"]', this); + } + } + }; + + /** + * Create a new ObjectNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {ObjectNode} Returns a transformed copy of the node + */ + ObjectNode.prototype.map = function (callback) { + var properties = {}; + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + properties[key] = this._ifNode(callback(this.properties[key], 'properties["' + key + '"]', this)); + } + } + return new ObjectNode(properties); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ObjectNode} + */ + ObjectNode.prototype.clone = function() { + var properties = {}; + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + properties[key] = this.properties[key]; + } + } + return new ObjectNode(properties); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + * @override + */ + ObjectNode.prototype._toString = function(options) { + var entries = []; + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + entries.push('"' + key + '": ' + this.properties[key].toString(options)); + } + } + return '{' + entries.join(', ') + '}'; + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + ObjectNode.prototype._toTex = function(options) { + var entries = []; + for (var key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + entries.push("\\mathbf{" + key + ':} & ' + this.properties[key].toTex(options) + "\\\\"); + } + } + return '\\left\\{\\begin{array}{ll}' + entries.join('\n') + '\\end{array}\\right\\}'; + }; + + return ObjectNode; + } + + exports.name = 'ObjectNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 289 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(32); + var operators = __webpack_require__(280); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(272)); + var ConstantNode = load(__webpack_require__(283)); + var SymbolNode = load(__webpack_require__(287)); + var FunctionNode = load(__webpack_require__(290)); + + /** + * @constructor OperatorNode + * @extends {Node} + * An operator with two arguments, like 2+3 + * + * @param {string} op Operator name, for example '+' + * @param {string} fn Function name, for example 'add' + * @param {Node[]} args Operator arguments + * @param {boolean} [implicit] Is this an implicit multiplication? + */ + function OperatorNode(op, fn, args, implicit) { + if (!(this instanceof OperatorNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + //validate input + if (typeof op !== 'string') { + throw new TypeError('string expected for parameter "op"'); + } + if (typeof fn !== 'string') { + throw new TypeError('string expected for parameter "fn"'); + } + if (!Array.isArray(args) + || !args.every(function (node) {return node && node.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "args"'); + } + + this.implicit = (implicit === true); + this.op = op; + this.fn = fn; + this.args = args || []; + } + + OperatorNode.prototype = new Node(); + + OperatorNode.prototype.type = 'OperatorNode'; + + OperatorNode.prototype.isOperatorNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + OperatorNode.prototype._compile = function (defs, args) { + if (!defs.math[this.fn]) { + throw new Error('Function ' + this.fn + ' missing in provided namespace "math"'); + } + + var jsArgs = this.args.map(function (arg) { + return arg._compile(defs, args); + }); + + return 'math.' + this.fn + '(' + jsArgs.join(', ') + ')'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + OperatorNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.args.length; i++) { + callback(this.args[i], 'args[' + i + ']', this); + } + }; + + /** + * Create a new OperatorNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {OperatorNode} Returns a transformed copy of the node + */ + OperatorNode.prototype.map = function (callback) { + var args = []; + for (var i = 0; i < this.args.length; i++) { + args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); + } + return new OperatorNode(this.op, this.fn, args); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {OperatorNode} + */ + OperatorNode.prototype.clone = function () { + return new OperatorNode(this.op, this.fn, this.args.slice(0)); + }; + + /** + * Calculate which parentheses are necessary. Gets an OperatorNode + * (which is the root of the tree) and an Array of Nodes + * (this.args) and returns an array where 'true' means that an argument + * has to be enclosed in parentheses whereas 'false' means the opposite. + * + * @param {OperatorNode} root + * @param {string} parenthesis + * @param {Node[]} args + * @param {boolean} latex + * @return {boolean[]} + * @private + */ + function calculateNecessaryParentheses(root, parenthesis, args, latex) { + //precedence of the root OperatorNode + var precedence = operators.getPrecedence(root, parenthesis); + var associativity = operators.getAssociativity(root, parenthesis); + + if ((parenthesis === 'all') || (args.length > 2)) { + var parens = []; + args.forEach(function (arg) { + switch (arg.getContent().type) { //Nodes that don't need extra parentheses + case 'ArrayNode': + case 'ConstantNode': + case 'SymbolNode': + case 'ParenthesisNode': + parens.push(false); + break; + default: + parens.push(true); + } + }); + return parens; + } + + switch (args.length) { + case 0: + return []; + case 1: //unary operators + //precedence of the operand + var operandPrecedence = operators.getPrecedence(args[0], parenthesis); + + //handle special cases for LaTeX, where some of the parentheses aren't needed + if (latex && (operandPrecedence !== null)) { + var operandIdentifier; + var rootIdentifier; + if (parenthesis === 'keep') { + operandIdentifier = args[0].getIdentifier(); + rootIdentifier = root.getIdentifier(); + } + else { + //Ignore Parenthesis Nodes when not in 'keep' mode + operandIdentifier = args[0].getContent().getIdentifier(); + rootIdentifier = root.getContent().getIdentifier(); + } + if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { + return [false]; + } + + if (operators.properties[operandPrecedence][operandIdentifier].latexParens === false) { + return [false]; + } + } + + if (operandPrecedence === null) { + //if the operand has no defined precedence, no parens are needed + return [false]; + } + + if (operandPrecedence <= precedence) { + //if the operands precedence is lower, parens are needed + return [true]; + } + + //otherwise, no parens needed + return [false]; + + case 2: //binary operators + var lhsParens; //left hand side needs parenthesis? + //precedence of the left hand side + var lhsPrecedence = operators.getPrecedence(args[0], parenthesis); + //is the root node associative with the left hand side + var assocWithLhs = operators.isAssociativeWith(root, args[0], parenthesis); + + if (lhsPrecedence === null) { + //if the left hand side has no defined precedence, no parens are needed + //FunctionNode for example + lhsParens = false; + } + else if ((lhsPrecedence === precedence) && (associativity === 'right') && !assocWithLhs) { + //In case of equal precedence, if the root node is left associative + // parens are **never** necessary for the left hand side. + //If it is right associative however, parens are necessary + //if the root node isn't associative with the left hand side + lhsParens = true; + } + else if (lhsPrecedence < precedence) { + lhsParens = true; + } + else { + lhsParens = false; + } + + var rhsParens; //right hand side needs parenthesis? + //precedence of the right hand side + var rhsPrecedence = operators.getPrecedence(args[1], parenthesis); + //is the root node associative with the right hand side? + var assocWithRhs = operators.isAssociativeWith(root, args[1], parenthesis); + + if (rhsPrecedence === null) { + //if the right hand side has no defined precedence, no parens are needed + //FunctionNode for example + rhsParens = false; + } + else if ((rhsPrecedence === precedence) && (associativity === 'left') && !assocWithRhs) { + //In case of equal precedence, if the root node is right associative + // parens are **never** necessary for the right hand side. + //If it is left associative however, parens are necessary + //if the root node isn't associative with the right hand side + rhsParens = true; + } + else if (rhsPrecedence < precedence) { + rhsParens = true; + } + else { + rhsParens = false; + } + + //handle special cases for LaTeX, where some of the parentheses aren't needed + if (latex) { + var rootIdentifier; + var lhsIdentifier; + var rhsIdentifier; + if (parenthesis === 'keep') { + rootIdentifier = root.getIdentifier(); + lhsIdentifier = root.args[0].getIdentifier(); + rhsIdentifier = root.args[1].getIdentifier(); + } + else { + //Ignore ParenthesisNodes when not in 'keep' mode + rootIdentifier = root.getContent().getIdentifier(); + lhsIdentifier = root.args[0].getContent().getIdentifier(); + rhsIdentifier = root.args[1].getContent().getIdentifier(); + } + + if (lhsPrecedence !== null) { + if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { + lhsParens = false; + } + + if (operators.properties[lhsPrecedence][lhsIdentifier].latexParens === false) { + lhsParens = false; + } + } + + if (rhsPrecedence !== null) { + if (operators.properties[precedence][rootIdentifier].latexRightParens === false) { + rhsParens = false; + } + + if (operators.properties[rhsPrecedence][rhsIdentifier].latexParens === false) { + rhsParens = false; + } + } + } + + return [lhsParens, rhsParens]; + } + } + + /** + * Get string representation. + * @param {Object} options + * @return {string} str + */ + OperatorNode.prototype._toString = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var implicit = (options && options.implicit) ? options.implicit : 'hide'; + var args = this.args; + var parens = calculateNecessaryParentheses(this, parenthesis, args, false); + + switch (args.length) { + case 1: //unary operators + var assoc = operators.getAssociativity(this, parenthesis); + + var operand = args[0].toString(options); + if (parens[0]) { + operand = '(' + operand + ')'; + } + + if (assoc === 'right') { //prefix operator + return this.op + operand; + } + else if (assoc === 'left') { //postfix + return operand + this.op; + } + + //fall back to postfix + return operand + this.op; + + case 2: + var lhs = args[0].toString(options); //left hand side + var rhs = args[1].toString(options); //right hand side + if (parens[0]) { //left hand side in parenthesis? + lhs = '(' + lhs + ')'; + } + if (parens[1]) { //right hand side in parenthesis? + rhs = '(' + rhs + ')'; + } + + if (this.implicit && (this.getIdentifier() === 'OperatorNode:multiply') && (implicit == 'hide')) { + return lhs + ' ' + rhs; + } + + return lhs + ' ' + this.op + ' ' + rhs; + + default: + //fallback to formatting as a function call + return this.fn + '(' + this.args.join(', ') + ')'; + } + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + OperatorNode.prototype._toTex = function (options) { + var parenthesis = (options && options.parenthesis) ? options.parenthesis : 'keep'; + var implicit = (options && options.implicit) ? options.implicit : 'hide'; + var args = this.args; + var parens = calculateNecessaryParentheses(this, parenthesis, args, true); + var op = latex.operators[this.fn]; + op = typeof op === 'undefined' ? this.op : op; //fall back to using this.op + + switch (args.length) { + case 1: //unary operators + var assoc = operators.getAssociativity(this, parenthesis); + + var operand = args[0].toTex(options); + if (parens[0]) { + operand = '\\left(' + operand + '\\right)'; + } + + if (assoc === 'right') { //prefix operator + return op + operand; + } + else if (assoc === 'left') { //postfix operator + return operand + op; + } + + //fall back to postfix + return operand + op; + + case 2: //binary operators + var lhs = args[0]; //left hand side + var lhsTex = lhs.toTex(options); + if (parens[0]) { + lhsTex = '\\left(' + lhsTex + '\\right)'; + } + + var rhs = args[1]; //right hand side + var rhsTex = rhs.toTex(options); + if (parens[1]) { + rhsTex = '\\left(' + rhsTex + '\\right)'; + } + + //handle some exceptions (due to the way LaTeX works) + var lhsIdentifier; + if (parenthesis === 'keep') { + lhsIdentifier = lhs.getIdentifier(); + } + else { + //Ignore ParenthesisNodes if in 'keep' mode + lhsIdentifier = lhs.getContent().getIdentifier(); + } + switch (this.getIdentifier()) { + case 'OperatorNode:divide': + //op contains '\\frac' at this point + return op + '{' + lhsTex + '}' + '{' + rhsTex + '}'; + case 'OperatorNode:pow': + lhsTex = '{' + lhsTex + '}'; + rhsTex = '{' + rhsTex + '}'; + switch (lhsIdentifier) { + case 'ConditionalNode': // + case 'OperatorNode:divide': + lhsTex = '\\left(' + lhsTex + '\\right)'; + } + case 'OperatorNode:multiply': + if (this.implicit && (implicit === 'hide')) { + return lhsTex + '~' + rhsTex; + } + } + return lhsTex + op + rhsTex; + + default: + //fall back to formatting as a function call + //as this is a fallback, it doesn't use + //fancy function names + return '\\mathrm{' + this.fn + '}\\left(' + + args.map(function (arg) { + return arg.toTex(options); + }).join(',') + '\\right)'; + } + }; + + /** + * Get identifier. + * @return {string} + */ + OperatorNode.prototype.getIdentifier = function () { + return this.type + ':' + this.fn; + }; + + return OperatorNode; + } + + exports.name = 'OperatorNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 290 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(32); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(272)); + var SymbolNode = load(__webpack_require__(287)); + + /** + * @constructor FunctionNode + * @extends {./Node} + * invoke a list with arguments on a node + * @param {./Node} fn Node resolving with a function on which to invoke + * the arguments, typically a SymboNode or AccessorNode + * @param {./Node[]} args + */ + function FunctionNode(fn, args) { + if (!(this instanceof FunctionNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // TODO deprecated since v3.0, cleanup some day + if (typeof fn === 'string') { + console.warn('WARNING: passing a string to FunctionNode is deprecated, pass a SymbolNode instead.'); + fn = new SymbolNode(fn); + } + + // validate input + if (!fn || !fn.isNode) throw new TypeError('Node expected as parameter "fn"'); + if (!Array.isArray(args) + || !args.every(function (arg) {return arg && arg.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "args"'); + } + + this.fn = fn; + this.args = args || []; + + // readonly property name + Object.defineProperty(this, 'name', { + get: function () { + return this.fn.name || ''; + }.bind(this), + set: function () { + throw new Error('Cannot assign a new name, name is read-only'); + } + }); + + // TODO: deprecated since v3, remove some day + var deprecated = function () { + throw new Error('Property `FunctionNode.object` is deprecated, use `FunctionNode.fn` instead'); + }; + Object.defineProperty(this, 'object', { get: deprecated, set: deprecated }); + } + + FunctionNode.prototype = new Node(); + + FunctionNode.prototype.type = 'FunctionNode'; + + FunctionNode.prototype.isFunctionNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + FunctionNode.prototype._compile = function (defs, args) { + // compile fn and arguments + var jsFn = this.fn._compile(defs, args); + var jsArgs = this.args.map(function (arg) { + return arg._compile(defs, args); + }); + var argsName; + + if (this.fn.isSymbolNode) { + // we can statically determine whether the function has an rawArgs property + var name = this.fn.name; + var fn = defs.math[name]; + var isRaw = (typeof fn === 'function') && (fn.rawArgs == true); + + if (isRaw) { + // pass unevaluated parameters (nodes) to the function + argsName = this._getUniqueArgumentsName(defs); + defs[argsName] = this.args; + + return jsFn + '(' + argsName + ', math, scope)'; + } + else { + // "regular" evaluation + return jsFn + '(' + jsArgs.join(', ') + ')'; + } + } + else if (this.fn.isAccessorNode && this.fn.index.isObjectProperty()) { + // execute the function with the right context: the object of the AccessorNode + argsName = this._getUniqueArgumentsName(defs); + defs[argsName] = this.args; + + var jsObject = this.fn.object._compile(defs, args); + var prop = this.fn.index.getObjectProperty(); + + return '(function () {' + + 'var object = ' + jsObject + ';' + + 'return (object["' + prop + '"] && object["' + prop + '"].rawArgs) ' + + ' ? object["' + prop + '"](' + argsName + ', math, scope)' + + ' : object["' + prop + '"](' + jsArgs.join(', ') + ')' + + '})()'; + } + else { // this.fn.isAccessorNode && !this.fn.index.isObjectProperty() + // we have to dynamically determine whether the function has a rawArgs property + argsName = this._getUniqueArgumentsName(defs); + defs[argsName] = this.args; + + return '(function () {' + + 'var fn = ' + jsFn + ';' + + 'return (fn && fn.rawArgs) ' + + ' ? fn(' + argsName + ', math, scope)' + + ' : fn(' + jsArgs.join(', ') + ')' + + '})()'; + } + }; + + /** + * Get a unique name for a arguments to store in defs + * @param {Object} defs + * @return {string} A string like 'args1', 'args2', ... + * @private + */ + FunctionNode.prototype._getUniqueArgumentsName = function (defs) { + var argsName; + var i = 0; + + do { + argsName = 'args' + i; + i++; + } + while (argsName in defs); + + return argsName; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + FunctionNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.args.length; i++) { + callback(this.args[i], 'args[' + i + ']', this); + } + }; + + /** + * Create a new FunctionNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {FunctionNode} Returns a transformed copy of the node + */ + FunctionNode.prototype.map = function (callback) { + var fn = this.fn.map(callback); + var args = []; + for (var i = 0; i < this.args.length; i++) { + args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); + } + return new FunctionNode(fn, args); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {FunctionNode} + */ + FunctionNode.prototype.clone = function () { + return new FunctionNode(this.fn, this.args.slice(0)); + }; + + //backup Node's toString function + //@private + var nodeToString = FunctionNode.prototype.toString; + + /** + * Get string representation. (wrapper function) + * This overrides parts of Node's toString function. + * If callback is an object containing callbacks, it + * calls the correct callback for the current node, + * otherwise it falls back to calling Node's toString + * function. + * + * @param {Object} options + * @return {string} str + * @override + */ + FunctionNode.prototype.toString = function (options) { + var customString; + var name = this.fn.toString(options); + if (options && (typeof options.handler === 'object') && options.handler.hasOwnProperty(name)) { + //callback is a map of callback functions + customString = options.handler[name](this, options); + } + + if (typeof customString !== 'undefined') { + return customString; + } + + //fall back to Node's toString + return nodeToString.call(this, options); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + */ + FunctionNode.prototype._toString = function (options) { + var args = this.args.map(function (arg) { + return arg.toString(options); + }); + + // format the arguments like "add(2, 4.2)" + return this.fn.toString(options) + '(' + args.join(', ') + ')'; + }; + + /* + * Expand a LaTeX template + * + * @param {string} template + * @param {Node} node + * @param {Object} options + * @private + **/ + function expandTemplate(template, node, options) { + var latex = ''; + + // Match everything of the form ${identifier} or ${identifier[2]} or $$ + // while submatching identifier and 2 (in the second case) + var regex = new RegExp('\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)', 'ig'); + + var inputPos = 0; //position in the input string + var match; + while ((match = regex.exec(template)) !== null) { //go through all matches + // add everything in front of the match to the LaTeX string + latex += template.substring(inputPos, match.index); + inputPos = match.index; + + if (match[0] === '$$') { // escaped dollar sign + latex += '$'; + inputPos++; + } + else { // template parameter + inputPos += match[0].length; + var property = node[match[1]]; + if (!property) { + throw new ReferenceError('Template: Property ' + match[1] + ' does not exist.'); + } + if (match[2] === undefined) { //no square brackets + switch (typeof property) { + case 'string': + latex += property; + break; + case 'object': + if (property.isNode) { + latex += property.toTex(options); + } + else if (Array.isArray(property)) { + //make array of Nodes into comma separated list + latex += property.map(function (arg, index) { + if (arg && arg.isNode) { + return arg.toTex(options); + } + throw new TypeError('Template: ' + match[1] + '[' + index + '] is not a Node.'); + }).join(','); + } + else { + throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes'); + } + break; + default: + throw new TypeError('Template: ' + match[1] + ' has to be a Node, String or array of Nodes'); + } + } + else { //with square brackets + if (property[match[2]] && property[match[2]].isNode) { + latex += property[match[2]].toTex(options); + } + else { + throw new TypeError('Template: ' + match[1] + '[' + match[2] + '] is not a Node.'); + } + } + } + } + latex += template.slice(inputPos); //append rest of the template + + return latex; + } + + //backup Node's toTex function + //@private + var nodeToTex = FunctionNode.prototype.toTex; + + /** + * Get LaTeX representation. (wrapper function) + * This overrides parts of Node's toTex function. + * If callback is an object containing callbacks, it + * calls the correct callback for the current node, + * otherwise it falls back to calling Node's toTex + * function. + * + * @param {Object} options + * @return {string} + */ + FunctionNode.prototype.toTex = function (options) { + var customTex; + if (options && (typeof options.handler === 'object') && options.handler.hasOwnProperty(this.name)) { + //callback is a map of callback functions + customTex = options.handler[this.name](this, options); + } + + if (typeof customTex !== 'undefined') { + return customTex; + } + + //fall back to Node's toTex + return nodeToTex.call(this, options); + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + */ + FunctionNode.prototype._toTex = function (options) { + var args = this.args.map(function (arg) { //get LaTeX of the arguments + return arg.toTex(options); + }); + + var latexConverter; + + if (math[this.name] && ((typeof math[this.name].toTex === 'function') || (typeof math[this.name].toTex === 'object') || (typeof math[this.name].toTex === 'string'))) { + //.toTex is a callback function + latexConverter = math[this.name].toTex; + } + + var customToTex; + switch (typeof latexConverter) { + case 'function': //a callback function + customToTex = latexConverter(this, options); + break; + case 'string': //a template string + customToTex = expandTemplate(latexConverter, this, options); + break; + case 'object': //an object with different "converters" for different numbers of arguments + switch (typeof latexConverter[args.length]) { + case 'function': + customToTex = latexConverter[args.length](this, options); + break; + case 'string': + customToTex = expandTemplate(latexConverter[args.length], this, options); + break; + } + } + + if (typeof customToTex !== 'undefined') { + return customToTex; + } + + return expandTemplate(latex.defaultTemplate, this, options); + }; + + /** + * Get identifier. + * @return {string} + */ + FunctionNode.prototype.getIdentifier = function () { + return this.type + ':' + this.name; + }; + + return FunctionNode; + } + + exports.name = 'FunctionNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 291 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(272)); + + /** + * @constructor ParenthesisNode + * @extends {Node} + * A parenthesis node describes manual parenthesis from the user input + * @param {Node} content + * @extends {Node} + */ + function ParenthesisNode(content) { + if (!(this instanceof ParenthesisNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (!(content && content.isNode)) { + throw new TypeError('Node expected for parameter "content"'); + } + + this.content = content; + } + + ParenthesisNode.prototype = new Node(); + + ParenthesisNode.prototype.type = 'ParenthesisNode'; + + ParenthesisNode.prototype.isParenthesisNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @param {Object} args Object with local function arguments, the key is + * the name of the argument, and the value is `true`. + * The object may not be mutated, but must be + * extended instead. + * @return {string} js + * @private + */ + ParenthesisNode.prototype._compile = function (defs, args) { + return this.content._compile(defs, args); + }; + + /** + * Get the content of the current Node. + * @return {Node} content + * @override + **/ + ParenthesisNode.prototype.getContent = function () { + return this.content.getContent(); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ParenthesisNode.prototype.forEach = function (callback) { + callback(this.content, 'content', this); + }; + + /** + * Create a new ParenthesisNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node) : Node} callback + * @returns {ParenthesisNode} Returns a clone of the node + */ + ParenthesisNode.prototype.map = function (callback) { + var content = callback(this.content, 'content', this); + return new ParenthesisNode(content); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ParenthesisNode} + */ + ParenthesisNode.prototype.clone = function() { + return new ParenthesisNode(this.content); + }; + + /** + * Get string representation + * @param {Object} options + * @return {string} str + * @override + */ + ParenthesisNode.prototype._toString = function(options) { + if ((!options) || (options && !options.parenthesis) || (options && options.parenthesis === 'keep')) { + return '(' + this.content.toString(options) + ')'; + } + return this.content.toString(options); + }; + + /** + * Get LaTeX representation + * @param {Object} options + * @return {string} str + * @override + */ + ParenthesisNode.prototype._toTex = function(options) { + if ((!options) || (options && !options.parenthesis) || (options && options.parenthesis === 'keep')) { + return '\\left(' + this.content.toTex(options) + '\\right)'; + } + return this.content.toTex(options); + }; + + return ParenthesisNode; + } + + exports.name = 'ParenthesisNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 292 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var parse = load(__webpack_require__(270)); + + /** + * Evaluate an expression. + * + * Syntax: + * + * math.eval(expr) + * math.eval(expr, scope) + * math.eval([expr1, expr2, expr3, ...]) + * math.eval([expr1, expr2, expr3, ...], scope) + * + * Example: + * + * math.eval('(2+3)/4'); // 1.25 + * math.eval('sqrt(3^2 + 4^2)'); // 5 + * math.eval('sqrt(-4)'); // 2i + * math.eval(['a=3', 'b=4', 'a*b']);, // [3, 4, 12] + * + * var scope = {a:3, b:4}; + * math.eval('a * b', scope); // 12 + * + * See also: + * + * parse, compile + * + * @param {string | string[] | Matrix} expr The expression to be evaluated + * @param {Object} [scope] Scope to read/write variables + * @return {*} The result of the expression + * @throws {Error} + */ + return typed('compile', { + 'string': function (expr) { + var scope = {}; + return parse(expr).compile().eval(scope); + }, + + 'string, Object': function (expr, scope) { + return parse(expr).compile().eval(scope); + }, + + 'Array | Matrix': function (expr) { + var scope = {}; + return deepMap(expr, function (entry) { + return parse(entry).compile().eval(scope); + }); + }, + + 'Array | Matrix, Object': function (expr, scope) { + return deepMap(expr, function (entry) { + return parse(entry).compile().eval(scope); + }); + } + }); + } + + exports.name = 'eval'; + exports.factory = factory; + +/***/ }, +/* 293 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var docs = load(__webpack_require__(96)); + + /** + * Retrieve help on a function or data type. + * Help files are retrieved from the documentation in math.expression.docs. + * + * Syntax: + * + * math.help(search) + * + * Examples: + * + * console.log(math.help('sin').toString()); + * console.log(math.help(math.add).toString()); + * console.log(math.help(math.add).toJSON()); + * + * @param {Function | string | Object} search A function or function name + * for which to get help + * @return {Help} A help object + */ + return typed('help', { + 'any': function (search) { + var prop; + var name = search; + + if (typeof search !== 'string') { + for (prop in math) { + // search in functions and constants + if (math.hasOwnProperty(prop) && (search === math[prop])) { + name = prop; + break; + } + } + + /* TODO: implement help for data types + if (!text) { + // search data type + for (prop in math.type) { + if (math.type.hasOwnProperty(prop)) { + if (search === math.type[prop]) { + text = prop; + break; + } + } + } + } + */ + } + + var doc = docs[name]; + if (!doc) { + throw new Error('No documentation found on "' + name + '"'); + } + return new type.Help(doc); + } + }); + } + + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.name = 'help'; + exports.factory = factory; + + +/***/ }, +/* 294 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var parse = load(__webpack_require__(270)); + + /** + * Parse an expression. Returns a node tree, which can be evaluated by + * invoking node.eval(); + * + * Syntax: + * + * math.parse(expr) + * math.parse(expr, options) + * math.parse([expr1, expr2, expr3, ...]) + * math.parse([expr1, expr2, expr3, ...], options) + * + * Example: + * + * var node = math.parse('sqrt(3^2 + 4^2)'); + * node.compile().eval(); // 5 + * + * var scope = {a:3, b:4} + * var node = math.parse('a * b'); // 12 + * var code = node.compile(); + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 + * + * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); + * nodes[2].compile().eval(); // 12 + * + * See also: + * + * eval, compile + * + * @param {string | string[] | Matrix} expr Expression to be parsed + * @param {{nodes: Object}} [options] Available options: + * - `nodes` a set of custom nodes + * @return {Node | Node[]} node + * @throws {Error} + */ + return typed('parse', { + 'string | Array | Matrix': parse, + 'string | Array | Matrix, Object': parse + }); + } + + exports.name = 'parse'; + exports.factory = factory; + + +/***/ }, +/* 295 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var Parser = load(__webpack_require__(296)); + + /** + * Create a parser. The function creates a new `math.expression.Parser` object. + * + * Syntax: + * + * math.parser() + * + * Examples: + * + * var parser = new math.parser(); + * + * // evaluate expressions + * var a = parser.eval('sqrt(3^2 + 4^2)'); // 5 + * var b = parser.eval('sqrt(-4)'); // 2i + * var c = parser.eval('2 inch in cm'); // 5.08 cm + * var d = parser.eval('cos(45 deg)'); // 0.7071067811865476 + * + * // define variables and functions + * parser.eval('x = 7 / 2'); // 3.5 + * parser.eval('x + 3'); // 6.5 + * parser.eval('function f(x, y) = x^y'); // f(x, y) + * parser.eval('f(2, 3)'); // 8 + * + * // get and set variables and functions + * var x = parser.get('x'); // 7 + * var f = parser.get('f'); // function + * var g = f(3, 2); // 9 + * parser.set('h', 500); + * var i = parser.eval('h / 2'); // 250 + * parser.set('hello', function (name) { + * return 'hello, ' + name + '!'; + * }); + * parser.eval('hello("user")'); // "hello, user!" + * + * // clear defined functions and variables + * parser.clear(); + * + * See also: + * + * eval, compile, parse + * + * @return {Parser} Parser + */ + return typed('parser', { + '': function () { + return new Parser(math); + } + }); + } + + exports.name = 'parser'; + exports.factory = factory; + exports.math = true; // requires the math namespace as 5th argument + + +/***/ }, +/* 296 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var extend = __webpack_require__(3).extend; + + function factory (type, config, load, typed, math) { + var _parse = load(__webpack_require__(270)); + + /** + * @constructor Parser + * Parser contains methods to evaluate or parse expressions, and has a number + * of convenience methods to get, set, and remove variables from memory. Parser + * keeps a scope containing variables in memory, which is used for all + * evaluations. + * + * Methods: + * var result = parser.eval(expr); // evaluate an expression + * var value = parser.get(name); // retrieve a variable from the parser + * var values = parser.getAll(); // retrieve all defined variables + * parser.set(name, value); // set a variable in the parser + * parser.remove(name); // clear a variable from the + * // parsers scope + * parser.clear(); // clear the parsers scope + * + * Example usage: + * var parser = new Parser(); + * // Note: there is a convenience method which can be used instead: + * // var parser = new math.parser(); + * + * // evaluate expressions + * parser.eval('sqrt(3^2 + 4^2)'); // 5 + * parser.eval('sqrt(-4)'); // 2i + * parser.eval('2 inch in cm'); // 5.08 cm + * parser.eval('cos(45 deg)'); // 0.7071067811865476 + * + * // define variables and functions + * parser.eval('x = 7 / 2'); // 3.5 + * parser.eval('x + 3'); // 6.5 + * parser.eval('function f(x, y) = x^y'); // f(x, y) + * parser.eval('f(2, 3)'); // 8 + * + * // get and set variables and functions + * var x = parser.get('x'); // 7 + * var f = parser.get('f'); // function + * var g = f(3, 2); // 9 + * parser.set('h', 500); + * var i = parser.eval('h / 2'); // 250 + * parser.set('hello', function (name) { + * return 'hello, ' + name + '!'; + * }); + * parser.eval('hello("user")'); // "hello, user!" + * + * // clear defined functions and variables + * parser.clear(); + * + */ + function Parser() { + if (!(this instanceof Parser)) { + throw new SyntaxError( + 'Constructor must be called with the new operator'); + } + this.scope = {}; + } + + /** + * Attach type information + */ + Parser.prototype.type = 'Parser'; + Parser.prototype.isParser = true; + + /** + * Parse an expression and return the parsed function node. + * The node tree can be compiled via `code = node.compile(math)`, + * and the compiled code can be executed as `code.eval([scope])` + * @param {string} expr + * @return {Node} node + * @throws {Error} + */ + Parser.prototype.parse = function (expr) { + throw new Error('Parser.parse is deprecated. Use math.parse instead.'); + }; + + /** + * Parse and compile an expression, return the compiled javascript code. + * The node can be evaluated via code.eval([scope]) + * @param {string} expr + * @return {{eval: function}} code + * @throws {Error} + */ + Parser.prototype.compile = function (expr) { + throw new Error('Parser.compile is deprecated. Use math.compile instead.'); + }; + + /** + * Parse and evaluate the given expression + * @param {string} expr A string containing an expression, for example "2+3" + * @return {*} result The result, or undefined when the expression was empty + * @throws {Error} + */ + Parser.prototype.eval = function (expr) { + // TODO: validate arguments + return _parse(expr) + .compile() + .eval(this.scope); + }; + + /** + * Get a variable (a function or variable) by name from the parsers scope. + * Returns undefined when not found + * @param {string} name + * @return {* | undefined} value + */ + Parser.prototype.get = function (name) { + // TODO: validate arguments + return this.scope[name]; + }; + + /** + * Get a map with all defined variables + * @return {Object} values + */ + Parser.prototype.getAll = function () { + return extend({}, this.scope); + }; + + /** + * Set a symbol (a function or variable) by name from the parsers scope. + * @param {string} name + * @param {* | undefined} value + */ + Parser.prototype.set = function (name, value) { + // TODO: validate arguments + return this.scope[name] = value; + }; + + /** + * Remove a variable from the parsers scope + * @param {string} name + */ + Parser.prototype.remove = function (name) { + // TODO: validate arguments + delete this.scope[name]; + }; + + /** + * Clear the scope with variables and functions + */ + Parser.prototype.clear = function () { + for (var name in this.scope) { + if (this.scope.hasOwnProperty(name)) { + delete this.scope[name]; + } + } + }; + + return Parser; + } + + exports.name = 'Parser'; + exports.path = 'expression'; + exports.factory = factory; + exports.math = true; // requires the math namespace as 5th argument + + +/***/ }, +/* 297 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(271), + __webpack_require__(277), + __webpack_require__(278), + __webpack_require__(281), + __webpack_require__(282), + __webpack_require__(283), + __webpack_require__(285), + __webpack_require__(284), + __webpack_require__(290), + __webpack_require__(272), + __webpack_require__(288), + __webpack_require__(289), + __webpack_require__(291), + __webpack_require__(286), + __webpack_require__(287), + __webpack_require__(298) + ]; + + +/***/ }, +/* 298 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * @constructor UpdateNode + */ + function UpdateNode() { + // TODO: deprecated since v3. Cleanup some day + throw new Error('UpdateNode is deprecated. Use AssignmentNode instead.'); + } + + return UpdateNode; + } + + exports.name = 'UpdateNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 299 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(300), + __webpack_require__(302), + __webpack_require__(304), + __webpack_require__(306), + __webpack_require__(307), + __webpack_require__(309), + __webpack_require__(315), + __webpack_require__(320), + __webpack_require__(322), + __webpack_require__(324) + ]; + + +/***/ }, +/* 300 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(275).transform; + + /** + * Attach a transform function to math.range + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function concat + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var concat = load(__webpack_require__(301)); + + // @see: comment of concat itself + return typed('concat', { + '...any': function (args) { + // change last argument from one-based to zero-based + var lastIndex = args.length - 1; + var last = args[lastIndex]; + if (typeof last === 'number') { + args[lastIndex] = last - 1; + } + else if (last && last.isBigNumber === true) { + args[lastIndex] = last.minus(1); + } + + try { + return concat.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + } + + exports.name = 'concat'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 301 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var isInteger = __webpack_require__(6).isInteger; + var array = __webpack_require__(40); + var IndexError = __webpack_require__(43); + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Concatenate two or more matrices. + * + * Syntax: + * + * math.concat(A, B, C, ...) + * math.concat(A, B, C, ..., dim) + * + * Where: + * + * - `dim: number` is a zero-based dimension over which to concatenate the matrices. + * By default the last dimension of the matrices. + * + * Examples: + * + * var A = [[1, 2], [5, 6]]; + * var B = [[3, 4], [7, 8]]; + * + * math.concat(A, B); // returns [[1, 2, 3, 4], [5, 6, 7, 8]] + * math.concat(A, B, 0); // returns [[1, 2], [5, 6], [3, 4], [7, 8]] + * math.concat('hello', ' ', 'world'); // returns 'hello world' + * + * See also: + * + * size, squeeze, subset, transpose + * + * @param {... Array | Matrix} args Two or more matrices + * @return {Array | Matrix} Concatenated matrix + */ + var concat = typed('concat', { + // TODO: change signature to '...Array | Matrix, dim?' when supported + '...Array | Matrix | number | BigNumber': function (args) { + var i; + var len = args.length; + var dim = -1; // zero-based dimension + var prevDim; + var asMatrix = false; + var matrices = []; // contains multi dimensional arrays + + for (i = 0; i < len; i++) { + var arg = args[i]; + + // test whether we need to return a Matrix (if not we return an Array) + if (arg && arg.isMatrix === true) { + asMatrix = true; + } + + if (typeof arg === 'number' || (arg && arg.isBigNumber === true)) { + if (i !== len - 1) { + throw new Error('Dimension must be specified as last argument'); + } + + // last argument contains the dimension on which to concatenate + prevDim = dim; + dim = arg.valueOf(); // change BigNumber to number + + if (!isInteger(dim)) { + throw new TypeError('Integer number expected for dimension'); + } + + if (dim < 0 || (i > 0 && dim > prevDim)) { + // TODO: would be more clear when throwing a DimensionError here + throw new IndexError(dim, prevDim + 1); + } + } + else { + // this is a matrix or array + var m = clone(arg).valueOf(); + var size = array.size(m); + matrices[i] = m; + prevDim = dim; + dim = size.length - 1; + + // verify whether each of the matrices has the same number of dimensions + if (i > 0 && dim != prevDim) { + throw new DimensionError(prevDim + 1, dim + 1); + } + } + } + + if (matrices.length == 0) { + throw new SyntaxError('At least one matrix expected'); + } + + var res = matrices.shift(); + while (matrices.length) { + res = _concat(res, matrices.shift(), dim, 0); + } + + return asMatrix ? matrix(res) : res; + }, + + '...string': function (args) { + return args.join(''); + } + }); + + concat.toTex = undefined; // use default template + + return concat; + } + + /** + * Recursively concatenate two matrices. + * The contents of the matrices is not cloned. + * @param {Array} a Multi dimensional array + * @param {Array} b Multi dimensional array + * @param {number} concatDim The dimension on which to concatenate (zero-based) + * @param {number} dim The current dim (zero-based) + * @return {Array} c The concatenated matrix + * @private + */ + function _concat(a, b, concatDim, dim) { + if (dim < concatDim) { + // recurse into next dimension + if (a.length != b.length) { + throw new DimensionError(a.length, b.length); + } + + var c = []; + for (var i = 0; i < a.length; i++) { + c[i] = _concat(a[i], b[i], concatDim, dim + 1); + } + return c; + } + else { + // concatenate this dimension + return a.concat(b); + } + } + + exports.name = 'concat'; + exports.factory = factory; + + +/***/ }, +/* 302 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.filter + * Adds a property transform containing the transform function. + * + * This transform adds support for equations as test function for math.filter, + * so you can do something like 'filter([3, -2, 5], x > 0)'. + */ + function factory (type, config, load, typed) { + var filter = load(__webpack_require__(303)); + var SymbolNode = load(__webpack_require__(287)); + + function filterTransform(args, math, scope) { + var x, test; + + if (args[0]) { + x = args[0].compile().eval(scope); + } + + if (args[1]) { + if (args[1] && args[1].isSymbolNode) { + // a function pointer, like filter([3, -2, 5], myTestFunction); + test = args[1].compile().eval(scope); + } + else { + // an equation like filter([3, -2, 5], x > 0) + + // find an undefined symbol + var _scope = scope || {}; + var symbol = args[1] + .filter(function (node) { + return (node && node.isSymbolNode) && + !(node.name in math) && + !(node.name in _scope); + })[0]; + + // create a test function for this equation + var sub = Object.create(_scope); + var eq = args[1].compile(); + if (symbol) { + var name = symbol.name; + test = function (x) { + sub[name] = x; + return eq.eval(sub); + } + } + else { + throw new Error('No undefined variable found in filter equation'); + } + } + } + + return filter(x, test); + } + + filterTransform.rawArgs = true; + + return filterTransform; + } + + exports.name = 'filter'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 303 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(40).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Filter the items in an array or one dimensional matrix. + * + * Syntax: + * + * math.filter(x, test) + * + * Examples: + * + * function isPositive (x) { + * return x > 0; + * } + * math.filter([6, -2, -1, 4, 3], isPositive); // returns [6, 4, 3] + * + * math.filter(["23", "foo", "100", "55", "bar"], /[0-9]+/); // returns ["23", "100", "55"] + * + * See also: + * + * forEach, map, sort + * + * @param {Matrix | Array} x A one dimensional matrix or array to filter + * @param {Function | RegExp} test + * A function or regular expression to test items. + * When `test` is a function, it must return a boolean. + * All entries for which `test` returns true are returned. + * @return {Matrix | Array} Returns the filtered matrix. + */ + var filter = typed('filter', { + 'Array, function': _filterCallback, + + 'Array, RegExp': _filterRegExp, + + 'Matrix, function': function (x, test) { + return matrix(_filterCallback(x.toArray(), test)); + }, + + 'Matrix, RegExp': function (x, test) { + return matrix(_filterRegExp(x.toArray(), test)); + } + }); + + filter.toTex = undefined; // use default template + + return filter; + } + + /** + * Filter values in a callback given a callback function + * @param {Array} x + * @param {Function} callback + * @return {Array} Returns the filtered array + * @private + */ + function _filterCallback (x, callback) { + if (size(x).length !== 1) { + throw new Error('Only one dimensional matrices supported'); + } + + return x.filter(function (entry) { + return callback(entry); + }); + } + + /** + * Filter values in a callback given a regular expression + * @param {Array} x + * @param {Function} regexp + * @return {Array} Returns the filtered array + * @private + */ + function _filterRegExp (x, regexp) { + if (size(x).length !== 1) { + throw new Error('Only one dimensional matrices supported'); + } + + return x.filter(function (entry) { + return regexp.test(entry); + }); + } + + exports.name = 'filter'; + exports.factory = factory; + + +/***/ }, +/* 304 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.forEach + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load, typed) { + var forEach = load(__webpack_require__(305)); + + return typed('forEach', { + 'Array | Matrix, function': function (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + value.forEach(function (child, i) { + // we create a copy of the index array and append the new index value + recurse(child, index.concat(i + 1)); // one based index, hence i+1 + }); + } + else { + callback(value, index, array); + } + }; + recurse(array.valueOf(), []); // pass Array + } + }); + } + + exports.name = 'forEach'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 305 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Iterate over all elements of a matrix/array, and executes the given callback function. + * + * Syntax: + * + * math.forEach(x, callback) + * + * Examples: + * + * math.forEach([1, 2, 3], function(value) { + * console.log(value); + * }); + * // outputs 1, 2, 3 + * + * See also: + * + * filter, map, sort + * + * @param {Matrix | Array} x The matrix to iterate on. + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix/array being traversed. + */ + var forEach = typed('forEach', { + 'Array, function': _forEach, + + 'Matrix, function': function (x, callback) { + return x.forEach(callback); + } + }); + + forEach.toTex = undefined; // use default template + + return forEach; + } + + /** + * forEach for a multi dimensional array + * @param {Array} array + * @param {Function} callback + * @private + */ + function _forEach (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + value.forEach(function (child, i) { + // we create a copy of the index array and append the new index value + recurse(child, index.concat(i)); + }); + } + else { + callback(value, index, array); + } + }; + recurse(array, []); + } + + exports.name = 'forEach'; + exports.factory = factory; + + +/***/ }, +/* 306 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isArray = Array.isArray; + + /** + * Attach a transform function to math.index + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load) { + var indexFactory = load(__webpack_require__(68)); + + return function indexTransform() { + var args = []; + for (var i = 0, ii = arguments.length; i < ii; i++) { + var arg = arguments[i]; + + // change from one-based to zero based, and convert BigNumber to number + if (arg && arg.isRange === true) { + arg.start--; + arg.end -= (arg.step > 0 ? 0 : 2); + } + else if (arg && arg.isSet === true) { + arg = arg.map(function (v) { return v - 1; }); + } + else if (arg && (arg.isArray === true || arg.isMatrix)) { + arg = arg.map(function (v) { return v - 1; }); + } + else if (typeof arg === 'number') { + arg--; + } + else if (arg && arg.isBigNumber === true) { + arg = arg.toNumber() - 1; + } + else if (typeof arg === 'string') { + // leave as is + } + else { + throw new TypeError('Dimension must be an Array, Matrix, number, string, or Range'); + } + + args[i] = arg; + } + + var res = new type.Index(); + type.Index.apply(res, args); + return res; + }; + } + + exports.name = 'index'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 307 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.map + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load, typed) { + var map = load(__webpack_require__(308)); + var matrix = load(__webpack_require__(52)); + + return typed('max', { + 'Array, function': function (x, callback) { + return _map(x, callback, x); + }, + + 'Matrix, function': function (x, callback) { + return matrix(_map(x.valueOf(), callback, x)); + } + }); + } + + /** + * Map for a multi dimensional array. One-based indexes + * @param {Array} array + * @param {function} callback + * @param {Array} orig + * @return {Array} + * @private + */ + function _map (array, callback, orig) { + function recurse(value, index) { + if (Array.isArray(value)) { + return value.map(function (child, i) { + // we create a copy of the index array and append the new index value + return recurse(child, index.concat(i + 1)); // one based index, hence i + 1 + }); + } + else { + return callback(value, index, orig); + } + } + + return recurse(array, []); + } + + exports.name = 'map'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 308 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Create a new matrix or array with the results of the callback function executed on + * each entry of the matrix/array. + * + * Syntax: + * + * math.map(x, callback) + * + * Examples: + * + * math.map([1, 2, 3], function(value) { + * return value * value; + * }); // returns [1, 4, 9] + * + * See also: + * + * filter, forEach, sort + * + * @param {Matrix | Array} x The matrix to iterate on. + * @param {Function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the matrix being traversed. + * @return {Matrix | array} Transformed map of x + */ + var map = typed('map', { + 'Array, function': _map, + + 'Matrix, function': function (x, callback) { + return x.map(callback); + } + }); + + map.toTex = undefined; // use default template + + return map; + } + + /** + * Map for a multi dimensional array + * @param {Array} array + * @param {Function} callback + * @return {Array} + * @private + */ + function _map (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + return value.map(function (child, i) { + // we create a copy of the index array and append the new index value + return recurse(child, index.concat(i)); + }); + } + else { + return callback(value, index, array); + } + }; + + return recurse(array, []); + } + + exports.name = 'map'; + exports.factory = factory; + + +/***/ }, +/* 309 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(275).transform; + var isCollection = __webpack_require__(310); + + /** + * Attach a transform function to math.max + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function max + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var max = load(__webpack_require__(311)); + + return typed('max', { + '...any': function (args) { + // change last argument dim from one-based to zero-based + if (args.length == 2 && isCollection(args[0])) { + var dim = args[1]; + if (typeof dim === 'number') { + args[1] = dim - 1; + } + else if (dim && dim.isBigNumber === true) { + args[1] = dim.minus(1); + } + } + + try { + return max.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + } + + exports.name = 'max'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 310 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Test whether a value is a collection: an Array or Matrix + * @param {*} x + * @returns {boolean} isCollection + */ + module.exports = function isCollection (x) { + return (Array.isArray(x) || (x && x.isMatrix === true)); + }; + + +/***/ }, +/* 311 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepForEach = __webpack_require__(312); + var reduce = __webpack_require__(313); + var containsCollections = __webpack_require__(314); + + function factory (type, config, load, typed) { + var larger = load(__webpack_require__(64)); + + /** + * Compute the maximum value of a matrix or a list with values. + * In case of a multi dimensional array, the maximum of the flattened array + * will be calculated. When `dim` is provided, the maximum over the selected + * dimension will be calculated. Parameter `dim` is zero-based. + * + * Syntax: + * + * math.max(a, b, c, ...) + * math.max(A) + * math.max(A, dim) + * + * Examples: + * + * math.max(2, 1, 4, 3); // returns 4 + * math.max([2, 1, 4, 3]); // returns 4 + * + * // maximum over a specified dimension (zero-based) + * math.max([[2, 5], [4, 3], [1, 7]], 0); // returns [4, 7] + * math.max([[2, 5], [4, 3]], [1, 7], 1); // returns [5, 4, 7] + * + * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 + * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 + * + * See also: + * + * mean, median, min, prod, std, sum, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The maximum value + */ + var max = typed('max', { + // max([a, b, c, d, ...]) + 'Array | Matrix': _max, + + // max([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + return reduce(array, dim.valueOf(), _largest); + }, + + // max(a, b, c, d, ...) + '...': function (args) { + if (containsCollections(args)) { + throw new TypeError('Scalar values expected in function max'); + } + + return _max(args); + } + }); + + max.toTex = '\\max\\left(${args}\\right)'; + + return max; + + /** + * Return the largest of two values + * @param {*} x + * @param {*} y + * @returns {*} Returns x when x is largest, or y when y is largest + * @private + */ + function _largest(x, y){ + return larger(x, y) ? x : y; + } + + /** + * Recursively calculate the maximum value in an n-dimensional array + * @param {Array} array + * @return {number} max + * @private + */ + function _max(array) { + var max = undefined; + + deepForEach(array, function (value) { + if (max === undefined || larger(value, max)) { + max = value; + } + }); + + if (max === undefined) { + throw new Error('Cannot calculate max of an empty array'); + } + + return max; + } + } + + exports.name = 'max'; + exports.factory = factory; + + +/***/ }, +/* 312 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Recursively loop over all elements in a given multi dimensional array + * and invoke the callback on each of the elements. + * @param {Array | Matrix} array + * @param {Function} callback The callback method is invoked with one + * parameter: the current element in the array + */ + module.exports = function deepForEach (array, callback) { + if (array && array.isMatrix === true) { + array = array.valueOf(); + } + + for (var i = 0, ii = array.length; i < ii; i++) { + var value = array[i]; + + if (Array.isArray(value)) { + deepForEach(value, callback); + } + else { + callback(value); + } + } + }; + + +/***/ }, +/* 313 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var arraySize = __webpack_require__(40).size; + var IndexError = __webpack_require__(43); + + /** + * Reduce a given matrix or array to a new matrix or + * array with one less dimension, applying the given + * callback in the selected dimension. + * @param {Array | Matrix} mat + * @param {number} dim + * @param {Function} callback + * @return {Array | Matrix} res + */ + module.exports = function(mat, dim, callback) { + var size = Array.isArray(mat) ? arraySize(mat) : mat.size(); + if (dim < 0 || (dim >= size.length)) { + // TODO: would be more clear when throwing a DimensionError here + throw new IndexError(dim, size.length); + } + + if (mat && mat.isMatrix === true) { + return mat.create(_reduce(mat.valueOf(), dim, callback)); + }else { + return _reduce(mat, dim, callback); + } + }; + + /** + * Recursively reduce a matrix + * @param {Array} mat + * @param {number} dim + * @param {Function} callback + * @returns {Array} ret + * @private + */ + function _reduce(mat, dim, callback){ + var i, ret, val, tran; + + if(dim<=0){ + if( !Array.isArray(mat[0]) ){ + val = mat[0]; + for(i=1; i 0) { + while (x < end) { + array.push(x); + x += step; + } + } + else if (step < 0) { + while (x > end) { + array.push(x); + x += step; + } + } + + return array; + } + + /** + * Create a range with numbers. End is included + * @param {number} start + * @param {number} end + * @param {number} step + * @returns {Array} range + * @private + */ + function _rangeInc (start, end, step) { + var array = [], + x = start; + if (step > 0) { + while (x <= end) { + array.push(x); + x += step; + } + } + else if (step < 0) { + while (x >= end) { + array.push(x); + x += step; + } + } + + return array; + } + + /** + * Create a range with big numbers. End is excluded + * @param {BigNumber} start + * @param {BigNumber} end + * @param {BigNumber} step + * @returns {Array} range + * @private + */ + function _bigRangeEx (start, end, step) { + var array = [], + x = start; + if (step.gt(ZERO)) { + while (x.lt(end)) { + array.push(x); + x = x.plus(step); + } + } + else if (step.lt(ZERO)) { + while (x.gt(end)) { + array.push(x); + x = x.plus(step); + } + } + + return array; + } + + /** + * Create a range with big numbers. End is included + * @param {BigNumber} start + * @param {BigNumber} end + * @param {BigNumber} step + * @returns {Array} range + * @private + */ + function _bigRangeInc (start, end, step) { + var array = [], + x = start; + if (step.gt(ZERO)) { + while (x.lte(end)) { + array.push(x); + x = x.plus(step); + } + } + else if (step.lt(ZERO)) { + while (x.gte(end)) { + array.push(x); + x = x.plus(step); + } + } + + return array; + } + + /** + * Parse a string into a range, + * The string contains the start, optional step, and end, separated by a colon. + * If the string does not contain a valid range, null is returned. + * For example str='0:2:11'. + * @param {string} str + * @return {{start: number, end: number, step: number} | null} range Object containing properties start, end, step + * @private + */ + function _parse (str) { + var args = str.split(':'); + + // number + var nums = args.map(function (arg) { + // use Number and not parseFloat as Number returns NaN on invalid garbage in the string + return Number(arg); + }); + + var invalid = nums.some(function (num) { + return isNaN(num); + }); + if(invalid) { + return null; + } + + switch (nums.length) { + case 2: + return { + start: nums[0], + end: nums[1], + step: 1 + }; + + case 3: + return { + start: nums[0], + end: nums[2], + step: nums[1] + }; + + default: + return null; + } + } + + } + + exports.name = 'range'; + exports.factory = factory; + + +/***/ }, +/* 324 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(275).transform; + + /** + * Attach a transform function to math.subset + * Adds a property transform containing the transform function. + * + * This transform creates a range which includes the end value + */ + function factory (type, config, load, typed) { + var subset = load(__webpack_require__(276)); + + return typed('subset', { + '...any': function (args) { + try { + return subset.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + } + + exports.name = 'subset'; + exports.path = 'expression.transform'; + exports.factory = factory; + + +/***/ }, +/* 325 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(3); + var string = __webpack_require__(23); + + function factory (type, config, load, typed) { + var parser = load(__webpack_require__(295))(); + + /** + * Documentation object + * @param {Object} doc Object containing properties: + * {string} name + * {string} category + * {string} description + * {string[]} syntax + * {string[]} examples + * {string[]} seealso + * @constructor + */ + function Help(doc) { + if (!(this instanceof Help)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (!doc) throw new Error('Argument "doc" missing'); + + this.doc = doc; + } + + /** + * Attach type information + */ + Help.prototype.type = 'Help'; + Help.prototype.isHelp = true; + + /** + * Generate a string representation of the Help object + * @return {string} Returns a string + * @private + */ + Help.prototype.toString = function () { + var doc = this.doc || {}; + var desc = '\n'; + + if (doc.name) { + desc += 'Name: ' + doc.name + '\n\n'; + } + if (doc.category) { + desc += 'Category: ' + doc.category + '\n\n'; + } + if (doc.description) { + desc += 'Description:\n ' + doc.description + '\n\n'; + } + if (doc.syntax) { + desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n'; + } + if (doc.examples) { + desc += 'Examples:\n'; + for (var i = 0; i < doc.examples.length; i++) { + var expr = doc.examples[i]; + desc += ' ' + expr + '\n'; + + var res; + try { + res = parser.eval(expr); + } + catch (e) { + res = e; + } + if (res && !res.isHelp) { + desc += ' ' + string.format(res, {precision: 14}) + '\n'; + } + } + desc += '\n'; + } + if (doc.seealso) { + desc += 'See also: ' + doc.seealso.join(', ') + '\n'; + } + + return desc; + }; + + /** + * Export the help object to JSON + */ + Help.prototype.toJSON = function () { + var obj = object.clone(this.doc); + obj.mathjs = 'Help'; + return obj; + }; + + /** + * Instantiate a Help object from a JSON object + * @param {Object} json + * @returns {Help} Returns a new Help object + */ + Help.fromJSON = function (json) { + var doc = {}; + for (var prop in json) { + if (prop !== 'mathjs') { // ignore mathjs field + doc[prop] = json[prop]; + } + } + return new Help(doc); + }; + + /** + * Returns a string representation of the Help object + */ + Help.prototype.valueOf = Help.prototype.toString; + + return Help; + } + + exports.name = 'Help'; + exports.path = 'type'; + exports.factory = factory; + + +/***/ }, +/* 326 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(327), + __webpack_require__(354), + __webpack_require__(386), + __webpack_require__(402), + __webpack_require__(411), + __webpack_require__(416), + __webpack_require__(419), + __webpack_require__(425), + __webpack_require__(437), + __webpack_require__(446), + __webpack_require__(450), + __webpack_require__(457), + __webpack_require__(459), + __webpack_require__(485), + __webpack_require__(487) + ]; + + +/***/ }, +/* 327 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // decomposition + __webpack_require__(328), + __webpack_require__(329), + + // solver + __webpack_require__(349), + __webpack_require__(351), + __webpack_require__(353) + ]; + + +/***/ }, +/* 328 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + + var object = util.object; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var abs = load(__webpack_require__(86)); + var addScalar = load(__webpack_require__(53)); + var divideScalar = load(__webpack_require__(81)); + var multiplyScalar = load(__webpack_require__(80)); + var subtract = load(__webpack_require__(77)); + var larger = load(__webpack_require__(64)); + var equalScalar = load(__webpack_require__(48)); + var unaryMinus = load(__webpack_require__(78)); + + var SparseMatrix = type.SparseMatrix; + var DenseMatrix = type.DenseMatrix; + var Spa = type.Spa; + + /** + * Calculate the Matrix LU decomposition with partial pivoting. Matrix `A` is decomposed in two matrices (`L`, `U`) and a + * row permutation vector `p` where `A[p,:] = L * U` + * + * Syntax: + * + * math.lup(A); + * + * Example: + * + * var m = [[2, 1], [1, 4]]; + * var r = math.lup(); + * // r = { + * // L: [[1, 0], [0.5, 1]], + * // U: [[2, 1], [0, 3.5]], + * // P: [0, 1] + * // } + * + * See also: + * + * slu, lsolve, lusolve, usolve + * + * @param {Matrix | Array} A A two dimensional matrix or array for which to get the LUP decomposition. + * + * @return {Array} The lower triangular matrix, the upper triangular matrix and the permutation matrix. + */ + var lup = typed('lup', { + + 'DenseMatrix': function (m) { + return _denseLUP(m); + }, + + 'SparseMatrix': function (m) { + return _sparseLUP(m); + }, + + 'Array': function (a) { + // create dense matrix from array + var m = matrix(a); + // lup, use matrix implementation + var r = _denseLUP(m); + // result + return { + L: r.L.valueOf(), + U: r.U.valueOf(), + p: r.p + }; + } + }); + + var _denseLUP = function (m) { + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // minimum rows and columns + var n = Math.min(rows, columns); + // matrix array, clone original data + var data = object.clone(m._data); + // l matrix arrays + var ldata = []; + var lsize = [rows, n]; + // u matrix arrays + var udata = []; + var usize = [n, columns]; + // vars + var i, j, k; + // permutation vector + var p = []; + for (i = 0; i < rows; i++) + p[i] = i; + // loop columns + for (j = 0; j < columns; j++) { + // skip first column in upper triangular matrix + if (j > 0) { + // loop rows + for (i = 0; i < rows; i++) { + // min i,j + var min = Math.min(i, j); + // v[i, j] + var s = 0; + // loop up to min + for (k = 0; k < min; k++) { + // s = l[i, k] - data[k, j] + s = addScalar(s, multiplyScalar(data[i][k], data[k][j])); + } + data[i][j] = subtract(data[i][j], s); + } + } + // row with larger value in cvector, row >= j + var pi = j; + var pabsv = 0; + var vjj = 0; + // loop rows + for (i = j; i < rows; i++) { + // data @ i, j + var v = data[i][j]; + // absolute value + var absv = abs(v); + // value is greater than pivote value + if (larger(absv, pabsv)) { + // store row + pi = i; + // update max value + pabsv = absv; + // value @ [j, j] + vjj = v; + } + } + // swap rows (j <-> pi) + if (j !== pi) { + // swap values j <-> pi in p + p[j] = [p[pi], p[pi] = p[j]][0]; + // swap j <-> pi in data + DenseMatrix._swapRows(j, pi, data); + } + // check column is in lower triangular matrix + if (j < rows) { + // loop rows (lower triangular matrix) + for (i = j + 1; i < rows; i++) { + // value @ i, j + var vij = data[i][j]; + if (!equalScalar(vij, 0)) { + // update data + data[i][j] = divideScalar(data[i][j], vjj); + } + } + } + } + // loop columns + for (j = 0; j < columns; j++) { + // loop rows + for (i = 0; i < rows; i++) { + // initialize row in arrays + if (j === 0) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i] = []; + } + // L + ldata[i] = []; + } + // check we are in the upper triangular matrix + if (i < j) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = data[i][j]; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = 0; + } + continue; + } + // diagonal value + if (i === j) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = data[i][j]; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = 1; + } + continue; + } + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = 0; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = data[i][j]; + } + } + } + // l matrix + var l = new DenseMatrix({ + data: ldata, + size: lsize + }); + // u matrix + var u = new DenseMatrix({ + data: udata, + size: usize + }); + // p vector + var pv = []; + for (i = 0, n = p.length; i < n; i++) + pv[p[i]] = i; + // return matrices + return { + L: l, + U: u, + p: pv, + toString: function () { + return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.p; + } + }; + }; + + var _sparseLUP = function (m) { + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // minimum rows and columns + var n = Math.min(rows, columns); + // matrix arrays (will not be modified, thanks to permutation vector) + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // l matrix arrays + var lvalues = []; + var lindex = []; + var lptr = []; + var lsize = [rows, n]; + // u matrix arrays + var uvalues = []; + var uindex = []; + var uptr = []; + var usize = [n, columns]; + // vars + var i, j, k; + // permutation vectors, (current index -> original index) and (original index -> current index) + var pv_co = []; + var pv_oc = []; + for (i = 0; i < rows; i++) { + pv_co[i] = i; + pv_oc[i] = i; + } + // swap indices in permutation vectors (condition x < y)! + var swapIndeces = function (x, y) { + // find pv indeces getting data from x and y + var kx = pv_oc[x]; + var ky = pv_oc[y]; + // update permutation vector current -> original + pv_co[kx] = y; + pv_co[ky] = x; + // update permutation vector original -> current + pv_oc[x] = ky; + pv_oc[y] = kx; + }; + // loop columns + for (j = 0; j < columns; j++) { + // sparse accumulator + var spa = new Spa(); + // check lower triangular matrix has a value @ column j + if (j < rows) { + // update ptr + lptr.push(lvalues.length); + // first value in j column for lower triangular matrix + lvalues.push(1); + lindex.push(j); + } + // update ptr + uptr.push(uvalues.length); + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // copy column j into sparse accumulator + for (k = k0; k < k1; k++) { + // row + i = index[k]; + // copy column values into sparse accumulator (use permutation vector) + spa.set(pv_co[i], values[k]); + } + // skip first column in upper triangular matrix + if (j > 0) { + // loop rows in column j (above diagonal) + spa.forEach(0, j - 1, function (k, vkj) { + // loop rows in column k (L) + SparseMatrix._forEachRow(k, lvalues, lindex, lptr, function (i, vik) { + // check row is below k + if (i > k) { + // update spa value + spa.accumulate(i, unaryMinus(multiplyScalar(vik, vkj))); + } + }); + }); + } + // row with larger value in spa, row >= j + var pi = j; + var vjj = spa.get(j); + var pabsv = abs(vjj); + // loop values in spa (order by row, below diagonal) + spa.forEach(j + 1, rows - 1, function (x, v) { + // absolute value + var absv = abs(v); + // value is greater than pivote value + if (larger(absv, pabsv)) { + // store row + pi = x; + // update max value + pabsv = absv; + // value @ [j, j] + vjj = v; + } + }); + // swap rows (j <-> pi) + if (j !== pi) { + // swap values j <-> pi in L + SparseMatrix._swapRows(j, pi, lsize[1], lvalues, lindex, lptr); + // swap values j <-> pi in U + SparseMatrix._swapRows(j, pi, usize[1], uvalues, uindex, uptr); + // swap values in spa + spa.swap(j, pi); + // update permutation vector (swap values @ j, pi) + swapIndeces(j, pi); + } + // loop values in spa (order by row) + spa.forEach(0, rows - 1, function (x, v) { + // check we are above diagonal + if (x <= j) { + // update upper triangular matrix + uvalues.push(v); + uindex.push(x); + } + else { + // update value + v = divideScalar(v, vjj); + // check value is non zero + if (!equalScalar(v, 0)) { + // update lower triangular matrix + lvalues.push(v); + lindex.push(x); + } + } + }); + } + // update ptrs + uptr.push(uvalues.length); + lptr.push(lvalues.length); + + // return matrices + return { + L: new SparseMatrix({ + values: lvalues, + index: lindex, + ptr: lptr, + size: lsize + }), + U: new SparseMatrix({ + values: uvalues, + index: uindex, + ptr: uptr, + size: usize + }), + p: pv_co, + toString: function () { + return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.p; + } + }; + }; + + return lup; + } + + exports.name = 'lup'; + exports.factory = factory; + + +/***/ }, +/* 329 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + + var number = util.number, + + isInteger = number.isInteger; + + function factory (type, config, load, typed) { + + var cs_sqr = load(__webpack_require__(330)); + var cs_lu = load(__webpack_require__(341)); + + /** + * Calculate the Sparse Matrix LU decomposition with full pivoting. Sparse Matrix `A` is decomposed in two matrices (`L`, `U`) and two permutation vectors (`pinv`, `q`) where + * + * `P * A * Q = L * U` + * + * Syntax: + * + * math.slu(A, order, threshold); + * + * See also: + * + * lup, lsolve, usolve, lusolve + * + * @param {SparseMatrix} A A two dimensional sparse matrix for which to get the LU decomposition. + * @param {Number} order The Symbolic Ordering and Analysis order: + * 0 - Natural ordering, no permutation vector q is returned + * 1 - Matrix must be square, symbolic ordering and analisis is performed on M = A + A' + * 2 - Symbolic ordering and analisis is performed on M = A' * A. Dense columns from A' are dropped, A recreated from A'. + * This is appropriatefor LU factorization of unsymmetric matrices. + * 3 - Symbolic ordering and analisis is performed on M = A' * A. This is best used for LU factorization is matrix M has no dense rows. + * A dense row is a row with more than 10*sqr(columns) entries. + * @param {Number} threshold Partial pivoting threshold (1 for partial pivoting) + * + * @return {Object} The lower triangular matrix, the upper triangular matrix and the permutation vectors. + */ + var slu = typed('slu', { + + 'SparseMatrix, number, number': function (a, order, threshold) { + // verify order + if (!isInteger(order) || order < 0 || order > 3) + throw new Error('Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]'); + // verify threshold + if (threshold < 0 || threshold > 1) + throw new Error('Partial pivoting threshold must be a number from 0 to 1'); + + // perform symbolic ordering and analysis + var s = cs_sqr(order, a, false); + + // perform lu decomposition + var f = cs_lu(a, s, threshold); + + // return decomposition + return { + L: f.L, + U: f.U, + p: f.pinv, + q: s.q, + toString: function () { + return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\np: ' + this.p.toString() + (this.q ? '\nq: ' + this.q.toString() : '') + '\n'; + } + }; + } + }); + + return slu; + } + + exports.name = 'slu'; + exports.factory = factory; + + +/***/ }, +/* 330 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_amd = load(__webpack_require__(331)); + var cs_permute = load(__webpack_require__(336)); + var cs_etree = load(__webpack_require__(337)); + var cs_post = load(__webpack_require__(338)); + var cs_counts = load(__webpack_require__(339)); + + /** + * Symbolic ordering and analysis for QR and LU decompositions. + * + * @param {Number} order The ordering strategy (see cs_amd for more details) + * @param {Matrix} a The A matrix + * @param {boolean} qr Symbolic ordering and analysis for QR decomposition (true) or + * symbolic ordering and analysis for LU decomposition (false) + * + * @return {Object} The Symbolic ordering and analysis for matrix A + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_sqr = function (order, a, qr) { + // a arrays + var aptr = a._ptr; + var asize = a._size; + // columns + var n = asize[1]; + // vars + var k; + // symbolic analysis result + var s = {}; + // fill-reducing ordering + s.q = cs_amd(order, a); + // validate results + if (order && !s.q) + return null; + // QR symbolic analysis + if (qr) { + // apply permutations if needed + var c = order ? cs_permute(a, null, s.q, 0) : a; + // etree of C'*C, where C=A(:,q) + s.parent = cs_etree(c, 1); + // post order elimination tree + var post = cs_post (s.parent, n); + // col counts chol(C'*C) + s.cp = cs_counts(c, s.parent, post, 1); + // check we have everything needed to calculate number of nonzero elements + if (c && s.parent && s.cp && _vcount(c, s)) { + // calculate number of nonzero elements + for (s.unz = 0, k = 0; k < n; k++) + s.unz += s.cp[k]; + } + } + else { + // for LU factorization only, guess nnz(L) and nnz(U) + s.unz = 4 * (aptr[n]) + n; + s.lnz = s.unz; + } + // return result S + return s; + }; + + /** + * Compute nnz(V) = s.lnz, s.pinv, s.leftmost, s.m2 from A and s.parent + */ + var _vcount = function (a, s) { + // a arrays + var aptr = a._ptr; + var aindex = a._index; + var asize = a._size; + // rows & columns + var m = asize[0]; + var n = asize[1]; + // initialize s arrays + s.pinv = []; // (m + n); + s.leftmost = []; // (m); + // vars + var parent = s.parent; + var pinv = s.pinv; + var leftmost = s.leftmost; + // workspace, next: first m entries, head: next n entries, tail: next n entries, nque: next n entries + var w = []; // (m + 3 * n); + var next = 0; + var head = m; + var tail = m + n; + var nque = m + 2 * n; + // vars + var i, k, p, p0, p1; + // initialize w + for (k = 0; k < n; k++) { + // queue k is empty + w[head + k] = -1; + w[tail + k] = -1; + w[nque + k] = 0; + } + // initialize row arrays + for (i = 0; i < m; i++) + leftmost[i] = -1; + // loop columns backwards + for (k = n - 1; k >= 0; k--) { + // values & index for column k + for (p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) { + // leftmost[i] = min(find(A(i,:))) + leftmost[aindex[p]] = k; + } + } + // scan rows in reverse order + for (i = m - 1; i >= 0; i--) { + // row i is not yet ordered + pinv[i] = -1; + k = leftmost[i]; + // check row i is empty + if (k == -1) + continue; + // first row in queue k + if (w[nque + k]++ === 0) + w[tail + k] = i; + // put i at head of queue k + w[next + i] = w[head + k]; + w[head + k] = i; + } + s.lnz = 0; + s.m2 = m; + // find row permutation and nnz(V) + for (k = 0; k < n; k++) { + // remove row i from queue k + i = w[head + k]; + // count V(k,k) as nonzero + s.lnz++; + // add a fictitious row + if (i < 0) + i = s.m2++; + // associate row i with V(:,k) + pinv[i] = k; + // skip if V(k+1:m,k) is empty + if (--nque[k] <= 0) + continue; + // nque[k] is nnz (V(k+1:m,k)) + s.lnz += w[nque + k]; + // move all rows to parent of k + var pa = parent[k]; + if (pa != -1) { + if (w[nque + pa] === 0) + w[tail + pa] = w[tail + k]; + w[next + w[tail + k]] = w[head + pa]; + w[head + pa] = w[next + i]; + w[nque + pa] += w[nque + k]; + } + } + for (i = 0; i < m; i++) { + if (pinv[i] < 0) + pinv[i] = k++; + } + return true; + }; + + return cs_sqr; + } + + exports.name = 'cs_sqr'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 331 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_flip = load(__webpack_require__(332)); + var cs_fkeep = load(__webpack_require__(333)); + var cs_tdfs = load(__webpack_require__(334)); + + var add = load(__webpack_require__(51)); + var multiply = load(__webpack_require__(84)); + var transpose = load(__webpack_require__(335)); + + /** + * Approximate minimum degree ordering. The minimum degree algorithm is a widely used + * heuristic for finding a permutation P so that P*A*P' has fewer nonzeros in its factorization + * than A. It is a gready method that selects the sparsest pivot row and column during the course + * of a right looking sparse Cholesky factorization. + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + * + * @param {Number} order 0: Natural, 1: Cholesky, 2: LU, 3: QR + * @param {Matrix} m Sparse Matrix + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_amd = function (order, a) { + // check input parameters + if (!a || order <= 0 || order > 3) + return null; + // a matrix arrays + var asize = a._size; + // rows and columns + var m = asize[0]; + var n = asize[1]; + // initialize vars + var lemax = 0; + // dense threshold + var dense = Math.max(16, 10 * Math.sqrt(n)); + dense = Math.min(n - 2, dense); + // create target matrix C + var cm = _createTargetMatrix(order, a, m, n, dense); + // drop diagonal entries + cs_fkeep(cm, _diag, null); + // C matrix arrays + var cindex = cm._index; + var cptr = cm._ptr; + + // number of nonzero elements in C + var cnz = cptr[n]; + + // allocate result (n+1) + var P = []; + + // create workspace (8 * (n + 1)) + var W = []; + var len = 0; // first n + 1 entries + var nv = n + 1; // next n + 1 entries + var next = 2 * (n + 1); // next n + 1 entries + var head = 3 * (n + 1); // next n + 1 entries + var elen = 4 * (n + 1); // next n + 1 entries + var degree = 5 * (n + 1); // next n + 1 entries + var w = 6 * (n + 1); // next n + 1 entries + var hhead = 7 * (n + 1); // last n + 1 entries + + // use P as workspace for last + var last = P; + + // initialize quotient graph + var mark = _initializeQuotientGraph(n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree); + + // initialize degree lists + var nel = _initializeDegreeLists(n, cptr, W, degree, elen, w, dense, nv, head, last, next); + + // minimum degree node + var mindeg = 0; + + // vars + var i, j, k, k1, k2, e, pj, ln, nvi, pk, eln, p1, p2, pn, h, d; + + // while (selecting pivots) do + while (nel < n) { + // select node of minimum approximate degree. amd() is now ready to start eliminating the graph. It first + // finds a node k of minimum degree and removes it from its degree list. The variable nel keeps track of thow + // many nodes have been eliminated. + for (k = -1; mindeg < n && (k = W[head + mindeg]) == -1; mindeg++); + if (W[next + k] != -1) + last[W[next + k]] = -1; + // remove k from degree list + W[head + mindeg] = W[next + k]; + // elenk = |Ek| + var elenk = W[elen + k]; + // # of nodes k represents + var nvk = W[nv + k]; + // W[nv + k] nodes of A eliminated + nel += nvk; + + // Construct a new element. The new element Lk is constructed in place if |Ek| = 0. nv[i] is + // negated for all nodes i in Lk to flag them as members of this set. Each node i is removed from the + // degree lists. All elements e in Ek are absorved into element k. + var dk = 0; + // flag k as in Lk + W[nv + k] = -nvk; + var p = cptr[k]; + // do in place if W[elen + k] == 0 + var pk1 = (elenk === 0) ? p : cnz; + var pk2 = pk1; + for (k1 = 1; k1 <= elenk + 1; k1++) { + if (k1 > elenk) { + // search the nodes in k + e = k; + // list of nodes starts at cindex[pj] + pj = p; + // length of list of nodes in k + ln = W[len + k] - elenk; + } + else { + // search the nodes in e + e = cindex[p++]; + pj = cptr[e]; + // length of list of nodes in e + ln = W[len + e]; + } + for (k2 = 1; k2 <= ln; k2++) { + i = cindex[pj++]; + // check node i dead, or seen + if ((nvi = W[nv + i]) <= 0) + continue; + // W[degree + Lk] += size of node i + dk += nvi; + // negate W[nv + i] to denote i in Lk + W[nv + i] = -nvi; + // place i in Lk + cindex[pk2++] = i; + if (W[next + i] != -1) + last[W[next + i]] = last[i]; + // check we need to remove i from degree list + if (last[i] != -1) + W[next + last[i]] = W[next + i]; + else + W[head + W[degree + i]] = W[next + i]; + } + if (e != k) { + // absorb e into k + cptr[e] = cs_flip(k); + // e is now a dead element + W[w + e] = 0; + } + } + // cindex[cnz...nzmax] is free + if (elenk !== 0) + cnz = pk2; + // external degree of k - |Lk\i| + W[degree + k] = dk; + // element k is in cindex[pk1..pk2-1] + cptr[k] = pk1; + W[len + k] = pk2 - pk1; + // k is now an element + W[elen + k] = -2; + + // Find set differences. The scan1 function now computes the set differences |Le \ Lk| for all elements e. At the start of the + // scan, no entry in the w array is greater than or equal to mark. + + // clear w if necessary + mark = _wclear(mark, lemax, W, w, n); + // scan 1: find |Le\Lk| + for (pk = pk1; pk < pk2; pk++) { + i = cindex[pk]; + // check if W[elen + i] empty, skip it + if ((eln = W[elen + i]) <= 0) + continue; + // W[nv + i] was negated + nvi = -W[nv + i]; + var wnvi = mark - nvi; + // scan Ei + for (p = cptr[i], p1 = cptr[i] + eln - 1; p <= p1; p++) { + e = cindex[p]; + if (W[w + e] >= mark) { + // decrement |Le\Lk| + W[w + e] -= nvi; + } + else if (W[w + e] !== 0) { + // ensure e is a live element, 1st time e seen in scan 1 + W[w + e] = W[degree + e] + wnvi; + } + } + } + + // degree update + // The second pass computes the approximate degree di, prunes the sets Ei and Ai, and computes a hash + // function h(i) for all nodes in Lk. + + // scan2: degree update + for (pk = pk1; pk < pk2; pk++) { + // consider node i in Lk + i = cindex[pk]; + p1 = cptr[i]; + p2 = p1 + W[elen + i] - 1; + pn = p1; + // scan Ei + for (h = 0, d = 0, p = p1; p <= p2; p++) { + e = cindex[p]; + // check e is an unabsorbed element + if (W[w + e] !== 0) { + // dext = |Le\Lk| + var dext = W[w + e] - mark; + if (dext > 0) { + // sum up the set differences + d += dext; + // keep e in Ei + cindex[pn++] = e; + // compute the hash of node i + h += e; + } + else { + // aggressive absorb. e->k + cptr[e] = cs_flip(k); + // e is a dead element + W[w + e] = 0; + } + } + } + // W[elen + i] = |Ei| + W[elen + i] = pn - p1 + 1; + var p3 = pn; + var p4 = p1 + W[len + i]; + // prune edges in Ai + for (p = p2 + 1; p < p4; p++) { + j = cindex[p]; + // check node j dead or in Lk + var nvj = W[nv + j]; + if (nvj <= 0) + continue; + // degree(i) += |j| + d += nvj; + // place j in node list of i + cindex[pn++] = j; + // compute hash for node i + h += j; + } + // check for mass elimination + if (d === 0) { + // absorb i into k + cptr[i] = cs_flip(k); + nvi = -W[nv + i]; + // |Lk| -= |i| + dk -= nvi; + // |k| += W[nv + i] + nvk += nvi; + nel += nvi; + W[nv + i] = 0; + // node i is dead + W[elen + i] = -1; + } + else { + // update degree(i) + W[degree + i] = Math.min(W[degree + i], d); + // move first node to end + cindex[pn] = cindex[p3]; + // move 1st el. to end of Ei + cindex[p3] = cindex[p1]; + // add k as 1st element in of Ei + cindex[p1] = k; + // new len of adj. list of node i + W[len + i] = pn - p1 + 1; + // finalize hash of i + h = (h < 0 ? -h : h) % n; + // place i in hash bucket + W[next + i] = W[hhead + h]; + W[hhead + h] = i; + // save hash of i in last[i] + last[i] = h; + } + } + // finalize |Lk| + W[degree + k] = dk; + lemax = Math.max(lemax, dk); + // clear w + mark = _wclear(mark + lemax, lemax, W, w, n); + + // Supernode detection. Supernode detection relies on the hash function h(i) computed for each node i. + // If two nodes have identical adjacency lists, their hash functions wil be identical. + for (pk = pk1; pk < pk2; pk++) { + i = cindex[pk]; + // check i is dead, skip it + if (W[nv + i] >= 0) + continue; + // scan hash bucket of node i + h = last[i]; + i = W[hhead + h]; + // hash bucket will be empty + W[hhead + h] = -1; + for (; i != -1 && W[next + i] != -1; i = W[next + i], mark++) { + ln = W[len + i]; + eln = W[elen + i]; + for (p = cptr[i] + 1; p <= cptr[i] + ln - 1; p++) + W[w + cindex[p]] = mark; + var jlast = i; + // compare i with all j + for (j = W[next + i]; j != -1; ) { + var ok = W[len + j] === ln && W[elen + j] === eln; + for (p = cptr[j] + 1; ok && p <= cptr[j] + ln - 1; p++) { + // compare i and j + if (W[w + cindex[p]] != mark) + ok = 0; + } + // check i and j are identical + if (ok) { + // absorb j into i + cptr[j] = cs_flip(i); + W[nv + i] += W[nv + j]; + W[nv + j] = 0; + // node j is dead + W[elen + j] = -1; + // delete j from hash bucket + j = W[next + j]; + W[next + jlast] = j; + } + else { + // j and i are different + jlast = j; + j = W[next + j]; + } + } + } + } + + // Finalize new element. The elimination of node k is nearly complete. All nodes i in Lk are scanned one last time. + // Node i is removed from Lk if it is dead. The flagged status of nv[i] is cleared. + for (p = pk1, pk = pk1; pk < pk2; pk++) { + i = cindex[pk]; + // check i is dead, skip it + if ((nvi = -W[nv + i]) <= 0) + continue; + // restore W[nv + i] + W[nv + i] = nvi; + // compute external degree(i) + d = W[degree + i] + dk - nvi; + d = Math.min(d, n - nel - nvi); + if (W[head + d] != -1) + last[W[head + d]] = i; + // put i back in degree list + W[next + i] = W[head + d]; + last[i] = -1; + W[head + d] = i; + // find new minimum degree + mindeg = Math.min(mindeg, d); + W[degree + i] = d; + // place i in Lk + cindex[p++] = i; + } + // # nodes absorbed into k + W[nv + k] = nvk; + // length of adj list of element k + if ((W[len + k] = p - pk1) === 0) { + // k is a root of the tree + cptr[k] = -1; + // k is now a dead element + W[w + k] = 0; + } + if (elenk !== 0) { + // free unused space in Lk + cnz = p; + } + } + + // Postordering. The elimination is complete, but no permutation has been computed. All that is left + // of the graph is the assembly tree (ptr) and a set of dead nodes and elements (i is a dead node if + // nv[i] is zero and a dead element if nv[i] > 0). It is from this information only that the final permutation + // is computed. The tree is restored by unflipping all of ptr. + + // fix assembly tree + for (i = 0; i < n; i++) + cptr[i] = cs_flip(cptr[i]); + for (j = 0; j <= n; j++) + W[head + j] = -1; + // place unordered nodes in lists + for (j = n; j >= 0; j--) { + // skip if j is an element + if (W[nv + j] > 0) + continue; + // place j in list of its parent + W[next + j] = W[head + cptr[j]]; + W[head + cptr[j]] = j; + } + // place elements in lists + for (e = n; e >= 0; e--) { + // skip unless e is an element + if (W[nv + e] <= 0) + continue; + if (cptr[e] != -1) { + // place e in list of its parent + W[next + e] = W[head + cptr[e]]; + W[head + cptr[e]] = e; + } + } + // postorder the assembly tree + for (k = 0, i = 0; i <= n; i++) { + if (cptr[i] == -1) + k = cs_tdfs(i, k, W, head, next, P, w); + } + // remove last item in array + P.splice(P.length - 1, 1); + // return P + return P; + }; + + /** + * Creates the matrix that will be used by the approximate minimum degree ordering algorithm. The function accepts the matrix M as input and returns a permutation + * vector P. The amd algorithm operates on a symmetrix matrix, so one of three symmetric matrices is formed. + * + * Order: 0 + * A natural ordering P=null matrix is returned. + * + * Order: 1 + * Matrix must be square. This is appropriate for a Cholesky or LU factorization. + * P = M + M' + * + * Order: 2 + * Dense columns from M' are dropped, M recreated from M'. This is appropriatefor LU factorization of unsymmetric matrices. + * P = M' * M + * + * Order: 3 + * This is best used for QR factorization or LU factorization is matrix M has no dense rows. A dense row is a row with more than 10*sqr(columns) entries. + * P = M' * M + */ + var _createTargetMatrix = function (order, a, m, n, dense) { + // compute A' + var at = transpose(a); + + // check order = 1, matrix must be square + if (order === 1 && n === m) { + // C = A + A' + return add(a, at); + } + + // check order = 2, drop dense columns from M' + if (order == 2) { + // transpose arrays + var tindex = at._index; + var tptr = at._ptr; + // new column index + var p2 = 0; + // loop A' columns (rows) + for (var j = 0; j < m; j++) { + // column j of AT starts here + var p = tptr[j]; + // new column j starts here + tptr[j] = p2; + // skip dense col j + if (tptr[j + 1] - p > dense) + continue; + // map rows in column j of A + for (var p1 = tptr[j + 1]; p < p1; p++) + tindex[p2++] = tindex[p]; + } + // finalize AT + tptr[m] = p2; + // recreate A from new transpose matrix + a = transpose(at); + // use A' * A + return multiply(at, a); + } + + // use A' * A, square or rectangular matrix + return multiply(at, a); + }; + + /** + * Initialize quotient graph. There are four kind of nodes and elements that must be represented: + * + * - A live node is a node i (or a supernode) that has not been selected as a pivot nad has not been merged into another supernode. + * - A dead node i is one that has been removed from the graph, having been absorved into r = flip(ptr[i]). + * - A live element e is one that is in the graph, having been formed when node e was selected as the pivot. + * - A dead element e is one that has benn absorved into a subsequent element s = flip(ptr[e]). + */ + var _initializeQuotientGraph = function (n, cptr, W, len, head, last, next, hhead, nv, w, elen, degree) { + // Initialize quotient graph + for (var k = 0; k < n; k++) + W[len + k] = cptr[k + 1] - cptr[k]; + W[len + n] = 0; + // initialize workspace + for (var i = 0; i <= n; i++) { + // degree list i is empty + W[head + i] = -1; + last[i] = -1; + W[next + i] = -1; + // hash list i is empty + W[hhead + i] = -1; + // node i is just one node + W[nv + i] = 1; + // node i is alive + W[w + i] = 1; + // Ek of node i is empty + W[elen + i] = 0; + // degree of node i + W[degree + i] = W[len + i]; + } + // clear w + var mark = _wclear(0, 0, W, w, n); + // n is a dead element + W[elen + n] = -2; + // n is a root of assembly tree + cptr[n] = -1; + // n is a dead element + W[w + n] = 0; + // return mark + return mark; + }; + + /** + * Initialize degree lists. Each node is placed in its degree lists. Nodes of zero degree are eliminated immediately. Nodes with + * degree >= dense are alsol eliminated and merged into a placeholder node n, a dead element. Thes nodes will appera last in the + * output permutation p. + */ + var _initializeDegreeLists = function (n, cptr, W, degree, elen, w, dense, nv, head, last, next) { + // result + var nel = 0; + // loop columns + for (var i = 0; i < n; i++) { + // degree @ i + var d = W[degree + i]; + // check node i is empty + if (d === 0) { + // element i is dead + W[elen + i] = -2; + nel++; + // i is a root of assembly tree + cptr[i] = -1; + W[w + i] = 0; + } + else if (d > dense) { + // absorb i into element n + W[nv + i] = 0; + // node i is dead + W[elen + i] = -1; + nel++; + cptr[i] = cs_flip(n); + W[nv + n]++; + } + else { + var h = W[head + d]; + if (h != -1) + last[h] = i; + // put node i in degree list d + W[next + i] = W[head + d]; + W[head + d] = i; + } + } + return nel; + }; + + var _wclear = function(mark, lemax, W, w, n) { + if (mark < 2 || (mark + lemax < 0)) { + for (var k = 0; k < n; k++) { + if (W[w + k] !== 0) + W[w + k] = 1; + } + mark = 2 ; + } + // at this point, W [0..n-1] < mark holds + return mark; + }; + + var _diag = function (i, j) { + return i != j; + }; + + return cs_amd; + } + + exports.name = 'cs_amd'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 332 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * This function "flips" its input about the integer -1. + * + * @param {Number} i The value to flip + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_flip = function (i) { + // flip the value + return -i - 2; + }; + + return cs_flip; + } + + exports.name = 'cs_flip'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 333 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * Keeps entries in the matrix when the callback function returns true, removes the entry otherwise + * + * @param {Matrix} a The sparse matrix + * @param {function} callback The callback function, function will be invoked with the following args: + * - The entry row + * - The entry column + * - The entry value + * - The state parameter + * @param {any} other The state + * + * @return The number of nonzero elements in the matrix + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_fkeep = function (a, callback, other) { + // a arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + // columns + var n = asize[1]; + // nonzero items + var nz = 0; + // loop columns + for (var j = 0; j < n; j++) { + // get current location of col j + var p = aptr[j]; + // record new location of col j + aptr[j] = nz; + for (; p < aptr[j+1]; p++) { + // check we need to keep this item + if (callback(aindex[p], j, avalues ? avalues[p] : 1, other)) { + // keep A(i,j) + aindex[nz] = aindex[p]; + // check we need to process values (pattern only) + if (avalues) + avalues[nz] = avalues[p]; + // increment nonzero items + nz++; + } + } + } + // finalize A + aptr[n] = nz; + // trim arrays + aindex.splice(nz, aindex.length - nz); + // check we need to process values (pattern only) + if (avalues) + avalues.splice(nz, avalues.length - nz); + // return number of nonzero items + return (nz); + }; + + return cs_fkeep; + } + + exports.name = 'cs_fkeep'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 334 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * Depth-first search and postorder of a tree rooted at node j + * + * @param {Number} j The tree node + * @param {Number} k + * @param {Array} w The workspace array + * @param {Number} head The index offset within the workspace for the head array + * @param {Number} next The index offset within the workspace for the next array + * @param {Array} post The post ordering array + * @param {Number} stack The index offset within the workspace for the stack array + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_tdfs = function (j, k, w, head, next, post, stack) { + // variables + var top = 0; + // place j on the stack + w[stack] = j; + // while (stack is not empty) + while (top >= 0) { + // p = top of stack + var p = w[stack + top]; + // i = youngest child of p + var i = w[head + p]; + if (i == -1) { + // p has no unordered children left + top--; + // node p is the kth postordered node + post[k++] = p; + } + else { + // remove i from children of p + w[head + p] = w[next + i]; + // increment top + ++top; + // start dfs on child node i + w[stack + top] = i; + } + } + return k; + }; + + return cs_tdfs; + } + + exports.name = 'cs_tdfs'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 335 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var format = __webpack_require__(23).format; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var DenseMatrix = type.DenseMatrix, + SparseMatrix = type.SparseMatrix; + + /** + * Transpose a matrix. All values of the matrix are reflected over its + * main diagonal. Only two dimensional matrices are supported. + * + * Syntax: + * + * math.transpose(x) + * + * Examples: + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.transpose(A); // returns [[1, 4], [2, 5], [3, 6]] + * + * See also: + * + * diag, inv, subset, squeeze + * + * @param {Array | Matrix} x Matrix to be transposed + * @return {Array | Matrix} The transposed matrix + */ + var transpose = typed('transpose', { + + 'Array': function (x) { + // use dense matrix implementation + return transpose(matrix(x)).valueOf(); + }, + + 'Matrix': function (x) { + // matrix size + var size = x.size(); + + // result + var c; + + // process dimensions + switch (size.length) { + case 1: + // vector + c = x.clone(); + break; + + case 2: + // rows and columns + var rows = size[0]; + var columns = size[1]; + + // check columns + if (columns === 0) { + // throw exception + throw new RangeError('Cannot transpose a 2D matrix with no columns (size: ' + format(size) + ')'); + } + + // process storage format + switch (x.storage()) { + case 'dense': + c = _denseTranspose(x, rows, columns); + break; + case 'sparse': + c = _sparseTranspose(x, rows, columns); + break; + } + break; + + default: + // multi dimensional + throw new RangeError('Matrix must be a vector or two dimensional (size: ' + format(this._size) + ')'); + } + return c; + }, + + // scalars + 'any': function (x) { + return clone(x); + } + }); + + var _denseTranspose = function (m, rows, columns) { + // matrix array + var data = m._data; + // transposed matrix data + var transposed = []; + var transposedRow; + // loop columns + for (var j = 0; j < columns; j++) { + // initialize row + transposedRow = transposed[j] = []; + // loop rows + for (var i = 0; i < rows; i++) { + // set data + transposedRow[i] = clone(data[i][j]); + } + } + // return matrix + return new DenseMatrix({ + data: transposed, + size: [columns, rows], + datatype: m._datatype + }); + }; + + var _sparseTranspose = function (m, rows, columns) { + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // result matrices + var cvalues = values ? [] : undefined; + var cindex = []; + var cptr = []; + // row counts + var w = []; + for (var x = 0; x < rows; x++) + w[x] = 0; + // vars + var p, l, j; + // loop values in matrix + for (p = 0, l = index.length; p < l; p++) { + // number of values in row + w[index[p]]++; + } + // cumulative sum + var sum = 0; + // initialize cptr with the cummulative sum of row counts + for (var i = 0; i < rows; i++) { + // update cptr + cptr.push(sum); + // update sum + sum += w[i]; + // update w + w[i] = cptr[i]; + } + // update cptr + cptr.push(sum); + // loop columns + for (j = 0; j < columns; j++) { + // values & index in column + for (var k0 = ptr[j], k1 = ptr[j + 1], k = k0; k < k1; k++) { + // C values & index + var q = w[index[k]]++; + // C[j, i] = A[i, j] + cindex[q] = j; + // check we need to process values (pattern matrix) + if (values) + cvalues[q] = clone(values[k]); + } + } + // return matrix + return new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [columns, rows], + datatype: m._datatype + }); + }; + + transpose.toTex = {1: '\\left(${args[0]}\\right)' + latex.operators['transpose']}; + + return transpose; + } + + exports.name = 'transpose'; + exports.factory = factory; + + +/***/ }, +/* 336 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type) { + + var SparseMatrix = type.SparseMatrix; + + /** + * Permutes a sparse matrix C = P * A * Q + * + * @param {Matrix} a The Matrix A + * @param {Array} pinv The row permutation vector + * @param {Array} q The column permutation vector + * @param {boolean} values Create a pattern matrix (false), values and pattern otherwise + * + * @return {Matrix} C = P * A * Q, null on error + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_permute = function (a, pinv, q, values) { + // a arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + // rows & columns + var m = asize[0]; + var n = asize[1]; + // c arrays + var cvalues = values && a._values ? [] : null; + var cindex = []; // (aptr[n]); + var cptr = []; // (n + 1); + // initialize vars + var nz = 0; + // loop columns + for (var k = 0; k < n; k++) { + // column k of C is column q[k] of A + cptr[k] = nz; + // apply column permutation + var j = q ? (q[k]) : k; + // loop values in column j of A + for (var t0 = aptr[j], t1 = aptr[j + 1], t = t0; t < t1; t++) { + // row i of A is row pinv[i] of C + var r = pinv ? pinv[aindex[t]] : aindex[t]; + // index + cindex[nz] = r; + // check we need to populate values + if (cvalues) + cvalues[nz] = avalues[t]; + // increment number of nonzero elements + nz++; + } + } + // finalize the last column of C + cptr[n] = nz; + // return C matrix + return new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [m, n], + datatype: adt + }); + }; + + return cs_permute; + } + + exports.name = 'cs_permute'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 337 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * Computes the elimination tree of Matrix A (using triu(A)) or the + * elimination tree of A'A without forming A'A. + * + * @param {Matrix} a The A Matrix + * @param {boolean} ata A value of true the function computes the etree of A'A + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_etree = function (a, ata) { + // check inputs + if (!a) + return null; + // a arrays + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + // rows & columns + var m = asize[0]; + var n = asize[1]; + + // allocate result + var parent = []; // (n) + + // allocate workspace + var w = []; // (n + (ata ? m : 0)) + var ancestor = 0; // first n entries in w + var prev = n; // last m entries (ata = true) + + var i, inext; + + // check we are calculating A'A + if (ata) { + // initialize workspace + for (i = 0; i < m; i++) + w[prev + i] = -1; + } + // loop columns + for (var k = 0; k < n; k++) { + // node k has no parent yet + parent[k] = -1; + // nor does k have an ancestor + w[ancestor + k] = -1; + // values in column k + for (var p0 = aptr[k], p1 = aptr[k + 1], p = p0; p < p1; p++) { + // row + var r = aindex[p]; + // node + i = ata ? (w[prev + r]) : r; + // traverse from i to k + for (; i != -1 && i < k; i = inext) { + // inext = ancestor of i + inext = w[ancestor + i]; + // path compression + w[ancestor + i] = k; + // check no anc., parent is k + if (inext == -1) + parent[i] = k; + } + if (ata) + w[prev + r] = k; + } + } + return parent; + }; + + return cs_etree; + } + + exports.name = 'cs_etree'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 338 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_tdfs = load(__webpack_require__(334)); + + /** + * Post order a tree of forest + * + * @param {Array} parent The tree or forest + * @param {Number} n Number of columns + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_post = function (parent, n) { + // check inputs + if (!parent) + return null; + // vars + var k = 0; + var j; + // allocate result + var post = []; // (n); + // workspace, head: first n entries, next: next n entries, stack: last n entries + var w = []; // (3 * n); + var head = 0; + var next = n; + var stack = 2 * n; + // initialize workspace + for (j = 0; j < n; j++) { + // empty linked lists + w[head + j] = -1; + } + // traverse nodes in reverse order + for (j = n-1; j >= 0; j--) { + // check j is a root + if (parent[j] == -1) + continue; + // add j to list of its parent + w[next + j] = w[head + parent[j]]; + w[head + parent[j]] = j; + } + // loop nodes + for (j = 0; j < n; j++) { + // skip j if it is not a root + if (parent[j] != -1) + continue; + // depth-first search + k = cs_tdfs(j, k, w, head, next, post, stack); + } + return post; + }; + + return cs_post; + } + + exports.name = 'cs_post'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 339 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var transpose = load(__webpack_require__(335)); + + var cs_leaf = load(__webpack_require__(340)); + + /** + * Computes the column counts using the upper triangular part of A. + * It transposes A internally, none of the input parameters are modified. + * + * @param {Matrix} a The sparse matrix A + * + * @param {Matrix} ata Count the columns of A'A instead + * + * @return An array of size n of the column counts or null on error + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_counts = function (a, parent, post, ata) { + // check inputs + if (!a || !parent || !post) + return null; + // a matrix arrays + var asize = a._size; + // rows and columns + var m = asize[0]; + var n = asize[1]; + // variables + var i, j, k, J, p, p0, p1; + + // workspace size + var s = 4 * n + (ata ? (n + m + 1) : 0); + // allocate workspace + var w = []; // (s) + var ancestor = 0; // first n entries + var maxfirst = n; // next n entries + var prevleaf = 2 * n; // next n entries + var first = 3 * n; // next n entries + var head = 4 * n; // next n + 1 entries (used when ata is true) + var next = 5 * n + 1; // last entries in workspace + // clear workspace w[0..s-1] + for (k = 0; k < s; k++) + w[k] = -1; + + // allocate result + var colcount = []; // (n); + + // AT = A' + var at = transpose(a); + // at arrays + var tindex = at._index; + var tptr = at._ptr; + + // find w[first + j] + for (k = 0; k < n; k++) { + j = post[k]; + // colcount[j]=1 if j is a leaf + colcount[j] = (w[first + j] == -1) ? 1 : 0; + for (; j != -1 && w[first + j] == -1; j = parent[j]) + w[first + j] = k; + } + + // initialize ata if needed + if (ata) { + // invert post + for (k = 0; k < n; k++) + w[post[k]] = k; + // loop rows (columns in AT) + for (i = 0; i < m; i++) { + // values in column i of AT + for (k = n, p0 = tptr[i], p1 = tptr[i + 1], p = p0; p < p1; p++) + k = Math.min(k, w[tindex[p]]); + // place row i in linked list k + w[next + i] = w[head + k]; + w[head + k] = i; + } + } + + // each node in its own set + for (i = 0; i < n; i++) + w[ancestor + i] = i; + + for (k = 0; k < n; k++) { + // j is the kth node in postordered etree + j = post[k]; + // check j is not a root + if (parent[j] != -1) + colcount[parent[j]]--; + + // J=j for LL'=A case + for (J = (ata ? w[head + k] : j); J != -1; J = (ata ? w[next + J] : -1)) { + for (p = tptr[J]; p < tptr[J+1]; p++) { + i = tindex[p]; + var r = cs_leaf(i, j, w, first, maxfirst, prevleaf, ancestor); + // check A(i,j) is in skeleton + if (r.jleaf >= 1) + colcount[j]++; + // check account for overlap in q + if (r.jleaf == 2) + colcount[r.q]--; + } + } + if (parent[j] != -1) + w[ancestor + j] = parent[j]; + } + // sum up colcount's of each child + for (j = 0; j < n; j++) { + if (parent[j] != -1) + colcount[parent[j]] += colcount[j]; + } + return colcount; + }; + + return cs_counts; + } + + exports.name = 'cs_counts'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 340 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * This function determines if j is a leaf of the ith row subtree. + * Consider A(i,j), node j in ith row subtree and return lca(jprev,j) + * + * @param {Number} i The ith row subtree + * @param {Number} j The node to test + * @param {Array} w The workspace array + * @param {Number} first The index offset within the workspace for the first array + * @param {Number} maxfirst The index offset within the workspace for the maxfirst array + * @param {Number} prevleaf The index offset within the workspace for the prevleaf array + * @param {Number} ancestor The index offset within the workspace for the ancestor array + * + * @return {Object} + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_leaf = function (i, j, w, first, maxfirst, prevleaf, ancestor) { + + var s, sparent, jprev; + + // our result + var jleaf = 0; + var q; + + // check j is a leaf + if (i <= j || w[first + j] <= w[maxfirst + i]) + return (-1); + // update max first[j] seen so far + w[maxfirst + i] = w[first + j]; + // jprev = previous leaf of ith subtree + jprev = w[prevleaf + i]; + w[prevleaf + i] = j; + + // check j is first or subsequent leaf + if (jprev === -1) { + // 1st leaf, q = root of ith subtree + jleaf = 1; + q = i; + } + else { + // update jleaf + jleaf = 2; + // q = least common ancester (jprev,j) + for (q = jprev; q != w[ancestor + q]; q = w[ancestor + q]); + for (s = jprev; s != q; s = sparent) { + // path compression + sparent = w[ancestor + s]; + w[ancestor + s] = q; + } + } + return { + jleaf: jleaf, + q: q + }; + }; + + return cs_leaf; + } + + exports.name = 'cs_leaf'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 341 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var abs = load(__webpack_require__(86)); + var divideScalar = load(__webpack_require__(81)); + var multiply = load(__webpack_require__(84)); + + var larger = load(__webpack_require__(64)); + var largerEq = load(__webpack_require__(342)); + + var cs_spsolve = load(__webpack_require__(343)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Computes the numeric LU factorization of the sparse matrix A. Implements a Left-looking LU factorization + * algorithm that computes L and U one column at a tume. At the kth step, it access columns 1 to k-1 of L + * and column k of A. Given the fill-reducing column ordering q (see parameter s) computes L, U and pinv so + * L * U = A(p, q), where p is the inverse of pinv. + * + * @param {Matrix} m The A Matrix to factorize + * @param {Object} s The symbolic analysis from cs_sqr(). Provides the fill-reducing + * column ordering q + * @param {Number} tol Partial pivoting threshold (1 for partial pivoting) + * + * @return {Number} The numeric LU factorization of A or null + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_lu = function (m, s, tol) { + // validate input + if (!m) + return null; + // m arrays + var size = m._size; + // columns + var n = size[1]; + // symbolic analysis result + var q; + var lnz = 100; + var unz = 100; + // update symbolic analysis parameters + if (s) { + q = s.q; + lnz = s.lnz || lnz; + unz = s.unz || unz; + } + // L arrays + var lvalues = []; // (lnz) + var lindex = []; // (lnz); + var lptr = []; // (n + 1); + // L + var L = new SparseMatrix({ + values: lvalues, + index: lindex, + ptr: lptr, + size: [n, n] + }); + // U arrays + var uvalues = []; // (unz); + var uindex = []; // (unz); + var uptr = []; // (n + 1); + // U + var U = new SparseMatrix({ + values: uvalues, + index: uindex, + ptr: uptr, + size: [n, n] + }); + // inverse of permutation vector + var pinv = []; // (n); + // vars + var i, p; + // allocate arrays + var x = []; // (n); + var xi = []; // (2 * n); + // initialize variables + for (i = 0; i < n; i++) { + // clear workspace + x[i] = 0; + // no rows pivotal yet + pinv[i] = -1; + // no cols of L yet + lptr[i + 1] = 0; + } + // reset number of nonzero elements in L and U + lnz = 0; + unz = 0; + // compute L(:,k) and U(:,k) + for (var k = 0; k < n; k++) { + // update ptr + lptr[k] = lnz; + uptr[k] = unz; + // apply column permutations if needed + var col = q ? q[k] : k; + // solve triangular system, x = L\A(:,col) + var top = cs_spsolve(L, m, col, xi, x, pinv, 1); + // find pivot + var ipiv = -1; + var a = -1; + // loop xi[] from top -> n + for (p = top; p < n; p++) { + // x[i] is nonzero + i = xi[p]; + // check row i is not yet pivotal + if (pinv[i] < 0) { + // absolute value of x[i] + var xabs = abs(x[i]); + // check absoulte value is greater than pivot value + if (larger(xabs, a)) { + // largest pivot candidate so far + a = xabs; + ipiv = i; + } + } + else { + // x(i) is the entry U(pinv[i],k) + uindex[unz] = pinv[i]; + uvalues[unz++] = x[i]; + } + } + // validate we found a valid pivot + if (ipiv == -1 || a <= 0) + return null; + // update actual pivot column, give preference to diagonal value + if (pinv[col] < 0 && largerEq(abs(x[col]), multiply(a, tol))) + ipiv = col; + // the chosen pivot + var pivot = x[ipiv]; + // last entry in U(:,k) is U(k,k) + uindex[unz] = k; + uvalues[unz++] = pivot; + // ipiv is the kth pivot row + pinv[ipiv] = k; + // first entry in L(:,k) is L(k,k) = 1 + lindex[lnz] = ipiv; + lvalues[lnz++] = 1; + // L(k+1:n,k) = x / pivot + for (p = top; p < n; p++) { + // row + i = xi[p]; + // check x(i) is an entry in L(:,k) + if (pinv[i] < 0) { + // save unpermuted row in L + lindex[lnz] = i; + // scale pivot column + lvalues[lnz++] = divideScalar(x[i], pivot); + } + // x[0..n-1] = 0 for next k + x[i] = 0; + } + } + // update ptr + lptr[n] = lnz; + uptr[n] = unz; + // fix row indices of L for final pinv + for (p = 0; p < lnz; p++) + lindex[p] = pinv[lindex[p]]; + // trim arrays + lvalues.splice(lnz, lvalues.length - lnz); + lindex.splice(lnz, lindex.length - lnz); + uvalues.splice(unz, uvalues.length - unz); + uindex.splice(unz, uindex.length - unz); + // return LU factor + return { + L: L, + U: U, + pinv: pinv + }; + }; + + return cs_lu; + } + + exports.name = 'cs_lu'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 342 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether value x is larger or equal to y. + * + * The function returns true when x is larger than y or the relative + * difference between x and y is smaller than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.largerEq(x, y) + * + * Examples: + * + * math.larger(2, 1 + 1); // returns false + * math.largerEq(2, 1 + 1); // returns true + * + * See also: + * + * equal, unequal, smaller, smallerEq, larger, compare + * + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the x is larger or equal to y, else returns false + */ + var largerEq = typed('largerEq', { + + 'boolean, boolean': function (x, y) { + return x >= y; + }, + + 'number, number': function (x, y) { + return x >= y || nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.gte(y) || bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return x.compare(y) !== -1; + }, + + 'Complex, Complex': function () { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return largerEq(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x >= y; + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, largerEq); + break; + default: + // sparse + dense + c = algorithm03(y, x, largerEq, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, largerEq, false); + break; + default: + // dense + dense + c = algorithm13(x, y, largerEq); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return largerEq(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return largerEq(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return largerEq(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, largerEq, false); + break; + default: + c = algorithm14(x, y, largerEq, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, largerEq, true); + break; + default: + c = algorithm14(y, x, largerEq, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, largerEq, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, largerEq, true).valueOf(); + } + }); + + largerEq.toTex = { + 2: '\\left(${args[0]}' + latex.operators['largerEq'] + '${args[1]}\\right)' + }; + + return largerEq; + } + + exports.name = 'largerEq'; + exports.factory = factory; + + +/***/ }, +/* 343 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var divideScalar = load(__webpack_require__(81)); + var multiply = load(__webpack_require__(84)); + var subtract = load(__webpack_require__(77)); + + var cs_reach = load(__webpack_require__(344)); + + /** + * The function cs_spsolve() computes the solution to G * x = bk, where bk is the + * kth column of B. When lo is true, the function assumes G = L is lower triangular with the + * diagonal entry as the first entry in each column. When lo is true, the function assumes G = U + * is upper triangular with the diagonal entry as the last entry in each column. + * + * @param {Matrix} g The G matrix + * @param {Matrix} b The B matrix + * @param {Number} k The kth column in B + * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n + * The first n entries is the nonzero pattern, the last n entries is the stack + * @param {Array} x The soluton to the linear system G * x = b + * @param {Array} pinv The inverse row permutation vector, must be null for L * x = b + * @param {boolean} lo The lower (true) upper triangular (false) flag + * + * @return {Number} The index for the nonzero pattern + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_spsolve = function (g, b, k, xi, x, pinv, lo) { + // g arrays + var gvalues = g._values; + var gindex = g._index; + var gptr = g._ptr; + var gsize = g._size; + // columns + var n = gsize[1]; + // b arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + // vars + var p, p0, p1, q; + // xi[top..n-1] = cs_reach(B(:,k)) + var top = cs_reach(g, b, k, xi, pinv); + // clear x + for (p = top; p < n; p++) + x[xi[p]] = 0; + // scatter b + for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) + x[bindex[p]] = bvalues[p]; + // loop columns + for (var px = top; px < n; px++) { + // x array index for px + var j = xi[px]; + // apply permutation vector (U x = b), j maps to column J of G + var J = pinv ? pinv[j] : j; + // check column J is empty + if (J < 0) + continue; + // column value indeces in G, p0 <= p < p1 + p0 = gptr[J]; + p1 = gptr[J + 1]; + // x(j) /= G(j,j) + x[j] = divideScalar(x[j], gvalues[lo ? p0 : (p1 - 1)]); + // first entry L(j,j) + p = lo ? (p0 + 1) : p0; + q = lo ? (p1) : (p1 - 1); + // loop + for ( ; p < q ; p++) { + // row + var i = gindex[p]; + // x(i) -= G(i,j) * x(j) + x[i] = subtract(x[i], multiply(gvalues[p], x[j])); + } + } + // return top of stack + return top; + }; + + return cs_spsolve; + } + + exports.name = 'cs_spsolve'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 344 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_dfs = load(__webpack_require__(345)); + var cs_marked = load(__webpack_require__(346)); + var cs_mark = load(__webpack_require__(347)); + + /** + * The cs_reach function computes X = Reach(B), where B is the nonzero pattern of the n-by-1 + * sparse column of vector b. The function returns the set of nodes reachable from any node in B. The + * nonzero pattern xi of the solution x to the sparse linear system Lx=b is given by X=Reach(B). + * + * @param {Matrix} g The G matrix + * @param {Matrix} b The B matrix + * @param {Number} k The kth column in B + * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n + * The first n entries is the nonzero pattern, the last n entries is the stack + * @param {Array} pinv The inverse row permutation vector + * + * @return {Number} The index for the nonzero pattern + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_reach = function (g, b, k, xi, pinv) { + // g arrays + var gptr = g._ptr; + var gsize = g._size; + // b arrays + var bindex = b._index; + var bptr = b._ptr; + // columns + var n = gsize[1]; + // vars + var p, p0, p1; + // initialize top + var top = n; + // loop column indeces in B + for (p0 = bptr[k], p1 = bptr[k + 1], p = p0; p < p1; p++) { + // node i + var i = bindex[p]; + // check node i is marked + if (!cs_marked(gptr, i)) { + // start a dfs at unmarked node i + top = cs_dfs(i, g, top, xi, pinv); + } + } + // loop columns from top -> n - 1 + for (p = top; p < n; p++) { + // restore G + cs_mark(gptr, xi[p]); + } + return top; + }; + + return cs_reach; + } + + exports.name = 'cs_reach'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 345 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_marked = load(__webpack_require__(346)); + var cs_mark = load(__webpack_require__(347)); + var cs_unflip = load(__webpack_require__(348)); + + /** + * Depth-first search computes the nonzero pattern xi of the directed graph G (Matrix) starting + * at nodes in B (see cs_reach()). + * + * @param {Number} j The starting node for the DFS algorithm + * @param {Matrix} g The G matrix to search, ptr array modified, then restored + * @param {Number} top Start index in stack xi[top..n-1] + * @param {Number} k The kth column in B + * @param {Array} xi The nonzero pattern xi[top] .. xi[n - 1], an array of size = 2 * n + * The first n entries is the nonzero pattern, the last n entries is the stack + * @param {Array} pinv The inverse row permutation vector, must be null for L * x = b + * + * @return {Number} New value of top + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_dfs = function (j, g, top, xi, pinv) { + // g arrays + var index = g._index; + var ptr = g._ptr; + var size = g._size; + // columns + var n = size[1]; + // vars + var i, p, p2; + // initialize head + var head = 0; + // initialize the recursion stack + xi[0] = j; + // loop + while (head >= 0) { + // get j from the top of the recursion stack + j = xi[head]; + // apply permutation vector + var jnew = pinv ? pinv[j] : j; + // check node j is marked + if (!cs_marked(ptr, j)) { + // mark node j as visited + cs_mark(ptr, j); + // update stack (last n entries in xi) + xi[n + head] = jnew < 0 ? 0 : cs_unflip(ptr[jnew]); + } + // node j done if no unvisited neighbors + var done = 1; + // examine all neighbors of j, stack (last n entries in xi) + for (p = xi[n + head], p2 = jnew < 0 ? 0 : cs_unflip(ptr[jnew+1]); p < p2; p++) { + // consider neighbor node i + i = index[p]; + // check we have visited node i, skip it + if (cs_marked(ptr, i)) + continue; + // pause depth-first search of node j, update stack (last n entries in xi) + xi[n + head] = p; + // start dfs at node i + xi[++head] = i; + // node j is not done + done = 0; + // break, to start dfs(i) + break; + } + // check depth-first search at node j is done + if (done) { + // remove j from the recursion stack + head--; + // and place in the output stack + xi[--top] = j; + } + } + return top; + }; + + return cs_dfs; + } + + exports.name = 'cs_dfs'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 346 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * Checks if the node at w[j] is marked + * + * @param {Array} w The array + * @param {Number} j The array index + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_marked = function (w, j) { + // check node is marked + return w[j] < 0; + }; + + return cs_marked; + } + + exports.name = 'cs_marked'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 347 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_flip = load(__webpack_require__(332)); + + /** + * Marks the node at w[j] + * + * @param {Array} w The array + * @param {Number} j The array index + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_mark = function (w, j) { + // mark w[j] + w[j] = cs_flip(w [j]); + }; + + return cs_mark; + } + + exports.name = 'cs_mark'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 348 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load) { + + var cs_flip = load(__webpack_require__(332)); + + /** + * Flips the value if it is negative of returns the same value otherwise. + * + * @param {Number} i The value to flip + * + * Reference: http://faculty.cse.tamu.edu/davis/publications.html + */ + var cs_unflip = function (i) { + // flip the value if it is negative + return i < 0 ? cs_flip(i) : i; + }; + + return cs_unflip; + } + + exports.name = 'cs_unflip'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 349 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var divideScalar = load(__webpack_require__(81)); + var multiplyScalar = load(__webpack_require__(80)); + var subtract = load(__webpack_require__(77)); + var equalScalar = load(__webpack_require__(48)); + + var solveValidation = load(__webpack_require__(350)); + + var DenseMatrix = type.DenseMatrix; + + /** + * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. + * + * `L * x = b` + * + * Syntax: + * + * math.lsolve(L, b); + * + * Examples: + * + * var a = [[-2, 3], [2, 1]]; + * var b = [11, 9]; + * var x = lsolve(a, b); // [[-5.5], [20]] + * + * See also: + * + * lup, slu, usolve, lusolve + * + * @param {Matrix, Array} L A N x N matrix or array (L) + * @param {Matrix, Array} b A column vector with the b values + * + * @return {DenseMatrix | Array} A column vector with the linear system solution (x) + */ + var lsolve = typed('lsolve', { + + 'SparseMatrix, Array | Matrix': function (m, b) { + // process matrix + return _sparseForwardSubstitution(m, b); + }, + + 'DenseMatrix, Array | Matrix': function (m, b) { + // process matrix + return _denseForwardSubstitution(m, b); + }, + + 'Array, Array | Matrix': function (a, b) { + // create dense matrix from array + var m = matrix(a); + // use matrix implementation + var r = _denseForwardSubstitution(m, b); + // result + return r.valueOf(); + } + }); + + var _denseForwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = solveValidation(m, b, true); + // column vector data + var bdata = b._data; + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // result + var x = []; + // data + var data = m._data; + // forward solve m * x = b, loop columns + for (var j = 0; j < columns; j++) { + // b[j] + var bj = bdata[j][0] || 0; + // x[j] + var xj; + // forward substitution (outer product) avoids inner looping when bj == 0 + if (!equalScalar(bj, 0)) { + // value @ [j, j] + var vjj = data[j][j]; + // check vjj + if (equalScalar(vjj, 0)) { + // system cannot be solved + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + xj = divideScalar(bj, vjj); + // loop rows + for (var i = j + 1; i < rows; i++) { + // update copy of b + bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, data[i][j]))]; + } + } + else { + // zero @ j + xj = 0; + } + // update x + x[j] = [xj]; + } + // return vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + var _sparseForwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = solveValidation(m, b, true); + // column vector data + var bdata = b._data; + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // vars + var i, k; + // result + var x = []; + // forward solve m * x = b, loop columns + for (var j = 0; j < columns; j++) { + // b[j] + var bj = bdata[j][0] || 0; + // forward substitution (outer product) avoids inner looping when bj == 0 + if (!equalScalar(bj, 0)) { + // value @ [j, j] + var vjj = 0; + // lower triangular matrix values & index (column j) + var jvalues = []; + var jindex = []; + // last index in column + var l = ptr[j + 1]; + // values in column, find value @ [j, j] + for (k = ptr[j]; k < l; k++) { + // row + i = index[k]; + // check row (rows are not sorted!) + if (i === j) { + // update vjj + vjj = values[k]; + } + else if (i > j) { + // store lower triangular + jvalues.push(values[k]); + jindex.push(i); + } + } + // at this point we must have a value @ [j, j] + if (equalScalar(vjj, 0)) { + // system cannot be solved, there is no value @ [j, j] + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + var xj = divideScalar(bj, vjj); + // loop lower triangular + for (k = 0, l = jindex.length; k < l; k++) { + // row + i = jindex[k]; + // update copy of b + bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, jvalues[k]))]; + } + // update x + x[j] = [xj]; + } + else { + // update x + x[j] = [0]; + } + } + // return vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + return lsolve; + } + + exports.name = 'lsolve'; + exports.factory = factory; + + +/***/ }, +/* 350 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(39); + + var string = util.string; + var array = util.array; + + var isArray = Array.isArray; + + function factory (type) { + + var DenseMatrix = type.DenseMatrix; + + /** + * Validates matrix and column vector b for backward/forward substitution algorithms. + * + * @param {Matrix} m An N x N matrix + * @param {Array | Matrix} b A column vector + * @param {Boolean} copy Return a copy of vector b + * + * @return {DenseMatrix} Dense column vector b + */ + var solveValidation = function (m, b, copy) { + // matrix size + var size = m.size(); + // validate matrix dimensions + if (size.length !== 2) + throw new RangeError('Matrix must be two dimensional (size: ' + string.format(size) + ')'); + // rows & columns + var rows = size[0]; + var columns = size[1]; + // validate rows & columns + if (rows !== columns) + throw new RangeError('Matrix must be square (size: ' + string.format(size) + ')'); + // vars + var data, i, bdata; + // check b is matrix + if (b && b.isMatrix === true) { + // matrix size + var msize = b.size(); + // vector + if (msize.length === 1) { + // check vector length + if (msize[0] !== rows) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // create data array + data = []; + // matrix data (DenseMatrix) + bdata = b._data; + // loop b data + for (i = 0; i < rows; i++) { + // row array + data[i] = [bdata[i]]; + } + // return Dense Matrix + return new DenseMatrix({ + data: data, + size: [rows, 1], + datatype: b._datatype + }); + } + // two dimensions + if (msize.length === 2) { + // array must be a column vector + if (msize[0] !== rows || msize[1] !== 1) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // check matrix type + if (b.isDenseMatrix === true) { + // check a copy is needed + if (copy) { + // create data array + data = []; + // matrix data (DenseMatrix) + bdata = b._data; + // loop b data + for (i = 0; i < rows; i++) { + // row array + data[i] = [bdata[i][0]]; + } + // return Dense Matrix + return new DenseMatrix({ + data: data, + size: [rows, 1], + datatype: b._datatype + }); + } + // b is already a column vector + return b; + } + // create data array + data = []; + for (i = 0; i < rows; i++) + data[i] = [0]; + // sparse matrix arrays + var values = b._values; + var index = b._index; + var ptr = b._ptr; + // loop values in column 0 + for (var k1 = ptr[1], k = ptr[0]; k < k1; k++) { + // row + i = index[k]; + // add to data + data[i][0] = values[k]; + } + // return Dense Matrix + return new DenseMatrix({ + data: data, + size: [rows, 1], + datatype: b._datatype + }); + } + // throw error + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + // check b is array + if (isArray(b)) { + // size + var asize = array.size(b); + // check matrix dimensions, vector + if (asize.length === 1) { + // check vector length + if (asize[0] !== rows) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // create data array + data = []; + // loop b + for (i = 0; i < rows; i++) { + // row array + data[i] = [b[i]]; + } + // return Dense Matrix + return new DenseMatrix({ + data: data, + size: [rows, 1] + }); + } + if (asize.length === 2) { + // array must be a column vector + if (asize[0] !== rows || asize[1] !== 1) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // create data array + data = []; + // loop b data + for (i = 0; i < rows; i++) { + // row array + data[i] = [b[i][0]]; + } + // return Dense Matrix + return new DenseMatrix({ + data: data, + size: [rows, 1] + }); + } + // throw error + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + }; + + return solveValidation; + } + + exports.factory = factory; + +/***/ }, +/* 351 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isArray = Array.isArray; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var lup = load(__webpack_require__(328)); + var slu = load(__webpack_require__(329)); + var cs_ipvec = load(__webpack_require__(352)); + + var solveValidation = load(__webpack_require__(350)); + + var usolve = load(__webpack_require__(353)); + var lsolve = load(__webpack_require__(349)); + + /** + * Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector. + * + * Syntax: + * + * math.lusolve(A, b) // returns column vector with the solution to the linear system A * x = b + * math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A) + * + * Examples: + * + * var m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]; + * + * var x = math.lusolve(m, [-1, -1, -1, -1]); // x = [[-1], [-0.5], [-1/3], [-0.25]] + * + * var f = math.lup(m); + * var x1 = math.lusolve(f, [-1, -1, -1, -1]); // x1 = [[-1], [-0.5], [-1/3], [-0.25]] + * var x2 = math.lusolve(f, [1, 2, 1, -1]); // x2 = [[1], [1], [1/3], [-0.25]] + * + * var a = [[-2, 3], [2, 1]]; + * var b = [11, 9]; + * var x = lusolve(a, b); // [[-5.5], [20]] + * + * See also: + * + * lup, slu, lsolve, usolve + * + * @param {Matrix | Array | Object} A Invertible Matrix or the Matrix LU decomposition + * @param {Matrix | Array} b Column Vector + * @param {number} [order] The Symbolic Ordering and Analysis order, see slu for details. Matrix must be a SparseMatrix + * @param {Number} [threshold] Partial pivoting threshold (1 for partial pivoting), see slu for details. Matrix must be a SparseMatrix. + * + * @return {DenseMatrix | Array} Column vector with the solution to the linear system A * x = b + */ + var lusolve = typed('lusolve', { + + 'Array, Array | Matrix': function (a, b) { + // convert a to matrix + a = matrix(a); + // matrix lup decomposition + var d = lup(a); + // solve + var x = _lusolve(d.L, d.U, d.p, null, b); + // convert result to array + return x.valueOf(); + }, + + 'DenseMatrix, Array | Matrix': function (a, b) { + // matrix lup decomposition + var d = lup(a); + // solve + return _lusolve(d.L, d.U, d.p, null, b); + }, + + 'SparseMatrix, Array | Matrix': function (a, b) { + // matrix lup decomposition + var d = lup(a); + // solve + return _lusolve(d.L, d.U, d.p, null, b); + }, + + 'SparseMatrix, Array | Matrix, number, number': function (a, b, order, threshold) { + // matrix lu decomposition + var d = slu(a, order, threshold); + // solve + return _lusolve(d.L, d.U, d.p, d.q, b); + }, + + 'Object, Array | Matrix': function (d, b) { + // solve + return _lusolve(d.L, d.U, d.p, d.q, b); + } + }); + + var _toMatrix = function (a) { + // check it is a matrix + if (a && a.isMatrix === true) + return a; + // check array + if (isArray(a)) + return matrix(a); + // throw + throw new TypeError('Invalid Matrix LU decomposition'); + }; + + var _lusolve = function (l, u, p, q, b) { + // verify L, U, P + l = _toMatrix(l); + u = _toMatrix(u); + // validate matrix and vector + b = solveValidation(l, b, false); + // apply row permutations if needed (b is a DenseMatrix) + if (p) + b._data = cs_ipvec(p, b._data); + // use forward substitution to resolve L * y = b + var y = lsolve(l, b); + // use backward substitution to resolve U * x = y + var x = usolve(u, y); + // apply column permutations if needed (x is a DenseMatrix) + if (q) + x._data = cs_ipvec(q, x._data); + // return solution + return x; + }; + + return lusolve; + } + + exports.name = 'lusolve'; + exports.factory = factory; + + +/***/ }, +/* 352 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory () { + + /** + * Permutes a vector; x = P'b. In MATLAB notation, x(p)=b. + * + * @param {Array} p The permutation vector of length n. null value denotes identity + * @param {Array} b The input vector + * + * @return {Array} The output vector x = P'b + */ + var cs_ipvec = function (p, b, n) { + // vars + var k; + var n = b.length; + var x = []; + // check permutation vector was provided, p = null denotes identity + if (p) { + // loop vector + for (k = 0; k < n; k++) { + // apply permutation + x[p[k]] = b[k]; + } + } + else { + // loop vector + for (k = 0; k < n; k++) { + // x[i] = b[i] + x[k] = b[k]; + } + } + return x; + }; + + return cs_ipvec; + } + + exports.name = 'cs_ipvec'; + exports.path = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 353 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var divideScalar = load(__webpack_require__(81)); + var multiplyScalar = load(__webpack_require__(80)); + var subtract = load(__webpack_require__(77)); + var equalScalar = load(__webpack_require__(48)); + + var solveValidation = load(__webpack_require__(350)); + + var DenseMatrix = type.DenseMatrix; + + /** + * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. + * + * `U * x = b` + * + * Syntax: + * + * math.usolve(U, b); + * + * Examples: + * + * var a = [[-2, 3], [2, 1]]; + * var b = [11, 9]; + * var x = usolve(a, b); // [[8], [9]] + * + * See also: + * + * lup, slu, usolve, lusolve + * + * @param {Matrix, Array} U A N x N matrix or array (U) + * @param {Matrix, Array} b A column vector with the b values + * + * @return {DenseMatrix | Array} A column vector with the linear system solution (x) + */ + var usolve = typed('usolve', { + + 'SparseMatrix, Array | Matrix': function (m, b) { + // process matrix + return _sparseBackwardSubstitution(m, b); + }, + + 'DenseMatrix, Array | Matrix': function (m, b) { + // process matrix + return _denseBackwardSubstitution(m, b); + }, + + 'Array, Array | Matrix': function (a, b) { + // create dense matrix from array + var m = matrix(a); + // use matrix implementation + var r = _denseBackwardSubstitution(m, b); + // result + return r.valueOf(); + } + }); + + var _denseBackwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = solveValidation(m, b, true); + // column vector data + var bdata = b._data; + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // result + var x = []; + // arrays + var data = m._data; + // backward solve m * x = b, loop columns (backwards) + for (var j = columns - 1; j >= 0 ; j--) { + // b[j] + var bj = bdata[j][0] || 0; + // x[j] + var xj; + // backward substitution (outer product) avoids inner looping when bj == 0 + if (!equalScalar(bj, 0)) { + // value @ [j, j] + var vjj = data[j][j]; + // check vjj + if (equalScalar(vjj, 0)) { + // system cannot be solved + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + xj = divideScalar(bj, vjj); + // loop rows + for (var i = j - 1; i >= 0; i--) { + // update copy of b + bdata[i] = [subtract(bdata[i][0] || 0, multiplyScalar(xj, data[i][j]))]; + } + } + else { + // zero value @ j + xj = 0; + } + // update x + x[j] = [xj]; + } + // return column vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + var _sparseBackwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = solveValidation(m, b, true); + // column vector data + var bdata = b._data; + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // vars + var i, k; + // result + var x = []; + // backward solve m * x = b, loop columns (backwards) + for (var j = columns - 1; j >= 0 ; j--) { + // b[j] + var bj = bdata[j][0] || 0; + // backward substitution (outer product) avoids inner looping when bj == 0 + if (!equalScalar(bj, 0)) { + // value @ [j, j] + var vjj = 0; + // upper triangular matrix values & index (column j) + var jvalues = []; + var jindex = []; + // first & last indeces in column + var f = ptr[j]; + var l = ptr[j + 1]; + // values in column, find value @ [j, j], loop backwards + for (k = l - 1; k >= f; k--) { + // row + i = index[k]; + // check row + if (i === j) { + // update vjj + vjj = values[k]; + } + else if (i < j) { + // store upper triangular + jvalues.push(values[k]); + jindex.push(i); + } + } + // at this point we must have a value @ [j, j] + if (equalScalar(vjj, 0)) { + // system cannot be solved, there is no value @ [j, j] + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + var xj = divideScalar(bj, vjj); + // loop upper triangular + for (k = 0, l = jindex.length; k < l; k++) { + // row + i = jindex[k]; + // update copy of b + bdata[i] = [subtract(bdata[i][0], multiplyScalar(xj, jvalues[k]))]; + } + // update x + x[j] = [xj]; + } + else { + // update x + x[j] = [0]; + } + } + // return vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + return usolve; + } + + exports.name = 'usolve'; + exports.factory = factory; + + +/***/ }, +/* 354 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(86), + __webpack_require__(51), + __webpack_require__(53), + __webpack_require__(355), + __webpack_require__(357), + __webpack_require__(358), + __webpack_require__(317), + __webpack_require__(359), + __webpack_require__(361), + __webpack_require__(363), + __webpack_require__(364), + __webpack_require__(365), + __webpack_require__(366), + __webpack_require__(367), + __webpack_require__(368), + __webpack_require__(371), + __webpack_require__(374), + __webpack_require__(375), + __webpack_require__(376), + __webpack_require__(84), + __webpack_require__(377), + __webpack_require__(379), + __webpack_require__(82), + __webpack_require__(380), + __webpack_require__(382), + __webpack_require__(369), + __webpack_require__(383), + __webpack_require__(77), + __webpack_require__(78), + __webpack_require__(384), + __webpack_require__(385) + ]; + + +/***/ }, +/* 355 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var unaryMinus = load(__webpack_require__(78)); + var isNegative = load(__webpack_require__(356)); + var matrix = load(__webpack_require__(52)); + + /** + * Calculate the cubic root of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cbrt(x) + * math.cbrt(x, allRoots) + * + * Examples: + * + * math.cbrt(27); // returns 3 + * math.cube(3); // returns 27 + * math.cbrt(-64); // returns -4 + * math.cbrt(math.unit('27 m^3')); // returns Unit 3 m + * math.cbrt([27, 64, 125]); // returns [3, 4, 5] + * + * var x = math.complex('8i'); + * math.cbrt(x); // returns Complex 1.7320508075689 + i + * math.cbrt(x, true); // returns Matrix [ + * // 1.7320508075689 + i + * // -1.7320508075689 + i + * // -2i + * // ] + * + * See also: + * + * square, sqrt, cube + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x + * Value for which to calculate the cubic root. + * @param {boolean} [allRoots] Optional, false by default. Only applicable + * when `x` is a number or complex number. If true, all complex + * roots are returned, if false (default) the principal root is + * returned. + * @return {number | BigNumber | Complex | Unit | Array | Matrix} + * Returns the cubic root of `x` + */ + var cbrt = typed('cbrt', { + 'number': _cbrtNumber, + // note: signature 'number, boolean' is also supported, + // created by typed as it knows how to convert number to Complex + + 'Complex': _cbrtComplex, + + 'Complex, boolean': _cbrtComplex, + + 'BigNumber': function (x) { + return x.cbrt(); + }, + + 'Unit': _cbrtUnit, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since cbrt(0) = 0 + return deepMap(x, cbrt, true); + } + }); + + /** + * Calculate the cubic root for a complex number + * @param {Complex} x + * @param {boolean} [allRoots] If true, the function will return an array + * with all three roots. If false or undefined, + * the principal root is returned. + * @returns {Complex | Array. | Matrix.} Returns the cubic root(s) of x + * @private + */ + function _cbrtComplex(x, allRoots) { + // https://www.wikiwand.com/en/Cube_root#/Complex_numbers + + var arg_3 = x.arg() / 3; + var abs = x.abs(); + + // principal root: + var principal = new type.Complex(_cbrtNumber(abs), 0).mul( + new type.Complex(0, arg_3).exp()); + + if (allRoots) { + var all = [ + principal, + new type.Complex(_cbrtNumber(abs), 0).mul( + new type.Complex(0, arg_3 + Math.PI * 2 / 3).exp()), + new type.Complex(_cbrtNumber(abs), 0).mul( + new type.Complex(0, arg_3 - Math.PI * 2 / 3).exp()) + ]; + + return (config.matrix === 'Array') ? all : matrix(all); + } + else { + return principal; + } + } + + /** + * Calculate the cubic root for a Unit + * @param {Unit} x + * @return {Unit} Returns the cubic root of x + * @private + */ + function _cbrtUnit(x) { + if(x.value && x.value.isComplex) { + var result = x.clone(); + result.value = 1.0; + result = result.pow(1.0/3); // Compute the units + result.value = _cbrtComplex(x.value); // Compute the value + return result; + } + else { + var negate = isNegative(x.value); + if (negate) { + x.value = unaryMinus(x.value); + } + + // TODO: create a helper function for this + var third; + if (x.value && x.value.isBigNumber) { + third = new type.BigNumber(1).div(3); + } + else if (x.value && x.value.isFraction) { + third = new type.Fraction(1, 3); + } + else { + third = 1/3; + } + + var result = x.pow(third); + + if (negate) { + result.value = unaryMinus(result.value); + } + + return result; + } + } + + cbrt.toTex = {1: '\\sqrt[3]{${args[0]}}'}; + + return cbrt; + } + + /** + * Calculate cbrt for a number + * + * Code from es6-shim.js: + * https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1564-L1577 + * + * @param {number} x + * @returns {number | Complex} Returns the cubic root of x + * @private + */ + var _cbrtNumber = Math.cbrt || function (x) { + if (x === 0) { + return x; + } + + var negate = x < 0; + var result; + if (negate) { + x = -x; + } + + if (isFinite(x)) { + result = Math.exp(Math.log(x) / 3); + // from http://en.wikipedia.org/wiki/Cube_root#Numerical_methods + result = (x / (result * result) + (2 * result)) / 3; + } else { + result = x; + } + + return negate ? -result : result; + }; + + exports.name = 'cbrt'; + exports.factory = factory; + + +/***/ }, +/* 356 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Test whether a value is negative: smaller than zero. + * The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`. + * + * The function is evaluated element-wise in case of Array or Matrix input. + * + * Syntax: + * + * math.isNegative(x) + * + * Examples: + * + * math.isNegative(3); // returns false + * math.isNegative(-2); // returns true + * math.isNegative(0); // returns false + * math.isNegative(-0); // returns false + * math.isNegative(math.bignumber(2)); // returns false + * math.isNegative(math.fraction(-2, 5)); // returns true + * math.isNegative('-2'); // returns true + * math.isNegative([2, 0, -3]'); // returns [false, false, true] + * + * See also: + * + * isNumeric, isPositive, isZero, isInteger + * + * @param {number | BigNumber | Fraction | Unit | Array | Matrix} x Value to be tested + * @return {boolean} Returns true when `x` is larger than zero. + * Throws an error in case of an unknown data type. + */ + var isNegative = typed('isNegative', { + 'number': function (x) { + return x < 0; + }, + + 'BigNumber': function (x) { + return x.isNeg() && !x.isZero() && !x.isNaN(); + }, + + 'Fraction': function (x) { + return x.s < 0; // It's enough to decide on the sign + }, + + 'Unit': function (x) { + return isNegative(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, isNegative); + } + }); + + return isNegative; + } + + exports.name = 'isNegative'; + exports.factory = factory; + + +/***/ }, +/* 357 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Round a value towards plus infinity + * If `x` is complex, both real and imaginary part are rounded towards plus infinity. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.ceil(x) + * + * Examples: + * + * math.ceil(3.2); // returns number 4 + * math.ceil(3.8); // returns number 4 + * math.ceil(-4.2); // returns number -4 + * math.ceil(-4.7); // returns number -4 + * + * var c = math.complex(3.2, -2.7); + * math.ceil(c); // returns Complex 4 - 2i + * + * math.ceil([3.2, 3.8, -4.7]); // returns Array [4, 4, -4] + * + * See also: + * + * floor, fix, round + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded + * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value + */ + var ceil = typed('ceil', { + 'number': Math.ceil, + + 'Complex': function (x) { + return x.ceil(); + }, + + 'BigNumber': function (x) { + return x.ceil(); + }, + + 'Fraction': function (x) { + return x.ceil(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since ceil(0) = 0 + return deepMap(x, ceil, true); + } + }); + + ceil.toTex = {1: '\\left\\lceil${args[0]}\\right\\rceil'}; + + return ceil; + } + + exports.name = 'ceil'; + exports.factory = factory; + + +/***/ }, +/* 358 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Compute the cube of a value, `x * x * x`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cube(x) + * + * Examples: + * + * math.cube(2); // returns number 8 + * math.pow(2, 3); // returns number 8 + * math.cube(4); // returns number 64 + * 4 * 4 * 4; // returns number 64 + * + * math.cube([1, 2, 3, 4]); // returns Array [1, 8, 27, 64] + * + * See also: + * + * multiply, square, pow, cbrt + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x Number for which to calculate the cube + * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} Cube of x + */ + var cube = typed('cube', { + 'number': function (x) { + return x * x * x; + }, + + 'Complex': function (x) { + return x.mul(x).mul(x); // Is faster than pow(x, 3) + }, + + 'BigNumber': function (x) { + return x.times(x).times(x); + }, + + 'Fraction': function (x) { + return x.pow(3); // Is faster than mul()mul()mul() + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since cube(0) = 0 + return deepMap(x, cube, true); + }, + + 'Unit': function(x) { + return x.pow(3); + } + }); + + cube.toTex = {1: '\\left(${args[0]}\\right)^3'}; + + return cube; + } + + exports.name = 'cube'; + exports.factory = factory; + + +/***/ }, +/* 359 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var divideScalar = load(__webpack_require__(81)); + var latex = __webpack_require__(32); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Divide two matrices element wise. The function accepts both matrices and + * scalar values. + * + * Syntax: + * + * math.dotDivide(x, y) + * + * Examples: + * + * math.dotDivide(2, 4); // returns 0.5 + * + * a = [[9, 5], [6, 1]]; + * b = [[3, 2], [5, 2]]; + * + * math.dotDivide(a, b); // returns [[3, 2.5], [1.2, 0.5]] + * math.divide(a, b); // returns [[1.75, 0.75], [-1.75, 2.25]] + * + * See also: + * + * divide, multiply, dotMultiply + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Numerator + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Denominator + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Quotient, `x ./ y` + */ + var dotDivide = typed('dotDivide', { + + 'any, any': divideScalar, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse ./ sparse + c = algorithm07(x, y, divideScalar, false); + break; + default: + // sparse ./ dense + c = algorithm02(y, x, divideScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense ./ sparse + c = algorithm03(x, y, divideScalar, false); + break; + default: + // dense ./ dense + c = algorithm13(x, y, divideScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotDivide(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotDivide(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotDivide(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, divideScalar, false); + break; + default: + c = algorithm14(x, y, divideScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, divideScalar, true); + break; + default: + c = algorithm14(y, x, divideScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, divideScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, divideScalar, true).valueOf(); + } + }); + + dotDivide.toTex = { + 2: '\\left(${args[0]}' + latex.operators['dotDivide'] + '${args[1]}\\right)' + }; + + return dotDivide; + } + + exports.name = 'dotDivide'; + exports.factory = factory; + + +/***/ }, +/* 360 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). + * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (S) + * @param {Function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm02 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result (SparseMatrix) + var cvalues = []; + var cindex = []; + var cptr = []; + + // loop columns in b + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + var i = bindex[k]; + // update C(i,j) + var cij = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); + // check for nonzero + if (!eq(cij, zero)) { + // push i & v + cindex.push(i); + cvalues.push(cij); + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + }; + + return algorithm02; + } + + exports.name = 'algorithm02'; + exports.factory = factory; + + +/***/ }, +/* 361 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var multiplyScalar = load(__webpack_require__(80)); + var latex = __webpack_require__(32); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm09 = load(__webpack_require__(362)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Multiply two matrices element wise. The function accepts both matrices and + * scalar values. + * + * Syntax: + * + * math.dotMultiply(x, y) + * + * Examples: + * + * math.dotMultiply(2, 4); // returns 8 + * + * a = [[9, 5], [6, 1]]; + * b = [[3, 2], [5, 2]]; + * + * math.dotMultiply(a, b); // returns [[27, 10], [30, 2]] + * math.multiply(a, b); // returns [[52, 28], [23, 14]] + * + * See also: + * + * multiply, divide, dotDivide + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Left hand value + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Right hand value + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` + */ + var dotMultiply = typed('dotMultiply', { + + 'any, any': multiplyScalar, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse .* sparse + c = algorithm09(x, y, multiplyScalar, false); + break; + default: + // sparse .* dense + c = algorithm02(y, x, multiplyScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense .* sparse + c = algorithm02(x, y, multiplyScalar, false); + break; + default: + // dense .* dense + c = algorithm13(x, y, multiplyScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotMultiply(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotMultiply(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotMultiply(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, multiplyScalar, false); + break; + default: + c = algorithm14(x, y, multiplyScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm11(y, x, multiplyScalar, true); + break; + default: + c = algorithm14(y, x, multiplyScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, multiplyScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, multiplyScalar, true).valueOf(); + } + }); + + dotMultiply.toTex = { + 2: '\\left(${args[0]}' + latex.operators['dotMultiply'] + '${args[1]}\\right)' + }; + + return dotMultiply; + } + + exports.name = 'dotMultiply'; + exports.factory = factory; + + +/***/ }, +/* 362 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix A and invokes the callback function f(Aij, Bij). + * Callback function invoked NZA times, number of nonzero elements in A. + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm09 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var x = cvalues ? [] : undefined; + // marks indicating we have a value in x for a given column + var w = []; + + // vars + var i, j, k, k0, k1; + + // loop columns + for (j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // column mark + var mark = j + 1; + // check we need to process values + if (x) { + // loop B(:,j) + for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + i = bindex[k]; + // update workspace + w[i] = mark; + x[i] = bvalues[k]; + } + } + // loop A(:,j) + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // check we need to process values + if (x) { + // b value @ i,j + var vb = w[i] === mark ? x[i] : zero; + // invoke f + var vc = cf(avalues[k], vb); + // check zero value + if (!eq(vc, zero)) { + // push index + cindex.push(i); + // push value + cvalues.push(vc); + } + } + else { + // push index + cindex.push(i); + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm09; + } + + exports.name = 'algorithm09'; + exports.factory = factory; + + +/***/ }, +/* 363 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var pow = load(__webpack_require__(82)); + var latex = __webpack_require__(32); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculates the power of x to y element wise. + * + * Syntax: + * + * math.dotPow(x, y) + * + * Examples: + * + * math.dotPow(2, 3); // returns number 8 + * + * var a = [[1, 2], [4, 3]]; + * math.dotPow(a, 2); // returns Array [[1, 4], [16, 9]] + * math.pow(a, 2); // returns Array [[9, 8], [16, 17]] + * + * See also: + * + * pow, sqrt, multiply + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x The base + * @param {number | BigNumber | Complex | Unit | Array | Matrix} y The exponent + * @return {number | BigNumber | Complex | Unit | Array | Matrix} The value of `x` to the power `y` + */ + var dotPow = typed('dotPow', { + + 'any, any': pow, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse .^ sparse + c = algorithm07(x, y, pow, false); + break; + default: + // sparse .^ dense + c = algorithm03(y, x, pow, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense .^ sparse + c = algorithm03(x, y, pow, false); + break; + default: + // dense .^ dense + c = algorithm13(x, y, pow); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotPow(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotPow(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotPow(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, dotPow, false); + break; + default: + c = algorithm14(x, y, dotPow, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, dotPow, true); + break; + default: + c = algorithm14(y, x, dotPow, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, dotPow, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, dotPow, true).valueOf(); + } + }); + + dotPow.toTex = { + 2: '\\left(${args[0]}' + latex.operators['dotPow'] + '${args[1]}\\right)' + }; + + return dotPow; + } + + exports.name = 'dotPow'; + exports.factory = factory; + + +/***/ }, +/* 364 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the exponent of a value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.exp(x) + * + * Examples: + * + * math.exp(2); // returns number 7.3890560989306495 + * math.pow(math.e, 2); // returns number 7.3890560989306495 + * math.log(math.exp(2)); // returns number 2 + * + * math.exp([1, 2, 3]); + * // returns Array [ + * // 2.718281828459045, + * // 7.3890560989306495, + * // 20.085536923187668 + * // ] + * + * See also: + * + * log, pow + * + * @param {number | BigNumber | Complex | Array | Matrix} x A number or matrix to exponentiate + * @return {number | BigNumber | Complex | Array | Matrix} Exponent of `x` + */ + var exp = typed('exp', { + 'number': Math.exp, + + 'Complex': function (x) { + return x.exp(); + }, + + 'BigNumber': function (x) { + return x.exp(); + }, + + 'Array | Matrix': function (x) { + // TODO: exp(sparse) should return a dense matrix since exp(0)==1 + return deepMap(x, exp); + } + }); + + exp.toTex = {1: '\\exp\\left(${args[0]}\\right)'}; + + return exp; + } + + exports.name = 'exp'; + exports.factory = factory; + + +/***/ }, +/* 365 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Round a value towards zero. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.fix(x) + * + * Examples: + * + * math.fix(3.2); // returns number 3 + * math.fix(3.8); // returns number 3 + * math.fix(-4.2); // returns number -4 + * math.fix(-4.7); // returns number -4 + * + * var c = math.complex(3.2, -2.7); + * math.fix(c); // returns Complex 3 - 2i + * + * math.fix([3.2, 3.8, -4.7]); // returns Array [3, 3, -4] + * + * See also: + * + * ceil, floor, round + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded + * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value + */ + var fix = typed('fix', { + 'number': function (x) { + return (x > 0) ? Math.floor(x) : Math.ceil(x); + }, + + 'Complex': function (x) { + return new type.Complex( + (x.re > 0) ? Math.floor(x.re) : Math.ceil(x.re), + (x.im > 0) ? Math.floor(x.im) : Math.ceil(x.im) + ); + }, + + 'BigNumber': function (x) { + return x.isNegative() ? x.ceil() : x.floor(); + }, + + 'Fraction': function (x) { + return x.s < 0 ? x.ceil() : x.floor(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since fix(0) = 0 + return deepMap(x, fix, true); + } + }); + + fix.toTex = {1: '\\mathrm{${name}}\\left(${args[0]}\\right)'}; + + return fix; + } + + exports.name = 'fix'; + exports.factory = factory; + + +/***/ }, +/* 366 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Round a value towards minus infinity. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.floor(x) + * + * Examples: + * + * math.floor(3.2); // returns number 3 + * math.floor(3.8); // returns number 3 + * math.floor(-4.2); // returns number -5 + * math.floor(-4.7); // returns number -5 + * + * var c = math.complex(3.2, -2.7); + * math.floor(c); // returns Complex 3 - 3i + * + * math.floor([3.2, 3.8, -4.7]); // returns Array [3, 3, -5] + * + * See also: + * + * ceil, fix, round + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded + * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value + */ + var floor = typed('floor', { + 'number': Math.floor, + + 'Complex': function (x) { + return x.floor(); + }, + + 'BigNumber': function (x) { + return x.floor(); + }, + + 'Fraction': function (x) { + return x.floor(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since floor(0) = 0 + return deepMap(x, floor, true); + } + }); + + floor.toTex = {1: '\\left\\lfloor${args[0]}\\right\\rfloor'}; + + return floor; + } + + exports.name = 'floor'; + exports.factory = factory; + + +/***/ }, +/* 367 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm04 = load(__webpack_require__(55)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculate the greatest common divisor for two or more values or arrays. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.gcd(a, b) + * math.gcd(a, b, c, ...) + * + * Examples: + * + * math.gcd(8, 12); // returns 4 + * math.gcd(-4, 6); // returns 2 + * math.gcd(25, 15, -10); // returns 5 + * + * math.gcd([8, -4], [12, 6]); // returns [4, 2] + * + * See also: + * + * lcm, xgcd + * + * @param {... number | BigNumber | Fraction | Array | Matrix} args Two or more integer numbers + * @return {number | BigNumber | Fraction | Array | Matrix} The greatest common divisor + */ + var gcd = typed('gcd', { + + 'number, number': _gcd, + + 'BigNumber, BigNumber': _gcdBigNumber, + + 'Fraction, Fraction': function (x, y) { + return x.gcd(y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm04(x, y, gcd); + break; + default: + // sparse + dense + c = algorithm01(y, x, gcd, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm01(x, y, gcd, false); + break; + default: + // dense + dense + c = algorithm13(x, y, gcd); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return gcd(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return gcd(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return gcd(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm10(x, y, gcd, false); + break; + default: + c = algorithm14(x, y, gcd, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, gcd, true); + break; + default: + c = algorithm14(y, x, gcd, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, gcd, false).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, gcd, true).valueOf(); + }, + + // TODO: need a smarter notation here + 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { + var res = gcd(a, b); + for (var i = 0; i < args.length; i++) { + res = gcd(res, args[i]); + } + return res; + } + }); + + gcd.toTex = '\\gcd\\left(${args}\\right)'; + + return gcd; + + /** + * Calculate gcd for BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @returns {BigNumber} Returns greatest common denominator of a and b + * @private + */ + function _gcdBigNumber(a, b) { + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function gcd must be integer numbers'); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + var zero = new type.BigNumber(0); + while (!b.isZero()) { + var r = a.mod(b); + a = b; + b = r; + } + return a.lt(zero) ? a.neg() : a; + } + } + + /** + * Calculate gcd for numbers + * @param {number} a + * @param {number} b + * @returns {number} Returns the greatest common denominator of a and b + * @private + */ + function _gcd(a, b) { + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function gcd must be integer numbers'); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + var r; + while (b != 0) { + r = a % b; + a = b; + b = r; + } + return (a < 0) ? -a : a; + } + + exports.name = 'gcd'; + exports.factory = factory; + + +/***/ }, +/* 368 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var flatten = __webpack_require__(40).flatten; + + function factory (type, config, load, typed) { + var abs = load(__webpack_require__(86)); + var add = load(__webpack_require__(53)); + var divide = load(__webpack_require__(81)); + var multiply = load(__webpack_require__(80)); + var sqrt = load(__webpack_require__(369)); + var smaller = load(__webpack_require__(60)); + var isPositive = load(__webpack_require__(370)); + + /** + * Calculate the hypotenusa of a list with values. The hypotenusa is defined as: + * + * hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) + * + * For matrix input, the hypotenusa is calculated for all values in the matrix. + * + * Syntax: + * + * math.hypot(a, b, ...) + * math.hypot([a, b, c, ...]) + * + * Examples: + * + * math.hypot(3, 4); // 5 + * math.hypot(3, 4, 5); // 7.0710678118654755 + * math.hypot([3, 4, 5]); // 7.0710678118654755 + * math.hypot(-2); // 2 + * + * See also: + * + * abs, norm + * + * @param {... number | BigNumber} args + * @return {number | BigNumber} Returns the hypothenusa of the input values. + */ + var hypot = typed('hypot', { + '... number | BigNumber': _hypot, + + 'Array': function (x) { + return hypot.apply(hypot, flatten(x)); + }, + + 'Matrix': function (x) { + return hypot.apply(hypot, flatten(x.toArray())); + } + }); + + /** + * Calculate the hypotenusa for an Array with values + * @param {Array.} args + * @return {number | BigNumber} Returns the result + * @private + */ + function _hypot (args) { + // code based on `hypot` from es6-shim: + // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1619-L1633 + var result = 0; + var largest = 0; + + for (var i = 0; i < args.length; i++) { + var value = abs(args[i]); + if (smaller(largest, value)) { + result = multiply(result, multiply(divide(largest, value), divide(largest, value))); + result = add(result, 1); + largest = value; + } else { + result = add(result, isPositive(value) ? multiply(divide(value, largest), divide(value, largest)) : value); + } + } + + return multiply(largest, sqrt(result)); + } + + hypot.toTex = '\\hypot\\left(${args}\\right)'; + + return hypot; + } + + exports.name = 'hypot'; + exports.factory = factory; + + +/***/ }, +/* 369 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the square root of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sqrt(x) + * + * Examples: + * + * math.sqrt(25); // returns 5 + * math.square(5); // returns 25 + * math.sqrt(-4); // returns Complex 2i + * + * See also: + * + * square, multiply, cube, cbrt + * + * @param {number | BigNumber | Complex | Array | Matrix | Unit} x + * Value for which to calculate the square root. + * @return {number | BigNumber | Complex | Array | Matrix | Unit} + * Returns the square root of `x` + */ + var sqrt = typed('sqrt', { + 'number': _sqrtNumber, + + 'Complex': function (x) { + return x.sqrt(); + }, + + 'BigNumber': function (x) { + if (!x.isNegative() || config.predictable) { + return x.sqrt(); + } + else { + // negative value -> downgrade to number to do complex value computation + return _sqrtNumber(x.toNumber()); + } + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sqrt(0) = 0 + return deepMap(x, sqrt, true); + }, + + 'Unit': function (x) { + // Someday will work for complex units when they are implemented + return x.pow(0.5); + } + + }); + + /** + * Calculate sqrt for a number + * @param {number} x + * @returns {number | Complex} Returns the square root of x + * @private + */ + function _sqrtNumber(x) { + if (x >= 0 || config.predictable) { + return Math.sqrt(x); + } + else { + return new type.Complex(x, 0).sqrt(); + } + } + + sqrt.toTex = {1: '\\sqrt{${args[0]}}'}; + + return sqrt; + } + + exports.name = 'sqrt'; + exports.factory = factory; + + +/***/ }, +/* 370 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Test whether a value is positive: larger than zero. + * The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`. + * + * The function is evaluated element-wise in case of Array or Matrix input. + * + * Syntax: + * + * math.isPositive(x) + * + * Examples: + * + * math.isPositive(3); // returns true + * math.isPositive(-2); // returns false + * math.isPositive(0); // returns false + * math.isPositive(-0); // returns false + * math.isPositive(0.5); // returns true + * math.isPositive(math.bignumber(2)); // returns true + * math.isPositive(math.fraction(-2, 5)); // returns false + * math.isPositive(math.fraction(1,3)); // returns false + * math.isPositive('2'); // returns true + * math.isPositive([2, 0, -3]'); // returns [true, false, false] + * + * See also: + * + * isNumeric, isZero, isNegative, isInteger + * + * @param {number | BigNumber | Fraction | Unit | Array | Matrix} x Value to be tested + * @return {boolean} Returns true when `x` is larger than zero. + * Throws an error in case of an unknown data type. + */ + var isPositive = typed('isPositive', { + 'number': function (x) { + return x > 0; + }, + + 'BigNumber': function (x) { + return !x.isNeg() && !x.isZero() && !x.isNaN(); + }, + + 'Fraction': function (x) { + return x.s > 0 && x.n > 0; + }, + + 'Unit': function (x) { + return isPositive(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, isPositive); + } + }); + + return isPositive; + } + + exports.name = 'isPositive'; + exports.factory = factory; + + +/***/ }, +/* 371 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm06 = load(__webpack_require__(372)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculate the least common multiple for two or more values or arrays. + * + * lcm is defined as: + * + * lcm(a, b) = abs(a * b) / gcd(a, b) + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.lcm(a, b) + * math.lcm(a, b, c, ...) + * + * Examples: + * + * math.lcm(4, 6); // returns 12 + * math.lcm(6, 21); // returns 42 + * math.lcm(6, 21, 5); // returns 210 + * + * math.lcm([4, 6], [6, 21]); // returns [12, 42] + * + * See also: + * + * gcd, xgcd + * + * @param {... number | BigNumber | Array | Matrix} args Two or more integer numbers + * @return {number | BigNumber | Array | Matrix} The least common multiple + */ + var lcm = typed('lcm', { + 'number, number': _lcm, + + 'BigNumber, BigNumber': _lcmBigNumber, + + 'Fraction, Fraction': function (x, y) { + + return x.lcm(y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm06(x, y, lcm); + break; + default: + // sparse + dense + c = algorithm02(y, x, lcm, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm02(x, y, lcm, false); + break; + default: + // dense + dense + c = algorithm13(x, y, lcm); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return lcm(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return lcm(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return lcm(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, lcm, false); + break; + default: + c = algorithm14(x, y, lcm, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm11(y, x, lcm, true); + break; + default: + c = algorithm14(y, x, lcm, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, lcm, false).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, lcm, true).valueOf(); + }, + + // TODO: need a smarter notation here + 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { + var res = lcm(a, b); + for (var i = 0; i < args.length; i++) { + res = lcm(res, args[i]); + } + return res; + } + }); + + lcm.toTex = undefined; // use default template + + return lcm; + + /** + * Calculate lcm for two BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @returns {BigNumber} Returns the least common multiple of a and b + * @private + */ + function _lcmBigNumber(a, b) { + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function lcm must be integer numbers'); + } + + if (a.isZero() || b.isZero()) { + return new type.BigNumber(0); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + // evaluate lcm here inline to reduce overhead + var prod = a.times(b); + while (!b.isZero()) { + var t = b; + b = a.mod(t); + a = t; + } + return prod.div(a).abs(); + } + } + + /** + * Calculate lcm for two numbers + * @param {number} a + * @param {number} b + * @returns {number} Returns the least common multiple of a and b + * @private + */ + function _lcm (a, b) { + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function lcm must be integer numbers'); + } + + if (a == 0 || b == 0) { + return 0; + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + // evaluate lcm here inline to reduce overhead + var t; + var prod = a * b; + while (b != 0) { + t = b; + b = a % t; + a = t; + } + return Math.abs(prod / a); + } + + exports.name = 'lcm'; + exports.factory = factory; + + +/***/ }, +/* 372 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var scatter = __webpack_require__(373); + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked (Anz U Bnz) times, where Anz and Bnz are the nonzero elements in both matrices. + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm06 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bvalues = b._values; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var x = cvalues ? [] : undefined; + // marks indicating we have a value in x for a given column + var w = []; + // marks indicating value in a given row has been updated + var u = []; + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + scatter(a, j, w, x, u, mark, c, cf); + // scatter the values of B(:,j) into workspace + scatter(b, j, w, x, u, mark, c, cf); + // check we need to process values (non pattern matrix) + if (x) { + // initialize first index in j + var k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + var i = cindex[k]; + // check function was invoked on current row (Aij !=0 && Bij != 0) + if (u[i] === mark) { + // value @ i + var v = x[i]; + // check for zero value + if (!eq(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + else { + // initialize first index in j + var p = cptr[j]; + // loop index in j + while (p < cindex.length) { + // row + var r = cindex[p]; + // check function was invoked on current row (Aij !=0 && Bij != 0) + if (u[r] !== mark) { + // remove value @ i, do not increment pointer + cindex.splice(p, 1); + } + else { + // increment pointer + p++; + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm06; + } + + exports.name = 'algorithm06'; + exports.factory = factory; + + +/***/ }, +/* 373 */ +/***/ function(module, exports) { + + 'use strict'; + + module.exports = function scatter(a, j, w, x, u, mark, c, f, inverse, update, value) { + // a arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + // c arrays + var cindex = c._index; + + // vars + var k, k0, k1, i; + + // check we need to process values (pattern matrix) + if (x) { + // values in j + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // check value exists in current j + if (w[i] !== mark) { + // i is new entry in j + w[i] = mark; + // add i to pattern of C + cindex.push(i); + // x(i) = A, check we need to call function this time + if (update) { + // copy value to workspace calling callback function + x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]); + // function was called on current row + u[i] = mark; + } + else { + // copy value to workspace + x[i] = avalues[k]; + } + } + else { + // i exists in C already + x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]); + // function was called on current row + u[i] = mark; + } + } + } + else { + // values in j + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // check value exists in current j + if (w[i] !== mark) { + // i is new entry in j + w[i] = mark; + // add i to pattern of C + cindex.push(i); + } + else { + // indicate function was called on current row + u[i] = mark; + } + } + } + }; + + +/***/ }, +/* 374 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var divideScalar = load(__webpack_require__(81)); + + /** + * Calculate the logarithm of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.log(x) + * math.log(x, base) + * + * Examples: + * + * math.log(3.5); // returns 1.252762968495368 + * math.exp(math.log(2.4)); // returns 2.4 + * + * math.pow(10, 4); // returns 10000 + * math.log(10000, 10); // returns 4 + * math.log(10000) / math.log(10); // returns 4 + * + * math.log(1024, 2); // returns 10 + * math.pow(2, 10); // returns 1024 + * + * See also: + * + * exp, log10 + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * Value for which to calculate the logarithm. + * @param {number | BigNumber | Complex} [base=e] + * Optional base for the logarithm. If not provided, the natural + * logarithm of `x` is calculated. + * @return {number | BigNumber | Complex | Array | Matrix} + * Returns the logarithm of `x` + */ + var log = typed('log', { + 'number': function (x) { + if (x >= 0 || config.predictable) { + return Math.log(x); + } + else { + // negative value -> complex value computation + return new type.Complex(x, 0).log(); + } + }, + + 'Complex': function (x) { + return x.log(); + }, + + 'BigNumber': function (x) { + if (!x.isNegative() || config.predictable) { + return x.ln(); + } + else { + // downgrade to number, return Complex valued result + return new type.Complex(x.toNumber(), 0).log(); + } + }, + + 'Array | Matrix': function (x) { + return deepMap(x, log); + }, + + 'any, any': function (x, base) { + // calculate logarithm for a specified base, log(x, base) + return divideScalar(log(x), log(base)); + } + }); + + log.toTex = { + 1: '\\ln\\left(${args[0]}\\right)', + 2: '\\log_{${args[1]}}\\left(${args[0]}\\right)' + }; + + return log; + } + + exports.name = 'log'; + exports.factory = factory; + + +/***/ }, +/* 375 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the 10-base logarithm of a value. This is the same as calculating `log(x, 10)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.log10(x) + * + * Examples: + * + * math.log10(0.00001); // returns -5 + * math.log10(10000); // returns 4 + * math.log(10000) / math.log(10); // returns 4 + * math.pow(10, 4); // returns 10000 + * + * See also: + * + * exp, log + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * Value for which to calculate the logarithm. + * @return {number | BigNumber | Complex | Array | Matrix} + * Returns the 10-base logarithm of `x` + */ + var log10 = typed('log10', { + 'number': function (x) { + if (x >= 0 || config.predictable) { + return _log10(x); + } + else { + // negative value -> complex value computation + return new type.Complex(x, 0).log().div(Math.LN10); + } + }, + + 'Complex': function (x) { + return new type.Complex(x).log().div(Math.LN10); + }, + + 'BigNumber': function (x) { + if (!x.isNegative() || config.predictable) { + return x.log(); + } + else { + // downgrade to number, return Complex valued result + return new type.Complex(x.toNumber(), 0).log().div(Math.LN10); + } + }, + + 'Array | Matrix': function (x) { + return deepMap(x, log10); + } + }); + + log10.toTex = {1: '\\log_{10}\\left(${args[0]}\\right)'}; + + return log10; + } + + /** + * Calculate the 10-base logarithm of a number + * @param {number} x + * @return {number} + * @private + */ + var _log10 = Math.log10 || function (x) { + return Math.log(x) / Math.LN10; + }; + + exports.name = 'log10'; + exports.factory = factory; + + + +/***/ }, +/* 376 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var latex = __webpack_require__(32); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm03 = load(__webpack_require__(61)); + var algorithm05 = load(__webpack_require__(79)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculates the modulus, the remainder of an integer division. + * + * For matrices, the function is evaluated element wise. + * + * The modulus is defined as: + * + * x - y * floor(x / y) + * + * See http://en.wikipedia.org/wiki/Modulo_operation. + * + * Syntax: + * + * math.mod(x, y) + * + * Examples: + * + * math.mod(8, 3); // returns 2 + * math.mod(11, 2); // returns 1 + * + * function isOdd(x) { + * return math.mod(x, 2) != 0; + * } + * + * isOdd(2); // returns false + * isOdd(3); // returns true + * + * See also: + * + * divide + * + * @param {number | BigNumber | Fraction | Array | Matrix} x Dividend + * @param {number | BigNumber | Fraction | Array | Matrix} y Divisor + * @return {number | BigNumber | Fraction | Array | Matrix} Returns the remainder of `x` divided by `y`. + */ + var mod = typed('mod', { + + 'number, number': _mod, + + 'BigNumber, BigNumber': function (x, y) { + return y.isZero() ? x : x.mod(y); + }, + + 'Fraction, Fraction': function (x, y) { + return x.mod(y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // mod(sparse, sparse) + c = algorithm05(x, y, mod, false); + break; + default: + // mod(sparse, dense) + c = algorithm02(y, x, mod, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // mod(dense, sparse) + c = algorithm03(x, y, mod, false); + break; + default: + // mod(dense, dense) + c = algorithm13(x, y, mod); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return mod(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return mod(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return mod(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, mod, false); + break; + default: + c = algorithm14(x, y, mod, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, mod, true); + break; + default: + c = algorithm14(y, x, mod, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, mod, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, mod, true).valueOf(); + } + }); + + mod.toTex = { + 2: '\\left(${args[0]}' + latex.operators['mod'] + '${args[1]}\\right)' + }; + + return mod; + + /** + * Calculate the modulus of two numbers + * @param {number} x + * @param {number} y + * @returns {number} res + * @private + */ + function _mod(x, y) { + if (y > 0) { + // We don't use JavaScript's % operator here as this doesn't work + // correctly for x < 0 and x == 0 + // see http://en.wikipedia.org/wiki/Modulo_operation + return x - y * Math.floor(x / y); + } + else if (y === 0) { + return x; + } + else { // y < 0 + // TODO: implement mod for a negative divisor + throw new Error('Cannot calculate mod for a negative divisor'); + } + } + } + + exports.name = 'mod'; + exports.factory = factory; + + +/***/ }, +/* 377 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var abs = load(__webpack_require__(86)); + var add = load(__webpack_require__(51)); + var pow = load(__webpack_require__(82)); + var sqrt = load(__webpack_require__(369)); + var multiply = load(__webpack_require__(84)); + var equalScalar = load(__webpack_require__(48)); + var larger = load(__webpack_require__(64)); + var smaller = load(__webpack_require__(60)); + var matrix = load(__webpack_require__(52)); + var trace = load(__webpack_require__(378)); + var transpose = load(__webpack_require__(335)); + + + /** + * Calculate the norm of a number, vector or matrix. + * + * The second parameter p is optional. If not provided, it defaults to 2. + * + * Syntax: + * + * math.norm(x) + * math.norm(x, p) + * + * Examples: + * + * math.abs(-3.5); // returns 3.5 + * math.norm(-3.5); // returns 3.5 + * + * math.norm(math.complex(3, -4)); // returns 5 + * + * math.norm([1, 2, -3], Infinity); // returns 3 + * math.norm([1, 2, -3], -Infinity); // returns 1 + * + * math.norm([3, 4], 2); // returns 5 + * + * math.norm([[1, 2], [3, 4]], 1) // returns 6 + * math.norm([[1, 2], [3, 4]], 'inf'); // returns 7 + * math.norm([[1, 2], [3, 4]], 'fro'); // returns 5.477225575051661 + * + * See also: + * + * abs, hypot + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * Value for which to calculate the norm + * @param {number | BigNumber | string} [p=2] + * Vector space. + * Supported numbers include Infinity and -Infinity. + * Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) + * @return {number | BigNumber} the p-norm + */ + var norm = typed('norm', { + 'number': Math.abs, + + 'Complex': function (x) { + return x.abs(); + }, + + 'BigNumber': function (x) { + // norm(x) = abs(x) + return x.abs(); + }, + + 'boolean | null' : function (x) { + // norm(x) = abs(x) + return Math.abs(x); + }, + + 'Array': function (x) { + return _norm(matrix(x), 2); + }, + + 'Matrix': function (x) { + return _norm(x, 2); + }, + + 'number | Complex | BigNumber | boolean | null, number | BigNumber | string': function (x) { + // ignore second parameter, TODO: remove the option of second parameter for these types + return norm(x); + }, + + 'Array, number | BigNumber | string': function (x, p) { + return _norm(matrix(x), p); + }, + + 'Matrix, number | BigNumber | string': function (x, p) { + return _norm(x, p); + } + }); + + /** + * Calculate the norm for an array + * @param {Array} x + * @param {number | string} p + * @returns {number} Returns the norm + * @private + */ + function _norm (x, p) { + // size + var sizeX = x.size(); + + // check if it is a vector + if (sizeX.length == 1) { + // check p + if (p === Number.POSITIVE_INFINITY || p === 'inf') { + // norm(x, Infinity) = max(abs(x)) + var pinf = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + var v = abs(value); + if (larger(v, pinf)) + pinf = v; + }, + true); + return pinf; + } + if (p === Number.NEGATIVE_INFINITY || p === '-inf') { + // norm(x, -Infinity) = min(abs(x)) + var ninf; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + var v = abs(value); + if (!ninf || smaller(v, ninf)) + ninf = v; + }, + true); + return ninf || 0; + } + if (p === 'fro') { + return _norm(x, 2); + } + if (typeof p === 'number' && !isNaN(p)) { + // check p != 0 + if (!equalScalar(p, 0)) { + // norm(x, p) = sum(abs(xi) ^ p) ^ 1/p + var n = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + n = add(pow(abs(value), p), n); + }, + true); + return pow(n, 1 / p); + } + return Number.POSITIVE_INFINITY; + } + // invalid parameter value + throw new Error('Unsupported parameter value'); + } + // MxN matrix + if (sizeX.length == 2) { + // check p + if (p === 1) { + // norm(x) = the largest column sum + var c = []; + // result + var maxc = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value, index) { + var j = index[1]; + var cj = add(c[j] || 0, abs(value)); + if (larger(cj, maxc)) + maxc = cj; + c[j] = cj; + }, + true); + return maxc; + } + if (p === Number.POSITIVE_INFINITY || p === 'inf') { + // norm(x) = the largest row sum + var r = []; + // result + var maxr = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value, index) { + var i = index[0]; + var ri = add(r[i] || 0, abs(value)); + if (larger(ri, maxr)) + maxr = ri; + r[i] = ri; + }, + true); + return maxr; + } + if (p === 'fro') { + // norm(x) = sqrt(sum(diag(x'x))) + return sqrt(trace(multiply(transpose(x), x))); + } + if (p === 2) { + // not implemented + throw new Error('Unsupported parameter value, missing implementation of matrix singular value decomposition'); + } + // invalid parameter value + throw new Error('Unsupported parameter value'); + } + } + + norm.toTex = { + 1: '\\left\\|${args[0]}\\right\\|', + 2: undefined // use default template + }; + + return norm; + } + + exports.name = 'norm'; + exports.factory = factory; + + +/***/ }, +/* 378 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var format = __webpack_require__(23).format; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + var add = load(__webpack_require__(51)); + + /** + * Calculate the trace of a matrix: the sum of the elements on the main + * diagonal of a square matrix. + * + * Syntax: + * + * math.trace(x) + * + * Examples: + * + * math.trace([[1, 2], [3, 4]]); // returns 5 + * + * var A = [ + * [1, 2, 3], + * [-1, 2, 3], + * [2, 0, 3] + * ] + * math.trace(A); // returns 6 + * + * See also: + * + * diag + * + * @param {Array | Matrix} x A matrix + * + * @return {number} The trace of `x` + */ + var trace = typed('trace', { + + 'Array': function (x) { + // use dense matrix implementation + return trace(matrix(x)); + }, + + 'Matrix': function (x) { + // result + var c; + // process storage format + switch (x.storage()) { + case 'dense': + c = _denseTrace(x); + break; + case 'sparse': + c = _sparseTrace(x); + break; + } + return c; + }, + + 'any': clone + }); + + var _denseTrace = function (m) { + // matrix size & data + var size = m._size; + var data = m._data; + + // process dimensions + switch (size.length) { + case 1: + // vector + if (size[0] == 1) { + // return data[0] + return clone(data[0]); + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + case 2: + // two dimensional + var rows = size[0]; + var cols = size[1]; + if (rows === cols) { + // calulate sum + var sum = 0; + // loop diagonal + for (var i = 0; i < rows; i++) + sum = add(sum, data[i][i]); + // return trace + return sum; + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + default: + // multi dimensional + throw new RangeError('Matrix must be two dimensional (size: ' + format(size) + ')'); + } + }; + + var _sparseTrace = function (m) { + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + var size = m._size; + // check dimensions + var rows = size[0]; + var columns = size[1]; + // matrix must be square + if (rows === columns) { + // calulate sum + var sum = 0; + // check we have data (avoid looping columns) + if (values.length > 0) { + // loop columns + for (var j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + var i = index[k]; + // check row + if (i === j) { + // accumulate value + sum = add(sum, values[k]); + // exit loop + break; + } + if (i > j) { + // exit loop, no value on the diagonal for column j + break; + } + } + } + } + // return trace + return sum; + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + }; + + trace.toTex = {1: '\\mathrm{tr}\\left(${args[0]}\\right)'}; + + return trace; + } + + exports.name = 'trace'; + exports.factory = factory; + + +/***/ }, +/* 379 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm02 = load(__webpack_require__(360)); + var algorithm06 = load(__webpack_require__(372)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculate the nth root of a value. + * The principal nth root of a positive real number A, is the positive real + * solution of the equation + * + * x^root = A + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.nthRoot(a) + * math.nthRoot(a, root) + * + * Examples: + * + * math.nthRoot(9, 2); // returns 3, as 3^2 == 9 + * math.sqrt(9); // returns 3, as 3^2 == 9 + * math.nthRoot(64, 3); // returns 4, as 4^3 == 64 + * + * See also: + * + * sqrt, pow + * + * @param {number | BigNumber | Array | Matrix | Complex} a + * Value for which to calculate the nth root + * @param {number | BigNumber} [root=2] The root. + * @return {number | Complex | Array | Matrix} Returns the nth root of `a` + */ + var nthRoot = typed('nthRoot', { + + 'number': function (x) { + return _nthRoot(x, 2); + }, + 'number, number': _nthRoot, + + 'BigNumber': function (x) { + return _bigNthRoot(x, new type.BigNumber(2)); + }, + 'Complex' : function(x) { + return _nthComplexRoot(x, 2); + }, + 'Complex, number' : _nthComplexRoot, + 'BigNumber, BigNumber': _bigNthRoot, + + 'Array | Matrix': function (x) { + return nthRoot(x, 2); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // density must be one (no zeros in matrix) + if (y.density() === 1) { + // sparse + sparse + c = algorithm06(x, y, nthRoot); + } + else { + // throw exception + throw new Error('Root must be non-zero'); + } + break; + default: + // sparse + dense + c = algorithm02(y, x, nthRoot, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // density must be one (no zeros in matrix) + if (y.density() === 1) { + // dense + sparse + c = algorithm01(x, y, nthRoot, false); + } + else { + // throw exception + throw new Error('Root must be non-zero'); + } + break; + default: + // dense + dense + c = algorithm13(x, y, nthRoot); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return nthRoot(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return nthRoot(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return nthRoot(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, nthRoot, false); + break; + default: + c = algorithm14(x, y, nthRoot, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + // density must be one (no zeros in matrix) + if (y.density() === 1) { + // sparse - scalar + c = algorithm11(y, x, nthRoot, true); + } + else { + // throw exception + throw new Error('Root must be non-zero'); + } + break; + default: + c = algorithm14(y, x, nthRoot, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return nthRoot(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return nthRoot(x, matrix(y)).valueOf(); + } + }); + + nthRoot.toTex = {2: '\\sqrt[${args[1]}]{${args[0]}}'}; + + return nthRoot; + + /** + * Calculate the nth root of a for BigNumbers, solve x^root == a + * http://rosettacode.org/wiki/Nth_root#JavaScript + * @param {BigNumber} a + * @param {BigNumber} root + * @private + */ + function _bigNthRoot(a, root) { + var precision = type.BigNumber.precision; + var Big = type.BigNumber.clone({precision: precision + 2}); + var zero = new type.BigNumber(0); + + var one = new Big(1); + var inv = root.isNegative(); + if (inv) { + root = root.neg(); + } + + if (root.isZero()) { + throw new Error('Root must be non-zero'); + } + if (a.isNegative() && !root.abs().mod(2).equals(1)) { + throw new Error('Root must be odd when a is negative.'); + } + + // edge cases zero and infinity + if (a.isZero()) { + return inv ? new Big(Infinity) : 0; + } + if (!a.isFinite()) { + return inv ? zero : a; + } + + var x = a.abs().pow(one.div(root)); + // If a < 0, we require that root is an odd integer, + // so (-1) ^ (1/root) = -1 + x = a.isNeg() ? x.neg() : x; + return new type.BigNumber((inv ? one.div(x) : x).toPrecision(precision)); + } + } + + /** + * Calculate the nth root of a, solve x^root == a + * http://rosettacode.org/wiki/Nth_root#JavaScript + * @param {number} a + * @param {number} root + * @private + */ + function _nthRoot(a, root) { + var inv = root < 0; + if (inv) { + root = -root; + } + + if (root === 0) { + throw new Error('Root must be non-zero'); + } + if (a < 0 && (Math.abs(root) % 2 != 1)) { + throw new Error('Root must be odd when a is negative.'); + } + + // edge cases zero and infinity + if (a == 0) { + return inv ? Infinity : 0; + } + if (!isFinite(a)) { + return inv ? 0 : a; + } + + var x = Math.pow(Math.abs(a), 1/root); + // If a < 0, we require that root is an odd integer, + // so (-1) ^ (1/root) = -1 + x = a < 0 ? -x : x; + return inv ? 1 / x : x; + + // Very nice algorithm, but fails with nthRoot(-2, 3). + // Newton's method has some well-known problems at times: + // https://en.wikipedia.org/wiki/Newton%27s_method#Failure_analysis + /* + var x = 1; // Initial guess + var xPrev = 1; + var i = 0; + var iMax = 10000; + do { + var delta = (a / Math.pow(x, root - 1) - x) / root; + xPrev = x; + x = x + delta; + i++; + } + while (xPrev !== x && i < iMax); + + if (xPrev !== x) { + throw new Error('Function nthRoot failed to converge'); + } + + return inv ? 1 / x : x; + */ + } + + /** + * Calculate the nth root of a Complex Number a using De Moviers Theorem. + * @param {Complex} a + * @param {number} root + * @return {Array} array or n Complex Roots in Polar Form. + */ + function _nthComplexRoot(a, root) { + if (root < 0) throw new Error('Root must be greater than zero'); + if (root === 0) throw new Error('Root must be non-zero'); + if (root % 1 !== 0) throw new Error('Root must be an integer'); + var arg = a.arg(); + var abs = a.abs(); + var roots = []; + var r = Math.pow(abs, 1/root); + for(var k = 0; k < root; k++) { + roots.push({r: r, phi: (arg + 2 * Math.PI * k)/root}); + } + return roots; + } + + exports.name = 'nthRoot'; + exports.factory = factory; + + +/***/ }, +/* 380 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var toFixed = __webpack_require__(6).toFixed; + var deepMap = __webpack_require__(19); + + var NO_INT = 'Number of decimals in function round must be an integer'; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + var equalScalar = load(__webpack_require__(48)); + var zeros = load(__webpack_require__(381)); + + var algorithm11 = load(__webpack_require__(85)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Round a value towards the nearest integer. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.round(x) + * math.round(x, n) + * + * Examples: + * + * math.round(3.2); // returns number 3 + * math.round(3.8); // returns number 4 + * math.round(-4.2); // returns number -4 + * math.round(-4.7); // returns number -5 + * math.round(math.pi, 3); // returns number 3.142 + * math.round(123.45678, 2); // returns number 123.46 + * + * var c = math.complex(3.2, -2.7); + * math.round(c); // returns Complex 3 - 3i + * + * math.round([3.2, 3.8, -4.7]); // returns Array [3, 4, -5] + * + * See also: + * + * ceil, fix, floor + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded + * @param {number | BigNumber | Array} [n=0] Number of decimals + * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value + */ + var round = typed('round', { + + 'number': Math.round, + + 'number, number': function (x, n) { + if (!isInteger(n)) {throw new TypeError(NO_INT);} + if (n < 0 || n > 15) {throw new Error('Number of decimals in function round must be in te range of 0-15');} + + return _round(x, n); + }, + + 'Complex': function (x) { + return x.round(); + }, + + 'Complex, number': function (x, n) { + if (n % 1) {throw new TypeError(NO_INT);} + + return x.round(n); + }, + + 'Complex, BigNumber': function (x, n) { + if (!n.isInteger()) {throw new TypeError(NO_INT);} + + var _n = n.toNumber(); + return x.round(_n); + }, + + 'number, BigNumber': function (x, n) { + if (!n.isInteger()) {throw new TypeError(NO_INT);} + + return new type.BigNumber(x).toDecimalPlaces(n.toNumber()); + }, + + 'BigNumber': function (x) { + return x.toDecimalPlaces(0); + }, + + 'BigNumber, BigNumber': function (x, n) { + if (!n.isInteger()) {throw new TypeError(NO_INT);} + + return x.toDecimalPlaces(n.toNumber()); + }, + + 'Fraction': function (x) { + return x.round(); + }, + + 'Fraction, number': function (x, n) { + if (n % 1) {throw new TypeError(NO_INT);} + return x.round(n); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since round(0) = 0 + return deepMap(x, round, true); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, round, false); + break; + default: + c = algorithm14(x, y, round, false); + break; + } + return c; + }, + + 'number | Complex | BigNumber, Matrix': function (x, y) { + // check scalar is zero + if (!equalScalar(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, round, true); + break; + default: + c = algorithm14(y, x, round, true); + break; + } + return c; + } + // do not execute algorithm, result will be a zero matrix + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, round, false).valueOf(); + }, + + 'number | Complex | BigNumber, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, round, true).valueOf(); + } + }); + + round.toTex = { + 1: '\\left\\lfloor${args[0]}\\right\\rceil', + 2: undefined // use default template + }; + + return round; + } + + /** + * round a number to the given number of decimals, or to zero if decimals is + * not provided + * @param {number} value + * @param {number} decimals number of decimals, between 0 and 15 (0 by default) + * @return {number} roundedValue + * @private + */ + function _round (value, decimals) { + return parseFloat(toFixed(value, decimals)); + } + + exports.name = 'round'; + exports.factory = factory; + + +/***/ }, +/* 381 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var resize = __webpack_require__(40).resize; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Create a matrix filled with zeros. The created matrix can have one or + * multiple dimensions. + * + * Syntax: + * + * math.zeros(m) + * math.zeros(m, format) + * math.zeros(m, n) + * math.zeros(m, n, format) + * math.zeros([m, n]) + * math.zeros([m, n], format) + * + * Examples: + * + * math.zeros(3); // returns [0, 0, 0] + * math.zeros(3, 2); // returns [[0, 0], [0, 0], [0, 0]] + * math.zeros(3, 'dense'); // returns [0, 0, 0] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.zeros(math.size(A)); // returns [[0, 0, 0], [0, 0, 0]] + * + * See also: + * + * ones, eye, size, range + * + * @param {...number | Array} size The size of each dimension of the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Array | Matrix} A matrix filled with zeros + */ + var zeros = typed('zeros', { + '': function () { + return (config.matrix === 'Array') + ? _zeros([]) + : _zeros([], 'default'); + }, + + // math.zeros(m, n, p, ..., format) + // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this + '...number | BigNumber | string': function (size) { + var last = size[size.length - 1]; + if (typeof last === 'string') { + var format = size.pop(); + return _zeros(size, format); + } + else if (config.matrix === 'Array') { + return _zeros(size); + } + else { + return _zeros(size, 'default'); + } + }, + + 'Array': _zeros, + + 'Matrix': function (size) { + var format = size.storage(); + return _zeros(size.valueOf(), format); + }, + + 'Array | Matrix, string': function (size, format) { + return _zeros (size.valueOf(), format); + } + }); + + zeros.toTex = undefined; // use default template + + return zeros; + + /** + * Create an Array or Matrix with zeros + * @param {Array} size + * @param {string} [format='default'] + * @return {Array | Matrix} + * @private + */ + function _zeros(size, format) { + var hasBigNumbers = _normalize(size); + var defaultValue = hasBigNumbers ? new type.BigNumber(0) : 0; + _validate(size); + + if (format) { + // return a matrix + var m = matrix(format); + if (size.length > 0) { + return m.resize(size, defaultValue); + } + return m; + } + else { + // return an Array + var arr = []; + if (size.length > 0) { + return resize(arr, size, defaultValue); + } + return arr; + } + } + + // replace BigNumbers with numbers, returns true if size contained BigNumbers + function _normalize(size) { + var hasBigNumbers = false; + size.forEach(function (value, index, arr) { + if (value && value.isBigNumber === true) { + hasBigNumbers = true; + arr[index] = value.toNumber(); + } + }); + return hasBigNumbers; + } + + // validate arguments + function _validate (size) { + size.forEach(function (value) { + if (typeof value !== 'number' || !isInteger(value) || value < 0) { + throw new Error('Parameters in function zeros must be positive integers'); + } + }); + } + } + + // TODO: zeros contains almost the same code as ones. Reuse this? + + exports.name = 'zeros'; + exports.factory = factory; + + +/***/ }, +/* 382 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var number = __webpack_require__(6); + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Compute the sign of a value. The sign of a value x is: + * + * - 1 when x > 1 + * - -1 when x < 0 + * - 0 when x == 0 + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sign(x) + * + * Examples: + * + * math.sign(3.5); // returns 1 + * math.sign(-4.2); // returns -1 + * math.sign(0); // returns 0 + * + * math.sign([3, 5, -2, 0, 2]); // returns [1, 1, -1, 0, 1] + * + * See also: + * + * abs + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x + * The number for which to determine the sign + * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}e + * The sign of `x` + */ + var sign = typed('sign', { + 'number': number.sign, + + 'Complex': function (x) { + return x.sign(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(x.cmp(0)); + }, + + 'Fraction': function (x) { + return new type.Fraction(x.s, 1); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sign(0) = 0 + return deepMap(x, sign, true); + }, + + 'Unit': function(x) { + return sign(x.value); + } + }); + + sign.toTex = {1: '\\mathrm{${name}}\\left(${args[0]}\\right)'}; + + return sign; + } + + exports.name = 'sign'; + exports.factory = factory; + + + +/***/ }, +/* 383 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Compute the square of a value, `x * x`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.square(x) + * + * Examples: + * + * math.square(2); // returns number 4 + * math.square(3); // returns number 9 + * math.pow(3, 2); // returns number 9 + * math.multiply(3, 3); // returns number 9 + * + * math.square([1, 2, 3, 4]); // returns Array [1, 4, 9, 16] + * + * See also: + * + * multiply, cube, sqrt, pow + * + * @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x + * Number for which to calculate the square + * @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} + * Squared value + */ + var square = typed('square', { + 'number': function (x) { + return x * x; + }, + + 'Complex': function (x) { + return x.mul(x); + }, + + 'BigNumber': function (x) { + return x.times(x); + }, + + 'Fraction': function (x) { + return x.mul(x); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since square(0) = 0 + return deepMap(x, square, true); + }, + + 'Unit': function(x) { + return x.pow(2); + } + }); + + square.toTex = {1: '\\left(${args[0]}\\right)^2'}; + + return square; + } + + exports.name = 'square'; + exports.factory = factory; + + +/***/ }, +/* 384 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + /** + * Unary plus operation. + * Boolean values and strings will be converted to a number, numeric values will be returned as is. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.unaryPlus(x) + * + * Examples: + * + * math.unaryPlus(3.5); // returns 3.5 + * math.unaryPlus(1); // returns 1 + * + * See also: + * + * unaryMinus, add, subtract + * + * @param {number | BigNumber | Fraction | string | Complex | Unit | Array | Matrix} x + * Input value + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} + * Returns the input value when numeric, converts to a number when input is non-numeric. + */ + var unaryPlus = typed('unaryPlus', { + 'number': function (x) { + return x; + }, + + 'Complex': function (x) { + return x; // complex numbers are immutable + }, + + 'BigNumber': function (x) { + return x; // bignumbers are immutable + }, + + 'Fraction': function (x) { + return x; // fractions are immutable + }, + + 'Unit': function (x) { + return x.clone(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since unaryPlus(0) = 0 + return deepMap(x, unaryPlus, true); + }, + + 'boolean | string | null': function (x) { + // convert to a number or bignumber + return (config.number == 'BigNumber') ? new type.BigNumber(+x): +x; + } + }); + + unaryPlus.toTex = { + 1: latex.operators['unaryPlus'] + '\\left(${args[0]}\\right)' + }; + + return unaryPlus; + } + + exports.name = 'unaryPlus'; + exports.factory = factory; + + +/***/ }, +/* 385 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Calculate the extended greatest common divisor for two values. + * See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm. + * + * Syntax: + * + * math.xgcd(a, b) + * + * Examples: + * + * math.xgcd(8, 12); // returns [4, -1, 1] + * math.gcd(8, 12); // returns 4 + * math.xgcd(36163, 21199); // returns [1247, -7, 12] + * + * See also: + * + * gcd, lcm + * + * @param {number | BigNumber} a An integer number + * @param {number | BigNumber} b An integer number + * @return {Array} Returns an array containing 3 integers `[div, m, n]` + * where `div = gcd(a, b)` and `a*m + b*n = div` + */ + var xgcd = typed('xgcd', { + 'number, number': _xgcd, + 'BigNumber, BigNumber': _xgcdBigNumber + // TODO: implement support for Fraction + }); + + xgcd.toTex = undefined; // use default template + + return xgcd; + + /** + * Calculate xgcd for two numbers + * @param {number} a + * @param {number} b + * @return {number} result + * @private + */ + function _xgcd (a, b) { + // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm + var t, // used to swap two variables + q, // quotient + r, // remainder + x = 0, lastx = 1, + y = 1, lasty = 0; + + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function xgcd must be integer numbers'); + } + + while (b) { + q = Math.floor(a / b); + r = a % b; + + t = x; + x = lastx - q * x; + lastx = t; + + t = y; + y = lasty - q * y; + lasty = t; + + a = b; + b = r; + } + + var res; + if (a < 0) { + res = [-a, -lastx, -lasty]; + } + else { + res = [a, a ? lastx : 0, lasty]; + } + return (config.matrix === 'Array') ? res : matrix(res); + } + + /** + * Calculate xgcd for two BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @return {BigNumber[]} result + * @private + */ + function _xgcdBigNumber(a, b) { + // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm + var t, // used to swap two variables + q, // quotient + r, // remainder + zero = new type.BigNumber(0), + one = new type.BigNumber(1), + x = zero, + lastx = one, + y = one, + lasty = zero; + + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function xgcd must be integer numbers'); + } + + //console.log('start', [a, b].toString()) + + while (!b.isZero()) { + //console.log('inner', [a, b, t, q, r, x, y, lastx, lasty].toString()); + q = a.div(b).floor(); + r = a.mod(b); + //console.log('MOD', [a, b, a.mod(b), r].toString()) + + t = x; + x = lastx.minus(q.times(x)); + lastx = t; + + t = y; + y = lasty.minus(q.times(y)); + lasty = t; + + a = b; + b = r; + + //console.log('inner end', [a, b, t, q, r, x, y, lastx, lasty].toString()); + } + + //console.log('end', [a, lastx, lasty].toString()) + + var res; + if (a.lt(zero)) { + res = [a.neg(), lastx.neg(), lasty.neg()]; + } + else { + res = [a, !a.isZero() ? lastx : 0, lasty]; + } + return (config.matrix === 'Array') ? res : matrix(res); + } + } + + exports.name = 'xgcd'; + exports.factory = factory; + + +/***/ }, +/* 386 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(387), + __webpack_require__(391), + __webpack_require__(392), + __webpack_require__(394), + __webpack_require__(396), + __webpack_require__(399), + __webpack_require__(401) + ]; + + +/***/ }, +/* 387 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var bigBitAnd = __webpack_require__(388); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm06 = load(__webpack_require__(372)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise AND two values, `x & y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.bitAnd(x, y) + * + * Examples: + * + * math.bitAnd(53, 131); // returns number 1 + * + * math.bitAnd([1, 12, 31], 42); // returns Array [0, 8, 10] + * + * See also: + * + * bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x First value to and + * @param {number | BigNumber | Array | Matrix} y Second value to and + * @return {number | BigNumber | Array | Matrix} AND of `x` and `y` + */ + var bitAnd = typed('bitAnd', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitAnd'); + } + + return x & y; + }, + + 'BigNumber, BigNumber': bigBitAnd, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = algorithm06(x, y, bitAnd, false); + break; + default: + // sparse & dense + c = algorithm02(y, x, bitAnd, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = algorithm02(x, y, bitAnd, false); + break; + default: + // dense & dense + c = algorithm13(x, y, bitAnd); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitAnd(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitAnd(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitAnd(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, bitAnd, false); + break; + default: + c = algorithm14(x, y, bitAnd, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm11(y, x, bitAnd, true); + break; + default: + c = algorithm14(y, x, bitAnd, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, bitAnd, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, bitAnd, true).valueOf(); + } + }); + + bitAnd.toTex = { + 2: '\\left(${args[0]}' + latex.operators['bitAnd'] + '${args[1]}\\right)' + }; + + return bitAnd; + } + + exports.name = 'bitAnd'; + exports.factory = factory; + + +/***/ }, +/* 388 */ +/***/ function(module, exports, __webpack_require__) { + + var bitwise = __webpack_require__(389); + + /** + * Bitwise and for Bignumbers + * + * Special Cases: + * N & n = N + * n & 0 = 0 + * n & -1 = n + * n & n = n + * I & I = I + * -I & -I = -I + * I & -I = 0 + * I & n = n + * I & -n = I + * -I & n = 0 + * -I & -n = -I + * + * @param {BigNumber} x + * @param {BigNumber} y + * @return {BigNumber} Result of `x` & `y`, is fully precise + * @private + */ + module.exports = function bitAnd(x, y) { + if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { + throw new Error('Integers expected in function bitAnd'); + } + + var BigNumber = x.constructor; + if (x.isNaN() || y.isNaN()) { + return new BigNumber(NaN); + } + + if (x.isZero() || y.eq(-1) || x.eq(y)) { + return x; + } + if (y.isZero() || x.eq(-1)) { + return y; + } + + if (!x.isFinite() || !y.isFinite()) { + if (!x.isFinite() && !y.isFinite()) { + if (x.isNegative() == y.isNegative()) { + return x; + } + return new BigNumber(0); + } + if (!x.isFinite()) { + if (y.isNegative()) { + return x; + } + if (x.isNegative()) { + return new BigNumber(0); + } + return y; + } + if (!y.isFinite()) { + if (x.isNegative()) { + return y; + } + if (y.isNegative()) { + return new BigNumber(0); + } + return x; + } + } + return bitwise(x, y, function (a, b) { return a & b }); + }; + + +/***/ }, +/* 389 */ +/***/ function(module, exports, __webpack_require__) { + + var bitNot = __webpack_require__(390); + + /** + * Applies bitwise function to numbers + * @param {BigNumber} x + * @param {BigNumber} y + * @param {function (a, b)} func + * @return {BigNumber} + */ + module.exports = function bitwise(x, y, func) { + var BigNumber = x.constructor; + + var xBits, yBits; + var xSign = +(x.s < 0); + var ySign = +(y.s < 0); + if (xSign) { + xBits = decCoefficientToBinaryString(bitNot(x)); + for (var i = 0; i < xBits.length; ++i) { + xBits[i] ^= 1; + } + } else { + xBits = decCoefficientToBinaryString(x); + } + if (ySign) { + yBits = decCoefficientToBinaryString(bitNot(y)); + for (var i = 0; i < yBits.length; ++i) { + yBits[i] ^= 1; + } + } else { + yBits = decCoefficientToBinaryString(y); + } + + var minBits, maxBits, minSign; + if (xBits.length <= yBits.length) { + minBits = xBits; + maxBits = yBits; + minSign = xSign; + } else { + minBits = yBits; + maxBits = xBits; + minSign = ySign; + } + + var shortLen = minBits.length; + var longLen = maxBits.length; + var expFuncVal = func(xSign, ySign) ^ 1; + var outVal = new BigNumber(expFuncVal ^ 1); + var twoPower = new BigNumber(1); + var two = new BigNumber(2); + + var prevPrec = BigNumber.precision; + BigNumber.config({precision: 1E9}); + + while (shortLen > 0) { + if (func(minBits[--shortLen], maxBits[--longLen]) == expFuncVal) { + outVal = outVal.plus(twoPower); + } + twoPower = twoPower.times(two); + } + while (longLen > 0) { + if (func(minSign, maxBits[--longLen]) == expFuncVal) { + outVal = outVal.plus(twoPower); + } + twoPower = twoPower.times(two); + } + + BigNumber.config({precision: prevPrec}); + + if (expFuncVal == 0) { + outVal.s = -outVal.s; + } + return outVal; + }; + + /* Extracted from decimal.js, and edited to specialize. */ + function decCoefficientToBinaryString (x) { + // Convert to string + var a = x.d; // array with digits + var r = a[0] + ''; + + for (var i = 1; i < a.length; ++i) { + var s = a[i] + ''; + for (var z = 7 - s.length; z--; ) { + s = '0' + s; + } + + r += s; + } + + var j; + for (j = r.length - 1; r.charAt(j) == '0'; --j); + + var xe = x.e; + var str = r.slice(0, j + 1 || 1); + var strL = str.length; + if (xe > 0) { + if (++xe > strL) { + // Append zeros. + for (xe -= strL; xe--; str += '0'); + } else if (xe < strL) { + str = str.slice(0, xe) + '.' + str.slice(xe); + } + } + + // Convert from base 10 (decimal) to base 2 + var arr = [0]; + for (var i = 0; i < str.length; ) { + for (var arrL = arr.length; arrL--; arr[arrL] *= 10); + + arr[0] += str.charAt(i++) << 0; // convert to int + for (var j = 0; j < arr.length; ++j) { + if (arr[j] > 1) { + if (arr[j + 1] == null) { + arr[j + 1] = 0; + } + + arr[j + 1] += arr[j] >> 1; + arr[j] &= 1; + } + } + } + + return arr.reverse(); + } + + +/***/ }, +/* 390 */ +/***/ function(module, exports) { + + /** + * Bitwise not + * @param {BigNumber} value + * @return {BigNumber} Result of ~`x`, fully precise + * + */ + module.exports = function bitNot (x) { + if (x.isFinite() && !x.isInteger()) { + throw new Error('Integer expected in function bitNot'); + } + + var BigNumber = x.constructor; + var prevPrec = BigNumber.precision; + BigNumber.config({precision: 1E9}); + + var x = x.plus(new BigNumber(1)); + x.s = -x.s || null; + + BigNumber.config({precision: prevPrec}); + return x; + }; + + +/***/ }, +/* 391 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var bigBitNot = __webpack_require__(390); + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + /** + * Bitwise NOT value, `~x`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.bitNot(x) + * + * Examples: + * + * math.bitNot(1); // returns number -2 + * + * math.bitNot([2, -3, 4]); // returns Array [-3, 2, 5] + * + * See also: + * + * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x Value to not + * @return {number | BigNumber | Array | Matrix} NOT of `x` + */ + var bitNot = typed('bitNot', { + 'number': function (x) { + if (!isInteger(x)) { + throw new Error('Integer expected in function bitNot'); + } + + return ~x; + }, + + 'BigNumber': bigBitNot, + + 'Array | Matrix': function (x) { + return deepMap(x, bitNot); + } + }); + + bitNot.toTex = { + 1: latex.operators['bitNot'] + '\\left(${args[0]}\\right)' + }; + + return bitNot; + } + + exports.name = 'bitNot'; + exports.factory = factory; + + +/***/ }, +/* 392 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var bigBitOr = __webpack_require__(393); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm04 = load(__webpack_require__(55)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise OR two values, `x | y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the lowest print base. + * + * Syntax: + * + * math.bitOr(x, y) + * + * Examples: + * + * math.bitOr(1, 2); // returns number 3 + * + * math.bitOr([1, 2, 3], 4); // returns Array [5, 6, 7] + * + * See also: + * + * bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x First value to or + * @param {number | BigNumber | Array | Matrix} y Second value to or + * @return {number | BigNumber | Array | Matrix} OR of `x` and `y` + */ + var bitOr = typed('bitOr', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitOr'); + } + + return x | y; + }, + + 'BigNumber, BigNumber': bigBitOr, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm04(x, y, bitOr); + break; + default: + // sparse + dense + c = algorithm01(y, x, bitOr, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm01(x, y, bitOr, false); + break; + default: + c = algorithm13(x, y, bitOr); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitOr(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitOr(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitOr(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm10(x, y, bitOr, false); + break; + default: + c = algorithm14(x, y, bitOr, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, bitOr, true); + break; + default: + c = algorithm14(y, x, bitOr, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, bitOr, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, bitOr, true).valueOf(); + } + }); + + bitOr.toTex = { + 2: '\\left(${args[0]}' + latex.operators['bitOr'] + '${args[1]}\\right)' + }; + + return bitOr; + } + + exports.name = 'bitOr'; + exports.factory = factory; + + +/***/ }, +/* 393 */ +/***/ function(module, exports, __webpack_require__) { + + var bitwise = __webpack_require__(389); + + /** + * Bitwise OR for BigNumbers + * + * Special Cases: + * N | n = N + * n | 0 = n + * n | -1 = -1 + * n | n = n + * I | I = I + * -I | -I = -I + * I | -n = -1 + * I | -I = -1 + * I | n = I + * -I | n = -I + * -I | -n = -n + * + * @param {BigNumber} x + * @param {BigNumber} y + * @return {BigNumber} Result of `x` | `y`, fully precise + */ + module.exports = function bitOr (x, y) { + if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { + throw new Error('Integers expected in function bitOr'); + } + + var BigNumber = x.constructor; + if (x.isNaN() || y.isNaN()) { + return new BigNumber(NaN); + } + + var negOne = new BigNumber(-1); + if (x.isZero() || y.eq(negOne) || x.eq(y)) { + return y; + } + if (y.isZero() || x.eq(negOne)) { + return x; + } + + if (!x.isFinite() || !y.isFinite()) { + if ((!x.isFinite() && !x.isNegative() && y.isNegative()) || + (x.isNegative() && !y.isNegative() && !y.isFinite())) { + return negOne; + } + if (x.isNegative() && y.isNegative()) { + return x.isFinite() ? x : y; + } + return x.isFinite() ? y : x; + } + + return bitwise(x, y, function (a, b) { return a | b }); + }; + + +/***/ }, +/* 394 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var bigBitXor = __webpack_require__(395); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise XOR two values, `x ^ y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.bitXor(x, y) + * + * Examples: + * + * math.bitXor(1, 2); // returns number 3 + * + * math.bitXor([2, 3, 4], 4); // returns Array [6, 7, 0] + * + * See also: + * + * bitAnd, bitNot, bitOr, leftShift, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x First value to xor + * @param {number | BigNumber | Array | Matrix} y Second value to xor + * @return {number | BigNumber | Array | Matrix} XOR of `x` and `y` + */ + var bitXor = typed('bitXor', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitXor'); + } + + return x ^ y; + }, + + 'BigNumber, BigNumber': bigBitXor, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, bitXor); + break; + default: + // sparse + dense + c = algorithm03(y, x, bitXor, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, bitXor, false); + break; + default: + // dense + dense + c = algorithm13(x, y, bitXor); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitXor(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitXor(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitXor(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, bitXor, false); + break; + default: + c = algorithm14(x, y, bitXor, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, bitXor, true); + break; + default: + c = algorithm14(y, x, bitXor, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, bitXor, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, bitXor, true).valueOf(); + } + }); + + bitXor.toTex = { + 2: '\\left(${args[0]}' + latex.operators['bitXor'] + '${args[1]}\\right)' + }; + + return bitXor; + } + + exports.name = 'bitXor'; + exports.factory = factory; + + +/***/ }, +/* 395 */ +/***/ function(module, exports, __webpack_require__) { + + var bitwise = __webpack_require__(389); + var bitNot = __webpack_require__(390); + + /** + * Bitwise XOR for BigNumbers + * + * Special Cases: + * N ^ n = N + * n ^ 0 = n + * n ^ n = 0 + * n ^ -1 = ~n + * I ^ n = I + * I ^ -n = -I + * I ^ -I = -1 + * -I ^ n = -I + * -I ^ -n = I + * + * @param {BigNumber} x + * @param {BigNumber} y + * @return {BigNumber} Result of `x` ^ `y`, fully precise + * + */ + module.exports = function bitXor(x, y) { + if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { + throw new Error('Integers expected in function bitXor'); + } + + var BigNumber = x.constructor; + if (x.isNaN() || y.isNaN()) { + return new BigNumber(NaN); + } + if (x.isZero()) { + return y; + } + if (y.isZero()) { + return x; + } + + if (x.eq(y)) { + return new BigNumber(0); + } + + var negOne = new BigNumber(-1); + if (x.eq(negOne)) { + return bitNot(y); + } + if (y.eq(negOne)) { + return bitNot(x); + } + + if (!x.isFinite() || !y.isFinite()) { + if (!x.isFinite() && !y.isFinite()) { + return negOne; + } + return new BigNumber(x.isNegative() == y.isNegative() + ? Infinity + : -Infinity); + } + return bitwise(x, y, function (a, b) { return a ^ b }); + }; + + +/***/ }, +/* 396 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var bigLeftShift = __webpack_require__(397); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var equalScalar = load(__webpack_require__(48)); + var zeros = load(__webpack_require__(381)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm02 = load(__webpack_require__(360)); + var algorithm08 = load(__webpack_require__(398)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise left logical shift of a value x by y number of bits, `x << y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.leftShift(x, y) + * + * Examples: + * + * math.leftShift(1, 2); // returns number 4 + * + * math.leftShift([1, 2, 3], 4); // returns Array [16, 32, 64] + * + * See also: + * + * leftShift, bitNot, bitOr, bitXor, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x Value to be shifted + * @param {number | BigNumber} y Amount of shifts + * @return {number | BigNumber | Array | Matrix} `x` shifted left `y` times + */ + var leftShift = typed('leftShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function leftShift'); + } + + return x << y; + }, + + 'BigNumber, BigNumber': bigLeftShift, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = algorithm08(x, y, leftShift, false); + break; + default: + // sparse & dense + c = algorithm02(y, x, leftShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = algorithm01(x, y, leftShift, false); + break; + default: + // dense & dense + c = algorithm13(x, y, leftShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return leftShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equalScalar(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, leftShift, false); + break; + default: + c = algorithm14(x, y, leftShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equalScalar(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, leftShift, true); + break; + default: + c = algorithm14(y, x, leftShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return leftShift(x, matrix(y)).valueOf(); + } + }); + + leftShift.toTex = { + 2: '\\left(${args[0]}' + latex.operators['leftShift'] + '${args[1]}\\right)' + }; + + return leftShift; + } + + exports.name = 'leftShift'; + exports.factory = factory; + + +/***/ }, +/* 397 */ +/***/ function(module, exports) { + + + /** + * Bitwise left shift + * + * Special Cases: + * n << -n = N + * n << N = N + * N << n = N + * n << 0 = n + * 0 << n = 0 + * I << I = N + * I << n = I + * n << I = I + * + * @param {BigNumber} x + * @param {BigNumber} y + * @return {BigNumber} Result of `x` << `y` + * + */ + module.exports = function leftShift (x, y) { + if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { + throw new Error('Integers expected in function leftShift'); + } + + var BigNumber = x.constructor; + if (x.isNaN() || y.isNaN() || (y.isNegative() && !y.isZero())) { + return new BigNumber(NaN); + } + if (x.isZero() || y.isZero()) { + return x; + } + if (!x.isFinite() && !y.isFinite()) { + return new BigNumber(NaN); + } + + // Math.pow(2, y) is fully precise for y < 55, and fast + if (y.lt(55)) { + return x.times(Math.pow(2, y.toNumber()) + ''); + } + return x.times(new BigNumber(2).pow(y)); + }; + + +/***/ }, +/* 398 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + + function factory (type, config, load, typed) { + + var equalScalar = load(__webpack_require__(48)); + + var SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {Function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm08 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + // sparse matrix arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!avalues || !bvalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrices'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // datatype + var dt; + // equal signature to use + var eq = equalScalar; + // zero value + var zero = 0; + // callback signature to use + var cf = callback; + + // process data types + if (typeof adt === 'string' && adt === bdt) { + // datatype + dt = adt; + // find signature that matches (dt, dt) + eq = typed.find(equalScalar, [dt, dt]); + // convert 0 to the same datatype + zero = typed.convert(0, dt); + // callback + cf = typed.find(callback, [dt, dt]); + } + + // result arrays + var cvalues = []; + var cindex = []; + var cptr = []; + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspace + var x = []; + // marks indicating we have a value in x for a given column + var w = []; + + // vars + var k, k0, k1, i; + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // loop values in a + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // mark workspace + w[i] = mark; + // set value + x[i] = avalues[k]; + // add index + cindex.push(i); + } + // loop values in b + for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + i = bindex[k]; + // check value exists in workspace + if (w[i] === mark) { + // evaluate callback + x[i] = cf(x[i], bvalues[k]); + } + } + // initialize first index in j + k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + i = cindex[k]; + // value @ i + var v = x[i]; + // check for zero value + if (!eq(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + return algorithm08; + } + + exports.name = 'algorithm08'; + exports.factory = factory; + + +/***/ }, +/* 399 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var bigRightArithShift = __webpack_require__(400); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var equalScalar = load(__webpack_require__(48)); + var zeros = load(__webpack_require__(381)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm02 = load(__webpack_require__(360)); + var algorithm08 = load(__webpack_require__(398)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.rightArithShift(x, y) + * + * Examples: + * + * math.rightArithShift(4, 2); // returns number 1 + * + * math.rightArithShift([16, -32, 64], 4); // returns Array [1, -2, 3] + * + * See also: + * + * bitAnd, bitNot, bitOr, bitXor, rightArithShift, rightLogShift + * + * @param {number | BigNumber | Array | Matrix} x Value to be shifted + * @param {number | BigNumber} y Amount of shifts + * @return {number | BigNumber | Array | Matrix} `x` sign-filled shifted right `y` times + */ + var rightArithShift = typed('rightArithShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function rightArithShift'); + } + + return x >> y; + }, + + 'BigNumber, BigNumber': bigRightArithShift, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = algorithm08(x, y, rightArithShift, false); + break; + default: + // sparse & dense + c = algorithm02(y, x, rightArithShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = algorithm01(x, y, rightArithShift, false); + break; + default: + // dense & dense + c = algorithm13(x, y, rightArithShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return rightArithShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equalScalar(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, rightArithShift, false); + break; + default: + c = algorithm14(x, y, rightArithShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equalScalar(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, rightArithShift, true); + break; + default: + c = algorithm14(y, x, rightArithShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return rightArithShift(x, matrix(y)).valueOf(); + } + }); + + rightArithShift.toTex = { + 2: '\\left(${args[0]}' + latex.operators['rightArithShift'] + '${args[1]}\\right)' + }; + + return rightArithShift; + } + + exports.name = 'rightArithShift'; + exports.factory = factory; + + +/***/ }, +/* 400 */ +/***/ function(module, exports) { + + /* + * Special Cases: + * n >> -n = N + * n >> N = N + * N >> n = N + * I >> I = N + * n >> 0 = n + * I >> n = I + * -I >> n = -I + * -I >> I = -I + * n >> I = I + * -n >> I = -1 + * 0 >> n = 0 + * + * @param {BigNumber} value + * @param {BigNumber} value + * @return {BigNumber} Result of `x` >> `y` + * + */ + module.exports = function rightArithShift (x, y) { + if ((x.isFinite() && !x.isInteger()) || (y.isFinite() && !y.isInteger())) { + throw new Error('Integers expected in function rightArithShift'); + } + + var BigNumber = x.constructor; + if (x.isNaN() || y.isNaN() || (y.isNegative() && !y.isZero())) { + return new BigNumber(NaN); + } + if (x.isZero() || y.isZero()) { + return x; + } + if (!y.isFinite()) { + if (x.isNegative()) { + return new BigNumber(-1); + } + if (!x.isFinite()) { + return new BigNumber(NaN); + } + return new BigNumber(0); + } + + // Math.pow(2, y) is fully precise for y < 55, and fast + if (y.lt(55)) { + return x.div(Math.pow(2, y.toNumber()) + '').floor(); + } + return x.div(new BigNumber(2).pow(y)).floor(); + }; + + +/***/ }, +/* 401 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var equalScalar = load(__webpack_require__(48)); + var zeros = load(__webpack_require__(381)); + + var algorithm01 = load(__webpack_require__(54)); + var algorithm02 = load(__webpack_require__(360)); + var algorithm08 = load(__webpack_require__(398)); + var algorithm10 = load(__webpack_require__(56)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Bitwise right logical shift of value x by y number of bits, `x >>> y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.rightLogShift(x, y) + * + * Examples: + * + * math.rightLogShift(4, 2); // returns number 1 + * + * math.rightLogShift([16, -32, 64], 4); // returns Array [1, 2, 3] + * + * See also: + * + * bitAnd, bitNot, bitOr, bitXor, leftShift, rightLogShift + * + * @param {number | Array | Matrix} x Value to be shifted + * @param {number} y Amount of shifts + * @return {number | Array | Matrix} `x` zero-filled shifted right `y` times + */ + + var rightLogShift = typed('rightLogShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function rightLogShift'); + } + + return x >>> y; + }, + + // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = algorithm08(x, y, rightLogShift, false); + break; + default: + // sparse & dense + c = algorithm02(y, x, rightLogShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = algorithm01(x, y, rightLogShift, false); + break; + default: + // dense & dense + c = algorithm13(x, y, rightLogShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return rightLogShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equalScalar(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, rightLogShift, false); + break; + default: + c = algorithm14(x, y, rightLogShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equalScalar(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm10(y, x, rightLogShift, true); + break; + default: + c = algorithm14(y, x, rightLogShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return rightLogShift(x, matrix(y)).valueOf(); + } + }); + + rightLogShift.toTex = { + 2: '\\left(${args[0]}' + latex.operators['rightLogShift'] + '${args[1]}\\right)' + }; + + return rightLogShift; + } + + exports.name = 'rightLogShift'; + exports.factory = factory; + + +/***/ }, +/* 402 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(403), + __webpack_require__(409), + __webpack_require__(404), + __webpack_require__(410) + ]; + + +/***/ }, +/* 403 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var stirlingS2 = load(__webpack_require__(404)); + var isNegative = load(__webpack_require__(356)); + var isInteger = load(__webpack_require__(408)); + + /** + * The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. + * bellNumbers only takes integer arguments. + * The following condition must be enforced: n >= 0 + * + * Syntax: + * + * math.bellNumbers(n) + * + * Examples: + * + * math.bellNumbers(3); // returns 5; + * math.bellNumbers(8); // returns 4140; + * + * See also: + * + * stirlingS2 + * + * @param {Number | BigNumber} n Total number of objects in the set + * @return {Number | BigNumber} B(n) + */ + var bellNumbers = typed('bellNumbers', { + 'number | BigNumber': function (n) { + + if (!isInteger(n) || isNegative(n)) { + throw new TypeError('Non-negative integer value expected in function bellNumbers'); + } + + // Sum (k=0, n) S(n,k). + var result = 0; + for(var i = 0; i <= n; i++) { + result = add(result, stirlingS2(n, i)); + } + + return result; + } + }); + + bellNumbers.toTex = {1: '\\mathrm{B}_{${args[0]}}'}; + + return bellNumbers; + } + + exports.name = 'bellNumbers'; + exports.factory = factory; + + +/***/ }, +/* 404 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var subtract = load(__webpack_require__(77)); + var multiply = load(__webpack_require__(84)); + var divide = load(__webpack_require__(317)); + var pow = load(__webpack_require__(82)); + var factorial = load(__webpack_require__(405)); + var combinations = load(__webpack_require__(407)); + var isNegative = load(__webpack_require__(356)); + var isInteger = load(__webpack_require__(408)); + var larger = load(__webpack_require__(64)); + + /** + * The Stirling numbers of the second kind, counts the number of ways to partition + * a set of n labelled objects into k nonempty unlabelled subsets. + * stirlingS2 only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * If n = k or k = 1, then s(n,k) = 1 + * + * Syntax: + * + * math.stirlingS2(n, k) + * + * Examples: + * + * math.stirlingS2(5, 3); //returns 25 + * + * See also: + * + * Bell numbers + * + * @param {Number | BigNumber} n Total number of objects in the set + * @param {Number | BigNumber} k Number of objects in the subset + * @return {Number | BigNumber} S(n,k) + */ + var stirlingS2 = typed('stirlingS2', { + 'number | BigNumber, number | BigNumber': function (n, k) { + if (!isInteger(n) || isNegative(n) || !isInteger(k) || isNegative(k)) { + throw new TypeError('Non-negative integer value expected in function stirlingS2'); + } + else if (larger(k, n)) { + throw new TypeError('k must be less than or equal to n in function stirlingS2'); + } + + // 1/k! Sum(i=0 -> k) [(-1)^(k-i)*C(k,j)* i^n] + var kFactorial = factorial(k); + var result = 0; + for(var i = 0; i <= k; i++) { + var negativeOne = pow(-1, subtract(k,i)); + var kChooseI = combinations(k,i); + var iPower = pow(i,n); + + result = add(result, multiply(multiply(kChooseI, iPower), negativeOne)); + } + + return divide(result, kFactorial); + } + }); + + stirlingS2.toTex = {2: '\\mathrm{S}\\left(${args}\\right)'}; + + return stirlingS2; + } + + exports.name = 'stirlingS2'; + exports.factory = factory; + + +/***/ }, +/* 405 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var gamma = load(__webpack_require__(406)); + var latex = __webpack_require__(32); + + /** + * Compute the factorial of a value + * + * Factorial only supports an integer value as argument. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.factorial(n) + * + * Examples: + * + * math.factorial(5); // returns 120 + * math.factorial(3); // returns 6 + * + * See also: + * + * combinations, gamma, permutations + * + * @param {number | BigNumber | Array | Matrix} n An integer number + * @return {number | BigNumber | Array | Matrix} The factorial of `n` + */ + var factorial = typed('factorial', { + 'number': function (n) { + if (n < 0) { + throw new Error('Value must be non-negative'); + } + + return gamma(n + 1); + }, + + 'BigNumber': function (n) { + if (n.isNegative()) { + throw new Error('Value must be non-negative'); + } + + return gamma(n.plus(1)); + }, + + 'Array | Matrix': function (n) { + return deepMap(n, factorial); + } + }); + + factorial.toTex = { + 1: '\\left(${args[0]}\\right)' + latex.operators['factorial'] + }; + + return factorial; + } + + exports.name = 'factorial'; + exports.factory = factory; + + +/***/ }, +/* 406 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var multiply = load(__webpack_require__(84)); + var pow = load(__webpack_require__(82)); + + /** + * Compute the gamma function of a value using Lanczos approximation for + * small values, and an extended Stirling approximation for large values. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.gamma(n) + * + * Examples: + * + * math.gamma(5); // returns 24 + * math.gamma(-0.5); // returns -3.5449077018110335 + * math.gamma(math.i); // returns -0.15494982830180973 - 0.49801566811835596i + * + * See also: + * + * combinations, factorial, permutations + * + * @param {number | Array | Matrix} n A real or complex number + * @return {number | Array | Matrix} The gamma of `n` + */ + var gamma = typed('gamma', { + 'number': function (n) { + var t, x; + + if (isInteger(n)) { + if (n <= 0) { + return isFinite(n) ? Infinity : NaN; + } + + if (n > 171) { + return Infinity; // Will overflow + } + + var value = n - 2; + var res = n - 1; + while (value > 1) { + res *= value; + value--; + } + + if (res == 0) { + res = 1; // 0! is per definition 1 + } + + return res; + } + + if (n < 0.5) { + return Math.PI / (Math.sin(Math.PI * n) * gamma(1-n)); + } + + if (n >= 171.35) { + return Infinity; // will overflow + } + + if (n > 85.0) { // Extended Stirling Approx + var twoN = n*n; + var threeN = twoN*n; + var fourN = threeN*n; + var fiveN = fourN*n; + return Math.sqrt(2*Math.PI/n) * Math.pow((n/Math.E), n) * + (1 + 1/(12*n) + 1/(288*twoN) - 139/(51840*threeN) - + 571/(2488320*fourN) + 163879/(209018880*fiveN) + + 5246819/(75246796800*fiveN*n)); + } + + --n; + x = p[0]; + for (var i = 1; i < p.length; ++i) { + x += p[i] / (n+i); + } + + t = n + g + 0.5; + return Math.sqrt(2*Math.PI) * Math.pow(t, n+0.5) * Math.exp(-t) * x; + }, + + 'Complex': function (n) { + var t, x; + + if (n.im == 0) { + return gamma(n.re); + } + + n = new type.Complex(n.re - 1, n.im); + x = new type.Complex(p[0], 0); + for (var i = 1; i < p.length; ++i) { + var real = n.re + i; // x += p[i]/(n+i) + var den = real*real + n.im*n.im; + if (den != 0) { + x.re += p[i] * real / den; + x.im += -(p[i] * n.im) / den; + } else { + x.re = p[i] < 0 + ? -Infinity + : Infinity; + } + } + + t = new type.Complex(n.re + g + 0.5, n.im); + var twoPiSqrt = Math.sqrt(2*Math.PI); + + n.re += 0.5; + var result = pow(t, n); + if (result.im == 0) { // sqrt(2*PI)*result + result.re *= twoPiSqrt; + } else if (result.re == 0) { + result.im *= twoPiSqrt; + } else { + result.re *= twoPiSqrt; + result.im *= twoPiSqrt; + } + + var r = Math.exp(-t.re); // exp(-t) + t.re = r * Math.cos(-t.im); + t.im = r * Math.sin(-t.im); + + return multiply(multiply(result, t), x); + }, + + 'BigNumber': function (n) { + if (n.isInteger()) { + return (n.isNegative() || n.isZero()) + ? new type.BigNumber(Infinity) + : bigFactorial(n.minus(1)); + } + + if (!n.isFinite()) { + return new type.BigNumber(n.isNegative() ? NaN : Infinity); + } + + throw new Error('Integer BigNumber expected'); + }, + + 'Array | Matrix': function (n) { + return deepMap(n, gamma); + } + }); + + /** + * Calculate factorial for a BigNumber + * @param {BigNumber} n + * @returns {BigNumber} Returns the factorial of n + */ + function bigFactorial(n) { + if (n.isZero()) { + return new type.BigNumber(1); // 0! is per definition 1 + } + + var precision = config.precision + (Math.log(n.toNumber()) | 0); + var Big = type.BigNumber.clone({precision: precision}); + + var res = new Big(n); + var value = n.toNumber() - 1; // number + while (value > 1) { + res = res.times(value); + value--; + } + + return new type.BigNumber(res.toPrecision(type.BigNumber.precision)); + } + + gamma.toTex = {1: '\\Gamma\\left(${args[0]}\\right)'}; + + return gamma; + } + + // TODO: comment on the variables g and p + + var g = 4.7421875; + + var p = [ + 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + 0.33994649984811888699e-4, + 0.46523628927048575665e-4, + -0.98374475304879564677e-4, + 0.15808870322491248884e-3, + -0.21026444172410488319e-3, + 0.21743961811521264320e-3, + -0.16431810653676389022e-3, + 0.84418223983852743293e-4, + -0.26190838401581408670e-4, + 0.36899182659531622704e-5 + ]; + + exports.name = 'gamma'; + exports.factory = factory; + + +/***/ }, +/* 407 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + /** + * Compute the number of ways of picking `k` unordered outcomes from `n` + * possibilities. + * + * Combinations only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * Syntax: + * + * math.combinations(n, k) + * + * Examples: + * + * math.combinations(7, 5); // returns 21 + * + * See also: + * + * permutations, factorial + * + * @param {number | BigNumber} n Total number of objects in the set + * @param {number | BigNumber} k Number of objects in the subset + * @return {number | BigNumber} Number of possible combinations. + */ + var combinations = typed('combinations', { + 'number, number': function (n, k) { + var max, result, i; + + if (!isInteger(n) || n < 0) { + throw new TypeError('Positive integer value expected in function combinations'); + } + if (!isInteger(k) || k < 0) { + throw new TypeError('Positive integer value expected in function combinations'); + } + if (k > n) { + throw new TypeError('k must be less than or equal to n'); + } + + max = Math.max(k, n - k); + result = 1; + for (i = 1; i <= n - max; i++) { + result = result * (max + i) / i; + } + + return result; + }, + + 'BigNumber, BigNumber': function (n, k) { + var max, result, i, ii; + var one = new type.BigNumber(1); + + if (!isPositiveInteger(n) || !isPositiveInteger(k)) { + throw new TypeError('Positive integer value expected in function combinations'); + } + if (k.gt(n)) { + throw new TypeError('k must be less than n in function combinations'); + } + + max = n.minus(k); + if (k.lt(max)) max = k; + result = one; + for (i = one, ii = n.minus(max); i.lte(ii); i = i.plus(1)) { + result = result.times(max.plus(i)).dividedBy(i); + } + + return result; + } + + // TODO: implement support for collection in combinations + }); + + combinations.toTex = {2: '\\binom{${args[0]}}{${args[1]}}'}; + + return combinations; + } + + /** + * Test whether BigNumber n is a positive integer + * @param {BigNumber} n + * @returns {boolean} isPositiveInteger + */ + function isPositiveInteger(n) { + return n.isInteger() && n.gte(0); + } + + exports.name = 'combinations'; + exports.factory = factory; + + +/***/ }, +/* 408 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Test whether a value is an integer number. + * The function supports `number`, `BigNumber`, and `Fraction`. + * + * The function is evaluated element-wise in case of Array or Matrix input. + * + * Syntax: + * + * math.isInteger(x) + * + * Examples: + * + * math.isInteger(2); // returns true + * math.isInteger(0); // returns true + * math.isInteger(0.5); // returns false + * math.isInteger(math.bignumber(500)); // returns true + * math.isInteger(math.fraction(4)); // returns true + * math.isInteger('3'); // returns true + * math.isInteger([3, 0.5, -2]); // returns [true, false, true] + * math.isInteger(math.complex('2-4i'); // throws an error + * + * See also: + * + * isNumeric, isPositive, isNegative, isZero + * + * @param {number | BigNumber | Fraction | Array | Matrix} x Value to be tested + * @return {boolean} Returns true when `x` contains a numeric, integer value. + * Throws an error in case of an unknown data type. + */ + var isInteger = typed('isInteger', { + 'number': number.isInteger, // TODO: what to do with isInteger(add(0.1, 0.2)) ? + + 'BigNumber': function (x) { + return x.isInt(); + }, + + 'Fraction': function (x) { + return x.d === 1 && isFinite(x.n); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, isInteger); + } + }); + + return isInteger; + } + + exports.name = 'isInteger'; + exports.factory = factory; + + +/***/ }, +/* 409 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var combinations = load(__webpack_require__(407)); + var add = load(__webpack_require__(53)); + var isPositive = load(__webpack_require__(370)); + var isInteger = load(__webpack_require__(408)); + var larger = load(__webpack_require__(64)); + + /** + * The composition counts of n into k parts. + * + * composition only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * Syntax: + * + * math.composition(n, k) + * + * Examples: + * + * math.composition(5, 3); // returns 6 + * + * See also: + * + * combinations + * + * @param {Number | BigNumber} n Total number of objects in the set + * @param {Number | BigNumber} k Number of objects in the subset + * @return {Number | BigNumber} Returns the composition counts of n into k parts. + */ + var composition = typed('composition', { + 'number | BigNumber, number | BigNumber': function (n, k) { + if (!isInteger(n) || !isPositive(n) || !isInteger(k) || !isPositive(k)) { + throw new TypeError('Positive integer value expected in function composition'); + } + else if (larger(k, n)) { + throw new TypeError('k must be less than or equal to n in function composition'); + } + + return combinations(add(n, -1), add(k, -1)); + } + }); + + composition.toTex = undefined; // use default template + + return composition; + } + + exports.name = 'composition'; + exports.factory = factory; + + +/***/ }, +/* 410 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var divide = load(__webpack_require__(317)); + var multiply = load(__webpack_require__(84)); + var combinations = load(__webpack_require__(407)); + var isNegative = load(__webpack_require__(356)); + var isInteger = load(__webpack_require__(408)); + + + /** + * The Catalan Numbers enumerate combinatorial structures of many different types. + * catalan only takes integer arguments. + * The following condition must be enforced: n >= 0 + * + * Syntax: + * + * math.catalan(n) + * + * Examples: + * + * math.catalan(3); // returns 5; + * math.catalan(8); // returns 1430; + * + * See also: + * + * bellNumbers + * + * @param {Number | BigNumber} n nth Catalan number + * @return {Number | BigNumber} Cn(n) + */ + var catalan = typed('catalan', { + 'number | BigNumber': function (n) { + + if (!isInteger(n) || isNegative(n)) { + throw new TypeError('Non-negative integer value expected in function catalan'); + } + + return divide(combinations(multiply(n,2), n), add(n,1)); + + } + }); + + catalan.toTex = {1: '\\mathrm{C}_{${args[0]}}'}; + + return catalan; + } + + exports.name = 'catalan'; + exports.factory = factory; + + +/***/ }, +/* 411 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(412), + __webpack_require__(413), + __webpack_require__(414), + __webpack_require__(415) + ]; + + +/***/ }, +/* 412 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Compute the argument of a complex value. + * For a complex number `a + bi`, the argument is computed as `atan2(b, a)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.arg(x) + * + * Examples: + * + * var a = math.complex(2, 2); + * math.arg(a) / math.pi; // returns number 0.25 + * + * var b = math.complex('2 + 3i'); + * math.arg(b); // returns number 0.982793723247329 + * math.atan2(3, 2); // returns number 0.982793723247329 + * + * See also: + * + * re, im, conj, abs + * + * @param {number | Complex | Array | Matrix} x + * A complex number or array with complex numbers + * @return {number | Array | Matrix} The argument of x + */ + var arg = typed('arg', { + 'number': function (x) { + return Math.atan2(0, x); + }, + + 'Complex': function (x) { + return x.arg(); + }, + + // TODO: implement BigNumber support for function arg + + 'Array | Matrix': function (x) { + return deepMap(x, arg); + } + }); + + arg.toTex = {1: '\\arg\\left(${args[0]}\\right)'}; + + return arg; + } + + exports.name = 'arg'; + exports.factory = factory; + + +/***/ }, +/* 413 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Compute the complex conjugate of a complex value. + * If `x = a+bi`, the complex conjugate of `x` is `a - bi`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.conj(x) + * + * Examples: + * + * math.conj(math.complex('2 + 3i')); // returns Complex 2 - 3i + * math.conj(math.complex('2 - 3i')); // returns Complex 2 + 3i + * math.conj(math.complex('-5.2i')); // returns Complex 5.2i + * + * See also: + * + * re, im, arg, abs + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * A complex number or array with complex numbers + * @return {number | BigNumber | Complex | Array | Matrix} + * The complex conjugate of x + */ + var conj = typed('conj', { + 'number': function (x) { + return x; + }, + + 'BigNumber': function (x) { + return x; + }, + + 'Complex': function (x) { + return x.conjugate(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, conj); + } + }); + + conj.toTex = {1: '\\left(${args[0]}\\right)^*'}; + + return conj; + } + + exports.name = 'conj'; + exports.factory = factory; + + +/***/ }, +/* 414 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Get the imaginary part of a complex number. + * For a complex number `a + bi`, the function returns `b`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.im(x) + * + * Examples: + * + * var a = math.complex(2, 3); + * math.re(a); // returns number 2 + * math.im(a); // returns number 3 + * + * math.re(math.complex('-5.2i')); // returns number -5.2 + * math.re(math.complex(2.4)); // returns number 0 + * + * See also: + * + * re, conj, abs, arg + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * A complex number or array with complex numbers + * @return {number | BigNumber | Array | Matrix} The imaginary part of x + */ + var im = typed('im', { + 'number': function (x) { + return 0; + }, + + 'BigNumber': function (x) { + return new type.BigNumber(0); + }, + + 'Complex': function (x) { + return x.im; + }, + + 'Array | Matrix': function (x) { + return deepMap(x, im); + } + }); + + im.toTex = {1: '\\Im\\left\\lbrace${args[0]}\\right\\rbrace'}; + + return im; + } + + exports.name = 'im'; + exports.factory = factory; + + +/***/ }, +/* 415 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Get the real part of a complex number. + * For a complex number `a + bi`, the function returns `a`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.re(x) + * + * Examples: + * + * var a = math.complex(2, 3); + * math.re(a); // returns number 2 + * math.im(a); // returns number 3 + * + * math.re(math.complex('-5.2i')); // returns number 0 + * math.re(math.complex(2.4)); // returns number 2.4 + * + * See also: + * + * im, conj, abs, arg + * + * @param {number | BigNumber | Complex | Array | Matrix} x + * A complex number or array with complex numbers + * @return {number | BigNumber | Array | Matrix} The real part of x + */ + var re = typed('re', { + 'number': function (x) { + return x; + }, + + 'BigNumber': function (x) { + return x; + }, + + 'Complex': function (x) { + return x.re; + }, + + 'Array | Matrix': function (x) { + return deepMap(x, re); + } + }); + + re.toTex = {1: '\\Re\\left\\lbrace${args[0]}\\right\\rbrace'}; + + return re; + } + + exports.name = 're'; + exports.factory = factory; + + +/***/ }, +/* 416 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(417), + __webpack_require__(418) + ]; + + +/***/ }, +/* 417 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var abs = load(__webpack_require__(86)); + var add = load(__webpack_require__(51)); + var matrix = load(__webpack_require__(52)); + var multiply = load(__webpack_require__(84)); + var subtract = load(__webpack_require__(77)); + + /** + * Calculates the point of intersection of two lines in two or three dimensions + * and of a line and a plane in three dimensions. The inputs are in the form of + * arrays or 1 dimensional matrices. The line intersection functions return null + * if the lines do not meet. + * + * Note: Fill the plane coefficients as `x + y + z = c` and not as `x + y + z + c = 0`. + * + * Syntax: + * + * math.intersect(endPoint1Line1, endPoint2Line1, endPoint1Line2, endPoint2Line2) + * math.intersect(endPoint1, endPoint2, planeCoefficients) + * + * Examples: + * + * math.intersect([0, 0], [10, 10], [10, 0], [0, 10]); // Returns [5, 5] + * math.intersect([0, 0, 0], [10, 10, 0], [10, 0, 0], [0, 10, 0]); // Returns [5, 5, 0] + * math.intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6]); // Returns [7, -4, 3] + * + * @param {Array | Matrix} w Co-ordinates of first end-point of first line + * @param {Array | Matrix} x Co-ordinates of second end-point of first line + * @param {Array | Matrix} y Co-ordinates of first end-point of second line + * OR Co-efficients of the plane's equation + * @param {Array | Matrix} z Co-ordinates of second end-point of second line + * OR null if the calculation is for line and plane + * @return {Array} Returns the point of intersection of lines/lines-planes + */ + var intersect = typed('intersect', { + 'Array, Array, Array': function (x, y, plane) { + if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } + if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } + if (!_4d(plane)) { throw new TypeError('Array with 4 numbers expected as third argument'); } + + return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]); + }, + + 'Array, Array, Array, Array': function (w, x, y, z) { + if (w.length === 2) { + if (!_2d(w)) { throw new TypeError('Array with 2 numbers expected for first argument'); } + if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for second argument'); } + if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for third argument'); } + if (!_2d(z)) { throw new TypeError('Array with 2 numbers expected for fourth argument'); } + + return _intersect2d(w, x, y, z); + } + else if (w.length === 3) { + if (!_3d(w)) { throw new TypeError('Array with 3 numbers expected for first argument'); } + if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for second argument'); } + if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for third argument'); } + if (!_3d(z)) { throw new TypeError('Array with 3 numbers expected for fourth argument'); } + + return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]); + } + else { + throw new TypeError('Arrays with two or thee dimensional points expected'); + } + }, + + 'Matrix, Matrix, Matrix': function (x, y, plane) { + return matrix(intersect(x.valueOf(), y.valueOf(), plane.valueOf())); + }, + + 'Matrix, Matrix, Matrix, Matrix': function (w, x, y, z) { + // TODO: output matrix type should match input matrix type + return matrix(intersect(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf())); + } + }); + + function _2d(x) { + return x.length === 2 && typeof x[0] === 'number' && typeof x[1] === 'number'; + } + + function _3d(x) { + return x.length === 3 && typeof x[0] === 'number' && typeof x[1] === 'number' && typeof x[2] === 'number'; + } + + function _4d(x) { + return x.length === 4 && typeof x[0] === 'number' && typeof x[1] === 'number' && typeof x[2] === 'number' && typeof x[3] === 'number'; + } + + function _intersect2d(p1a, p1b, p2a, p2b){ + var o1 = p1a; + var o2 = p2a; + var d1 = subtract(o1, p1b); + var d2 = subtract(o2, p2b); + var det = d1[0]*d2[1] - d2[0]*d1[1]; + if (abs(det) < config.epsilon) { + return null; + } + var t = (d2[0]*o1[1] - d2[1]*o1[0] - d2[0]*o2[1] + d2[1]*o2[0]) / det; + return add(multiply(d1, t), o1); + } + + function _intersect3d(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4){ + var d1343 = (x1 - x3)*(x4 - x3) + (y1 - y3)*(y4 - y3) + (z1 - z3)*(z4 - z3); + var d4321 = (x4 - x3)*(x2 - x1) + (y4 - y3)*(y2 - y1) + (z4 - z3)*(z2 - z1); + var d1321 = (x1 - x3)*(x2 - x1) + (y1 - y3)*(y2 - y1) + (z1 - z3)*(z2 - z1); + var d4343 = (x4 - x3)*(x4 - x3) + (y4 - y3)*(y4 - y3) + (z4 - z3)*(z4 - z3); + var d2121 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) + (z2 - z1)*(z2 - z1); + var ta = ( d1343*d4321 - d1321*d4343 ) / ( d2121*d4343 - d4321*d4321 ); + var tb = ( d1343 + ta * d4321 ) / (d4343); + + var pax = x1 + ta * (x2 - x1); + var pay = y1 + ta * (y2 - y1); + var paz = z1 + ta * (z2 - z1); + var pbx = x3 + tb * (x4 - x3); + var pby = y3 + tb * (y4 - y3); + var pbz = z3 + tb * (z4 - z3); + if (pax === pbx && pay === pby && paz === pbz){ + return [pax, pay, paz]; + } + else{ + return null; + } + } + + function _intersectLinePlane(x1, y1, z1, x2, y2, z2, x, y, z, c){ + var t = (c - x1*x - y1*y - z1*z)/(x2*x + y2*y + z2*z - x1 - y1 - z1); + var px = x1 + t * (x2 - x1); + var py = y1 + t * (y2 - y1); + var pz = z1 + t * (z2 - z1); + return [px, py, pz]; + // TODO: Add cases when line is parallel to the plane: + // (a) no intersection, + // (b) line contained in plane + } + + return intersect; + } + + exports.name = 'intersect'; + exports.factory = factory; + + +/***/ }, +/* 418 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Calculates: + * The eucledian distance between two points in 2 and 3 dimensional spaces. + * Distance between point and a line in 2 and 3 dimensional spaces. + * Pairwise distance between a set of 2D or 3D points + * NOTE: + * When substituting coefficients of a line(a, b and c), use ax + by + c = 0 instead of ax + by = c + * For parametric equation of a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b, c) + * + * Syntax: + * math.distance([x1, y1], [x2, y2]) + *- math.distance({pointOneX: 4, pointOneY: 5}, {pointTwoX: 2, pointTwoY: 7}) + * math.distance([x1, y1, z1], [x2, y2, z2]) + * math.distance({pointOneX: 4, pointOneY: 5, pointOneZ: 8}, {pointTwoX: 2, pointTwoY: 7, pointTwoZ: 9}) + * math.distance([[A], [B], [C]...]) + * math.distance([x1, y1], [LinePtX1, LinePtY1], [LinePtX2, LinePtY2]) + * math.distance({pointX: 1, pointY: 4}, {lineOnePtX: 6, lineOnePtY: 3}, {lineTwoPtX: 2, lineTwoPtY: 8}) + * math.distance([x1, y1, z1], [LinePtX1, LinePtY1, LinePtZ1], [LinePtX2, LinePtY2, LinePtZ2]) + * math.distance({pointX: 1, pointY: 4, pointZ: 7}, {lineOnePtX: 6, lineOnePtY: 3, lineOnePtZ: 4}, {lineTwoPtX: 2, lineTwoPtY: 8, lineTwoPtZ: 5}) + * math.distance([x1, y1], [xCoeffLine, yCoeffLine, constant]) + * math.distance({pointX: 10, pointY: 10}, {xCoeffLine: 8, yCoeffLine: 1, constant: 3}) + * math.distance([x1, y1, z1], [x0, y0, z0, a-tCoeff, b-tCoeff, c-tCoeff]) point and parametric equation of 3D line + * math.distance([x, y, z], [x0, y0, z0, a, b, c]) + * math.distance({pointX: 2, pointY: 5, pointZ: 9}, {x0: 4, y0: 6, z0: 3, a: 4, b: 2, c: 0}) + * + * Examples: + * math.distance([0,0], [4,4]) // Returns 5.6569 + * math.distance( + * {pointOneX: 0, pointOneY: 0}, + * {pointTwoX: 10, pointTwoY: 10}) // Returns 14.142135623730951 + * math.distance([1, 0, 1], [4, -2, 2]) // Returns 3.74166 + * math.distance( + * {pointOneX: 4, pointOneY: 5, pointOneZ: 8}, + * {pointTwoX: 2, pointTwoY: 7, pointTwoZ: 9}) // Returns 3 + * math.distance([[1, 2], [1, 2], [1, 3]]) // Returns [0, 1, 1] + * math.distance([[1,2,4], [1,2,6], [8,1,3]]) // Returns [2, 7.14142842854285, 7.681145747868608] + * math.distance([10, 10], [8, 1, 3]) // Returns 11.535230316796387 + * math.distance([10, 10], [2, 3], [-8, 0]) // Returns 8.759953130362847 + * math.distance( + * {pointX: 1, pointY: 4}, + * {lineOnePtX: 6, lineOnePtY: 3}, + * {lineTwoPtX: 2, lineTwoPtY: 8}) // Returns 2.720549372624744 + * math.distance([2, 3, 1], [1, 1, 2, 5, 0, 1]) // Returns 2.3204774044612857 + * math.distance( + * {pointX: 2, pointY: 3, pointZ: 1}, + * {x0: 1, y0: 1, z0: 2, a: 5, b: 0, c: 1} // Returns 2.3204774044612857 + * + * @param {Array | Matrix | Object} x Co-ordinates of first point + * @param {Array | Matrix | Object} y Co-ordinates of second point + * @return {Number | BigNumber} Returns the distance from two/three points + */ + + var distance = typed('distance', { + 'Array, Array, Array': function(x, y, z){ + // Point to Line 2D; (x=Point, y=LinePoint1, z=LinePoint2) + if (x.length == 2 && y.length == 2 && z.length == 2){ + if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } + if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for second argument'); } + if (!_2d(z)) { throw new TypeError('Array with 2 numbers expected for third argument'); } + var m = (z[1]-z[0])/(y[1]-y[0]); + var xCoeff = m*m*y[0]; + var yCoeff = -1*(m*y[0]); + var constant = x[1]; + + return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant); + } + else{ + throw new TypeError('Invalid Arguments: Try again'); + } + }, + 'Object, Object, Object': function(x, y, z){ + if (Object.keys(x).length == 2 && Object.keys(y).length == 2 && Object.keys(z).length == 2){ + if (!_2d(x)) { throw new TypeError('Values of pointX and pointY should be numbers'); } + if (!_2d(y)) { throw new TypeError('Values of lineOnePtX and lineOnePtY should be numbers'); } + if (!_2d(z)) { throw new TypeError('Values of lineTwoPtX and lineTwoPtY should be numbers'); } + if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('lineOnePtX') && + y.hasOwnProperty('lineOnePtY') && z.hasOwnProperty('lineTwoPtX') && z.hasOwnProperty('lineTwoPtY')){ + var m = (z.lineTwoPtY-z.lineTwoPtX)/(y.lineOnePtY-y.lineOnePtX); + var xCoeff = m*m*y.lineOnePtX; + var yCoeff = -1*(m*y.lineOnePtX); + var constant = x.pointX; + + return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant); + } + else{ + throw new TypeError('Key names do not match'); + } + } + else{ + throw new TypeError('Invalid Arguments: Try again'); + } + }, + 'Array, Array': function(x, y){ + // Point to Line 2D; (x=[pointX, pointY], y=[x-coeff, y-coeff, const]) + if (x.length == 2 && y.length == 3){ + if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } + if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } + + return _distancePointLine2D(x[0], x[1], y[0], y[1], y[2]); + } + // Point to Line 3D + else if (x.length == 3 && y.length == 6){ + if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } + if (!_parametricLine(y)) { throw new TypeError('Array with 6 numbers expected for second argument'); } + + return _distancePointLine3D(x[0], x[1], x[2], y[0], y[1], y[2], y[3], y[4], y[5]); + } + // Point to Point 2D + else if (x.length == 2 && y.length == 2){ + if (!_2d(x)) { throw new TypeError('Array with 2 numbers expected for first argument'); } + if (!_2d(y)) { throw new TypeError('Array with 2 numbers expected for second argument'); } + + return _distance2d(x[0], x[1], y[0], y[1]); + } + // Point to Point 3D + else if(x.length == 3 && y.length == 3){ + if (!_3d(x)) { throw new TypeError('Array with 3 numbers expected for first argument'); } + if (!_3d(y)) { throw new TypeError('Array with 3 numbers expected for second argument'); } + + return _distance3d(x[0], x[1], x[2], y[0], y[1], y[2]); + } + else{ + throw new TypeError('Invalid Arguments: Try again'); + } + }, + 'Object, Object': function(x, y){ + if (Object.keys(x).length == 2 && Object.keys(y).length == 3){ + if (!_2d(x)) { throw new TypeError('Values of pointX and pointY should be numbers'); } + if (!_3d(y)) { throw new TypeError('Values of xCoeffLine, yCoeffLine and constant should be numbers'); } + if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('xCoeffLine') && + y.hasOwnProperty('yCoeffLine') && y.hasOwnProperty('yCoeffLine')){ + + return _distancePointLine2D(x.pointX, x.pointY, y.xCoeffLine, y.yCoeffLine, y.constant); + } + else{ + throw new TypeError('Key names do not match'); + } + } + // Point to Line 3D + else if (Object.keys(x).length == 3 && Object.keys(y).length == 6){ + if (!_3d(x)) { throw new TypeError('Values of pointX, pointY and pointZ should be numbers'); } + if (!_parametricLine(y)) { throw new TypeError('Values of x0, y0, z0, a, b and c should be numbers'); } + if (x.hasOwnProperty('pointX') && x.hasOwnProperty('pointY') && y.hasOwnProperty('x0') && + y.hasOwnProperty('y0') && y.hasOwnProperty('z0') && y.hasOwnProperty('a') && + y.hasOwnProperty('b') && y.hasOwnProperty('c')){ + + return _distancePointLine3D(x.pointX, x.pointY, x.pointZ, y.x0, y.y0, y.z0, y.a, y.b, y.c); + } + else{ + throw new TypeError('Key names do not match'); + } + } + // Point to Point 2D + else if (Object.keys(x).length == 2 && Object.keys(y).length == 2){ + if (!_2d(x)) { throw new TypeError('Values of pointOneX and pointOneY should be numbers'); } + if (!_2d(y)) { throw new TypeError('Values of pointTwoX and pointTwoY should be numbers'); } + if (x.hasOwnProperty('pointOneX') && x.hasOwnProperty('pointOneY') && + y.hasOwnProperty('pointTwoX') && y.hasOwnProperty('pointTwoY')){ + + return _distance2d(x.pointOneX, x.pointOneY, y.pointTwoX, y.pointTwoY); + } + else{ + throw new TypeError('Key names do not match'); + } + } + // Point to Point 3D + else if(Object.keys(x).length == 3 && Object.keys(y).length == 3){ + if (!_3d(x)) { throw new TypeError('Values of pointOneX, pointOneY and pointOneZ should be numbers'); } + if (!_3d(y)) { throw new TypeError('Values of pointTwoX, pointTwoY and pointTwoZ should be numbers'); } + if (x.hasOwnProperty('pointOneX') && x.hasOwnProperty('pointOneY') && x.hasOwnProperty('pointOneZ') && + y.hasOwnProperty('pointTwoX') && y.hasOwnProperty('pointTwoY') && y.hasOwnProperty('pointTwoZ')){ + + return _distance3d(x.pointOneX, x.pointOneY, x.pointOneZ, y.pointTwoX, y.pointTwoY, y.pointTwoZ); + } + else { + throw new TypeError('Key names do not match'); + } + } + else{ + throw new TypeError('Invalid Arguments: Try again'); + } + }, + 'Array': function(arr){ + if (!_pairwise(arr)) { throw new TypeError('Incorrect array format entered for pairwise distance calculation'); } + + return _distancePairwise(arr); + } + }); + return distance; + } + + function _2d(a){ + // checks if the number of arguments are correct in count and are valid (should be numbers) + if (a.constructor !== Array){ + a = _objectToArray(a); + } + return typeof a[0] === 'number' && typeof a[1] === 'number'; + } + + function _3d(a){ + // checks if the number of arguments are correct in count and are valid (should be numbers) + if (a.constructor !== Array){ + a = _objectToArray(a); + } + return typeof a[0] === 'number' && typeof a[1] === 'number' && typeof a[2] === 'number'; + } + + function _parametricLine(a){ + if (a.constructor !== Array){ + a = _objectToArray(a); + } + return typeof a[0] === 'number' && typeof a[1] === 'number' && typeof a[2] === 'number' && + typeof a[3] === 'number' && typeof a[4] === 'number' && typeof a[5] === 'number'; + + } + + function _objectToArray(o){ + var keys = Object.keys(o); + var a = []; + for (var i = 0; i < keys.length; i++) { + a.push(o[keys[i]]); + } + return a; + } + + function _pairwise(a){ + //checks for valid arguments passed to _distancePairwise(Array) + if (a[0].length == 2 && typeof a[0][0] === 'number' && typeof a[0][1] === 'number'){ + for(var i in a){ + if (a[i].length != 2 || typeof a[i][0] !== 'number' || typeof a[i][1] !== 'number'){ + return false; + } + } + } + else if (a[0].length == 3 && typeof a[0][0] === 'number' && typeof a[0][1] === 'number' && typeof a[0][2] === 'number'){ + for(var i in a){ + if (a[i].length != 3 || typeof a[i][0] !== 'number' || typeof a[i][1] !== 'number' || typeof a[i][2] !== 'number'){ + return false; + } + } + } + else{ + return false; + } + return true; + } + + function _distancePointLine2D(x, y, a, b, c){ + var num = Math.abs(a*x + b*y + c); + var den = Math.pow((a*a + b*b), 0.5); + var result = (num/den); + return result; + } + + function _distancePointLine3D(x, y, z, x0, y0, z0, a, b, c){ + var num = [((y0-y)*(c))-((z0-z)*(b)), ((z0-z)*(a))-((x0-x)*(c)), ((x0-x)*(b))-((y0-y)*(a))] + num = Math.pow(num[0]*num[0] + num[1]*num[1] + num[2]*num[2], 0.5); + var den = Math.pow(a*a + b*b + c*c, 0.5); + var result = num/den; + return result; + } + + function _distance2d(x1, y1, x2, y2){ + var yDiff = y2 - y1; + var xDiff = x2 - x1; + var radicant = yDiff * yDiff + xDiff * xDiff; + var result = Math.pow(radicant, 0.5); + return result; + } + + function _distance3d(x1, y1, z1, x2, y2, z2){ + var zDiff = z2 - z1; + var yDiff = y2 - y1; + var xDiff = x2 - x1; + var radicant = zDiff * zDiff + yDiff * yDiff + xDiff * xDiff; + var result = Math.pow(radicant, 0.5); + return result; + } + + function _distancePairwise(a){ + var result = []; + for(var i = 0; i < a.length-1; i++){ + for(var j = i+1; j < a.length; j++){ + if (a[0].length == 2){ + result.push(_distance2d(a[i][0], a[i][1], a[j][0], a[j][1])); + } + else if (a[0].length == 3){ + result.push(_distance3d(a[i][0], a[i][1], a[i][2], a[j][0], a[j][1], a[j][2])); + } + } + } + return result; + } + + exports.name = 'distance'; + exports.factory = factory; + + +/***/ }, +/* 419 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(420), + __webpack_require__(421), + __webpack_require__(423), + __webpack_require__(424) + ]; + + +/***/ }, +/* 420 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + var zeros = load(__webpack_require__(381)); + var not = load(__webpack_require__(421)); + var isZero = load(__webpack_require__(422)); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm06 = load(__webpack_require__(372)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Logical `and`. Test whether two values are both defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.and(x, y) + * + * Examples: + * + * math.and(2, 4); // returns true + * + * a = [2, 0, 0]; + * b = [3, 7, 0]; + * c = 0; + * + * math.and(a, b); // returns [true, false, false] + * math.and(a, c); // returns [false, false, false] + * + * See also: + * + * not, or, xor + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check + * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check + * @return {boolean | Array | Matrix} + * Returns true when both inputs are defined with a nonzero/nonempty value. + */ + var and = typed('and', { + + 'number, number': function (x, y) { + return !!(x && y); + }, + + 'Complex, Complex': function (x, y) { + return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0); + }, + + 'BigNumber, BigNumber': function (x, y) { + return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN(); + }, + + 'Unit, Unit': function (x, y) { + return and(x.value, y.value); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = algorithm06(x, y, and, false); + break; + default: + // sparse & dense + c = algorithm02(y, x, and, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = algorithm02(x, y, and, false); + break; + default: + // dense & dense + c = algorithm13(x, y, and); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return and(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return and(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return and(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // check scalar + if (not(y)) { + // return zero matrix + return zeros(x.size(), x.storage()); + } + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, and, false); + break; + default: + c = algorithm14(x, y, and, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // check scalar + if (not(x)) { + // return zero matrix + return zeros(x.size(), x.storage()); + } + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm11(y, x, and, true); + break; + default: + c = algorithm14(y, x, and, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return and(matrix(x), y).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return and(x, matrix(y)).valueOf(); + } + }); + + and.toTex = { + 2: '\\left(${args[0]}' + latex.operators['and'] + '${args[1]}\\right)' + }; + + return and; + } + + exports.name = 'and'; + exports.factory = factory; + + +/***/ }, +/* 421 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + /** + * Logical `not`. Flips boolean value of a given parameter. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.not(x) + * + * Examples: + * + * math.not(2); // returns false + * math.not(0); // returns true + * math.not(true); // returns false + * + * a = [2, -7, 0]; + * math.not(a); // returns [false, false, true] + * + * See also: + * + * and, or, xor + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check + * @return {boolean | Array | Matrix} + * Returns true when input is a zero or empty value. + */ + var not = typed('not', { + 'number': function (x) { + return !x; + }, + + 'Complex': function (x) { + return x.re === 0 && x.im === 0; + }, + + 'BigNumber': function (x) { + return x.isZero() || x.isNaN(); + }, + + 'Unit': function (x) { + return not(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, not); + } + }); + + not.toTex = { + 1: latex.operators['not'] + '\\left(${args[0]}\\right)' + }; + + return not; + } + + exports.name = 'not'; + exports.factory = factory; + + +/***/ }, +/* 422 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var number = __webpack_require__(6); + + function factory (type, config, load, typed) { + /** + * Test whether a value is zero. + * The function can check for zero for types `number`, `BigNumber`, `Fraction`, + * `Complex`, and `Unit`. + * + * The function is evaluated element-wise in case of Array or Matrix input. + * + * Syntax: + * + * math.isZero(x) + * + * Examples: + * + * math.isZero(0); // returns true + * math.isZero(2); // returns false + * math.isZero(0.5); // returns false + * math.isZero(math.bignumber(0)); // returns true + * math.isZero(math.fraction(0)); // returns true + * math.isZero(math.fraction(1,3)); // returns false + * math.isZero(math.complex('2 - 4i'); // returns false + * math.isZero(math.complex('0i'); // returns true + * math.isZero('0'); // returns true + * math.isZero('2'); // returns false + * math.isZero([2, 0, -3]'); // returns [false, true, false] + * + * See also: + * + * isNumeric, isPositive, isNegative, isInteger + * + * @param {number | BigNumber | Complex | Fraction | Unit | Array | Matrix} x Value to be tested + * @return {boolean} Returns true when `x` is zero. + * Throws an error in case of an unknown data type. + */ + var isZero = typed('isZero', { + 'number': function (x) { + return x === 0; + }, + + 'BigNumber': function (x) { + return x.isZero(); + }, + + 'Complex': function (x) { + return x.re === 0 && x.im === 0; + }, + + 'Fraction': function (x) { + return x.d === 1 && x.n === 0; + }, + + 'Unit': function (x) { + return isZero(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, isZero); + } + }); + + return isZero; + } + + exports.name = 'isZero'; + exports.factory = factory; + + +/***/ }, +/* 423 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm05 = load(__webpack_require__(79)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Logical `or`. Test if at least one value is defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.or(x, y) + * + * Examples: + * + * math.or(2, 4); // returns true + * + * a = [2, 5, 0]; + * b = [0, 22, 0]; + * c = 0; + * + * math.or(a, b); // returns [true, true, false] + * math.or(b, c); // returns [false, true, false] + * + * See also: + * + * and, not, xor + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check + * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check + * @return {boolean | Array | Matrix} + * Returns true when one of the inputs is defined with a nonzero/nonempty value. + */ + var or = typed('or', { + + 'number, number': function (x, y) { + return !!(x || y); + }, + + 'Complex, Complex': function (x, y) { + return (x.re !== 0 || x.im !== 0) || (y.re !== 0 || y.im !== 0); + }, + + 'BigNumber, BigNumber': function (x, y) { + return (!x.isZero() && !x.isNaN()) || (!y.isZero() && !y.isNaN()); + }, + + 'Unit, Unit': function (x, y) { + return or(x.value, y.value); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm05(x, y, or); + break; + default: + // sparse + dense + c = algorithm03(y, x, or, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, or, false); + break; + default: + // dense + dense + c = algorithm13(x, y, or); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return or(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return or(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return or(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, or, false); + break; + default: + c = algorithm14(x, y, or, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, or, true); + break; + default: + c = algorithm14(y, x, or, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, or, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, or, true).valueOf(); + } + }); + + or.toTex = { + 2: '\\left(${args[0]}' + latex.operators['or'] + '${args[1]}\\right)' + }; + + return or; + } + + exports.name = 'or'; + exports.factory = factory; + + +/***/ }, +/* 424 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Logical `xor`. Test whether one and only one value is defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.xor(x, y) + * + * Examples: + * + * math.xor(2, 4); // returns false + * + * a = [2, 0, 0]; + * b = [2, 7, 0]; + * c = 0; + * + * math.xor(a, b); // returns [false, true, false] + * math.xor(a, c); // returns [true, false, false] + * + * See also: + * + * and, not, or + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check + * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check + * @return {boolean | Array | Matrix} + * Returns true when one and only one input is defined with a nonzero/nonempty value. + */ + var xor = typed('xor', { + + 'number, number': function (x, y) { + return !!(!!x ^ !!y); + }, + + 'Complex, Complex': function (x, y) { + return ((x.re !== 0 || x.im !== 0) !== (y.re !== 0 || y.im !== 0)); + }, + + 'BigNumber, BigNumber': function (x, y) { + return ((!x.isZero() && !x.isNaN()) !== (!y.isZero() && !y.isNaN())); + }, + + 'Unit, Unit': function (x, y) { + return xor(x.value, y.value); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, xor); + break; + default: + // sparse + dense + c = algorithm03(y, x, xor, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, xor, false); + break; + default: + // dense + dense + c = algorithm13(x, y, xor); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return xor(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return xor(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return xor(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, xor, false); + break; + default: + c = algorithm14(x, y, xor, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, xor, true); + break; + default: + c = algorithm14(y, x, xor, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, xor, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, xor, true).valueOf(); + } + }); + + xor.toTex = { + 2: '\\left(${args[0]}' + latex.operators['xor'] + '${args[1]}\\right)' + }; + + return xor; + } + + exports.name = 'xor'; + exports.factory = factory; + + +/***/ }, +/* 425 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(301), + __webpack_require__(426), + __webpack_require__(319), + __webpack_require__(427), + __webpack_require__(428), + __webpack_require__(83), + __webpack_require__(303), + __webpack_require__(429), + __webpack_require__(305), + __webpack_require__(318), + __webpack_require__(308), + __webpack_require__(430), + __webpack_require__(431), + __webpack_require__(323), + __webpack_require__(433), + __webpack_require__(434), + __webpack_require__(435), + __webpack_require__(436), + __webpack_require__(276), + __webpack_require__(378), + __webpack_require__(335), + __webpack_require__(381) + ]; + + +/***/ }, +/* 426 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(40).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + var subtract = load(__webpack_require__(77)); + var multiply = load(__webpack_require__(84)); + + /** + * Calculate the cross product for two vectors in three dimensional space. + * The cross product of `A = [a1, a2, a3]` and `B =[b1, b2, b3]` is defined + * as: + * + * cross(A, B) = [ + * a2 * b3 - a3 * b2, + * a3 * b1 - a1 * b3, + * a1 * b2 - a2 * b1 + * ] + * + * Syntax: + * + * math.cross(x, y) + * + * Examples: + * + * math.cross([1, 1, 0], [0, 1, 1]); // Returns [1, -1, 1] + * math.cross([3, -3, 1], [4, 9, 2]); // Returns [-15, -2, 39] + * math.cross([2, 3, 4], [5, 6, 7]); // Returns [-3, 6, -3] + * + * See also: + * + * dot, multiply + * + * @param {Array | Matrix} x First vector + * @param {Array | Matrix} y Second vector + * @return {Array | Matrix} Returns the cross product of `x` and `y` + */ + var cross = typed('cross', { + 'Matrix, Matrix': function (x, y) { + return matrix(_cross(x.toArray(), y.toArray())); + }, + + 'Matrix, Array': function (x, y) { + return matrix(_cross(x.toArray(), y)); + }, + + 'Array, Matrix': function (x, y) { + return matrix(_cross(x, y.toArray())); + }, + + 'Array, Array': _cross + }); + + cross.toTex = { + 2: '\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)' + }; + + return cross; + + /** + * Calculate the cross product for two arrays + * @param {Array} x First vector + * @param {Array} y Second vector + * @returns {Array} Returns the cross product of x and y + * @private + */ + function _cross(x, y) { + var xSize= size(x); + var ySize = size(y); + + if (xSize.length != 1 || ySize.length != 1 || xSize[0] != 3 || ySize[0] != 3) { + throw new RangeError('Vectors with length 3 expected ' + + '(Size A = [' + xSize.join(', ') + '], B = [' + ySize.join(', ') + '])'); + } + + return [ + subtract(multiply(x[1], y[2]), multiply(x[2], y[1])), + subtract(multiply(x[2], y[0]), multiply(x[0], y[2])), + subtract(multiply(x[0], y[1]), multiply(x[1], y[0])) + ]; + } + } + + exports.name = 'cross'; + exports.factory = factory; + + +/***/ }, +/* 427 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(40); + var clone = __webpack_require__(3).clone; + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + /** + * Create a diagonal matrix or retrieve the diagonal of a matrix + * + * When `x` is a vector, a matrix with vector `x` on the diagonal will be returned. + * When `x` is a two dimensional matrix, the matrixes `k`th diagonal will be returned as vector. + * When k is positive, the values are placed on the super diagonal. + * When k is negative, the values are placed on the sub diagonal. + * + * Syntax: + * + * math.diag(X) + * math.diag(X, format) + * math.diag(X, k) + * math.diag(X, k, format) + * + * Examples: + * + * // create a diagonal matrix + * math.diag([1, 2, 3]); // returns [[1, 0, 0], [0, 2, 0], [0, 0, 3]] + * math.diag([1, 2, 3], 1); // returns [[0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]] + * math.diag([1, 2, 3], -1); // returns [[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]] + * + * // retrieve the diagonal from a matrix + * var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + * math.diag(a); // returns [1, 5, 9] + * + * See also: + * + * ones, zeros, eye + * + * @param {Matrix | Array} x A two dimensional matrix or a vector + * @param {number | BigNumber} [k=0] The diagonal where the vector will be filled + * in or retrieved. + * @param {string} [format='dense'] The matrix storage format. + * + * @returns {Matrix | Array} Diagonal matrix from input vector, or diagonal from input matrix. + */ + var diag = typed('diag', { + // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments + + 'Array': function (x) { + return _diag(x, 0, array.size(x), null); + }, + + 'Array, number': function (x, k) { + return _diag(x, k, array.size(x), null); + }, + + 'Array, BigNumber': function (x, k) { + return _diag(x, k.toNumber(), array.size(x), null); + }, + + 'Array, string': function (x, format) { + return _diag(x, 0, array.size(x), format); + }, + + 'Array, number, string': function (x, k, format) { + return _diag(x, k, array.size(x), format); + }, + + 'Array, BigNumber, string': function (x, k, format) { + return _diag(x, k.toNumber(), array.size(x), format); + }, + + 'Matrix': function (x) { + return _diag(x, 0, x.size(), x.storage()); + }, + + 'Matrix, number': function (x, k) { + return _diag(x, k, x.size(), x.storage()); + }, + + 'Matrix, BigNumber': function (x, k) { + return _diag(x, k.toNumber(), x.size(), x.storage()); + }, + + 'Matrix, string': function (x, format) { + return _diag(x, 0, x.size(), format); + }, + + 'Matrix, number, string': function (x, k, format) { + return _diag(x, k, x.size(), format); + }, + + 'Matrix, BigNumber, string': function (x, k, format) { + return _diag(x, k.toNumber(), x.size(), format); + } + }); + + diag.toTex = undefined; // use default template + + return diag; + + /** + * Creeate diagonal matrix from a vector or vice versa + * @param {Array | Matrix} x + * @param {number} k + * @param {string} format Storage format for matrix. If null, + * an Array is returned + * @returns {Array | Matrix} + * @private + */ + function _diag (x, k, size, format) { + if (!isInteger(k)) { + throw new TypeError ('Second parameter in function diag must be an integer'); + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // check dimensions + switch (size.length) { + case 1: + return _createDiagonalMatrix(x, k, format, size[0], kSub, kSuper); + case 2: + return _getDiagonal(x, k, format, size, kSub, kSuper); + } + throw new RangeError('Matrix for function diag must be 2 dimensional'); + } + + function _createDiagonalMatrix(x, k, format, l, kSub, kSuper) { + // matrix size + var ms = [l + kSub, l + kSuper]; + // get matrix constructor + var F = type.Matrix.storage(format || 'dense'); + // create diagonal matrix + var m = F.diagonal(ms, x, k); + // check we need to return a matrix + return format !== null ? m : m.valueOf(); + } + + function _getDiagonal(x, k, format, s, kSub, kSuper) { + // check x is a Matrix + if (x && x.isMatrix === true) { + // get diagonal matrix + var dm = x.diagonal(k); + // check we need to return a matrix + if (format !== null) { + // check we need to change matrix format + if (format !== dm.storage()) + return matrix(dm, format); + return dm; + } + return dm.valueOf(); + } + // vector size + var n = Math.min(s[0] - kSub, s[1] - kSuper); + // diagonal values + var vector = []; + // loop diagonal + for (var i = 0; i < n; i++) { + vector[i] = x[i + kSub][i + kSuper]; + } + // check we need to return a matrix + return format !== null ? matrix(vector) : vector; + } + } + + exports.name = 'diag'; + exports.factory = factory; + + +/***/ }, +/* 428 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(40).size; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var multiply = load(__webpack_require__(84)); + + /** + * Calculate the dot product of two vectors. The dot product of + * `A = [a1, a2, a3, ..., an]` and `B = [b1, b2, b3, ..., bn]` is defined as: + * + * dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn + * + * Syntax: + * + * math.dot(x, y) + * + * Examples: + * + * math.dot([2, 4, 1], [2, 2, 3]); // returns number 15 + * math.multiply([2, 4, 1], [2, 2, 3]); // returns number 15 + * + * See also: + * + * multiply, cross + * + * @param {Array | Matrix} x First vector + * @param {Array | Matrix} y Second vector + * @return {number} Returns the dot product of `x` and `y` + */ + var dot = typed('dot', { + 'Matrix, Matrix': function (x, y) { + return _dot(x.toArray(), y.toArray()); + }, + + 'Matrix, Array': function (x, y) { + return _dot(x.toArray(), y); + }, + + 'Array, Matrix': function (x, y) { + return _dot(x, y.toArray()); + }, + + 'Array, Array': _dot + }); + + dot.toTex = {2: '\\left(${args[0]}\\cdot${args[1]}\\right)'}; + + return dot; + + /** + * Calculate the dot product for two arrays + * @param {Array} x First vector + * @param {Array} y Second vector + * @returns {number} Returns the dot product of x and y + * @private + */ + // TODO: double code with math.multiply + function _dot(x, y) { + var xSize= size(x); + var ySize = size(y); + var len = xSize[0]; + + if (xSize.length !== 1 || ySize.length !== 1) throw new RangeError('Vector expected'); // TODO: better error message + if (xSize[0] != ySize[0]) throw new RangeError('Vectors must have equal length (' + xSize[0] + ' != ' + ySize[0] + ')'); + if (len == 0) throw new RangeError('Cannot calculate the dot product of empty vectors'); + + var prod = 0; + for (var i = 0; i < len; i++) { + prod = add(prod, multiply(x[i], y[i])); + } + + return prod; + } + } + + exports.name = 'dot'; + exports.factory = factory; + + +/***/ }, +/* 429 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(3).clone; + var _flatten = __webpack_require__(40).flatten; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Flatten a multi dimensional matrix into a single dimensional matrix. + * + * Syntax: + * + * math.flatten(x) + * + * Examples: + * + * math.flatten([[1,2], [3,4]]); // returns [1, 2, 3, 4] + * + * See also: + * + * concat, resize, size, squeeze + * + * @param {Matrix | Array} x Matrix to be flattened + * @return {Matrix | Array} Returns the flattened matrix + */ + var flatten = typed('flatten', { + 'Array': function (x) { + return _flatten(clone(x)); + }, + + 'Matrix': function (x) { + var flat = _flatten(clone(x.toArray())); + // TODO: return the same matrix type as x + return matrix(flat); + } + }); + + flatten.toTex = undefined; // use default template + + return flatten; + } + + exports.name = 'flatten'; + exports.factory = factory; + + +/***/ }, +/* 430 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var resize = __webpack_require__(40).resize; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Create a matrix filled with ones. The created matrix can have one or + * multiple dimensions. + * + * Syntax: + * + * math.ones(m) + * math.ones(m, format) + * math.ones(m, n) + * math.ones(m, n, format) + * math.ones([m, n]) + * math.ones([m, n], format) + * math.ones([m, n, p, ...]) + * math.ones([m, n, p, ...], format) + * + * Examples: + * + * math.ones(3); // returns [1, 1, 1] + * math.ones(3, 2); // returns [[1, 1], [1, 1], [1, 1]] + * math.ones(3, 2, 'dense'); // returns Dense Matrix [[1, 1], [1, 1], [1, 1]] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.ones(math.size(A)); // returns [[1, 1, 1], [1, 1, 1]] + * + * See also: + * + * zeros, eye, size, range + * + * @param {...number | Array} size The size of each dimension of the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Array | Matrix | number} A matrix filled with ones + */ + var ones = typed('ones', { + '': function () { + return (config.matrix === 'Array') + ? _ones([]) + : _ones([], 'default'); + }, + + // math.ones(m, n, p, ..., format) + // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this + '...number | BigNumber | string': function (size) { + var last = size[size.length - 1]; + if (typeof last === 'string') { + var format = size.pop(); + return _ones(size, format); + } + else if (config.matrix === 'Array') { + return _ones(size); + } + else { + return _ones(size, 'default'); + } + }, + + 'Array': _ones, + + 'Matrix': function (size) { + var format = size.storage(); + return _ones(size.valueOf(), format); + }, + + 'Array | Matrix, string': function (size, format) { + return _ones (size.valueOf(), format); + } + }); + + ones.toTex = undefined; // use default template + + return ones; + + /** + * Create an Array or Matrix with ones + * @param {Array} size + * @param {string} [format='default'] + * @return {Array | Matrix} + * @private + */ + function _ones(size, format) { + var hasBigNumbers = _normalize(size); + var defaultValue = hasBigNumbers ? new type.BigNumber(1) : 1; + _validate(size); + + if (format) { + // return a matrix + var m = matrix(format); + if (size.length > 0) { + return m.resize(size, defaultValue); + } + return m; + } + else { + // return an Array + var arr = []; + if (size.length > 0) { + return resize(arr, size, defaultValue); + } + return arr; + } + } + + // replace BigNumbers with numbers, returns true if size contained BigNumbers + function _normalize(size) { + var hasBigNumbers = false; + size.forEach(function (value, index, arr) { + if (value && value.isBigNumber === true) { + hasBigNumbers = true; + arr[index] = value.toNumber(); + } + }); + return hasBigNumbers; + } + + // validate arguments + function _validate (size) { + size.forEach(function (value) { + if (typeof value !== 'number' || !isInteger(value) || value < 0) { + throw new Error('Parameters in function ones must be positive integers'); + } + }); + } + } + + exports.name = 'ones'; + exports.factory = factory; + + +/***/ }, +/* 431 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var asc = load(__webpack_require__(432)); + function desc(a, b) { + return -asc(a, b); + } + + /** + * Partition-based selection of an array or 1D matrix. + * Will find the kth smallest value, and mutates the input array. + * Uses Quickselect. + * + * Syntax: + * + * math.partitionSelect(x, k) + * math.partitionSelect(x, k, compare) + * + * Examples: + * + * math.partitionSelect([5, 10, 1], 2); // returns 10 + * math.partitionSelect(['C', 'B', 'A', 'D'], 1); // returns 'B' + * + * function sortByLength (a, b) { + * return a.length - b.length; + * } + * math.partitionSelect(['Langdon', 'Tom', 'Sara'], 2, sortByLength); // returns 'Langdon' + * + * See also: + * + * sort + * + * @param {Matrix | Array} x A one dimensional matrix or array to sort + * @param {Number} k The kth smallest value to be retrieved; zero-based index + * @param {Function | 'asc' | 'desc'} [compare='asc'] + * An optional comparator function. The function is called as + * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, + * and 0 when a == b. + * @return {*} Returns the kth lowest value. + */ + return typed('partitionSelect', { + 'Array | Matrix, number': function (x, k) { + return _partitionSelect(x, k, asc); + }, + + 'Array | Matrix, number, string': function (x, k, compare) { + if (compare === 'asc') { + return _partitionSelect(x, k, asc); + } + else if (compare === 'desc') { + return _partitionSelect(x, k, desc); + } + else { + throw new Error('Compare string must be "asc" or "desc"'); + } + }, + + 'Array | Matrix, number, function': _partitionSelect + }); + + function _partitionSelect(x, k, compare) { + if (!isInteger(k) || k < 0) { + throw new Error('k must be a non-negative integer'); + } + + if (x && x.isMatrix) { + var size = x.size(); + if (size.length > 1) { + throw new Error('Only one dimensional matrices supported'); + } + return quickSelect(x.valueOf(), k, compare); + } + + if (Array.isArray(x)) { + return quickSelect(x, k, compare); + } + } + + /** + * Quickselect algorithm. + * Code adapted from: + * http://blog.teamleadnet.com/2012/07/quick-select-algorithm-find-kth-element.html + * + * @param {Array} arr + * @param {Number} k + * @param {Function} compare + * @private + */ + function quickSelect(arr, k, compare) { + if (k >= arr.length) { + throw new Error('k out of bounds'); + } + + var from = 0; + var to = arr.length - 1; + + // if from == to we reached the kth element + while (from < to) { + var r = from; + var w = to; + var pivot = arr[Math.floor(Math.random() * (to - from + 1)) + from]; + + // stop if the reader and writer meets + while (r < w) { + // arr[r] >= pivot + if (compare(arr[r], pivot) >= 0) { // put the large values at the end + var tmp = arr[w]; + arr[w] = arr[r]; + arr[r] = tmp; + --w; + } else { // the value is smaller than the pivot, skip + ++r; + } + } + + // if we stepped up (r++) we need to step one down (arr[r] > pivot) + if (compare(arr[r], pivot) > 0) { + --r; + } + + // the r pointer is on the end of the first k elements + if (k <= r) { + to = r; + } else { + from = r + 1; + } + } + + return arr[k]; + } + } + + exports.name = 'partitionSelect'; + exports.factory = factory; + + +/***/ }, +/* 432 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm05 = load(__webpack_require__(79)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y. + * + * x and y are considered equal when the relative difference between x and y + * is smaller than the configured epsilon. The function cannot be used to + * compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.compare(x, y) + * + * Examples: + * + * math.compare(6, 1); // returns 1 + * math.compare(2, 3); // returns -1 + * math.compare(7, 7); // returns 0 + * + * var a = math.unit('5 cm'); + * var b = math.unit('40 mm'); + * math.compare(a, b); // returns 1 + * + * math.compare(2, [1, 2, 3]); // returns [1, 0, -1] + * + * See also: + * + * equal, unequal, smaller, smallerEq, larger, largerEq + * + * @param {number | BigNumber | Fraction | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | Fraction | Unit | string | Array | Matrix} y Second value to compare + * @return {number | BigNumber | Fraction | Array | Matrix} Returns the result of the comparison: 1, 0 or -1. + */ + var compare = typed('compare', { + + 'boolean, boolean': function (x, y) { + return x === y ? 0 : (x > y ? 1 : -1); + }, + + 'number, number': function (x, y) { + return (x === y || nearlyEqual(x, y, config.epsilon)) + ? 0 + : (x > y ? 1 : -1); + }, + + 'BigNumber, BigNumber': function (x, y) { + return (x.eq(y) || bigNearlyEqual(x, y, config.epsilon)) + ? new type.BigNumber(0) + : new type.BigNumber(x.cmp(y)); + }, + + 'Fraction, Fraction': function (x, y) { + return new type.Fraction(x.compare(y)); + }, + + 'Complex, Complex': function () { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return compare(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x === y ? 0 : (x > y ? 1 : -1); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm05(x, y, compare); + break; + default: + // sparse + dense + c = algorithm03(y, x, compare, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, compare, false); + break; + default: + // dense + dense + c = algorithm13(x, y, compare); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return compare(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return compare(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return compare(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, compare, false); + break; + default: + c = algorithm14(x, y, compare, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, compare, true); + break; + default: + c = algorithm14(y, x, compare, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, compare, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, compare, true).valueOf(); + } + }); + + compare.toTex = undefined; // use default template + + return compare; + } + + exports.name = 'compare'; + exports.factory = factory; + + +/***/ }, +/* 433 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(42); + var ArgumentsError = __webpack_require__(11); + + var isInteger = __webpack_require__(6).isInteger; + var format = __webpack_require__(23).format; + var clone = __webpack_require__(3).clone; + var array = __webpack_require__(40); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Resize a matrix + * + * Syntax: + * + * math.resize(x, size) + * math.resize(x, size, defaultValue) + * + * Examples: + * + * math.resize([1, 2, 3, 4, 5], [3]); // returns Array [1, 2, 3] + * math.resize([1, 2, 3], [5], 0); // returns Array [1, 2, 3, 0, 0] + * math.resize(2, [2, 3], 0); // returns Matrix [[2, 0, 0], [0, 0, 0]] + * math.resize("hello", [8], "!"); // returns string 'hello!!!' + * + * See also: + * + * size, squeeze, subset + * + * @param {Array | Matrix | *} x Matrix to be resized + * @param {Array | Matrix} size One dimensional array with numbers + * @param {number | string} [defaultValue=0] Zero by default, except in + * case of a string, in that case + * defaultValue = ' ' + * @return {* | Array | Matrix} A resized clone of matrix `x` + */ + // TODO: rework resize to a typed-function + var resize = function resize (x, size, defaultValue) { + if (arguments.length != 2 && arguments.length != 3) { + throw new ArgumentsError('resize', arguments.length, 2, 3); + } + + if (size && size.isMatrix === true) { + size = size.valueOf(); // get Array + } + + if (size.length && size[0] && size[0].isBigNumber === true) { + // convert bignumbers to numbers + size = size.map(function (value) { + return (value && value.isBigNumber === true) ? value.toNumber() : value; + }); + } + + // check x is a Matrix + if (x && x.isMatrix === true) { + // use optimized matrix implementation, return copy + return x.resize(size, defaultValue, true); + } + + if (typeof x === 'string') { + // resize string + return _resizeString(x, size, defaultValue); + } + + // check result should be a matrix + var asMatrix = Array.isArray(x) ? false : (config.matrix !== 'Array'); + + if (size.length == 0) { + // output a scalar + while (Array.isArray(x)) { + x = x[0]; + } + + return clone(x); + } + else { + // output an array/matrix + if (!Array.isArray(x)) { + x = [x]; + } + x = clone(x); + + var res = array.resize(x, size, defaultValue); + return asMatrix ? matrix(res) : res; + } + }; + + resize.toTex = undefined; // use default template + + return resize; + + /** + * Resize a string + * @param {string} str + * @param {number[]} size + * @param {string} [defaultChar=' '] + * @private + */ + function _resizeString(str, size, defaultChar) { + if (defaultChar !== undefined) { + if (typeof defaultChar !== 'string' || defaultChar.length !== 1) { + throw new TypeError('Single character expected as defaultValue'); + } + } + else { + defaultChar = ' '; + } + + if (size.length !== 1) { + throw new DimensionError(size.length, 1); + } + var len = size[0]; + if (typeof len !== 'number' || !isInteger(len)) { + throw new TypeError('Invalid size, must contain positive integers ' + + '(size: ' + format(size) + ')'); + } + + if (str.length > len) { + return str.substring(0, len); + } + else if (str.length < len) { + var res = str; + for (var i = 0, ii = len - str.length; i < ii; i++) { + res += defaultChar; + } + return res; + } + else { + return str; + } + } + } + + exports.name = 'resize'; + exports.factory = factory; + + +/***/ }, +/* 434 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(40); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Calculate the size of a matrix or scalar. + * + * Syntax: + * + * math.size(x) + * + * Examples: + * + * math.size(2.3); // returns [] + * math.size('hello world'); // returns [11] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.size(A); // returns [2, 3] + * math.size(math.range(1,6)); // returns [5] + * + * See also: + * + * resize, squeeze, subset + * + * @param {boolean | number | Complex | Unit | string | Array | Matrix} x A matrix + * @return {Array | Matrix} A vector with size of `x`. + */ + var size = typed('size', { + 'Matrix': function (x) { + // TODO: return the same matrix type as the input + return matrix(x.size()); + }, + + 'Array': array.size, + + 'string': function (x) { + return (config.matrix === 'Array') ? [x.length] : matrix([x.length]); + }, + + 'number | Complex | BigNumber | Unit | boolean | null': function (x) { + // scalar + return (config.matrix === 'Array') ? [] : matrix([]); + } + }); + + size.toTex = undefined; // use default template + + return size; + } + + exports.name = 'size'; + exports.factory = factory; + + +/***/ }, +/* 435 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(40).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + var asc = load(__webpack_require__(432)); + var desc = function (a, b) { + return -asc(a, b); + }; + + /** + * Sort the items in a matrix. + * + * Syntax: + * + * math.sort(x) + * math.sort(x, compare) + * + * Examples: + * + * math.sort([5, 10, 1]); // returns [1, 5, 10] + * math.sort(['C', 'B', 'A', 'D']); // returns ['A', 'B', 'C', 'D'] + * + * function sortByLength (a, b) { + * return a.length - b.length; + * } + * math.sort(['Langdon', 'Tom', 'Sara'], sortByLength); // returns ['Tom', 'Sara', 'Langdon'] + * + * See also: + * + * filter, forEach, map + * + * @param {Matrix | Array} x A one dimensional matrix or array to sort + * @param {Function | 'asc' | 'desc'} [compare='asc'] + * An optional _comparator function. The function is called as + * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, + * and 0 when a == b. + * @return {Matrix | Array} Returns the sorted matrix. + */ + var sort = typed('sort', { + 'Array': function (x) { + _arrayIsVector(x); + return x.sort(asc); + }, + + 'Matrix': function (x) { + _matrixIsVector(x); + return matrix(x.toArray().sort(asc), x.storage()); + }, + + 'Array, function': function (x, _comparator) { + _arrayIsVector(x); + return x.sort(_comparator); + }, + + 'Matrix, function': function (x, _comparator) { + _matrixIsVector(x); + return matrix(x.toArray().sort(_comparator), x.storage()); + }, + + 'Array, string': function (x, order) { + _arrayIsVector(x); + return x.sort(_comparator(order)); + }, + + 'Matrix, string': function (x, order) { + _matrixIsVector(x); + return matrix(x.toArray().sort(_comparator(order)), x.storage()); + } + }); + + sort.toTex = undefined; // use default template + + /** + * Get the comparator for given order ('asc' or 'desc') + * @param {'asc' | 'desc'} order + * @return {Function} Returns a _comparator function + */ + function _comparator (order) { + if (order === 'asc') { + return asc; + } + else if (order === 'desc') { + return desc; + } + else { + throw new Error('String "asc" or "desc" expected'); + } + } + + /** + * Validate whether an array is one dimensional + * Throws an error when this is not the case + * @param {Array} array + * @private + */ + function _arrayIsVector (array) { + if (size(array).length !== 1) { + throw new Error('One dimensional array expected'); + } + } + + /** + * Validate whether a matrix is one dimensional + * Throws an error when this is not the case + * @param {Matrix} matrix + * @private + */ + function _matrixIsVector (matrix) { + if (matrix.size().length !== 1) { + throw new Error('One dimensional matrix expected'); + } + } + + return sort; + } + + exports.name = 'sort'; + exports.factory = factory; + + +/***/ }, +/* 436 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(3); + var array = __webpack_require__(40); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + + /** + * Squeeze a matrix, remove inner and outer singleton dimensions from a matrix. + * + * Syntax: + * + * math.squeeze(x) + * + * Examples: + * + * math.squeeze([3]); // returns 3 + * math.squeeze([[3]]); // returns 3 + * + * var A = math.zeros(3, 1); // returns [[0], [0], [0]] (size 3x1) + * math.squeeze(A); // returns [0, 0, 0] (size 3) + * + * var B = math.zeros(1, 3); // returns [[0, 0, 0]] (size 1x3) + * math.squeeze(B); // returns [0, 0, 0] (size 3) + * + * // only inner and outer dimensions are removed + * var C = math.zeros(2, 1, 3); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) + * math.squeeze(C); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) + * + * See also: + * + * subset + * + * @param {Matrix | Array} x Matrix to be squeezed + * @return {Matrix | Array} Squeezed matrix + */ + var squeeze = typed('squeeze', { + 'Array': function (x) { + return array.squeeze(object.clone(x)); + }, + + 'Matrix': function (x) { + var res = array.squeeze(x.toArray()); + // FIXME: return the same type of matrix as the input + return Array.isArray(res) ? matrix(res) : res; + }, + + 'any': function (x) { + // scalar + return object.clone(x); + } + }); + + squeeze.toTex = undefined; // use default template + + return squeeze; + } + + exports.name = 'squeeze'; + exports.factory = factory; + + +/***/ }, +/* 437 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + //require('./distribution'), // TODO: rethink math.distribution + __webpack_require__(407), + __webpack_require__(405), + __webpack_require__(406), + __webpack_require__(438), + __webpack_require__(440), + __webpack_require__(441), + __webpack_require__(442), + __webpack_require__(444), + __webpack_require__(445) + ]; + + +/***/ }, +/* 438 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + function factory(type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + var divide = load(__webpack_require__(317)); + var sum = load(__webpack_require__(439)); + var multiply = load(__webpack_require__(84)); + var dotDivide = load(__webpack_require__(359)); + var log = load(__webpack_require__(374)); + var isNumeric = load(__webpack_require__(88)); + + /** + * Calculate the Kullback-Leibler (KL) divergence between two distributions + * + * Syntax: + * + * math.kldivergence(x, y) + * + * Examples: + * + * math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5]); //returns 0.24376698773121153 + * + * + * @param {Array | Matrix} q First vector + * @param {Array | Matrix} p Second vector + * @return {number} Returns distance between q and p + */ + var kldivergence = typed('kldivergence', { + 'Array, Array': function(q, p) { + return _kldiv(matrix(q), matrix(p)); + }, + + 'Matrix, Array': function(q, p) { + return _kldiv(q, matrix(p)); + }, + + 'Array, Matrix': function(q, p){ + return _kldiv(matrix(q), p); + }, + + 'Matrix, Matrix': function(q, p){ + return _kldiv(q, p); + } + + }); + + function _kldiv(q, p) { + var plength = p.size().length; + var qlength = q.size().length; + if (plength > 1) { + throw new Error('first object must be one dimensional'); + } + + if (qlength > 1) { + throw new Error('second object must be one dimensional'); + } + + if(plength !== qlength){ + throw new Error("Length of two vectors must be equal"); + } + + //Before calculation, apply normalization + var sumq = sum(q); + if (sumq === 0) { + throw new Error("Sum of elements in first object must be non zero"); + } + + var sump = sum(p); + if (sump === 0) { + throw new Error("Sum of elements in second object must be non zero"); + } + var qnorm = divide(q, sum(q)); + var pnorm = divide(p, sum(p)); + + var result = sum(multiply(qnorm, log(dotDivide(qnorm, pnorm)))); + if (isNumeric(result)) { + return result; + } + else { + return Number.NaN; + } + } + + return kldivergence; + } + + + exports.name = 'kldivergence'; + exports.factory = factory; + + + +/***/ }, +/* 439 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepForEach = __webpack_require__(312); + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(53)); + + /** + * Compute the sum of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the sum of all + * elements will be calculated. + * + * Syntax: + * + * math.sum(a, b, c, ...) + * math.sum(A) + * + * Examples: + * + * math.sum(2, 1, 4, 3); // returns 10 + * math.sum([2, 1, 4, 3]); // returns 10 + * math.sum([[2, 5], [4, 3], [1, 7]]); // returns 22 + * + * See also: + * + * mean, median, min, max, prod, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The sum of all values + */ + var sum = typed('sum', { + 'Array | Matrix': function (args) { + // sum([a, b, c, d, ...]) + return _sum(args); + }, + + 'Array | Matrix, number | BigNumber': function () { + // sum([a, b, c, d, ...], dim) + // TODO: implement sum(A, dim) + throw new Error('sum(A, dim) is not yet supported'); + }, + + '...': function (args) { + // sum(a, b, c, d, ...) + return _sum(args); + } + }); + + sum.toTex = undefined; // use default template + + return sum; + + /** + * Recursively calculate the sum of an n-dimensional array + * @param {Array} array + * @return {number} sum + * @private + */ + function _sum(array) { + var sum = undefined; + + deepForEach(array, function (value) { + sum = (sum === undefined) ? value : add(sum, value); + }); + + if (sum === undefined) { + switch (config.number) { + case 'number': + return 0; + case 'BigNumber': + return new type.BigNumber(0); + case 'Fraction': + return new type.Fraction(0); + default: + return 0; + } + } + + return sum; + } + } + + exports.name = 'sum'; + exports.factory = factory; + + +/***/ }, +/* 440 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepForEach = __webpack_require__(312); + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var multiply = load(__webpack_require__(84)); + var divide = load(__webpack_require__(317)); + var factorial = load(__webpack_require__(405)); + var isInteger = load(__webpack_require__(408)); + var isPositive = load(__webpack_require__(370)); + + /** + * Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. + * + * multinomial takes one array of integers as an argument. + * The following condition must be enforced: every ai <= 0 + * + * Syntax: + * + * math.multinomial(a) // a is an array type + * + * Examples: + * + * math.multinomial([1,2,1]); // returns 12 + * + * See also: + * + * combinations, factorial + * + * @param {number[] | BigNumber[]} a Integer numbers of objects in the subset + * @return {Number | BigNumber} Multinomial coefficient. + */ + return typed('multinomial', { + 'Array | Matrix': function (a) { + var sum = 0; + var denom = 1; + + deepForEach(a, function(ai) { + if(!isInteger(ai) || !isPositive(ai)) { + throw new TypeError('Positive integer value expected in function multinomial'); + } + sum = add(sum, ai); + denom = multiply(denom, factorial(ai)); + }); + + return divide(factorial(sum), denom); + } + }); + } + + exports.name = 'multinomial'; + exports.factory = factory; + + +/***/ }, +/* 441 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + + function factory (type, config, load, typed) { + var factorial = load(__webpack_require__(405)); + + /** + * Compute the number of ways of obtaining an ordered subset of `k` elements + * from a set of `n` elements. + * + * Permutations only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * Syntax: + * + * math.permutations(n) + * math.permutations(n, k) + * + * Examples: + * + * math.permutations(5); // 120 + * math.permutations(5, 3); // 60 + * + * See also: + * + * combinations, factorial + * + * @param {number | BigNumber} n The number of objects in total + * @param {number | BigNumber} [k] The number of objects in the subset + * @return {number | BigNumber} The number of permutations + */ + var permutations = typed('permutations', { + 'number | BigNumber': factorial, + + 'number, number': function (n, k) { + var result, i; + + if (!isInteger(n) || n < 0) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (!isInteger(k) || k < 0) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (k > n) { + throw new TypeError('second argument k must be less than or equal to first argument n'); + } + + // Permute n objects, k at a time + result = 1; + for (i = n - k + 1; i <= n; i++) { + result = result * i; + } + + return result; + }, + + 'BigNumber, BigNumber': function (n, k) { + var result, i; + + if (!isPositiveInteger(n) || !isPositiveInteger(k)) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (k.gt(n)) { + throw new TypeError('second argument k must be less than or equal to first argument n'); + } + + result = new type.BigNumber(1); + for (i = n.minus(k).plus(1); i.lte(n); i = i.plus(1)) { + result = result.times(i); + } + + return result; + } + + // TODO: implement support for collection in permutations + }); + + permutations.toTex = undefined; // use default template + + return permutations; + } + + /** + * Test whether BigNumber n is a positive integer + * @param {BigNumber} n + * @returns {boolean} isPositiveInteger + */ + function isPositiveInteger(n) { + return n.isInteger() && n.gte(0); + } + + exports.name = 'permutations'; + exports.factory = factory; + + +/***/ }, +/* 442 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(443)); + + /** + * Random pick a value from a one dimensional array. + * Array element is picked using a random function with uniform distribution. + * + * Syntax: + * + * math.pickRandom(array) + * + * Examples: + * + * math.pickRandom([3, 6, 12, 2]); // returns one of the values in the array + * + * See also: + * + * random, randomInt + * + * @param {Array} array A one dimensional array + * @return {number} One of the elements of the provided input array + */ + // TODO: rework pickRandom to a typed-function + var pickRandom = distribution('uniform').pickRandom; + + pickRandom.toTex = undefined; // use default template + + return pickRandom; + } + + exports.name = 'pickRandom'; + exports.factory = factory; + + +/***/ }, +/* 443 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var ArgumentsError = __webpack_require__(11); + var isCollection = __webpack_require__(310); + + // TODO: rethink math.distribution + // TODO: rework to a typed function + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(52)); + var array = __webpack_require__(40); + + /** + * Create a distribution object with a set of random functions for given + * random distribution. + * + * Syntax: + * + * math.distribution(name) + * + * Examples: + * + * var normalDist = math.distribution('normal'); // create a normal distribution + * normalDist.random(0, 10); // get a random value between 0 and 10 + * + * See also: + * + * random, randomInt, pickRandom + * + * @param {string} name Name of a distribution. Choose from 'uniform', 'normal'. + * @return {Object} Returns a distribution object containing functions: + * `random([size] [, min] [, max])`, + * `randomInt([min] [, max])`, + * `pickRandom(array)` + */ + function distribution(name) { + if (!distributions.hasOwnProperty(name)) + throw new Error('Unknown distribution ' + name); + + var args = Array.prototype.slice.call(arguments, 1), + distribution = distributions[name].apply(this, args); + + return (function(distribution) { + + // This is the public API for all distributions + var randFunctions = { + + random: function(arg1, arg2, arg3) { + var size, min, max; + if (arguments.length > 3) { + throw new ArgumentsError('random', arguments.length, 0, 3); + + // `random(max)` or `random(size)` + } else if (arguments.length === 1) { + if (isCollection(arg1)) { + size = arg1; + } + else { + max = arg1; + } + // `random(min, max)` or `random(size, max)` + } else if (arguments.length === 2) { + if (isCollection(arg1)) { + size = arg1; + max = arg2; + } + else { + min = arg1; + max = arg2; + } + // `random(size, min, max)` + } else { + size = arg1; + min = arg2; + max = arg3; + } + + // TODO: validate type of min, max, and size + + if (max === undefined) max = 1; + if (min === undefined) min = 0; + if (size !== undefined) { + var res = _randomDataForMatrix(size.valueOf(), min, max, _random); + return (size && size.isMatrix === true) ? matrix(res) : res; + } + else return _random(min, max); + }, + + randomInt: function(arg1, arg2, arg3) { + var size, min, max; + if (arguments.length > 3 || arguments.length < 1) + throw new ArgumentsError('randomInt', arguments.length, 1, 3); + + // `random(max)` or `random(size)` + else if (arguments.length === 1) + if (isCollection(arg1)) { + size = arg1; + } + else { + max = arg1; + } + // `randomInt(min, max)` or `randomInt(size, max)` + else if (arguments.length === 2) { + if (isCollection(arg1)) { + size = arg1; + max = arg2; + } + else { + min = arg1; + max = arg2; + } + // `randomInt(size, min, max)` + } else { + size = arg1; + min = arg2; + max = arg3; + } + + // TODO: validate type of min, max, and size + + if (min === undefined) min = 0; + if (size !== undefined) { + var res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt); + return (size && size.isMatrix === true) ? matrix(res) : res; + } + else return _randomInt(min, max); + }, + + pickRandom: function(possibles) { + if (arguments.length !== 1) { + throw new ArgumentsError('pickRandom', arguments.length, 1); + } + if (possibles && possibles.isMatrix === true) { + possibles = possibles.valueOf(); // get Array + } + else if (!Array.isArray(possibles)) { + throw new TypeError('Unsupported type of value in function pickRandom'); + } + + if (array.size(possibles).length > 1) { + throw new Error('Only one dimensional vectors supported'); + } + + // TODO: add support for multi dimensional matrices + return possibles[Math.floor(Math.random() * possibles.length)]; + } + + }; + + var _random = function(min, max) { + return min + distribution() * (max - min); + }; + + var _randomInt = function(min, max) { + return Math.floor(min + distribution() * (max - min)); + }; + + // This is a function for generating a random matrix recursively. + var _randomDataForMatrix = function(size, min, max, randFunc) { + var data = [], length, i; + size = size.slice(0); + + if (size.length > 1) { + for (i = 0, length = size.shift(); i < length; i++) + data.push(_randomDataForMatrix(size, min, max, randFunc)); + } else { + for (i = 0, length = size.shift(); i < length; i++) + data.push(randFunc(min, max)); + } + + return data; + }; + + return randFunctions; + + })(distribution); + } + + // Each distribution is a function that takes no argument and when called returns + // a number between 0 and 1. + var distributions = { + + uniform: function() { + return Math.random; + }, + + // Implementation of normal distribution using Box-Muller transform + // ref : http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform + // We take : mean = 0.5, standard deviation = 1/6 + // so that 99.7% values are in [0, 1]. + normal: function() { + return function() { + var u1, u2, + picked = -1; + // We reject values outside of the interval [0, 1] + // TODO: check if it is ok to do that? + while (picked < 0 || picked > 1) { + u1 = Math.random(); + u2 = Math.random(); + picked = 1/6 * Math.pow(-2 * Math.log(u1), 0.5) * Math.cos(2 * Math.PI * u2) + 0.5; + } + return picked; + } + } + }; + + distribution.toTex = undefined; // use default template + + return distribution; + } + + exports.name = 'distribution'; + exports.factory = factory; + + +/***/ }, +/* 444 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(443)); + + /** + * Return a random number larger or equal to `min` and smaller than `max` + * using a uniform distribution. + * + * Syntax: + * + * math.random() // generate a random number between 0 and 1 + * math.random(max) // generate a random number between 0 and max + * math.random(min, max) // generate a random number between min and max + * math.random(size) // generate a matrix with random numbers between 0 and 1 + * math.random(size, max) // generate a matrix with random numbers between 0 and max + * math.random(size, min, max) // generate a matrix with random numbers between min and max + * + * Examples: + * + * math.random(); // returns a random number between 0 and 1 + * math.random(100); // returns a random number between 0 and 100 + * math.random(30, 40); // returns a random number between 30 and 40 + * math.random([2, 3]); // returns a 2x3 matrix with random numbers between 0 and 1 + * + * See also: + * + * randomInt, pickRandom + * + * @param {Array | Matrix} [size] If provided, an array or matrix with given + * size and filled with random values is returned + * @param {number} [min] Minimum boundary for the random value, included + * @param {number} [max] Maximum boundary for the random value, excluded + * @return {number | Array | Matrix} A random number + */ + // TODO: rework random to a typed-function + var random = distribution('uniform').random; + + random.toTex = undefined; // use default template + + return random; + } + + exports.name = 'random'; + exports.factory = factory; + + +/***/ }, +/* 445 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(443)); + + /** + * Return a random integer number larger or equal to `min` and smaller than `max` + * using a uniform distribution. + * + * Syntax: + * + * math.randomInt(max) // generate a random integer between 0 and max + * math.randomInt(min, max) // generate a random integer between min and max + * math.randomInt(size) // generate a matrix with random integer between 0 and 1 + * math.randomInt(size, max) // generate a matrix with random integer between 0 and max + * math.randomInt(size, min, max) // generate a matrix with random integer between min and max + * + * Examples: + * + * math.randomInt(100); // returns a random integer between 0 and 100 + * math.randomInt(30, 40); // returns a random integer between 30 and 40 + * math.randomInt([2, 3]); // returns a 2x3 matrix with random integers between 0 and 1 + * + * See also: + * + * random, pickRandom + * + * @param {Array | Matrix} [size] If provided, an array or matrix with given + * size and filled with random values is returned + * @param {number} [min] Minimum boundary for the random value, included + * @param {number} [max] Maximum boundary for the random value, excluded + * @return {number | Array | Matrix} A random integer value + */ + // TODO: rework randomInt to a typed-function + var randomInt = distribution('uniform').randomInt; + + randomInt.toTex = undefined; // use default template + + return randomInt; + } + + exports.name = 'randomInt'; + exports.factory = factory; + + +/***/ }, +/* 446 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(432), + __webpack_require__(447), + __webpack_require__(87), + __webpack_require__(64), + __webpack_require__(342), + __webpack_require__(60), + __webpack_require__(448), + __webpack_require__(449) + ]; + + +/***/ }, +/* 447 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var equal = load(__webpack_require__(87)); + + /** + * Test element wise whether two matrices are equal. + * The function accepts both matrices and scalar values. + * + * Syntax: + * + * math.deepEqual(x, y) + * + * Examples: + * + * math.deepEqual(2, 4); // returns false + * + * a = [2, 5, 1]; + * b = [2, 7, 1]; + * + * math.deepEqual(a, b); // returns false + * math.equal(a, b); // returns [true, false, true] + * + * See also: + * + * equal, unequal + * + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First matrix to compare + * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second matrix to compare + * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} + * Returns true when the input matrices have the same size and each of their elements is equal. + */ + var deepEqual = typed('deepEqual', { + 'any, any': function (x, y) { + return _deepEqual(x.valueOf(), y.valueOf()); + } + }); + + deepEqual.toTex = undefined; // use default template + + return deepEqual; + + /** + * Test whether two arrays have the same size and all elements are equal + * @param {Array | *} x + * @param {Array | *} y + * @return {boolean} Returns true if both arrays are deep equal + */ + function _deepEqual(x, y) { + if (Array.isArray(x)) { + if (Array.isArray(y)) { + var len = x.length; + if (len !== y.length) { + return false; + } + + for (var i = 0; i < len; i++) { + if (!_deepEqual(x[i], y[i])) { + return false; + } + } + + return true; + } + else { + return false; + } + } + else { + if (Array.isArray(y)) { + return false; + } + else { + return equal(x, y); + } + } + } + } + + exports.name = 'deepEqual'; + exports.factory = factory; + + +/***/ }, +/* 448 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether value x is smaller or equal to y. + * + * The function returns true when x is smaller than y or the relative + * difference between x and y is smaller than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.smallerEq(x, y) + * + * Examples: + * + * math.smaller(1 + 2, 3); // returns false + * math.smallerEq(1 + 2, 3); // returns true + * + * See also: + * + * equal, unequal, smaller, larger, largerEq, compare + * + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Unit | string | Array | Matrix} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false + */ + var smallerEq = typed('smallerEq', { + + 'boolean, boolean': function (x, y) { + return x <= y; + }, + + 'number, number': function (x, y) { + return x <= y || nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.lte(y) || bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return x.compare(y) !== 1; + }, + + 'Complex, Complex': function () { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return smallerEq(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x <= y; + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, smallerEq); + break; + default: + // sparse + dense + c = algorithm03(y, x, smallerEq, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, smallerEq, false); + break; + default: + // dense + dense + c = algorithm13(x, y, smallerEq); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return smallerEq(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return smallerEq(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return smallerEq(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, smallerEq, false); + break; + default: + c = algorithm14(x, y, smallerEq, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, smallerEq, true); + break; + default: + c = algorithm14(y, x, smallerEq, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, smallerEq, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, smallerEq, true).valueOf(); + } + }); + + smallerEq.toTex = { + 2: '\\left(${args[0]}' + latex.operators['smallerEq'] + '${args[1]}\\right)' + }; + + return smallerEq; + } + + exports.name = 'smallerEq'; + exports.factory = factory; + + +/***/ }, +/* 449 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(6).nearlyEqual; + var bigNearlyEqual = __webpack_require__(49); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm03 = load(__webpack_require__(61)); + var algorithm07 = load(__webpack_require__(62)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + var latex = __webpack_require__(32); + + /** + * Test whether two values are unequal. + * + * The function tests whether the relative difference between x and y is + * larger than the configured epsilon. The function cannot be used to compare + * values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im. + * + * Values `null` and `undefined` are compared strictly, thus `null` is unequal + * with everything except `null`, and `undefined` is unequal with everying + * except. `undefined`. + * + * Syntax: + * + * math.unequal(x, y) + * + * Examples: + * + * math.unequal(2 + 2, 3); // returns true + * math.unequal(2 + 2, 4); // returns false + * + * var a = math.unit('50 cm'); + * var b = math.unit('5 m'); + * math.unequal(a, b); // returns false + * + * var c = [2, 5, 1]; + * var d = [2, 7, 1]; + * + * math.unequal(c, d); // returns [false, true, false] + * math.deepEqual(c, d); // returns false + * + * math.unequal(0, null); // returns true + * See also: + * + * equal, deepEqual, smaller, smallerEq, larger, largerEq, compare + * + * @param {number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined} x First value to compare + * @param {number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined} y Second value to compare + * @return {boolean | Array | Matrix} Returns true when the compared values are unequal, else returns false + */ + var unequal = typed('unequal', { + + 'any, any': function (x, y) { + // strict equality for null and undefined? + if (x === null) { return y !== null; } + if (y === null) { return x !== null; } + if (x === undefined) { return y !== undefined; } + if (y === undefined) { return x !== undefined; } + + return _unequal(x, y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = algorithm07(x, y, _unequal); + break; + default: + // sparse + dense + c = algorithm03(y, x, _unequal, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = algorithm03(x, y, _unequal, false); + break; + default: + // dense + dense + c = algorithm13(x, y, _unequal); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return unequal(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return unequal(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return unequal(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm12(x, y, _unequal, false); + break; + default: + c = algorithm14(x, y, _unequal, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, _unequal, true); + break; + default: + c = algorithm14(y, x, _unequal, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, _unequal, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, _unequal, true).valueOf(); + } + }); + + var _unequal = typed('_unequal', { + + 'boolean, boolean': function (x, y) { + return x !== y; + }, + + 'number, number': function (x, y) { + return !nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return !bigNearlyEqual(x, y, config.epsilon); + }, + + 'Fraction, Fraction': function (x, y) { + return !x.equals(y); + }, + + 'Complex, Complex': function (x, y) { + return !x.equals(y); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return unequal(x.value, y.value); + }, + + 'string, string': function (x, y) { + return x !== y; + } + }); + + unequal.toTex = { + 2: '\\left(${args[0]}' + latex.operators['unequal'] + '${args[1]}\\right)' + }; + + return unequal; + } + + exports.name = 'unequal'; + exports.factory = factory; + + +/***/ }, +/* 450 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(311), + __webpack_require__(316), + __webpack_require__(451), + __webpack_require__(321), + __webpack_require__(452), + __webpack_require__(453), + __webpack_require__(454), + __webpack_require__(455), + __webpack_require__(439), + __webpack_require__(456) + ]; + +/***/ }, +/* 451 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var flatten = __webpack_require__(40).flatten; + var reduce = __webpack_require__(313); + var containsCollections = __webpack_require__(314); + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(53)); + var divide = load(__webpack_require__(81)); + var compare = load(__webpack_require__(432)); + var partitionSelect = load(__webpack_require__(431)); + + /** + * Compute the median of a matrix or a list with values. The values are + * sorted and the middle value is returned. In case of an even number of + * values, the average of the two middle values is returned. + * Supported types of values are: Number, BigNumber, Unit + * + * In case of a (multi dimensional) array or matrix, the median of all + * elements will be calculated. + * + * Syntax: + * + * math.median(a, b, c, ...) + * math.median(A) + * + * Examples: + * + * math.median(5, 2, 7); // returns 5 + * math.median([3, -1, 5, 7]); // returns 4 + * + * See also: + * + * mean, min, max, sum, prod, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The median + */ + var median = typed('median', { + // median([a, b, c, d, ...]) + 'Array | Matrix': _median, + + // median([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + // TODO: implement median(A, dim) + throw new Error('median(A, dim) is not yet supported'); + //return reduce(arguments[0], arguments[1], ...); + }, + + // median(a, b, c, d, ...) + '...': function (args) { + if (containsCollections(args)) { + throw new TypeError('Scalar values expected in function median'); + } + + return _median(args); + } + }); + + + /** + * Recursively calculate the median of an n-dimensional array + * @param {Array} array + * @return {Number} median + * @private + */ + function _median(array) { + array = flatten(array.valueOf()); + + var num = array.length; + if (num == 0) { + throw new Error('Cannot calculate median of an empty array'); + } + + if (num % 2 == 0) { + // even: return the average of the two middle values + var mid = num / 2 - 1; + var right = partitionSelect(array, mid + 1); + + // array now partitioned at mid + 1, take max of left part + var left = array[mid]; + for (var i = 0; i < mid; ++i) { + if (compare(array[i], left) > 0) { + left = array[i]; + } + } + + return middle2(left, right); + } + else { + // odd: return the middle value + var m = partitionSelect(array, (num - 1) / 2); + + return middle(m); + } + } + + // helper function to type check the middle value of the array + var middle = typed({ + 'number | BigNumber | Unit': function (value) { + return value; + } + }); + + // helper function to type check the two middle value of the array + var middle2 = typed({ + 'number | BigNumber | Unit, number | BigNumber | Unit': function (left, right) { + return divide(add(left, right), 2); + } + }); + + median.toTex = undefined; // use default template + + return median; + } + + exports.name = 'median'; + exports.factory = factory; + + +/***/ }, +/* 452 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var flatten = __webpack_require__(40).flatten; + + function factory (type, config, load, typed) { + + /** + * Computes the mode of a set of numbers or a list with values(numbers or characters). + * If there are more than one modes, it returns a list of those values. + * + * Syntax: + * + * math.mode(a, b, c, ...) + * math.mode(A) + * + * Examples: + * + * math.mode(2, 1, 4, 3, 1); // returns [1] + * math.mode([1, 2.7, 3.2, 4, 2.7]); // returns [2.7] + * math.mode(1, 4, 6, 1, 6) // returns [1, 6] + * math.mode('a','a','b','c') // returns ["a"] + * math.mode(1, 1.5, 'abc') // returns [1, 1.5, "abc"] + * + * See also: + * + * median, + * mean + * + * @param {... *} args A single matrix + * @return {*} The mode of all values + */ + + var mode = typed('mode', { + 'Array | Matrix' : _mode, + + '...': function (args) { + return _mode(args); + } + }); + + return mode; + + /** + * Calculates the mode in an 1-dimensional array + * @param {Array} values + * @return {number} mode + * @private + */ + function _mode(values) { + values = flatten(values.valueOf()); + var num = values.length; + if (num == 0) { + throw new Error('Cannot calculate mode of an empty array'); + } + + var count = {}, + mode = [], + max = 0; + for (var i in values) { + if (!(values[i] in count)){ + count[values[i]] = 0; + } + count[values[i]]++; + if (count[values[i]] == max){ + mode.push(values[i]); + } + else if (count[values[i]] > max) { + max = count[values[i]]; + mode = [values[i]]; + } + } + return mode; + }; + } + + exports.name = 'mode'; + exports.factory = factory; + +/***/ }, +/* 453 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepForEach = __webpack_require__(312); + + function factory (type, config, load, typed) { + var multiply = load(__webpack_require__(80)); + + /** + * Compute the product of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the sum of all + * elements will be calculated. + * + * Syntax: + * + * math.prod(a, b, c, ...) + * math.prod(A) + * + * Examples: + * + * math.multiply(2, 3); // returns 6 + * math.prod(2, 3); // returns 6 + * math.prod(2, 3, 4); // returns 24 + * math.prod([2, 3, 4]); // returns 24 + * math.prod([[2, 5], [4, 3]]); // returns 120 + * + * See also: + * + * mean, median, min, max, sum, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The product of all values + */ + var prod = typed('prod', { + // prod([a, b, c, d, ...]) + 'Array | Matrix': _prod, + + // prod([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + // TODO: implement prod(A, dim) + throw new Error('prod(A, dim) is not yet supported'); + //return reduce(arguments[0], arguments[1], math.prod); + }, + + // prod(a, b, c, d, ...) + '...': function (args) { + return _prod(args); + } + }); + + prod.toTex = undefined; // use default template + + return prod; + + /** + * Recursively calculate the product of an n-dimensional array + * @param {Array} array + * @return {number} prod + * @private + */ + function _prod(array) { + var prod = undefined; + + deepForEach(array, function (value) { + prod = (prod === undefined) ? value : multiply(prod, value); + }); + + if (prod === undefined) { + throw new Error('Cannot calculate prod of an empty array'); + } + + return prod; + } + } + + exports.name = 'prod'; + exports.factory = factory; + + +/***/ }, +/* 454 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(6).isInteger; + var isNumber = __webpack_require__(6).isNumber; + var flatten = __webpack_require__(40).flatten; + var isCollection = __webpack_require__(310); + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(51)); + var multiply = load(__webpack_require__(84)); + var partitionSelect = load(__webpack_require__(431)); + var compare = load(__webpack_require__(432)); + + /** + * Compute the prob order quantile of a matrix or a list with values. + * The sequence is sorted and the middle value is returned. + * Supported types of sequence values are: Number, BigNumber, Unit + * Supported types of probability are: Number, BigNumber + * + * In case of a (multi dimensional) array or matrix, the prob order quantile + * of all elements will be calculated. + * + * Syntax: + * + * math.quantileSeq(A, prob[, sorted]) + * math.quantileSeq(A, [prob1, prob2, ...][, sorted]) + * math.quantileSeq(A, N[, sorted]) + * + * Examples: + * + * math.quantileSeq([3, -1, 5, 7], 0.5); // returns 4 + * math.quantileSeq([3, -1, 5, 7], [1/3, 2/3]); // returns [3, 5] + * math.quantileSeq([3, -1, 5, 7], 2); // returns [3, 5] + * math.quantileSeq([-1, 3, 5, 7], 0.5, true); // returns 4 + * + * See also: + * + * median, mean, min, max, sum, prod, std, var + * + * @param {Array, Matrix} data A single matrix or Array + * @param {Number, BigNumber, Array} probOrN prob is the order of the quantile, while N is + * the amount of evenly distributed steps of + * probabilities; only one of these options can + * be provided + * @param {Boolean} sorted=false is data sorted in ascending order + * @return {Number, BigNumber, Unit, Array} Quantile(s) + */ + function quantileSeq(data, probOrN, sorted) { + var probArr, dataArr, one; + + if (arguments.length < 2 || arguments.length > 3) { + throw new SyntaxError('Function quantileSeq requires two or three parameters'); + } + + if (isCollection(data)) { + sorted = sorted || false; + if (typeof sorted === 'boolean') { + dataArr = data.valueOf(); + if (isNumber(probOrN)) { + if (probOrN < 0) { + throw new Error('N/prob must be non-negative'); + } + + if (probOrN <= 1) { + // quantileSeq([a, b, c, d, ...], prob[,sorted]) + return _quantileSeq(dataArr, probOrN, sorted); + } + + if (probOrN > 1) { + // quantileSeq([a, b, c, d, ...], N[,sorted]) + if (!isInteger(probOrN)) { + throw new Error('N must be a positive integer'); + } + + var nPlusOne = probOrN + 1; + probArr = new Array(probOrN); + for (var i = 0; i < probOrN;) { + probArr[i] = _quantileSeq(dataArr, (++i) / nPlusOne, sorted); + } + return probArr; + } + } + + if (probOrN && probOrN.isBigNumber) { + if (probOrN.isNegative()) { + throw new Error('N/prob must be non-negative'); + } + + one = new probOrN.constructor(1); + + if (probOrN.lte(one)) { + // quantileSeq([a, b, c, d, ...], prob[,sorted]) + return _quantileSeq(dataArr, probOrN, sorted); + } + + if (probOrN.gt(one)) { + // quantileSeq([a, b, c, d, ...], N[,sorted]) + if (!probOrN.isInteger()) { + throw new Error('N must be a positive integer'); + } + + // largest possible Array length is 2^32-1; + // 2^32 < 10^15, thus safe conversion guaranteed + var intN = probOrN.toNumber(); + if (intN > 4294967295) { + throw new Error('N must be less than or equal to 2^32-1, as that is the maximum length of an Array'); + } + + var nPlusOne = new type.BigNumber(intN + 1); + probArr = new Array(intN); + for (var i = 0; i < intN;) { + probArr[i] = _quantileSeq(dataArr, new type.BigNumber(++i).div(nPlusOne), sorted); + } + return probArr; + } + } + + if (Array.isArray(probOrN)) { + // quantileSeq([a, b, c, d, ...], [prob1, prob2, ...][,sorted]) + probArr = new Array(probOrN.length); + for (var i = 0; i < probArr.length; ++i) { + var currProb = probOrN[i]; + if (isNumber(currProb)) { + if (currProb < 0 || currProb > 1) { + throw new Error('Probability must be between 0 and 1, inclusive'); + } + } else if (currProb && currProb.isBigNumber) { + one = new currProb.constructor(1); + if (currProb.isNegative() || currProb.gt(one)) { + throw new Error('Probability must be between 0 and 1, inclusive'); + } + } else { + throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function + } + + probArr[i] = _quantileSeq(dataArr, currProb, sorted); + } + return probArr; + } + + throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function + } + + throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function + } + + throw new TypeError('Unexpected type of argument in function quantileSeq'); // FIXME: becomes redundant when converted to typed-function + } + + /** + * Calculate the prob order quantile of an n-dimensional array. + * + * @param {Array} array + * @param {Number, BigNumber} prob + * @param {Boolean} sorted + * @return {Number, BigNumber, Unit} prob order quantile + * @private + */ + function _quantileSeq(array, prob, sorted) { + var flat = flatten(array); + var len = flat.length; + if (len === 0) { + throw new Error('Cannot calculate quantile of an empty sequence'); + } + + if (isNumber(prob)) { + var index = prob * (len-1); + var fracPart = index % 1; + if (fracPart === 0) { + var value = sorted ? flat[index] : partitionSelect(flat, index); + + validate(value); + + return value; + } + + var integerPart = Math.floor(index); + + var left, right; + if (sorted) { + left = flat[integerPart]; + right = flat[integerPart+1]; + } else { + right = partitionSelect(flat, integerPart+1); + + // max of partition is kth largest + left = flat[integerPart]; + for (var i = 0; i < integerPart; ++i) { + if (compare(flat[i], left) > 0) { + left = flat[i]; + } + } + } + + validate(left); + validate(right); + + // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1] + return add(multiply(left, 1 - fracPart), multiply(right, fracPart)); + } + + // If prob is a BigNumber + var index = prob.times(len-1); + if (index.isInteger()) { + index = index.toNumber(); + var value = sorted ? flat[index] : partitionSelect(flat, index); + + validate(value); + + return value; + } + + var integerPart = index.floor(); + var fracPart = index.minus(integerPart); + var integerPartNumber = integerPart.toNumber(); + + var left, right; + if (sorted) { + left = flat[integerPartNumber]; + right = flat[integerPartNumber+1]; + } else { + right = partitionSelect(flat, integerPartNumber+1); + + // max of partition is kth largest + left = flat[integerPartNumber]; + for (var i = 0; i < integerPartNumber; ++i) { + if (compare(flat[i], left) > 0) { + left = flat[i]; + } + } + } + + validate(left); + validate(right); + + // Q(prob) = (1-f)*A[floor(index)] + f*A[floor(index)+1] + var one = new fracPart.constructor(1); + return add(multiply(left, one.minus(fracPart)), multiply(right, fracPart)); + } + + /** + * Check if array value types are valid, throw error otherwise. + * @param {number | BigNumber | Unit} x + * @param {number | BigNumber | Unit} x + * @private + */ + var validate = typed({ + 'number | BigNumber | Unit': function (x) { + return x; + } + }); + + return quantileSeq; + } + + exports.name = 'quantileSeq'; + exports.factory = factory; + + +/***/ }, +/* 455 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var sqrt = load(__webpack_require__(369)); + var variance = load(__webpack_require__(456)); + + /** + * Compute the standard deviation of a matrix or a list with values. + * The standard deviations is defined as the square root of the variance: + * `std(A) = sqrt(var(A))`. + * In case of a (multi dimensional) array or matrix, the standard deviation + * over all elements will be calculated. + * + * Optionally, the type of normalization can be specified as second + * parameter. The parameter `normalization` can be one of the following values: + * + * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + * + * Syntax: + * + * math.std(a, b, c, ...) + * math.std(A) + * math.std(A, normalization) + * + * Examples: + * + * math.std(2, 4, 6); // returns 2 + * math.std([2, 4, 6, 8]); // returns 2.581988897471611 + * math.std([2, 4, 6, 8], 'uncorrected'); // returns 2.23606797749979 + * math.std([2, 4, 6, 8], 'biased'); // returns 2 + * + * math.std([[1, 2, 3], [4, 5, 6]]); // returns 1.8708286933869707 + * + * See also: + * + * mean, median, max, min, prod, sum, var + * + * @param {Array | Matrix} array + * A single matrix or or multiple scalar values + * @param {string} [normalization='unbiased'] + * Determines how to normalize the variance. + * Choose 'unbiased' (default), 'uncorrected', or 'biased'. + * @return {*} The standard deviation + */ + var std = typed('std', { + // std([a, b, c, d, ...]) + 'Array | Matrix': _std, + + // std([a, b, c, d, ...], normalization) + 'Array | Matrix, string': _std, + + // std(a, b, c, d, ...) + '...': function (args) { + return _std(args); + } + }); + + std.toTex = undefined; // use default template + + return std; + + function _std(array, normalization) { + if (array.length == 0) { + throw new SyntaxError('Function std requires one or more parameters (0 provided)'); + } + + return sqrt(variance.apply(null, arguments)); + } + } + + exports.name = 'std'; + exports.factory = factory; + + +/***/ }, +/* 456 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DEFAULT_NORMALIZATION = 'unbiased'; + + var deepForEach = __webpack_require__(312); + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(53)); + var subtract = load(__webpack_require__(77)); + var multiply = load(__webpack_require__(80)); + var divide = load(__webpack_require__(81)); + + /** + * Compute the variance of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the variance over all + * elements will be calculated. + * + * Optionally, the type of normalization can be specified as second + * parameter. The parameter `normalization` can be one of the following values: + * + * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + * + * Note that older browser may not like the variable name `var`. In that + * case, the function can be called as `math['var'](...)` instead of + * `math.var(...)`. + * + * Syntax: + * + * math.var(a, b, c, ...) + * math.var(A) + * math.var(A, normalization) + * + * Examples: + * + * math.var(2, 4, 6); // returns 4 + * math.var([2, 4, 6, 8]); // returns 6.666666666666667 + * math.var([2, 4, 6, 8], 'uncorrected'); // returns 5 + * math.var([2, 4, 6, 8], 'biased'); // returns 4 + * + * math.var([[1, 2, 3], [4, 5, 6]]); // returns 3.5 + * + * See also: + * + * mean, median, max, min, prod, std, sum + * + * @param {Array | Matrix} array + * A single matrix or or multiple scalar values + * @param {string} [normalization='unbiased'] + * Determines how to normalize the variance. + * Choose 'unbiased' (default), 'uncorrected', or 'biased'. + * @return {*} The variance + */ + var variance = typed('variance', { + // var([a, b, c, d, ...]) + 'Array | Matrix': function (array) { + return _var(array, DEFAULT_NORMALIZATION); + }, + + // var([a, b, c, d, ...], normalization) + 'Array | Matrix, string': _var, + + // var(a, b, c, d, ...) + '...': function (args) { + return _var(args, DEFAULT_NORMALIZATION); + } + }); + + variance.toTex = '\\mathrm{Var}\\left(${args}\\right)'; + + return variance; + + /** + * Recursively calculate the variance of an n-dimensional array + * @param {Array} array + * @param {string} normalization + * Determines how to normalize the variance: + * - 'unbiased' The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + * @return {number | BigNumber} variance + * @private + */ + function _var(array, normalization) { + var sum = 0; + var num = 0; + + if (array.length == 0) { + throw new SyntaxError('Function var requires one or more parameters (0 provided)'); + } + + // calculate the mean and number of elements + deepForEach(array, function (value) { + sum = add(sum, value); + num++; + }); + if (num === 0) throw new Error('Cannot calculate var of an empty array'); + + var mean = divide(sum, num); + + // calculate the variance + sum = 0; + deepForEach(array, function (value) { + var diff = subtract(value, mean); + sum = add(sum, multiply(diff, diff)); + }); + + switch (normalization) { + case 'uncorrected': + return divide(sum, num); + + case 'biased': + return divide(sum, num + 1); + + case 'unbiased': + var zero = (sum && sum.isBigNumber === true) ? new type.BigNumber(0) : 0; + return (num == 1) ? zero : divide(sum, num - 1); + + default: + throw new Error('Unknown normalization "' + normalization + '". ' + + 'Choose "unbiased" (default), "uncorrected", or "biased".'); + } + } + } + + exports.name = 'var'; + exports.factory = factory; + + +/***/ }, +/* 457 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(89), + __webpack_require__(458) + ]; + + +/***/ }, +/* 458 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isString = __webpack_require__(23).isString; + var format = __webpack_require__(23).format; + + function factory (type, config, load, typed) { + /** + * Interpolate values into a string template. + * + * Syntax: + * + * math.print(template, values) + * math.print(template, values, precision) + * math.print(template, values, options) + * + * Example usage: + * + * // the following outputs: 'Lucy is 5 years old' + * math.print('Lucy is $age years old', {age: 5}); + * + * // the following outputs: 'The value of pi is 3.141592654' + * math.print('The value of pi is $pi', {pi: math.pi}, 10); + * + * // the following outputs: 'hello Mary! The date is 2013-03-23' + * math.print('Hello $user.name! The date is $date', { + * user: { + * name: 'Mary', + * }, + * date: new Date(2013, 2, 23).toISOString().substring(0, 10) + * }); + * + * See also: + * + * format + * + * @param {string} template A string containing variable placeholders. + * @param {Object} values An object containing variables which will + * be filled in in the template. + * @param {number | Object} [options] Formatting options, + * or the number of digits to format numbers. + * See function math.format for a description + * of all options. + * @return {string} Interpolated string + */ + var print = typed ('print', { + 'string, Object': _print, + 'string, Object, number': _print + }); + + print.toTex = undefined; // use default template + + return print; + } + + /** + * Interpolate values into a string template. + * @param {string} template + * @param {Object} values + * @param {number | Object} [options] + * @returns {string} Interpolated string + * @private + */ + function _print(template, values, options) { + return template.replace(/\$([\w\.]+)/g, function (original, key) { + var keys = key.split('.'); + var value = values[keys.shift()]; + while (keys.length && value !== undefined) { + var k = keys.shift(); + value = k ? value[k] : value + '.'; + } + + if (value !== undefined) { + if (!isString(value)) { + return format(value, options); + } + else { + return value; + } + } + + return original; + } + ); + } + + exports.name = 'print'; + exports.factory = factory; + + +/***/ }, +/* 459 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(460), + __webpack_require__(461), + __webpack_require__(462), + __webpack_require__(463), + __webpack_require__(464), + __webpack_require__(465), + __webpack_require__(466), + __webpack_require__(467), + __webpack_require__(468), + __webpack_require__(469), + __webpack_require__(470), + __webpack_require__(471), + __webpack_require__(472), + __webpack_require__(473), + __webpack_require__(474), + __webpack_require__(475), + __webpack_require__(476), + __webpack_require__(477), + __webpack_require__(478), + __webpack_require__(479), + __webpack_require__(480), + __webpack_require__(481), + __webpack_require__(482), + __webpack_require__(483), + __webpack_require__(484) + ]; + + +/***/ }, +/* 460 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse cosine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acos(x) + * + * Examples: + * + * math.acos(0.5); // returns number 1.0471975511965979 + * math.acos(math.cos(1.5)); // returns number 1.5 + * + * math.acos(2); // returns Complex 0 + 1.3169578969248166 i + * + * See also: + * + * cos, atan, asin + * + * @param {number | BigNumber | Complex | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} The arc cosine of x + */ + var acos = typed('acos', { + 'number': function (x) { + if ((x >= -1 && x <= 1) || config.predictable) { + return Math.acos(x); + } + else { + return new type.Complex(x, 0).acos(); + } + }, + + 'Complex': function (x) { + return x.acos(); + }, + + 'BigNumber': function (x) { + return x.acos(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acos); + } + }); + + acos.toTex = {1: '\\cos^{-1}\\left(${args[0]}\\right)'}; + + return acos; + } + + exports.name = 'acos'; + exports.factory = factory; + + +/***/ }, +/* 461 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the hyperbolic arccos of a value, + * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acosh(x) + * + * Examples: + * + * math.acosh(1.5); // returns 0.9624236501192069 + * + * See also: + * + * cosh, asinh, atanh + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arccosine of x + */ + var acosh = typed('acosh', { + 'number': function (x) { + if (x >= 1 || config.predictable) { + return _acosh(x); + } + if (x <= -1) { + return new type.Complex(Math.log(Math.sqrt(x*x - 1) - x), Math.PI); + } + return new type.Complex(x, 0).acosh(); + }, + + 'Complex': function (x) { + return x.acosh(); + }, + + 'BigNumber': function (x) { + return x.acosh(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acosh); + } + }); + + acosh.toTex = {1: '\\cosh^{-1}\\left(${args[0]}\\right)'}; + + return acosh; + } + + /** + * Calculate the hyperbolic arccos of a number + * @param {number} x + * @return {number} + * @private + */ + var _acosh = Math.acosh || function (x) { + return Math.log(Math.sqrt(x*x - 1) + x) + }; + + exports.name = 'acosh'; + exports.factory = factory; + + +/***/ }, +/* 462 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse cotangent of a value, defined as `acot(x) = atan(1/x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acot(x) + * + * Examples: + * + * math.acot(0.5); // returns number 0.4636476090008061 + * math.acot(math.cot(1.5)); // returns number 1.5 + * + * math.acot(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * cot, atan + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} The arc cotangent of x + */ + var acot = typed('acot', { + 'number': function (x) { + return Math.atan(1 / x); + }, + + 'Complex': function (x) { + return x.acot(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).atan(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acot); + } + }); + + acot.toTex = {1: '\\cot^{-1}\\left(${args[0]}\\right)'}; + + return acot; + } + + exports.name = 'acot'; + exports.factory = factory; + + +/***/ }, +/* 463 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the hyperbolic arccotangent of a value, + * defined as `acoth(x) = atanh(1/x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acoth(x) + * + * Examples: + * + * math.acoth(0.5); // returns 0.8047189562170503 + * + * See also: + * + * acsch, asech + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arccotangent of x + */ + var acoth = typed('acoth', { + 'number': function (x) { + if (x >= 1 || x <= -1 || config.predictable) { + return isFinite(x) ? (Math.log((x+1)/x) + Math.log(x/(x-1))) / 2 : 0; + } + return new type.Complex(x, 0).acoth(); + }, + + 'Complex': function (x) { + return x.acoth(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).atanh(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acoth); + } + }); + + acoth.toTex = {1: '\\coth^{-1}\\left(${args[0]}\\right)'}; + + return acoth; + } + + exports.name = 'acoth'; + exports.factory = factory; + + +/***/ }, +/* 464 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse cosecant of a value, defined as `acsc(x) = asin(1/x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acsc(x) + * + * Examples: + * + * math.acsc(0.5); // returns number 0.5235987755982989 + * math.acsc(math.csc(1.5)); // returns number ~1.5 + * + * math.acsc(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * csc, asin, asec + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} The arc cosecant of x + */ + var acsc = typed('acsc', { + 'number': function (x) { + if (x <= -1 || x >= 1 || config.predictable) { + return Math.asin(1 / x); + } + return new type.Complex(x, 0).acsc(); + }, + + 'Complex': function (x) { + return x.acsc(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).asin(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acsc); + } + }); + + acsc.toTex = {1: '\\csc^{-1}\\left(${args[0]}\\right)'}; + + return acsc; + } + + exports.name = 'acsc'; + exports.factory = factory; + + +/***/ }, +/* 465 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the hyperbolic arccosecant of a value, + * defined as `acsch(x) = asinh(1/x) = ln(1/x + sqrt(1/x^2 + 1))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acsch(x) + * + * Examples: + * + * math.acsch(0.5); // returns 1.4436354751788103 + * + * See also: + * + * asech, acoth + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arccosecant of x + */ + var acsch = typed('acsch', { + 'number': function (x) { + x = 1 / x; + return Math.log(x + Math.sqrt(x*x + 1)); + }, + + 'Complex': function (x) { + return x.acsch(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).asinh(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, acsch); + } + }); + + acsch.toTex = {1: '\\mathrm{csch}^{-1}\\left(${args[0]}\\right)'}; + + return acsch; + } + + exports.name = 'acsch'; + exports.factory = factory; + + +/***/ }, +/* 466 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse secant of a value. Defined as `asec(x) = acos(1/x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asec(x) + * + * Examples: + * + * math.asec(0.5); // returns 1.0471975511965979 + * math.asec(math.sec(1.5)); // returns 1.5 + * + * math.asec(2); // returns 0 + 1.3169578969248166 i + * + * See also: + * + * acos, acot, acsc + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} The arc secant of x + */ + var asec = typed('asec', { + 'number': function (x) { + if (x <= -1 || x >= 1 || config.predictable) { + return Math.acos(1 / x); + } + return new type.Complex(x, 0).asec(); + }, + + 'Complex': function (x) { + return x.asec(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).acos(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, asec); + } + }); + + asec.toTex = {1: '\\sec^{-1}\\left(${args[0]}\\right)'}; + + return asec; + } + + exports.name = 'asec'; + exports.factory = factory; + + +/***/ }, +/* 467 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + var acosh = typed.find(load(__webpack_require__(461)), ['Complex']); + + /** + * Calculate the hyperbolic arcsecant of a value, + * defined as `asech(x) = acosh(1/x) = ln(sqrt(1/x^2 - 1) + 1/x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asech(x) + * + * Examples: + * + * math.asech(0.5); // returns 1.3169578969248166 + * + * See also: + * + * acsch, acoth + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arcsecant of x + */ + var asech = typed('asech', { + 'number': function (x) { + if ((x <= 1 && x >= -1) || config.predictable) { + x = 1 / x; + + var ret = Math.sqrt(x*x - 1); + if (x > 0 || config.predictable) { + return Math.log(ret + x); + } + + return new type.Complex(Math.log(ret - x), Math.PI); + } + + return new type.Complex(x, 0).asech(); + }, + + 'Complex': function (x) { + return x.asech() + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x).acosh(); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, asech); + } + }); + + asech.toTex = {1: '\\mathrm{sech}^{-1}\\left(${args[0]}\\right)'}; + + return asech; + } + + exports.name = 'asech'; + exports.factory = factory; + + +/***/ }, +/* 468 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse sine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asin(x) + * + * Examples: + * + * math.asin(0.5); // returns number 0.5235987755982989 + * math.asin(math.sin(1.5)); // returns number ~1.5 + * + * math.asin(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * sin, atan, acos + * + * @param {number | BigNumber | Complex | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} The arc sine of x + */ + var asin = typed('asin', { + 'number': function (x) { + if ((x >= -1 && x <= 1) || config.predictable) { + return Math.asin(x); + } + else { + return new type.Complex(x, 0).asin(); + } + }, + + 'Complex': function (x) { + return x.asin(); + }, + + 'BigNumber': function (x) { + return x.asin(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since asin(0) = 0 + return deepMap(x, asin, true); + } + }); + + asin.toTex = {1: '\\sin^{-1}\\left(${args[0]}\\right)'}; + + return asin; + } + + exports.name = 'asin'; + exports.factory = factory; + + +/***/ }, +/* 469 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the hyperbolic arcsine of a value, + * defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asinh(x) + * + * Examples: + * + * math.asinh(0.5); // returns 0.48121182505960347 + * + * See also: + * + * acosh, atanh + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arcsine of x + */ + var asinh = typed('asinh', { + 'number': Math.asinh || function (x) { + return Math.log(Math.sqrt(x*x + 1) + x); + }, + + 'Complex': function (x) { + return x.asinh(); + }, + + 'BigNumber': function (x) { + return x.asinh(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since asinh(0) = 0 + return deepMap(x, asinh, true); + } + }); + + asinh.toTex = {1: '\\sinh^{-1}\\left(${args[0]}\\right)'}; + + return asinh; + } + + exports.name = 'asinh'; + exports.factory = factory; + + +/***/ }, +/* 470 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the inverse tangent of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atan(x) + * + * Examples: + * + * math.atan(0.5); // returns number 0.4636476090008061 + * math.atan(math.tan(1.5)); // returns number 1.5 + * + * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * tan, asin, acos + * + * @param {number | BigNumber | Complex | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} The arc tangent of x + */ + var atan = typed('atan', { + 'number': function (x) { + return Math.atan(x); + }, + + 'Complex': function (x) { + return x.atan(); + }, + + 'BigNumber': function (x) { + return x.atan(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since atan(0) = 0 + return deepMap(x, atan, true); + } + }); + + atan.toTex = {1: '\\tan^{-1}\\left(${args[0]}\\right)'}; + + return atan; + } + + exports.name = 'atan'; + exports.factory = factory; + + +/***/ }, +/* 471 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(52)); + + var algorithm02 = load(__webpack_require__(360)); + var algorithm03 = load(__webpack_require__(61)); + var algorithm09 = load(__webpack_require__(362)); + var algorithm11 = load(__webpack_require__(85)); + var algorithm12 = load(__webpack_require__(63)); + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Calculate the inverse tangent function with two arguments, y/x. + * By providing two arguments, the right quadrant of the computed angle can be + * determined. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atan2(y, x) + * + * Examples: + * + * math.atan2(2, 2) / math.pi; // returns number 0.25 + * + * var angle = math.unit(60, 'deg'); // returns Unit 60 deg + * var x = math.cos(angle); + * var y = math.sin(angle); + * + * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * tan, atan, sin, cos + * + * @param {number | Array | Matrix} y Second dimension + * @param {number | Array | Matrix} x First dimension + * @return {number | Array | Matrix} Four-quadrant inverse tangent + */ + var atan2 = typed('atan2', { + + 'number, number': Math.atan2, + + // Complex numbers doesn't seem to have a reasonable implementation of + // atan2(). Even Matlab removed the support, after they only calculated + // the atan only on base of the real part of the numbers and ignored the imaginary. + + 'BigNumber, BigNumber': function (y, x) { + return type.BigNumber.atan2(y, x); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse .* sparse + c = algorithm09(x, y, atan2, false); + break; + default: + // sparse .* dense + c = algorithm02(y, x, atan2, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense .* sparse + c = algorithm03(x, y, atan2, false); + break; + default: + // dense .* dense + c = algorithm13(x, y, atan2); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return atan2(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return atan2(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return atan2(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = algorithm11(x, y, atan2, false); + break; + default: + c = algorithm14(x, y, atan2, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = algorithm12(y, x, atan2, true); + break; + default: + c = algorithm14(y, x, atan2, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, atan2, false).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, atan2, true).valueOf(); + } + }); + + atan2.toTex = {2: '\\mathrm{atan2}\\left(${args}\\right)'}; + + return atan2; + } + + exports.name = 'atan2'; + exports.factory = factory; + + +/***/ }, +/* 472 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic arctangent of a value, + * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atanh(x) + * + * Examples: + * + * math.atanh(0.5); // returns 0.5493061443340549 + * + * See also: + * + * acosh, asinh + * + * @param {number | Complex | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic arctangent of x + */ + var atanh = typed('atanh', { + 'number': function (x) { + if ((x <= 1 && x >= -1) || config.predictable) { + return _atanh(x); + } + return new type.Complex(x, 0).atanh(); + }, + + 'Complex': function (x) { + return x.atanh(); + }, + + 'BigNumber': function (x) { + return x.atanh(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since atanh(0) = 0 + return deepMap(x, atanh, true); + } + }); + + atanh.toTex = {1: '\\tanh^{-1}\\left(${args[0]}\\right)'}; + + return atanh; + } + + /** + * Calculate the hyperbolic arctangent of a number + * @param {number} x + * @return {number} + * @private + */ + var _atanh = Math.atanh || function (x) { + return Math.log((1 + x)/(1 - x)) / 2 + }; + + exports.name = 'atanh'; + exports.factory = factory; + + +/***/ }, +/* 473 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the cosine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cos(x) + * + * Examples: + * + * math.cos(2); // returns number -0.4161468365471422 + * math.cos(math.pi / 4); // returns number 0.7071067811865475 + * math.cos(math.unit(180, 'deg')); // returns number -1 + * math.cos(math.unit(60, 'deg')); // returns number 0.5 + * + * var angle = 0.2; + * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns number ~1 + * + * See also: + * + * cos, tan + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Cosine of x + */ + var cos = typed('cos', { + 'number': Math.cos, + + 'Complex': function (x) { + return x.cos(); + }, + + 'BigNumber': function (x) { + return x.cos(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cos is no angle'); + } + return cos(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, cos); + } + }); + + cos.toTex = {1: '\\cos\\left(${args[0]}\\right)'}; + + return cos; + } + + exports.name = 'cos'; + exports.factory = factory; + + +/***/ }, +/* 474 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic cosine of a value, + * defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cosh(x) + * + * Examples: + * + * math.cosh(0.5); // returns number 1.1276259652063807 + * + * See also: + * + * sinh, tanh + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic cosine of x + */ + var cosh = typed('cosh', { + 'number': _cosh, + + 'Complex': function (x) { + return x.cosh(); + }, + + 'BigNumber': function (x) { + return x.cosh(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cosh is no angle'); + } + return cosh(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, cosh); + } + }); + + cosh.toTex = {1: '\\cosh\\left(${args[0]}\\right)'}; + + return cosh; + } + + /** + * Calculate the hyperbolic cosine of a number + * @param {number} x + * @returns {number} + * @private + */ + var _cosh = Math.cosh || function (x) { + return (Math.exp(x) + Math.exp(-x)) / 2; + }; + + exports.name = 'cosh'; + exports.factory = factory; + + +/***/ }, +/* 475 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the cotangent of a value. Defined as `cot(x) = 1 / tan(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cot(x) + * + * Examples: + * + * math.cot(2); // returns number -0.45765755436028577 + * 1 / math.tan(2); // returns number -0.45765755436028577 + * + * See also: + * + * tan, sec, csc + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Cotangent of x + */ + var cot = typed('cot', { + 'number': function (x) { + return 1 / Math.tan(x); + }, + + 'Complex': function (x) { + return x.cot(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.tan()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cot is no angle'); + } + return cot(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, cot); + } + }); + + cot.toTex = {1: '\\cot\\left(${args[0]}\\right)'}; + + return cot; + } + + exports.name = 'cot'; + exports.factory = factory; + + +/***/ }, +/* 476 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic cotangent of a value, + * defined as `coth(x) = 1 / tanh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.coth(x) + * + * Examples: + * + * // coth(x) = 1 / tanh(x) + * math.coth(2); // returns 1.0373147207275482 + * 1 / math.tanh(2); // returns 1.0373147207275482 + * + * See also: + * + * sinh, tanh, cosh + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic cotangent of x + */ + var coth = typed('coth', { + 'number': _coth, + + 'Complex': function (x) { + return x.coth(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.tanh()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function coth is no angle'); + } + return coth(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, coth); + } + }); + + coth.toTex = {1: '\\coth\\left(${args[0]}\\right)'}; + + return coth; + } + + /** + * Calculate the hyperbolic cosine of a number + * @param {number} x + * @returns {number} + * @private + */ + function _coth(x) { + var e = Math.exp(2 * x); + return (e + 1) / (e - 1); + } + + exports.name = 'coth'; + exports.factory = factory; + + +/***/ }, +/* 477 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.csc(x) + * + * Examples: + * + * math.csc(2); // returns number 1.099750170294617 + * 1 / math.sin(2); // returns number 1.099750170294617 + * + * See also: + * + * sin, sec, cot + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Cosecant of x + */ + var csc = typed('csc', { + 'number': function (x) { + return 1 / Math.sin(x); + }, + + 'Complex': function (x) { + return x.csc(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.sin()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function csc is no angle'); + } + return csc(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, csc); + } + }); + + csc.toTex = {1: '\\csc\\left(${args[0]}\\right)'}; + + return csc; + } + + exports.name = 'csc'; + exports.factory = factory; + + +/***/ }, +/* 478 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + var sign = __webpack_require__(6).sign; + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic cosecant of a value, + * defined as `csch(x) = 1 / sinh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.csch(x) + * + * Examples: + * + * // csch(x) = 1/ sinh(x) + * math.csch(0.5); // returns 1.9190347513349437 + * 1 / math.sinh(0.5); // returns 1.9190347513349437 + * + * See also: + * + * sinh, sech, coth + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic cosecant of x + */ + var csch = typed('csch', { + 'number': _csch, + + 'Complex': function (x) { + return x.csch(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.sinh()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function csch is no angle'); + } + return csch(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, csch); + } + }); + + csch.toTex = {1: '\\mathrm{csch}\\left(${args[0]}\\right)'}; + + return csch; + } + + /** + * Calculate the hyperbolic cosecant of a number + * @param {number} x + * @returns {number} + * @private + */ + function _csch(x) { + // consider values close to zero (+/-) + if (x == 0) { + return Number.POSITIVE_INFINITY; + } + else { + return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x); + } + } + + exports.name = 'csch'; + exports.factory = factory; + + +/***/ }, +/* 479 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sec(x) + * + * Examples: + * + * math.sec(2); // returns number -2.4029979617223822 + * 1 / math.cos(2); // returns number -2.4029979617223822 + * + * See also: + * + * cos, csc, cot + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Secant of x + */ + var sec = typed('sec', { + 'number': function (x) { + return 1 / Math.cos(x); + }, + + 'Complex': function (x) { + return x.sec(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.cos()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sec is no angle'); + } + return sec(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, sec); + } + }); + + sec.toTex = {1: '\\sec\\left(${args[0]}\\right)'}; + + return sec; + } + + exports.name = 'sec'; + exports.factory = factory; + + +/***/ }, +/* 480 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic secant of a value, + * defined as `sech(x) = 1 / cosh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sech(x) + * + * Examples: + * + * // sech(x) = 1/ cosh(x) + * math.sech(0.5); // returns 0.886818883970074 + * 1 / math.cosh(0.5); // returns 0.886818883970074 + * + * See also: + * + * cosh, csch, coth + * + * @param {number | Complex | Unit | Array | Matrix} x Function input + * @return {number | Complex | Array | Matrix} Hyperbolic secant of x + */ + var sech = typed('sech', { + 'number': _sech, + + 'Complex': function (x) { + return x.sech(); + }, + + 'BigNumber': function (x) { + return new type.BigNumber(1).div(x.cosh()); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sech is no angle'); + } + return sech(x.value); + }, + + 'Array | Matrix': function (x) { + return deepMap(x, sech); + } + }); + + sech.toTex = {1: '\\mathrm{sech}\\left(${args[0]}\\right)'}; + + return sech; + } + + /** + * Calculate the hyperbolic secant of a number + * @param {number} x + * @returns {number} + * @private + */ + function _sech(x) { + return 2 / (Math.exp(x) + Math.exp(-x)); + } + + exports.name = 'sech'; + exports.factory = factory; + + +/***/ }, +/* 481 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + + /** + * Calculate the sine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sin(x) + * + * Examples: + * + * math.sin(2); // returns number 0.9092974268256813 + * math.sin(math.pi / 4); // returns number 0.7071067811865475 + * math.sin(math.unit(90, 'deg')); // returns number 1 + * math.sin(math.unit(30, 'deg')); // returns number 0.5 + * + * var angle = 0.2; + * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns number ~1 + * + * See also: + * + * cos, tan + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Sine of x + */ + var sin = typed('sin', { + 'number': Math.sin, + + 'Complex': function (x) { + return x.sin(); + }, + + 'BigNumber': function (x) { + return x.sin(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sin is no angle'); + } + return sin(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sin(0) = 0 + return deepMap(x, sin, true); + } + }); + + sin.toTex = {1: '\\sin\\left(${args[0]}\\right)'}; + + return sin; + } + + exports.name = 'sin'; + exports.factory = factory; + + +/***/ }, +/* 482 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic sine of a value, + * defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sinh(x) + * + * Examples: + * + * math.sinh(0.5); // returns number 0.5210953054937474 + * + * See also: + * + * cosh, tanh + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic sine of x + */ + var sinh = typed('sinh', { + 'number': _sinh, + + 'Complex': function (x) { + return x.sinh(); + }, + + 'BigNumber': function (x) { + return x.sinh(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sinh is no angle'); + } + return sinh(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sinh(0) = 0 + return deepMap(x, sinh, true); + } + }); + + sinh.toTex = {1: '\\sinh\\left(${args[0]}\\right)'}; + + return sinh; + } + + /** + * Calculate the hyperbolic sine of a number + * @param {number} x + * @returns {number} + * @private + */ + var _sinh = Math.sinh || function (x) { + return (Math.exp(x) - Math.exp(-x)) / 2; + }; + + exports.name = 'sinh'; + exports.factory = factory; + + +/***/ }, +/* 483 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the tangent of a value. `tan(x)` is equal to `sin(x) / cos(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.tan(x) + * + * Examples: + * + * math.tan(0.5); // returns number 0.5463024898437905 + * math.sin(0.5) / math.cos(0.5); // returns number 0.5463024898437905 + * math.tan(math.pi / 4); // returns number 1 + * math.tan(math.unit(45, 'deg')); // returns number 1 + * + * See also: + * + * atan, sin, cos + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Tangent of x + */ + var tan = typed('tan', { + 'number': Math.tan, + + 'Complex': function (x) { + return x.tan(); + }, + + 'BigNumber': function (x) { + return x.tan(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function tan is no angle'); + } + return tan(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since tan(0) = 0 + return deepMap(x, tan, true); + } + }); + + tan.toTex = {1: '\\tan\\left(${args[0]}\\right)'}; + + return tan; + } + + exports.name = 'tan'; + exports.factory = factory; + + +/***/ }, +/* 484 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deepMap = __webpack_require__(19); + + function factory (type, config, load, typed) { + /** + * Calculate the hyperbolic tangent of a value, + * defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.tanh(x) + * + * Examples: + * + * // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x) + * math.tanh(0.5); // returns 0.46211715726000974 + * math.sinh(0.5) / math.cosh(0.5); // returns 0.46211715726000974 + * 1 / math.coth(0.5); // returns 0.46211715726000974 + * + * See also: + * + * sinh, cosh, coth + * + * @param {number | BigNumber | Complex | Unit | Array | Matrix} x Function input + * @return {number | BigNumber | Complex | Array | Matrix} Hyperbolic tangent of x + */ + var tanh = typed('tanh', { + 'number': _tanh, + + 'Complex': function (x) { + return x.tanh(); + }, + + 'BigNumber': function (x) { + return x.tanh(); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function tanh is no angle'); + } + return tanh(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since tanh(0) = 0 + return deepMap(x, tanh, true); + } + }); + + tanh.toTex = {1: '\\tanh\\left(${args[0]}\\right)'}; + + return tanh; + } + + /** + * Calculate the hyperbolic tangent of a number + * @param {number} x + * @returns {number} + * @private + */ + var _tanh = Math.tanh || function (x) { + var e = Math.exp(2 * x); + return (e - 1) / (e + 1); + }; + + exports.name = 'tanh'; + exports.factory = factory; + + +/***/ }, +/* 485 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(486) + ]; + +/***/ }, +/* 486 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var latex = __webpack_require__(32); + + var matrix = load(__webpack_require__(52)); + + var algorithm13 = load(__webpack_require__(57)); + var algorithm14 = load(__webpack_require__(58)); + + /** + * Change the unit of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.to(x, unit) + * + * Examples: + * + * math.to(math.unit('2 inch'), 'cm'); // returns Unit 5.08 cm + * math.to(math.unit('2 inch'), math.unit(null, 'cm')); // returns Unit 5.08 cm + * math.to(math.unit(16, 'bytes'), 'bits'); // returns Unit 128 bits + * + * See also: + * + * unit + * + * @param {Unit | Array | Matrix} x The unit to be converted. + * @param {Unit | Array | Matrix} unit New unit. Can be a string like "cm" + * or a unit without value. + * @return {Unit | Array | Matrix} value with changed, fixed unit. + */ + var to = typed('to', { + + 'Unit, Unit | string': function (x, unit) { + return x.to(unit); + }, + + 'Matrix, Matrix': function (x, y) { + // SparseMatrix does not support Units + return algorithm13(x, y, to); + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return to(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return to(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return to(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // SparseMatrix does not support Units + return algorithm14(x, y, to, false); + }, + + 'any, Matrix': function (x, y) { + // SparseMatrix does not support Units + return algorithm14(y, x, to, true); + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return algorithm14(matrix(x), y, to, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return algorithm14(matrix(y), x, to, true).valueOf(); + } + }); + + to.toTex = { + 2: '\\left(${args[0]}' + latex.operators['to'] + '${args[1]}\\right)' + }; + + return to; + } + + exports.name = 'to'; + exports.factory = factory; + + +/***/ }, +/* 487 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(488), + __webpack_require__(408), + __webpack_require__(356), + __webpack_require__(88), + __webpack_require__(370), + __webpack_require__(422), + __webpack_require__(90) + ]; + + +/***/ }, +/* 488 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object= __webpack_require__(3); + + function factory (type, config, load, typed) { + /** + * Clone an object. + * + * Syntax: + * + * math.clone(x) + * + * Examples: + * + * math.clone(3.5); // returns number 3.5 + * math.clone(math.complex('2-4i'); // returns Complex 2 - 4i + * math.clone(math.unit(45, 'deg')); // returns Unit 45 deg + * math.clone([[1, 2], [3, 4]]); // returns Array [[1, 2], [3, 4]] + * math.clone("hello world"); // returns string "hello world" + * + * @param {*} x Object to be cloned + * @return {*} A clone of object x + */ + var clone = typed('clone', { + 'any': object.clone + }); + + clone.toTex = undefined; // use default template + + return clone; + } + + exports.name = 'clone'; + exports.factory = factory; + + +/***/ }, +/* 489 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(490) + ]; + + +/***/ }, +/* 490 */ +/***/ function(module, exports) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Instantiate mathjs data types from their JSON representation + * @param {string} key + * @param {*} value + * @returns {*} Returns the revived object + */ + return function reviver(key, value) { + var constructor = type[value && value.mathjs]; + if (constructor && typeof constructor.fromJSON === 'function') { + return constructor.fromJSON(value); + } + + return value; + } + } + + exports.name = 'reviver'; + exports.path = 'json'; + exports.factory = factory; + + +/***/ }, +/* 491 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var ArgumentsError = __webpack_require__(11); + var DimensionError = __webpack_require__(42); + var IndexError = __webpack_require__(43); + + module.exports = [ + { + name: 'ArgumentsError', path: 'error', + factory: function () { + return ArgumentsError; + } + }, + { + name: 'DimensionError', + path: 'error', + factory: function () { + return DimensionError; + } + }, + { + name: 'IndexError', + path: 'error', + factory: function () { + return IndexError; + } + } + ]; + + // TODO: implement an InvalidValueError? + + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/webapp/mxClient.min.js b/webapp/mxClient.min.js new file mode 100644 index 0000000..80979cd --- /dev/null +++ b/webapp/mxClient.min.js @@ -0,0 +1,1564 @@ +var mxClient={VERSION:"1.10.4.1",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE"),IS_OP:0<=navigator.userAgent.indexOf("Opera/"),IS_OT:0>navigator.userAgent.indexOf("Presto/2.4.")&&0>navigator.userAgent.indexOf("Presto/2.3.")&&0>navigator.userAgent.indexOf("Presto/2.2.")&& +0>navigator.userAgent.indexOf("Presto/2.1.")&&0>navigator.userAgent.indexOf("Presto/2.0.")&&0>navigator.userAgent.indexOf("Presto/1."),IS_SF:0<=navigator.userAgent.indexOf("AppleWebKit/")&&0>navigator.userAgent.indexOf("Chrome/"),IS_GC:0<=navigator.userAgent.indexOf("Chrome/"),IS_MT:0<=navigator.userAgent.indexOf("Firefox/")&&0>navigator.userAgent.indexOf("Firefox/1.")&&0>navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/")&&0>navigator.userAgent.indexOf("Iceweasel/1.")&& +0>navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/")&&0>navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/")&&0>navigator.userAgent.indexOf("Iceape/1."),IS_SVG:0<=navigator.userAgent.indexOf("Firefox/")||0<=navigator.userAgent.indexOf("Iceweasel/")||0<=navigator.userAgent.indexOf("Seamonkey/")||0<=navigator.userAgent.indexOf("Iceape/")||0<=navigator.userAgent.indexOf("Galeon/")||0<=navigator.userAgent.indexOf("Epiphany/")||0<= +navigator.userAgent.indexOf("AppleWebKit/")||0<=navigator.userAgent.indexOf("Gecko/")||0<=navigator.userAgent.indexOf("Opera/"),NO_FO:0<=navigator.userAgent.indexOf("Firefox/1.")||0<=navigator.userAgent.indexOf("Iceweasel/1.")||0<=navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/1.")||0<=navigator.userAgent.indexOf("Camino/1.")||0<=navigator.userAgent.indexOf("Epiphany/2.")|| +0<=navigator.userAgent.indexOf("Opera/")||0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Mozilla/2."),IS_VML:"MICROSOFT INTERNET EXPLORER"==navigator.appName.toUpperCase(),IS_MAC:0document.location.href.indexOf("http://")&& +0>document.location.href.indexOf("https://"),isBrowserSupported:function(){return mxClient.IS_VML||mxClient.IS_SVG},link:function(a,b,c){c=c||document;if(mxClient.IS_IE6)c.write('');else{var d=c.createElement("link");d.setAttribute("rel",a);d.setAttribute("href",b);d.setAttribute("charset","ISO-8859-1");d.setAttribute("type","text/css");c.getElementsByTagName("head")[0].appendChild(d)}},include:function(a){document.write('