This commit is contained in:
Ozzie Gooen 2022-04-27 15:21:27 -04:00
parent dfa404f0d0
commit b2189777d5

View File

@ -163,13 +163,17 @@ module AlgebraicCombination = {
*/ */
let getLogarithmInputError = (t1: t, t2: t, ~toPointSetFn: toPointSetFn): option<error> => { let getLogarithmInputError = (t1: t, t2: t, ~toPointSetFn: toPointSetFn): option<error> => {
let firstOperandIsGreaterThanZero = let firstOperandIsGreaterThanZero =
toFloatOperation(t1, ~toPointSetFn, ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten)) |> E.R.fmap(r => toFloatOperation(
r > 0. t1,
) ~toPointSetFn,
~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten),
) |> E.R.fmap(r => r > 0.)
let secondOperandIsGreaterThanZero = let secondOperandIsGreaterThanZero =
toFloatOperation(t2, ~toPointSetFn, ~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten)) |> E.R.fmap(r => toFloatOperation(
r > 0. t2,
) ~toPointSetFn,
~distToFloatOperation=#Cdf(MagicNumbers.Epsilon.ten),
) |> E.R.fmap(r => r > 0.)
let items = E.A.R.firstErrorOrOpen([ let items = E.A.R.firstErrorOrOpen([
firstOperandIsGreaterThanZero, firstOperandIsGreaterThanZero,
secondOperandIsGreaterThanZero, secondOperandIsGreaterThanZero,
@ -238,8 +242,8 @@ module AlgebraicCombination = {
//I'm (Ozzie) really just guessing here, very little idea what's best //I'm (Ozzie) really just guessing here, very little idea what's best
let expectedConvolutionCost: t => int = x => let expectedConvolutionCost: t => int = x =>
switch x { switch x {
| Symbolic(#Float(_)) =>MagicNumbers.OpCost.floatCost | Symbolic(#Float(_)) => MagicNumbers.OpCost.floatCost
| Symbolic(_) =>MagicNumbers.OpCost.symbolicCost | Symbolic(_) => MagicNumbers.OpCost.symbolicCost
| PointSet(Discrete(m)) => m.xyShape->XYShape.T.length | PointSet(Discrete(m)) => m.xyShape->XYShape.T.length
| PointSet(Mixed(_)) => MagicNumbers.OpCost.mixedCost | PointSet(Mixed(_)) => MagicNumbers.OpCost.mixedCost
| PointSet(Continuous(_)) => MagicNumbers.OpCost.continuousCost | PointSet(Continuous(_)) => MagicNumbers.OpCost.continuousCost
@ -253,7 +257,8 @@ module AlgebraicCombination = {
#AsSymbolic #AsSymbolic
| #NoSolution => | #NoSolution =>
if Operation.Convolution.canDoAlgebraicOperation(arithmeticOperation) { if Operation.Convolution.canDoAlgebraicOperation(arithmeticOperation) {
expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > MagicNumbers.OpCost.monteCarloCost expectedConvolutionCost(t1) * expectedConvolutionCost(t2) >
MagicNumbers.OpCost.monteCarloCost
? #AsMonteCarlo ? #AsMonteCarlo
: #AsConvolution : #AsConvolution
} else { } else {