Changeset c572316 in OpenModelica
- Timestamp:
- 2012-11-15T23:41:47+01:00 (11 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
- Children:
- 0fda3e2
- Parents:
- 92c84b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Compiler/BackEnd/ExpressionSolve.mo
r92c84b1 rc572316 311 311 DAE.ComponentRef cr,cr1; 312 312 DAE.Exp invCr; 313 DAE.Type tp ;313 DAE.Type tp,tp1; 314 314 list<DAE.Exp> factors; 315 315 list<DAE.Statement> asserts; … … 373 373 then 374 374 (rhs,asserts); 375 376 // a^b = f(..) -> a = sign(pre(a))*(f(...)^(1/b)) 377 case (_,_,DAE.CREF(componentRef = cr),_) 378 equation 379 e = Expression.makeDiff(inExp1,inExp2); 380 ((e,(_,false,SOME(DAE.BINARY(operator=DAE.POW(tp1),exp2 = a))))) = Expression.traverseExpTopDown(e, traversingVarOnlyinPow, (cr,false,NONE())); 381 tp = Expression.typeof(e); 382 (z,_) = Expression.makeZeroExpression(Expression.arrayDimension(tp)); 383 (rhs,asserts) = solve(e,z,inExp3); 384 a = Expression.expDiv(DAE.RCONST(1.0),a); 385 rhs = DAE.BINARY(rhs,DAE.POW(tp1),a); 386 tp = Expression.typeof(inExp3); 387 dere = Expression.makeBuiltinCall("pre",{inExp3},tp); 388 dere = Expression.makeBuiltinCall("sign",{dere},DAE.T_INTEGER_DEFAULT); 389 rhs = Expression.expMul(dere,rhs); 390 then 391 (rhs,asserts); 375 392 /* 376 393 case (_,_,DAE.CREF(componentRef = cr),_) … … 415 432 end solve2; 416 433 434 protected function traversingVarOnlyinPow " 435 @author: Frenkel TUD 2011-04 436 Returns true if in the exp the componentRef is only in pow" 437 input tuple<DAE.Exp, tuple<DAE.ComponentRef,Boolean,Option<DAE.Exp>>> inExp; 438 output tuple<DAE.Exp, Boolean, tuple<DAE.ComponentRef,Boolean,Option<DAE.Exp>>> outExp; 439 algorithm 440 outExp := matchcontinue(inExp) 441 local 442 Boolean b; 443 DAE.ComponentRef cr,cr1; 444 DAE.Exp e,e1,e2; 445 Option<DAE.Exp> oe; 446 447 case ((e as DAE.BINARY(exp1 = e1 as DAE.CREF(componentRef = cr1),operator = DAE.POW(_),exp2 = e2), (cr,false,NONE()))) 448 equation 449 true = ComponentReference.crefPrefixOf(cr1,cr); 450 false = Expression.expHasCrefNoPreorDer(e2, cr); 451 then 452 ((e1,false,(cr,false,SOME(e)))); 453 454 case ((e as DAE.CREF(componentRef = cr1), (cr,false,oe))) 455 equation 456 b = ComponentReference.crefEqualNoStringCompare(cr,cr1); 457 then 458 ((e,not b,(cr,b,oe))); 459 460 case ((e as DAE.CREF(componentRef = cr1), (cr,false,oe))) 461 equation 462 b = ComponentReference.crefPrefixOf(cr1,cr); 463 then 464 ((e,not b,(cr,b,oe))); 465 466 case (((e,(cr,b,oe)))) then ((e,not b,(cr,b,oe))); 467 468 end matchcontinue; 469 end traversingVarOnlyinPow; 470 417 471 protected function generateAssert 418 472 input DAE.Exp inExp1; … … 423 477 output list<DAE.Statement> outAsserts; 424 478 algorithm 425 (outExp,outAsserts):= matchcontinue (inExp1,inExp2,inExp3,a,inAsserts)479 outAsserts := matchcontinue (inExp1,inExp2,inExp3,a,inAsserts) 426 480 local 427 481 DAE.Exp a,z;
Note: See TracChangeset
for help on using the changeset viewer.