Skip to content

Commit 1a7491d

Browse files
author
x02lucpo
committed
corrected the elab_builtin_diagonal to return an array of array. Added comments
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1311 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 60c70d2 commit 1a7491d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

modeq/ceval.rml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,12 @@ relation ceval_builtin_integer : (Env.Env, Exp.Exp, bool, Interactive.Interactiv
15721572

15731573
end
15741574

1575+
(* relation ceval_builtin_diagonal
1576+
** This relation generates a matrix[n,n] (A) of the vector {a,b,...,n}
1577+
** where the diagonal of A is the vector {a,b,...,n}
1578+
** ie A[1,1] == a, A[2,2] == b ...
1579+
*)
1580+
15751581
relation ceval_builtin_diagonal : (Env.Env, Exp.Exp, bool, Interactive.InteractiveSymbolTable option)
15761582
=> (Values.Value, Interactive.InteractiveSymbolTable option) =
15771583

@@ -1598,6 +1604,9 @@ relation ceval_builtin_diagonal : (Env.Env, Exp.Exp, bool, Interactive.Interacti
15981604

15991605
end
16001606

1607+
(* this is a help relation that is calling itself recursively to
1608+
generate the a nxn matrix with some special diagonal elements.
1609+
see ceval_builtin_diagonal *)
16011610

16021611
relation ceval_builtin_diagonal2 : (Env.Env, Exp.Exp, bool, Interactive.InteractiveSymbolTable option, int, int, Values.Value list )
16031612
=> Values.Value list =

modeq/staticexp.rml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,16 +1455,17 @@ end
14551455

14561456
relation elab_builtin_diagonal : (Env.Env, Absyn.Exp list) => (Exp.Exp, Types.Properties) =
14571457

1458-
rule Debug.fprint("failtrace", "elab_builtin_diagonal\n") &
1458+
rule Debug.fprint("failtrace", "elab_builtin_diagonal\n") &
14591459
elab_exp (env,s1,false,NONE)
1460-
=> (s1', Types.PROP((Types.T_ARRAY(Types.DIM(SOME(dimension)),arrType),NONE),c),_)
1460+
=> (s1', Types.PROP((Types.T_ARRAY(dim as Types.DIM(SOME(dimension)),arrType),NONE),c),_)
14611461
(**print "# integer function not implemented yet REAL\n" **)
1462-
--------------------------------------
1463-
elab_builtin_diagonal(env,[s1])
1464-
=> (Exp.CALL(Absyn.IDENT("diagonal"),[s1'],false,false),
1465-
Types.PROP((Types.T_ARRAY(Types.DIM(SOME(dimension)),arrType),NONE),c))
1462+
--------------------------------------
1463+
elab_builtin_diagonal(env,[s1])
1464+
=> (
1465+
Exp.CALL(Absyn.IDENT("diagonal"),[s1'],false,false),
1466+
Types.PROP((Types.T_ARRAY(dim,(Types.T_ARRAY(dim,arrType),NONE)),NONE),c))
14661467

1467-
1468+
14681469
rule print"#-- elab_builtin_diagonal: Couldn't elaborate diagonal()\n"
14691470
---------------------------------------------------------
14701471
elab_builtin_diagonal (_,_) => fail

0 commit comments

Comments
 (0)