Skip to content

Commit

Permalink
Merge branch 'matlab' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RolfSander committed Jul 1, 2022
2 parents ae9d778 + 5709ca3 commit aa595d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/code_matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ int number_of_lines = 1, MAX_NO_OF_LINES = 36;
0xad = '-' | 0xae ='.' | 0xaf = '/' */
/* char op_mult=0xaa, op_plus=0xab, op_minus=0xad, op_dot=0xae, op_div=0xaf; */
char op_plus='+', op_minus='-'; /* op_mult='*', op_dot='.', op_div='/'; */

crtident = 3 + ident * 2;
bprintf("%*s%s = ", crtident, "", ls);
start = strlen( ls ) + 2;
linelg = 70 - crtident - start - 1;
/* mz_rs_20220701+ increase max line length */
/* linelg = 70 - crtident - start - 1; */
linelg = 150 - crtident - start - 1;
/* mz_rs_20220701- */

first = 1;
while( strlen(rs) > linelg ) {
Expand All @@ -139,7 +142,7 @@ char op_plus='+', op_minus='-'; /* op_mult='*', op_dot='.', op_div='/'; */
Note: the approach below will create erroneous code if the +/- is within a subexpression, e.g. for
A*(B+C) one cannot start a new continuation line by splitting at the + sign */
for( j=linelg; j>5; j-- ) /* split row here if +, -, or comma */
if ( ( rs[j] == op_plus )||( rs[j] == op_minus )||( rs[j]==',' ) ) {
if ( ( rs[j] == op_plus )||( rs[j] == op_minus )||( rs[j]==',' ) ) {
jfound = 1; i=j; break;
}
}
Expand All @@ -149,10 +152,10 @@ char op_plus='+', op_minus='-'; /* op_mult='*', op_dot='.', op_div='/'; */
break;
}
if( i <= 10 ) {
printf("\n Warning: possible error in continuation lines for %s = ...",ls);
i = linelg;
printf("\n Warning: double-check continuation lines for:\n %s = %s\n",ls,rs);
i = linelg;
}
}
}
while ( rs[i-1] & 0x80 ) i--; /* put all operators on the next row */
while ( rs[i] == ',' ) i++; /* put commas on the current row */

Expand Down
10 changes: 9 additions & 1 deletion src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ int F_VAR, FSPLIT_VAR;
Declare( A );
if ( useLang==F77_LANG ) WriteOMPThreadPrivate("A");
}
if (useLang==MATLAB_LANG) {
MATLAB_Inline("A=zeros(1,length(RCT));");
MATLAB_Inline("Vdot=zeros(1,length(V));");
}
NewLines(1);
WriteComment("Computation of equation rates");

Expand Down Expand Up @@ -838,7 +842,7 @@ int F_VAR, FSPLIT_VAR;
}

if( z_useAggregate )
MATLAB_Inline("\n Vdot = Vdot(:);\n");
MATLAB_Inline("\n Vdotout = Vdot(:);\n");
else
MATLAB_Inline("\n P_VAR = P_VAR(:);\n D_VAR = D_VAR(:);\n");

Expand Down Expand Up @@ -1305,6 +1309,10 @@ int Jac_SP, Jac;
varTable[ NTMPB ] -> value = nonzeros_B;
Declare( BV );
}
if (useLang == MATLAB_LANG) {
MATLAB_Inline("B=zeros(1,%d);",nonzeros_B);
MATLAB_Inline("JVS=zeros(1,length(LU_IROW));");
}

NewLines(1);

Expand Down

0 comments on commit aa595d5

Please sign in to comment.