MCPcopy Create free account
hub / github.com/Cantera/cantera / newDiffFunction

Function newDiffFunction

src/numerics/Func1.cpp:629–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629shared_ptr<Func1> newDiffFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
630{
631 if (isZero(f2)) {
632 return f1;
633 }
634 if (isZero(f1)) {
635 return newTimesConstFunction(f2, -1.);
636 }
637 if (f1->isIdentical(f2)) {
638 return make_shared<Const1>(0.);
639 }
640 if (isConstant(f2)) {
641 return newPlusConstFunction(f1, -f2->c());
642 }
643 auto [prop, c] = isProportional(f1, f2);
644 if (prop) {
645 if (c == 1.0) {
646 return make_shared<Const1>(0.);
647 }
648 return newTimesConstFunction(f1, 1. - c);
649 }
650 return make_shared<Diff1>(f1, f2);
651}
652
653shared_ptr<Func1> newProdFunction(shared_ptr<Func1> f1, shared_ptr<Func1> f2)
654{

Callers 4

TESTFunction · 0.85
derivativeMethod · 0.85
func_new_diffFunction · 0.85
derivativeMethod · 0.85

Calls 7

isZeroFunction · 0.85
newTimesConstFunctionFunction · 0.85
isConstantFunction · 0.85
newPlusConstFunctionFunction · 0.85
isProportionalFunction · 0.85
cMethod · 0.80
isIdenticalMethod · 0.45

Tested by 1

TESTFunction · 0.68