Overview
Comment:Substitution of pi for its numerical value moved from
useful-functions.hh to fix_c.r
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 025d09bbeeaf5ef57b4a728f8c05c18fe1777a948f0b576f50ef3438e3844600
User & Date: gawthrop@users.sourceforge.net on 2002-05-10 12:41:08
Other Links: branch diff | manifest | tags
Context
2002-05-10
13:24:58
Added initial support for building Simulink S-functions.
Rates do not update properly yet.
Inertial switches do not work yet.
Implicit integration not supported yet.

build with: mtt -i euler MotorGenerator sfun mexglx. check-in: df65978405 user: geraint@users.sourceforge.net tags: origin/master, trunk

12:41:08
Substitution of pi for its numerical value moved from
useful-functions.hh to fix_c.r
check-in: 025d09bbee user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:38:11
Updated to new format check-in: b16f48db0a user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/cc/include/useful-functions.hh from [c2133a509b] to [3f974211f8].

1
2
3
4
5
6
7
8
#define pi 3.14159 // Predefine pi

#ifndef HAVE_USEFUL_FUNCTIONS_HH
#define HAVE_USEFUL_FUNCTIONS_HH


#ifndef __cplusplus
#define inline			/* strip */
|







1
2
3
4
5
6
7
8
//#define pi 3.14159 // Predefine pi

#ifndef HAVE_USEFUL_FUNCTIONS_HH
#define HAVE_USEFUL_FUNCTIONS_HH


#ifndef __cplusplus
#define inline			/* strip */

Modified mttroot/mtt/lib/reduce/fix_c.r from [0428d6f425] to [0b3202721a].

1



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

20
%% Fixes for c-code generation




ON ROUNDED$ % No integer output

%% Changes x^y to pow(x,y)
 OPERATOR pow$
 FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function
 
 %% Derivatives
 FOR ALL f,g,x LET df(pow(f,g),x)=
 	   pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$

 %% Special cases
 FOR ALL x LET pow(x,0) = 1$
 FOR ALL x LET pow(x,1) = x$

OPERATOR fabs$
FOR ALL x let abs(x) = fabs(x)$


END$

>
>
>


















>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%% Fixes for c-code generation

%% Set PI explicitly here to avoid later conflict with cc headers
LET PI = 3.1415$

ON ROUNDED$ % No integer output

%% Changes x^y to pow(x,y)
 OPERATOR pow$
 FOR ALL x,y LET x^y = pow(x,y)$ % Use the pow function
 
 %% Derivatives
 FOR ALL f,g,x LET df(pow(f,g),x)=
 	   pow(f,g-1) * (df(f,x)*g + df(g,x)*f*log(f))$

 %% Special cases
 FOR ALL x LET pow(x,0) = 1$
 FOR ALL x LET pow(x,1) = x$

OPERATOR fabs$
FOR ALL x let abs(x) = fabs(x)$


END$


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]