fix: formatting
This commit is contained in:
parent
27ca86e729
commit
6d75af61c3
|
@ -153,11 +153,13 @@ module Internals = {
|
||||||
let numTotalPoints = Belt.Float.toInt(numIntervals)
|
let numTotalPoints = Belt.Float.toInt(numIntervals)
|
||||||
let numInnerPoints = numTotalPoints - 2
|
let numInnerPoints = numTotalPoints - 2
|
||||||
let numOuterPoints = 2
|
let numOuterPoints = 2
|
||||||
let totalWeight = (max -. min)
|
let totalWeight = max -. min
|
||||||
let weightForAnInnerPoint = totalWeight/.E.I.toFloat(numTotalPoints-1)
|
let weightForAnInnerPoint = totalWeight /. E.I.toFloat(numTotalPoints - 1)
|
||||||
let weightForAnOuterPoint = totalWeight/.E.I.toFloat(numTotalPoints-1)/. 2.0
|
let weightForAnOuterPoint = totalWeight /. E.I.toFloat(numTotalPoints - 1) /. 2.0
|
||||||
let innerPointIncrement = (max -. min) /. E.I.toFloat(numTotalPoints -1)
|
let innerPointIncrement = (max -. min) /. E.I.toFloat(numTotalPoints - 1)
|
||||||
let innerXs = Belt.Array.makeBy(numInnerPoints, i => min +. Belt_Float.fromInt(i + 1) *. innerPointIncrement)
|
let innerXs = Belt.Array.makeBy(numInnerPoints, i =>
|
||||||
|
min +. Belt_Float.fromInt(i + 1) *. innerPointIncrement
|
||||||
|
)
|
||||||
// Note that makeBy goes from 0 to (n-1): <https://rescript-lang.org/docs/manual/latest/api/belt/array#makeby>
|
// Note that makeBy goes from 0 to (n-1): <https://rescript-lang.org/docs/manual/latest/api/belt/array#makeby>
|
||||||
let ysOptions = Belt.Array.map(innerXs, x => applyFunctionAtFloatToFloatOption(x))
|
let ysOptions = Belt.Array.map(innerXs, x => applyFunctionAtFloatToFloatOption(x))
|
||||||
let okYs = E.A.R.filterOk(ysOptions)
|
let okYs = E.A.R.filterOk(ysOptions)
|
||||||
|
@ -170,8 +172,16 @@ module Internals = {
|
||||||
Js.Console.log2("totalWeight", totalWeight) // 10 - 0 = 10
|
Js.Console.log2("totalWeight", totalWeight) // 10 - 0 = 10
|
||||||
Js.Console.log2("weightForAnInnerPoint", weightForAnInnerPoint) // 10/4 = 2.5
|
Js.Console.log2("weightForAnInnerPoint", weightForAnInnerPoint) // 10/4 = 2.5
|
||||||
Js.Console.log2("weightForAnOuterPoint", weightForAnOuterPoint) // 10/4/2 = 1.25
|
Js.Console.log2("weightForAnOuterPoint", weightForAnOuterPoint) // 10/4/2 = 1.25
|
||||||
Js.Console.log2("weightForAnInnerPoint * numInnerPoints + weightForAnOuterPoint * numOuterPoints", weightForAnInnerPoint *. E.I.toFloat(numInnerPoints) +. weightForAnOuterPoint *. E.I.toFloat(numOuterPoints)) // should be 10
|
Js.Console.log2(
|
||||||
Js.Console.log2("sum of weights == totalWeight", (weightForAnInnerPoint *. E.I.toFloat(numInnerPoints) +. weightForAnOuterPoint *. E.I.toFloat(numOuterPoints)) == totalWeight ) // true
|
"weightForAnInnerPoint * numInnerPoints + weightForAnOuterPoint * numOuterPoints",
|
||||||
|
weightForAnInnerPoint *. E.I.toFloat(numInnerPoints) +.
|
||||||
|
weightForAnOuterPoint *. E.I.toFloat(numOuterPoints),
|
||||||
|
) // should be 10
|
||||||
|
Js.Console.log2(
|
||||||
|
"sum of weights == totalWeight",
|
||||||
|
weightForAnInnerPoint *. E.I.toFloat(numInnerPoints) +.
|
||||||
|
weightForAnOuterPoint *. E.I.toFloat(numOuterPoints) == totalWeight,
|
||||||
|
) // true
|
||||||
Js.Console.log2("innerPointIncrement", innerPointIncrement) // (10-0)/4 = 2.5
|
Js.Console.log2("innerPointIncrement", innerPointIncrement) // (10-0)/4 = 2.5
|
||||||
Js.Console.log2("innerXs", innerXs) // 2.5, 5, 7.5
|
Js.Console.log2("innerXs", innerXs) // 2.5, 5, 7.5
|
||||||
Js.Console.log2("ysOptions", ysOptions)
|
Js.Console.log2("ysOptions", ysOptions)
|
||||||
|
@ -180,10 +190,14 @@ module Internals = {
|
||||||
let result = switch E.A.length(ysOptions) == E.A.length(okYs) {
|
let result = switch E.A.length(ysOptions) == E.A.length(okYs) {
|
||||||
| true => {
|
| true => {
|
||||||
let innerPointsSum = okYs->E.A.reduce(0.0, (a, b) => a +. b)
|
let innerPointsSum = okYs->E.A.reduce(0.0, (a, b) => a +. b)
|
||||||
let resultWithOuterPoints = switch(applyFunctionAtFloatToFloatOption(min), applyFunctionAtFloatToFloatOption(max)){
|
let resultWithOuterPoints = switch (
|
||||||
|
applyFunctionAtFloatToFloatOption(min),
|
||||||
|
applyFunctionAtFloatToFloatOption(max),
|
||||||
|
) {
|
||||||
| (Ok(yMin), Ok(yMax)) => {
|
| (Ok(yMin), Ok(yMax)) => {
|
||||||
let result = ((yMin +. yMax)*.weightForAnOuterPoint +. innerPointsSum*.weightForAnInnerPoint)
|
let result =
|
||||||
let wrappedResult = result -> ReducerInterface_InternalExpressionValue.IEvNumber -> Ok
|
(yMin +. yMax) *. weightForAnOuterPoint +. innerPointsSum *. weightForAnInnerPoint
|
||||||
|
let wrappedResult = result->ReducerInterface_InternalExpressionValue.IEvNumber->Ok
|
||||||
wrappedResult
|
wrappedResult
|
||||||
}
|
}
|
||||||
| (Error(b), _) => Error(b)
|
| (Error(b), _) => Error(b)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user