Revert partially the previous commit:

The two formulas are true iff 2n = 2 <=> n = 1.
This commit is contained in:
Edoardo Prezioso 2013-01-05 17:31:08 +01:00
parent c465cf4ab4
commit 4c73c29cdd
2 changed files with 6 additions and 15 deletions

View File

@ -9350,18 +9350,15 @@ void Tokenizer::simplifyMathExpressions()
tok->str("0");
}
//Pythagorean trigonometric identity: pow(sin(x),2n)+pow(cos(x),2n) = 1
//Hyperbolic identity: pow(sinh(x),2n)-pow(cosh(x),2n) = -1
//2n = any even number
//Pythagorean trigonometric identity: pow(sin(x),2)+pow(cos(x),2) = 1
//Hyperbolic identity: pow(sinh(x),2)-pow(cosh(x),2) = -1
if (Token::simpleMatch(tok, "pow (")) {
if (Token::simpleMatch(tok->tokAt(2), "sin (")) {
Token *tok2 = tok->linkAt(3);
if (!Token::Match(tok2, ") , %num% ) + pow ( cos (") ||
(MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1)
if (!Token::simpleMatch(tok2, ") , 2 ) + pow ( cos ("))
continue;
Token *tok3 = tok2->tokAt(8);
if (!Token::Match(tok3->link(), ") , %num% )") ||
tok3->link()->strAt(2) != tok2->strAt(2))
if (!Token::simpleMatch(tok3->link(), ") , 2 )"))
continue;
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
Token::eraseTokens(tok, tok3->link()->tokAt(4));
@ -9369,12 +9366,10 @@ void Tokenizer::simplifyMathExpressions()
}
} else if (Token::simpleMatch(tok->tokAt(2), "sinh (")) {
Token *tok2 = tok->linkAt(3);
if (!Token::Match(tok2, ") , %num% ) - pow ( cosh (") ||
(MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1)
if (!Token::simpleMatch(tok2, ") , 2 ) - pow ( cosh (") )
continue;
Token *tok3 = tok2->tokAt(8);
if (!Token::Match(tok3->link(), ") , %num% )") ||
tok3->link()->strAt(2) != tok2->strAt(2))
if (!Token::simpleMatch(tok3->link(), ") , 2 )"))
continue;
if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) {
Token::eraseTokens(tok, tok3->link()->tokAt(4));

View File

@ -7727,8 +7727,6 @@ private:
" 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(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"
@ -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"
"}";
ASSERT_EQUALS(expected1, tokenizeAndStringify(code1));