Skip to content

Commit

Permalink
Quite big check-in:
Browse files Browse the repository at this point in the history
DAE.mo: 
  - added some comments to operators
DAEUtil.mo : 
  -added some utility functions.
Exp.mo: 
  -implemented simplification of cross
  - fixed some bugs in simplification
  - added some utility functions
Inst.mo: 
  - bindings on parameters and constants are now also created using makeVariableBinding, as for variables. This makes them also type converted properly as for variabeles. (This affected many flat models).
  - Fixed bug in setFunctionInputIndex (used for derivative information on functions)
Lookup.mo :
  - fixed bug in makeExpIntegerArray with wrong value on the scalar attribute.
Static.mo :
  - made elabBuiltinCross2 public (used by Exp.simplify1)

+ a lot of updates to testsuite


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5029 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Feb 24, 2010
1 parent 934f9e0 commit 78823db
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 72 deletions.
50 changes: 25 additions & 25 deletions Compiler/DAE.mo
Expand Up @@ -1142,60 +1142,60 @@ uniontype Operator "Operators which are overloaded in the abstract syntax are he
ExpType ty;
end DIV_ARR;

record MUL_SCALAR_ARRAY
ExpType ty "a { b, c }" ;
record MUL_SCALAR_ARRAY " s * {a,b,c}"
ExpType ty "type of the array" ;
end MUL_SCALAR_ARRAY;

record MUL_ARRAY_SCALAR
ExpType ty "{a, b} c" ;
record MUL_ARRAY_SCALAR " {a,b,c} * s"
ExpType ty "type of the array" ;
end MUL_ARRAY_SCALAR;

record ADD_SCALAR_ARRAY
ExpType ty "a { b, c }" ;
record ADD_SCALAR_ARRAY "s + {a,b,c}"
ExpType ty "type of the array" ;
end ADD_SCALAR_ARRAY;

record ADD_ARRAY_SCALAR
ExpType ty "{a, b} c" ;
record ADD_ARRAY_SCALAR " {a,b,c} + s"
ExpType ty "type of the array";
end ADD_ARRAY_SCALAR;

record SUB_SCALAR_ARRAY
ExpType ty "a { b, c }" ;
record SUB_SCALAR_ARRAY "s - {a,b,c}"
ExpType ty "type of the array" ;
end SUB_SCALAR_ARRAY;

record SUB_ARRAY_SCALAR
ExpType ty "{a, b} c" ;
record SUB_ARRAY_SCALAR "{a,b,c} - s"
ExpType ty "type of the array" ;
end SUB_ARRAY_SCALAR;

record MUL_SCALAR_PRODUCT
ExpType ty "{a, b} {c, d}" ;
record MUL_SCALAR_PRODUCT " {a,b,c} * {c,d,e} => a*c+b*d+c*e"
ExpType ty "type of the array" ;
end MUL_SCALAR_PRODUCT;

record MUL_MATRIX_PRODUCT
record MUL_MATRIX_PRODUCT "M1 * M2, matrix dot product"
ExpType ty "{{..},..} {{..},{..}}" ;
end MUL_MATRIX_PRODUCT;

record DIV_ARRAY_SCALAR
ExpType ty "{a, b} / c" ;
record DIV_ARRAY_SCALAR "{a, b} / c"
ExpType ty "type of the array";
end DIV_ARRAY_SCALAR;

record DIV_SCALAR_ARRAY
ExpType ty "a { b, c }" ;
record DIV_SCALAR_ARRAY "c / {a,b}"
ExpType ty "type of the array" ;
end DIV_SCALAR_ARRAY;

record POW_ARRAY_SCALAR
ExpType ty "{a, b} / c" ;
ExpType ty "type of the array" ;
end POW_ARRAY_SCALAR;

record POW_SCALAR_ARRAY
ExpType ty "a { b, c }" ;
ExpType ty "type of the array" ;
end POW_SCALAR_ARRAY;

record POW_ARR
ExpType ty; /*Power of a matrix*/
record POW_ARR "Power of a matrix"
ExpType ty "type of the array";
end POW_ARR;

record POW_ARR2
ExpType ty; /*Elementwise power of arrays*/
record POW_ARR2 "elementwise power of arrays"
ExpType ty "type of the array";
end POW_ARR2;

record AND end AND;
Expand Down
72 changes: 72 additions & 0 deletions Compiler/DAEUtil.mo
Expand Up @@ -46,6 +46,64 @@ public import Values;

public constant DAE.DAElist emptyDae = DAE.DAE({},DAE.AVLTREENODE(NONE,0,NONE,NONE));

public function expTypeSimple "returns true if type is simple type"
input DAE.ExpType tp;
output Boolean isSimple;
algorithm
isSimple := matchcontinue(tp)
case(DAE.ET_REAL()) then true;
case(DAE.ET_INT()) then true;
case(DAE.ET_STRING()) then true;
case(DAE.ET_BOOL()) then true;
case(DAE.ET_ENUMERATION(path=_)) then true;

case(_) then false;

end matchcontinue;
end expTypeSimple;

public function expTypeElementType "returns the element type of an array"
input DAE.ExpType tp;
output DAE.ExpType eltTp;
algorithm
eltTp := matchcontinue(tp)
case(DAE.ET_ARRAY(ty=tp)) then expTypeElementType(tp);
case(tp) then tp;
end matchcontinue;
end expTypeElementType;

public function expTypeComplex "returns true if type is complex type"
input DAE.ExpType tp;
output Boolean isComplex;
algorithm
isComplex := matchcontinue(tp)
case(DAE.ET_COMPLEX(name=_)) then true;
case(_) then false;
end matchcontinue;
end expTypeComplex;

public function expTypeArray "returns true if type is array type"
input DAE.ExpType tp;
output Boolean isArray;
algorithm
isArray := matchcontinue(tp)
case(DAE.ET_ARRAY(ty=_)) then true;
case(_) then false;
end matchcontinue;
end expTypeArray;

public function expTypeArrayDimensions "returns the array dimensions of an ExpType"
input DAE.ExpType tp;
output list<Integer> dims;
algorithm
dims := matchcontinue(tp)
local list<Option<Integer>> optDims;
case(DAE.ET_ARRAY(arrayDimensions=optDims)) equation
dims = Util.listMap(optDims,Util.getOption);
then dims;
end matchcontinue;
end expTypeArrayDimensions;

public function derivativeOrder "
Function to sort derivatives.
Used for Util.sort"
Expand Down Expand Up @@ -3610,6 +3668,20 @@ algorithm
end matchcontinue;
end isFunction;

public function isFunctionInlineFalse "function: isFunctionInlineFalse
author: PA
Succeeds if Element is a function with Inline=false
"
input DAE.Element inElement;
output Boolean res;
algorithm
res := matchcontinue (inElement)
case DAE.FUNCTION(inlineType = DAE.NO_INLINE()) then true;
case _ then false;
end matchcontinue;
end isFunctionInlineFalse;

public function dumpDebug "

Dump the data structures in a
Expand Down

0 comments on commit 78823db

Please sign in to comment.