341 unsigned char b = 1 << std::tuple_size<typename D::P::type>::value >> 1;
342 auto m = (
b >> DIMENSION);
343 auto fixed = i.getFixed() &
m;
344 const auto& pl = i.getLower();
345 const auto& pu = i.getUpper();
346 X xl = std::get<DIMENSION>(pl);
347 X xu = std::get<DIMENSION>(pu);
349 function->partition(i.template getFixed<X, DIMENSION>(
lower), [&] (
const typename D::I& i1,
const IFunction<R, D> *f1) {
350 if (auto f1c = dynamic_cast<const ConstantFunction<R, D> *>(f1)) {
351 auto p1 = i1.getLower().template getReplaced<X, DIMENSION>(xl);
352 auto p2 = i1.getUpper().template getReplaced<X, DIMENSION>(math::minnan(lower, xu));
353 ConstantFunction<R, D> g(f1c->getConstantValue());
354 typename D::I i2(p1, p2, i.getLowerClosed() | fixed, (i.getUpperClosed() & ~m) | fixed, i.getFixed());
358 throw cRuntimeError(
"TODO");
369 function->partition(i.template getFixed<X, DIMENSION>(x1), [&] (
const typename D::I& i2,
const IFunction<R, D> *f2) {
370 function->partition(i2.template getFixed<X, DIMENSION>(x2), [&] (const typename D::I& i3, const IFunction<R, D> *f3) {
371 auto i4 = i3.template getReplaced<X, DIMENSION>(j);
372 if (auto f2c = dynamic_cast<const ConstantFunction<R, D> *>(f2)) {
373 auto r1 = f2c->getConstantValue();
374 if (auto f3c = dynamic_cast<const ConstantFunction<R, D> *>(f3)) {
375 auto r2 = f3c->getConstantValue();
376 if (dynamic_cast<const ConstantInterpolatorBase<X, R> *>(interpolator)) {
377 ConstantFunction<R, D> g(interpolator->getValue(x1, r1, x2, r2, (x1 + x2) / 2));
380 else if (dynamic_cast<const LinearInterpolator<X, R> *>(interpolator)) {
381 auto p3 = i3.getLower().template getReplaced<X, DIMENSION>(x1);
382 auto p4 = i3.getUpper().template getReplaced<X, DIMENSION>(x2);
383 UnilinearFunction<R, D> g(p3, p4, r1, r2, DIMENSION);
384 simplifyAndCall(i4, &g, callback);
387 throw cRuntimeError(
"TODO");
389 else if (auto f3l = dynamic_cast<const UnilinearFunction<R, D> *>(f3)) {
390 if (dynamic_cast<const ConstantInterpolatorBase<X, R> *>(interpolator))
391 throw cRuntimeError(
"TODO");
392 else if (dynamic_cast<const LinearInterpolator<X, R> *>(interpolator)) {
393 typename D::P lowerLower = i4.getLower();
394 typename D::P lowerUpper = i4.getUpper();
395 typename D::P upperLower = i3.getLower().template getReplaced<X, DIMENSION>(x1);
396 typename D::P upperUpper = i3.getUpper().template getReplaced<X, DIMENSION>(x2);
397 R rLowerLower = f2c->getConstantValue();
398 R rLowerUpper = f2c->getConstantValue();
399 R rUpperLower = f3l->getRLower();
400 R rUpperUpper = f3l->getRUpper();
401 BilinearFunction<R, D> g(lowerLower, lowerUpper, upperLower, upperUpper, rLowerLower, rLowerUpper, rUpperLower, rUpperUpper, f3l->getDimension(), DIMENSION);
402 simplifyAndCall(i4, &g, callback);
405 throw cRuntimeError(
"TODO");
408 throw cRuntimeError(
"TODO");
410 else if (auto f2l = dynamic_cast<const UnilinearFunction<R, D> *>(f2)) {
411 if (auto f3c = dynamic_cast<const ConstantFunction<R, D> *>(f3)) {
412 if (dynamic_cast<const ConstantInterpolatorBase<X, R> *>(interpolator))
413 throw cRuntimeError(
"TODO");
414 else if (dynamic_cast<const LinearInterpolator<X, R> *>(interpolator)) {
415 typename D::P lowerLower = i2.getLower().template getReplaced<X, DIMENSION>(x1);
416 typename D::P lowerUpper = i2.getUpper().template getReplaced<X, DIMENSION>(x2);
417 typename D::P upperLower = i4.getLower();
418 typename D::P upperUpper = i4.getUpper();
419 R rLowerLower = f2l->getRLower();
420 R rLowerUpper = f2l->getRUpper();
421 R rUpperLower = f3c->getConstantValue();
422 R rUpperUpper = f3c->getConstantValue();
423 BilinearFunction<R, D> g(lowerLower, lowerUpper, upperLower, upperUpper, rLowerLower, rLowerUpper, rUpperLower, rUpperUpper, f2l->getDimension(), DIMENSION);
424 simplifyAndCall(i4, &g, callback);
427 throw cRuntimeError(
"TODO");
429 else if (auto f3l = dynamic_cast<const UnilinearFunction<R, D> *>(f3)) {
430 ASSERT(f2l->getDimension() == f3l->getDimension());
431 typename D::P lowerLower = i2.getLower().template getReplaced<X, DIMENSION>(x1);
432 typename D::P lowerUpper = i2.getUpper().template getReplaced<X, DIMENSION>(x2);
433 typename D::P upperLower = i3.getLower().template getReplaced<X, DIMENSION>(x1);
434 typename D::P upperUpper = i3.getUpper().template getReplaced<X, DIMENSION>(x2);
435 R rLowerLower = f2l->getRLower();
436 R rLowerUpper = f2l->getRUpper();
437 R rUpperLower = f3l->getRLower();
438 R rUpperUpper = f3l->getRUpper();
439 BilinearFunction<R, D> g(lowerLower, lowerUpper, upperLower, upperUpper, rLowerLower, rLowerUpper, rUpperLower, rUpperUpper, f2l->getDimension(), DIMENSION);
440 simplifyAndCall(i4, &g, callback);
443 throw cRuntimeError(
"TODO");
446 throw cRuntimeError(
"TODO");
452 function->partition(i.template getFixed<X, DIMENSION>(
upper), [&] (
const typename D::I& i1,
const IFunction<R, D> *f1) {
453 if (
auto f1c =
dynamic_cast<const ConstantFunction<R, D> *
>(f1)) {
454 auto p1 = i1.getLower().template getReplaced<X, DIMENSION>(
math::maxnan(
upper, xl));
455 auto p2 = i1.getUpper().template getReplaced<X, DIMENSION>(xu);
456 ConstantFunction<R, D>
g(f1c->getConstantValue());
457 typename D::I i2(p1, p2, i.getLowerClosed() |
m, (i.getUpperClosed() & ~
m) | fixed, i.getFixed());
461 throw cRuntimeError(
"TODO");