Revert partially the previous commit:
The two formulas are true iff 2n = 2 <=> n = 1.
This commit is contained in:
parent
c465cf4ab4
commit
4c73c29cdd
|
@ -9350,18 +9350,15 @@ void Tokenizer::simplifyMathExpressions()
|
||||||
tok->str("0");
|
tok->str("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Pythagorean trigonometric identity: pow(sin(x),2n)+pow(cos(x),2n) = 1
|
//Pythagorean trigonometric identity: pow(sin(x),2)+pow(cos(x),2) = 1
|
||||||
//Hyperbolic identity: pow(sinh(x),2n)-pow(cosh(x),2n) = -1
|
//Hyperbolic identity: pow(sinh(x),2)-pow(cosh(x),2) = -1
|
||||||
//2n = any even number
|
|
||||||
if (Token::simpleMatch(tok, "pow (")) {
|
if (Token::simpleMatch(tok, "pow (")) {
|
||||||
if (Token::simpleMatch(tok->tokAt(2), "sin (")) {
|
if (Token::simpleMatch(tok->tokAt(2), "sin (")) {
|
||||||
Token *tok2 = tok->linkAt(3);
|
Token *tok2 = tok->linkAt(3);
|
||||||
if (!Token::Match(tok2, ") , %num% ) + pow ( cos (") ||
|
if (!Token::simpleMatch(tok2, ") , 2 ) + pow ( cos ("))
|
||||||
(MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1)
|
|
||||||
continue;
|
continue;
|
||||||
Token *tok3 = tok2->tokAt(8);
|
Token *tok3 = tok2->tokAt(8);
|
||||||
if (!Token::Match(tok3->link(), ") , %num% )") ||
|
if (!Token::simpleMatch(tok3->link(), ") , 2 )"))
|
||||||
tok3->link()->strAt(2) != tok2->strAt(2))
|
|
||||||
continue;
|
continue;
|
||||||
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
|
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
|
||||||
Token::eraseTokens(tok, tok3->link()->tokAt(4));
|
Token::eraseTokens(tok, tok3->link()->tokAt(4));
|
||||||
|
@ -9369,12 +9366,10 @@ void Tokenizer::simplifyMathExpressions()
|
||||||
}
|
}
|
||||||
} else if (Token::simpleMatch(tok->tokAt(2), "sinh (")) {
|
} else if (Token::simpleMatch(tok->tokAt(2), "sinh (")) {
|
||||||
Token *tok2 = tok->linkAt(3);
|
Token *tok2 = tok->linkAt(3);
|
||||||
if (!Token::Match(tok2, ") , %num% ) - pow ( cosh (") ||
|
if (!Token::simpleMatch(tok2, ") , 2 ) - pow ( cosh (") )
|
||||||
(MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1)
|
|
||||||
continue;
|
continue;
|
||||||
Token *tok3 = tok2->tokAt(8);
|
Token *tok3 = tok2->tokAt(8);
|
||||||
if (!Token::Match(tok3->link(), ") , %num% )") ||
|
if (!Token::simpleMatch(tok3->link(), ") , 2 )"))
|
||||||
tok3->link()->strAt(2) != tok2->strAt(2))
|
|
||||||
continue;
|
continue;
|
||||||
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
|
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
|
||||||
Token::eraseTokens(tok, tok3->link()->tokAt(4));
|
Token::eraseTokens(tok, tok3->link()->tokAt(4));
|
||||||
|
|
|
@ -7727,8 +7727,6 @@ private:
|
||||||
" std::cout<<pow(sinh(x),2)-pow(cosh(x),2);\n"
|
" std::cout<<pow(sinh(x),2)-pow(cosh(x),2);\n"
|
||||||
" std::cout<<pow(sin(x*y+z),2)+pow(cos(x*y+z),2);\n"
|
" std::cout<<pow(sin(x*y+z),2)+pow(cos(x*y+z),2);\n"
|
||||||
" std::cout<<pow(sinh(x*y+z),2)-pow(cosh(x*y+z),2);\n"
|
" std::cout<<pow(sinh(x*y+z),2)-pow(cosh(x*y+z),2);\n"
|
||||||
" std::cout<<pow(sin(x),4)+pow(cos(x),4);\n"
|
|
||||||
" std::cout<<pow(sinh(x),10)-pow(cosh(x),10);\n"
|
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const char expected1[] = "void foo ( ) {\n"
|
const char expected1[] = "void foo ( ) {\n"
|
||||||
|
@ -7744,8 +7742,6 @@ private:
|
||||||
"std :: cout << -1 ;\n"
|
"std :: cout << -1 ;\n"
|
||||||
"std :: cout << 1 ;\n"
|
"std :: cout << 1 ;\n"
|
||||||
"std :: cout << -1 ;\n"
|
"std :: cout << -1 ;\n"
|
||||||
"std :: cout << 1 ;\n"
|
|
||||||
"std :: cout << -1 ;\n"
|
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected1, tokenizeAndStringify(code1));
|
ASSERT_EQUALS(expected1, tokenizeAndStringify(code1));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue