mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Merge remote-tracking branch 'upstream/master' into omega-dev-e14
This commit is contained in:
@@ -406,7 +406,7 @@ Expression Power::shallowReduce(ExpressionNode::ReductionContext reductionContex
|
||||
// Step 1: Handle the units
|
||||
{
|
||||
Expression indexUnit;
|
||||
index.removeUnit(&indexUnit);
|
||||
index = index.removeUnit(&indexUnit);
|
||||
if (!indexUnit.isUninitialized()) {
|
||||
// There must be no unit in the exponent
|
||||
return replaceWithUndefinedInPlace();
|
||||
|
||||
@@ -79,8 +79,13 @@ Poincare::Expression parse_expression(const char * expression, Context * context
|
||||
void assert_simplify(const char * expression, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat, ExpressionNode::ReductionTarget target) {
|
||||
Shared::GlobalContext globalContext;
|
||||
Expression e = parse_expression(expression, &globalContext, false);
|
||||
assert_expression_simplify(e, angleUnit, complexFormat, target, expression);
|
||||
}
|
||||
|
||||
void assert_expression_simplify(Expression e, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat, ExpressionNode::ReductionTarget target, const char * printIfFailure) {
|
||||
Shared::GlobalContext globalContext;
|
||||
e = e.reduce(ExpressionNode::ReductionContext(&globalContext, complexFormat, angleUnit, target));
|
||||
quiz_assert_print_if_failure(!(e.isUninitialized()), expression);
|
||||
quiz_assert_print_if_failure(!(e.isUninitialized()), printIfFailure);
|
||||
}
|
||||
|
||||
void assert_parsed_expression_simplify_to(const char * expression, const char * simplifiedExpression, ExpressionNode::ReductionTarget target, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat, ExpressionNode::SymbolicComputation symbolicComputation, ExpressionNode::UnitConversion unitConversion) {
|
||||
|
||||
@@ -41,6 +41,8 @@ Poincare::Expression parse_expression(const char * expression, Poincare::Context
|
||||
|
||||
void assert_simplify(const char * expression, Poincare::Preferences::AngleUnit angleUnit = Radian, Poincare::Preferences::ComplexFormat complexFormat = Cartesian, Poincare::ExpressionNode::ReductionTarget target = User);
|
||||
|
||||
void assert_expression_simplify(Poincare::Expression expression, Poincare::Preferences::AngleUnit angleUnit = Radian, Poincare::Preferences::ComplexFormat complexFormat = Cartesian, Poincare::ExpressionNode::ReductionTarget target = User, const char * printIfFailure = "Error");
|
||||
|
||||
void assert_parsed_expression_simplify_to(const char * expression, const char * simplifiedExpression, Poincare::ExpressionNode::ReductionTarget target = User, Poincare::Preferences::AngleUnit angleUnit = Radian, Poincare::Preferences::ComplexFormat complexFormat = Cartesian, Poincare::ExpressionNode::SymbolicComputation symbolicComputation = ReplaceAllDefinedSymbolsWithDefinition, Poincare::ExpressionNode::UnitConversion unitConversion = DefaultUnitConversion);
|
||||
|
||||
// Approximation
|
||||
|
||||
@@ -1304,6 +1304,22 @@ QUIZ_CASE(poincare_simplification_user_function) {
|
||||
Ion::Storage::sharedStorage()->recordNamed("f.func").destroy();
|
||||
}
|
||||
|
||||
QUIZ_CASE(poincare_simplification_user_function_with_convert) {
|
||||
/* User defined function
|
||||
* f: x → 0→0
|
||||
* It cannot be created with a const char *, so we create it by hand. */
|
||||
Expression e = Store::Builder(
|
||||
UnitConvert::Builder(
|
||||
Rational::Builder(0),
|
||||
Rational::Builder(0)),
|
||||
Function::Builder(
|
||||
"f", 1,
|
||||
Symbol::Builder('x')));
|
||||
assert_expression_simplify(e);
|
||||
assert_simplify("e^(f(0))", Radian, Polar);
|
||||
Ion::Storage::sharedStorage()->recordNamed("f.func").destroy();
|
||||
}
|
||||
|
||||
QUIZ_CASE(poincare_simplification_mix) {
|
||||
// Root at denominator
|
||||
assert_parsed_expression_simplify_to("1/(√(2)+√(3))", "√(3)-√(2)");
|
||||
|
||||
Reference in New Issue
Block a user