Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
bf524d64
Commit
bf524d64
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
ModSim ass3: Code cleanup.
parent
52e5f14c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
modsim/ass3/logger.c
+3
-1
3 additions, 1 deletion
modsim/ass3/logger.c
modsim/ass3/logger.h
+0
-2
0 additions, 2 deletions
modsim/ass3/logger.h
modsim/ass3/plot.py
+3
-6
3 additions, 6 deletions
modsim/ass3/plot.py
modsim/ass3/test.c
+7
-2
7 additions, 2 deletions
modsim/ass3/test.c
with
13 additions
and
11 deletions
modsim/ass3/logger.c
+
3
−
1
View file @
bf524d64
...
...
@@ -5,6 +5,7 @@ FILE *logfile = NULL;
void
logger_open
(
const
char
*
filename
)
{
if
(
logfile
)
logger_close
();
logfile
=
fopen
(
filename
,
"w"
);
}
...
...
@@ -13,8 +14,10 @@ void logger(double t, int N, double *y) {
logfile
=
stdout
;
fprintf
(
logfile
,
"%e"
,
t
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
fprintf
(
logfile
,
",%e"
,
y
[
i
]);
fprintf
(
logfile
,
"
\n
"
);
}
...
...
@@ -22,4 +25,3 @@ void logger_close() {
if
(
logfile
&&
logfile
!=
stdout
&&
fclose
(
logfile
)
)
printf
(
"Failed to close logfile. Error no: %d"
,
errno
);
}
This diff is collapsed.
Click to expand it.
modsim/ass3/logger.h
+
0
−
2
View file @
bf524d64
...
...
@@ -4,8 +4,6 @@
#include
<stdio.h>
#include
<errno.h>
//typedef void (*log_function)(double t, double *y);
void
logger
(
double
t
,
int
N
,
double
*
y
);
void
logger_close
();
...
...
This diff is collapsed.
Click to expand it.
modsim/ass3/plot.py
+
3
−
6
View file @
bf524d64
...
...
@@ -2,12 +2,7 @@
from
sys
import
argv
,
stdin
from
pylab
import
figure
,
clf
,
plot
,
show
,
savefig
#try:
# f = open(argv[1], 'r')
#except IndexError:
f
=
stdin
lines
=
f
.
readlines
()
f
.
close
()
# Collect data
x
=
[]
y
=
[[]
for
i
in
range
(
lines
[
0
].
count
(
'
,
'
))]
for
i
in
range
(
len
(
lines
)):
...
...
@@ -18,6 +13,8 @@ for i in range(len(lines)):
y_values
=
parts
[
1
].
split
(
'
,
'
)
for
j
in
range
(
len
(
y_values
)):
y
[
j
].
append
(
y_values
[
j
])
# Plot and optionally save data
figure
(
1
)
clf
()
for
i
in
range
(
len
(
y
)):
...
...
This diff is collapsed.
Click to expand it.
modsim/ass3/test.c
+
7
−
2
View file @
bf524d64
#include
<stdlib.h>
#include
<stdio.h>
#include
<math.h>
#include
"methods.h"
#include
"integration.h"
#include
"logger.h"
#define DT .001
#define DT .01
extern
FILE
*
logfile
;
int
f_test_1
(
double
t
,
double
*
y
,
double
*
dy
,
void
*
params
)
{
*
dy
=
1
.
0
;
...
...
@@ -53,6 +56,8 @@ int f_test_4(double t, double *y, double *dy, void *params) {
int
main
(
void
)
{
double
y0
[
1
]
=
{.
0
},
y1
[
1
]
=
{.
0
};
logfile
=
fopen
(
"/dev/null"
,
"w"
);
COMPARE
(.
0
,
.
0
,
10
.
0
,
f_test_1
);
puts
(
""
);
COMPARE
(.
0
,
.
0
,
10
.
0
,
f_test_2
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment