/* Ċ Ġ* ĠCopyright Ġ 2 0 1 8 - 2 0 2 1 ĠK Math Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġspace . k science . k math . integration Ċ Ċ import Ġspace . k science . k math . misc . Feature Set Ċ import Ġspace . k science . k math . misc . Un stable K Math API Ċ import Ġspace . k science . k math . structures . Buffer Ċ import Ġspace . k science . k math . structures . Double Buffer Ċ Ċ public Ġclass ĠUn ivariate Integr and < T > Ġinternal Ġconstructor ( ĊĠĠĠ Ġoverride Ġval Ġfeatures : ĠFeature Set < Integr and Feature >, ĊĠĠĠ Ġpublic Ġval Ġfunction : Ġ( Double ) Ġ-> ĠT , Ċ ) Ġ: ĠIntegr and Ġ{ ĊĠĠĠ Ġpublic Ġoperator Ġfun Ġ< F Ġ: ĠIntegr and Feature > Ġplus ( feature : ĠF ): ĠUn ivariate Integr and < T > Ġ= ĊĠĠĠĠĠĠĠ ĠUn ivariate Integr and ( features . with ( feature ), Ġfunction ) Ċ } Ċ Ċ @ Suppress (" FunctionName ") Ċ public Ġfun Ġ< T Ġ: ĠAny > ĠUn ivariate Integr and ( ĊĠĠĠ Ġfunction : Ġ( Double ) Ġ-> ĠT , ĊĠĠĠ Ġvar arg Ġfeatures : ĠIntegr and Feature , Ċ ): ĠUn ivariate Integr and < T > Ġ= ĠUn ivariate Integr and ( Feature Set . of (* features ), Ġfunction ) Ċ Ċ public Ġtype alias ĠUn ivariate Integr ator < T > Ġ= ĠIntegr ator < Un ivariate Integr and < T >> Ċ Ċ public Ġclass ĠIntegration Range ( public Ġval Ġrange : ĠClosed Range < Double >) Ġ: ĠIntegr and Feature Ġ{ ĊĠĠĠ Ġoverride Ġfun ĠtoString (): ĠString Ġ= Ġ" Range (${ range . start } .. ${ range . end Inclusive })" Ċ } Ċ Ċ /** Ċ Ġ* ĠSet Ġof Ġun ivariate Ġintegration Ġranges . ĠFirst Ġcomponents Ġcorrespond Ġto Ġthe Ġranges Ġthemselves , Ġsecond Ġcomponents Ġto Ċ Ġ* Ġnumber Ġof Ġintegration Ġnodes Ġper Ġrange . Ċ Ġ*/ Ċ public Ġclass ĠUn ivariate Integr and Ranges ( public Ġval Ġranges : ĠList < Pair < Closed Range < Double >, ĠInt >>) Ġ: ĠIntegr and Feature Ġ{ ĊĠĠĠ Ġpublic Ġconstructor ( var arg Ġpairs : ĠPair < Closed Range < Double >, ĠInt >) Ġ: Ġthis ( pairs . toList ()) ĊĊĠĠĠ Ġoverride Ġfun ĠtoString (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġranges String Ġ= Ġranges . join ToString ( separator Ġ= Ġ", ") Ġ{ Ġ( range , Ġpoints ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"${ range . start } .. ${ range . end Inclusive } Ġ: Ġ$ points " ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġ" Un ivariate Ranges ($ ranges String )" ĊĠĠĠ Ġ} Ċ } Ċ Ċ public Ġclass ĠUn ivariate Integration Nodes ( public Ġval Ġnodes : ĠBuffer < Double >) Ġ: ĠIntegr and Feature Ġ{ ĊĠĠĠ Ġpublic Ġconstructor ( var arg Ġnodes : ĠDouble ) Ġ: Ġthis ( Double Buffer ( nodes )) ĊĊĠĠĠ Ġoverride Ġfun ĠtoString (): ĠString Ġ= Ġ" Un ivariate Nodes ($ nodes )" Ċ } ĊĊ Ċ /** Ċ Ġ* ĠValue Ġof Ġthe Ġintegr and Ġif Ġit Ġis Ġpresent Ġor Ġnull Ċ Ġ*/ Ċ public Ġval Ġ< T Ġ: ĠAny > ĠUn ivariate Integr and < T >. value OrNull : ĠT ? Ġget () Ġ= Ġget Feature < Integr and Value < T >>() ?. value Ċ Ċ /** Ċ Ġ* ĠValue Ġof Ġthe Ġintegr and Ġor Ġerror Ċ Ġ*/ Ċ public Ġval Ġ< T Ġ: ĠAny > ĠUn ivariate Integr and < T >. value : ĠT Ġget () Ġ= Ġvalue OrNull Ġ?: Ġerror (" No Ġvalue Ġin Ġthe Ġintegr and ") Ċ Ċ /** Ċ Ġ* ĠA Ġshortcut Ġmethod Ġto Ġintegrate Ġa Ġ[ function ] Ġwith Ġadditional Ġ[ features ]. ĠRange Ġmust Ġbe Ġprovided Ġin Ġfeatures . Ċ Ġ* ĠThe Ġ[ function ] Ġis Ġplaced Ġin Ġthe Ġend Ġposition Ġto Ġallow Ġpassing Ġa Ġlambda . Ċ Ġ*/ Ċ @ Un stable K Math API Ċ public Ġfun Ġ< T Ġ: ĠAny > ĠUn ivariate Integr ator < T >. integrate ( ĊĠĠĠ Ġvar arg Ġfeatures : ĠIntegr and Feature , ĊĠĠĠ Ġfunction : Ġ( Double ) Ġ-> ĠT , Ċ ): ĠUn ivariate Integr and < T > Ġ= Ġprocess ( Un ivariate Integr and ( function , Ġ* features )) Ċ Ċ /** Ċ Ġ* ĠA Ġshortcut Ġmethod Ġto Ġintegrate Ġa Ġ[ function ] Ġin Ġ[ range ] Ġwith Ġadditional Ġ[ features ]. Ċ Ġ* ĠThe Ġ[ function ] Ġis Ġplaced Ġin Ġthe Ġend Ġposition Ġto Ġallow Ġpassing Ġa Ġlambda . Ċ Ġ*/ Ċ @ Un stable K Math API Ċ public Ġfun Ġ< T Ġ: ĠAny > ĠUn ivariate Integr ator < T >. integrate ( ĊĠĠĠ Ġrange : ĠClosed Range < Double >, ĊĠĠĠ Ġvar arg Ġfeatures : ĠIntegr and Feature , ĊĠĠĠ Ġfunction : Ġ( Double ) Ġ-> ĠT , Ċ ): ĠUn ivariate Integr and < T > Ġ= Ġprocess ( Un ivariate Integr and ( function , ĠIntegration Range ( range ), Ġ* features )) Ċ Ċ /** Ċ Ġ* ĠA Ġshortcut Ġmethod Ġto Ġintegrate Ġa Ġ[ function ] Ġin Ġ[ range ] Ġwith Ġadditional Ġfeatures . Ċ Ġ* ĠThe Ġ[ function ] Ġis Ġplaced Ġin Ġthe Ġend Ġposition Ġto Ġallow Ġpassing Ġa Ġlambda . Ċ Ġ*/ Ċ @ Un stable K Math API Ċ public Ġfun Ġ< T Ġ: ĠAny > ĠUn ivariate Integr ator < T >. integrate ( ĊĠĠĠ Ġrange : ĠClosed Range < Double >, ĊĠĠĠ Ġfeature Builder : ĠMutable List < Integr and Feature >. () Ġ-> ĠUnit Ġ= Ġ{}, ĊĠĠĠ Ġfunction : Ġ( Double ) Ġ-> ĠT , Ċ ): ĠUn ivariate Integr and < T > Ġ{ ĊĠĠĠ Ġ// TODO Ġuse Ġdedicated Ġfeature Ġbuilder Ġclass Ġinstead Ġor Ġadd Ġextensions Ġto ĠMutable List < Integr and Feature > ĊĠĠĠ Ġval Ġfeatures Ġ= Ġbuild List Ġ{ ĊĠĠĠĠĠĠĠ Ġfeature Builder () ĊĠĠĠĠĠĠĠ Ġadd ( Integration Range ( range )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġprocess ( Un ivariate Integr and ( function , Ġ* features . to Typed Array ())) Ċ } Ċ