Merge remote-tracking branch 'upstream/master' into omega-master

This commit is contained in:
Quentin
2019-11-12 00:39:16 +01:00
6 changed files with 22 additions and 14 deletions

View File

@@ -60,13 +60,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: numworks/setup-emscripten@v1
with:
sdk: latest-fastcomp
- uses: actions/checkout@v1
- run: source $EMSDK/emsdk_env.sh && make -j2 PLATFORM=simulator TARGET=web
- run: make -j2 PLATFORM=simulator TARGET=web
- uses: actions/upload-artifact@master
with:
name: epsilon-simulator-web.zip
path: output/release/simulator/web/simulator.zip
- run: source $EMSDK/emsdk_env.sh && make -j2 PLATFORM=simulator TARGET=web test.headless.js
- run: make -j2 PLATFORM=simulator TARGET=web test.headless.js
- run: node output/release/simulator/web/test.headless.js
build-simulator-linux:
runs-on: ubuntu-latest

View File

@@ -59,7 +59,7 @@ Expression ComplexNode<T>::complexToExpression(Preferences::ComplexFormat comple
tb = this->imag();
}
return Expression::CreateComplexExpression(
Number::DecimalNumber<T>(std::fabs(ra)),
Number::DecimalNumber<T>(std::fabs(ra)), // TODO: Maybe use Number::FloatNumber instead to speed up 'complexToExpression'
Number::DecimalNumber<T>(std::fabs(tb)),
complexFormat,
(std::isnan(this->real()) || std::isnan(this->imag())),

View File

@@ -127,14 +127,11 @@ Expression ComplexCartesian::norm(ExpressionNode::ReductionContext reductionCont
a = imag();
}
if (!a.isUninitialized()) {
ExpressionNode::Sign s = a.sign(reductionContext.context());
if (s == ExpressionNode::Sign::Positive) {
// Case 1: the expression is positive real
return a;
} else if (s == ExpressionNode::Sign::Negative) {
// Case 2: the argument is negative real
return a.setSign(ExpressionNode::Sign::Positive, reductionContext);
}
// norm = sign(a) * a
Expression signa = SignFunction::Builder(a.clone());
Expression norm = Multiplication::Builder(a, signa);
signa.shallowReduce(reductionContext);
return norm;
}
Expression n2 = squareNorm(reductionContext);
Expression n = SquareRoot::Builder(n2);

View File

@@ -25,7 +25,7 @@ bool NAryExpressionNode::childAtIndexNeedsUserParentheses(const Expression & chi
void NAryExpressionNode::sortChildrenInPlace(ExpressionOrder order, Context * context, bool canSwapMatrices, bool canBeInterrupted) {
Expression reference(this);
for (int i = reference.numberOfChildren()-1; i > 0; i--) {
for (int i = 1; i < reference.numberOfChildren(); i++) {
bool isSorted = true;
for (int j = 0; j < reference.numberOfChildren()-1; j++) {
/* Warning: Matrix operations are not always commutative (ie,

View File

@@ -198,12 +198,12 @@ Expression Trigonometry::shallowReduceDirectFunction(Expression & e, ExpressionN
// reduce x^2
res.childAtIndex(0).childAtIndex(1).shallowReduce(reductionContext);
// reduce 1+*x^2
// reduce 1+x^2
res.childAtIndex(0).shallowReduce(reductionContext);
if (e.type() == ExpressionNode::Type::Sine) {
res = Multiplication::Builder(x, res);
// reduce (1+x^2)^(-1/2)
res.childAtIndex(0).shallowReduce(reductionContext);
res.childAtIndex(1).shallowReduce(reductionContext);
}
e.replaceWithInPlace(res);
// reduce (1+x^2)^(-1/2) or x*(1+x^2)^(-1/2)

View File

@@ -604,6 +604,9 @@ QUIZ_CASE(poincare_simplication_trigonometry_functions) {
// tan(asin)
assert_parsed_expression_simplify_to("tan(asin(x))", "x/√(-x^2+1)", User, Degree);
assert_parsed_expression_simplify_to("tan(asin(-x))", "-x/√(-x^2+1)", User, Degree);
// Mix
assert_parsed_expression_simplify_to("sin(atan(3/4))", "3/5", User, Degree);
}
QUIZ_CASE(poincare_simplication_hyperbolic_trigonometry_functions) {
@@ -798,6 +801,8 @@ QUIZ_CASE(poincare_simplification_complex_format) {
assert_parsed_expression_simplify_to("(-8)^(1/4)", "unreal", User, Radian, Real);
assert_parsed_expression_simplify_to("(-8)^(1/3)", "-2", User, Radian, Real);
assert_parsed_expression_simplify_to("[[1,2+√(-1)]]", "unreal", User, Radian, Real);
assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Real);
assert_parsed_expression_simplify_to("atan(-2)", "-atan(2)", User, Radian, Real);
// User defined variable
assert_parsed_expression_simplify_to("a", "a", User, Radian, Real);
@@ -841,6 +846,8 @@ QUIZ_CASE(poincare_simplification_complex_format) {
assert_parsed_expression_simplify_to("π", "π", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("𝐢", "𝐢", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("atan(-2)", "-atan(2)", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("abs(-3)", "3", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("abs(-3+𝐢)", "√(10)", User, Radian, Cartesian);
assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Cartesian);
@@ -931,6 +938,8 @@ QUIZ_CASE(poincare_simplification_complex_format) {
assert_parsed_expression_simplify_to("conj(2×^(𝐢×π/2))", "2×^\u0012-π/2×𝐢\u0013", User, Radian, Polar);
assert_parsed_expression_simplify_to("-2×^(𝐢×π/2)", "2×^\u0012-π/2×𝐢\u0013", User, Radian, Polar);
assert_parsed_expression_simplify_to("[[1,√(-1)]]", "[[1,^\u0012π/2×𝐢\u0013]]", User, Radian, Polar);
assert_parsed_expression_simplify_to("atan(2)", "atan(2)", User, Radian, Polar);
assert_parsed_expression_simplify_to("atan(-2)", "atan(2)×^\u0012π×𝐢\u0013", User, Radian, Polar);
// User defined variable
assert_parsed_expression_simplify_to("a", "a", User, Radian, Polar);