예제 #1
0
	Expression * GetDerivativeVisitor::visit(Fcn::Cosh * expression) {
		ExpressionList * parameters = expression->getParameterList();
		if (parameters->getLength() != 1) {
			throw InvalidFunctionParametersException();
		}

		Expression * parameterExpr = parameters->getExpressionAt(0);
		std::unique_ptr<Expression> derivedParameterExprPtr((Expression *)parameterExpr->accept(this));

		return new Op::Multiplication(
			new Fcn::Sinh(parameterExpr->copy()),
			derivedParameterExprPtr.release()
		);
	}
예제 #2
0
	Expression * GetDerivativeVisitor::visit(Fcn::ArTanh * expression) {
		ExpressionList * parameters = expression->getParameterList();
		if (parameters->getLength() != 1) {
			throw InvalidFunctionParametersException();
		}

		Expression * parameterExpr = parameters->getExpressionAt(0);
		std::unique_ptr<Expression> derivedParameterExprPtr((Expression *)parameterExpr->accept(this));

		return new Op::Division(
			derivedParameterExprPtr.release(),
			new Op::Subtraction(
				new Number(1.0),
				new Op::Power(parameterExpr->copy(), new Number(2.0))
		    )
		);
	}