Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
d2902159
Commit
d2902159
authored
Jul 07, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModSim ass4 taddeus: made command line arguments more sensible.
parent
5a84959c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
modsim/ass4_taddeus/vibstring/draw.py
modsim/ass4_taddeus/vibstring/draw.py
+10
-2
modsim/ass4_taddeus/vibstring/seq.c
modsim/ass4_taddeus/vibstring/seq.c
+12
-16
No files found.
modsim/ass4_taddeus/vibstring/draw.py
View file @
d2902159
...
@@ -2,12 +2,20 @@
...
@@ -2,12 +2,20 @@
from
sys
import
stdin
from
sys
import
stdin
from
pylab
import
figure
,
plot
,
axis
,
draw
,
ion
,
clf
from
pylab
import
figure
,
plot
,
axis
,
draw
,
ion
,
clf
from
time
import
sleep
from
time
import
sleep
from
sys
import
argv
,
exit
if
len
(
argv
)
<
2
:
print
'Usage: python %s TIME_STEP [ DELAY ]'
%
argv
[
0
]
exit
()
stride
=
int
(
argv
[
1
])
delay
=
.
1
if
len
(
argv
)
<
3
else
float
(
argv
[
2
])
# Collect data
# Collect data
y
=
[]
y
=
[]
lines
=
stdin
.
readlines
()
lines
=
stdin
.
readlines
()
x
=
map
(
float
,
lines
[
0
].
split
(
' '
))
x
=
map
(
float
,
lines
[
0
].
split
(
' '
))
for
line
in
lines
[
1
:]:
for
line
in
lines
[
1
:
:
stride
]:
y
+=
[
map
(
float
,
line
.
split
(
' '
))]
y
+=
[
map
(
float
,
line
.
split
(
' '
))]
# Find axis maxima
# Find axis maxima
...
@@ -22,4 +30,4 @@ for i in range(len(y)):
...
@@ -22,4 +30,4 @@ for i in range(len(y)):
plot
(
x
,
y
[
i
],
'-'
)
plot
(
x
,
y
[
i
],
'-'
)
axis
(
ranges
)
axis
(
ranges
)
draw
()
draw
()
sleep
(
.
01
)
sleep
(
delay
)
modsim/ass4_taddeus/vibstring/seq.c
View file @
d2902159
...
@@ -54,7 +54,7 @@ void print(int index) {
...
@@ -54,7 +54,7 @@ void print(int index) {
/*
/*
*
*
*/
*/
void
calculate_steps
(
int
calc_steps
,
int
print_resolution
,
double
tau
)
{
void
calculate_steps
(
int
calc_steps
,
double
tau
)
{
double
x
;
double
x
;
int
i
,
t
,
prev
=
0
,
current
=
1
,
next
=
2
;
int
i
,
t
,
prev
=
0
,
current
=
1
,
next
=
2
;
...
@@ -79,9 +79,7 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
...
@@ -79,9 +79,7 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
// Print init states
// Print init states
print
(
prev
);
print
(
prev
);
print
(
current
);
if
(
print_resolution
==
1
)
print
(
current
);
#endif
#endif
// Iterate over the length of the string for each time interval step
// Iterate over the length of the string for each time interval step
...
@@ -92,8 +90,7 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
...
@@ -92,8 +90,7 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
}
}
#ifdef VERBOSE
#ifdef VERBOSE
if
(
!
(
t
%
print_resolution
)
)
print
(
next
);
print
(
next
);
#endif
#endif
prev
=
current
;
prev
=
current
;
...
@@ -103,14 +100,14 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
...
@@ -103,14 +100,14 @@ void calculate_steps(int calc_steps, int print_resolution, double tau) {
}
}
int
main
(
int
argc
,
const
char
**
argv
)
{
int
main
(
int
argc
,
const
char
**
argv
)
{
int
calc_steps
,
i
,
print_resolution
;
int
calc_steps
,
i
;
void
(
*
init_method
)(
double
,
double
);
void
(
*
init_method
)(
double
,
double
);
double
l
,
tau
,
constant
;
double
l
,
tau
,
constant
;
// Parse argument
// Parse argument
if
(
argc
<
8
)
{
if
(
argc
<
7
)
{
printf
(
"Usage: %s INIT_METHOD CALCULATION_STEPS
PRINT_RESOLUTION LENGTH"
printf
(
"Usage: %s INIT_METHOD CALCULATION_STEPS
LENGTH DX TAU N|XP
\n
"
,
" DX TAU N|XP
\n
"
,
argv
[
0
]);
argv
[
0
]);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
...
@@ -124,11 +121,10 @@ int main(int argc, const char **argv) {
...
@@ -124,11 +121,10 @@ int main(int argc, const char **argv) {
}
}
calc_steps
=
atoi
(
argv
[
2
]);
calc_steps
=
atoi
(
argv
[
2
]);
print_resolution
=
atoi
(
argv
[
3
]);
l
=
atof
(
argv
[
3
]);
l
=
atof
(
argv
[
4
]);
dx
=
atof
(
argv
[
4
]);
dx
=
atof
(
argv
[
5
]);
tau
=
atof
(
argv
[
5
]);
tau
=
atof
(
argv
[
6
]);
constant
=
atof
(
argv
[
6
]);
constant
=
atof
(
argv
[
7
]);
// Allocate a 3xN two-dimensional area that functions as a cyclic buffer
// Allocate a 3xN two-dimensional area that functions as a cyclic buffer
// for three states of the string (previous, current, next)
// for three states of the string (previous, current, next)
...
@@ -146,7 +142,7 @@ int main(int argc, const char **argv) {
...
@@ -146,7 +142,7 @@ int main(int argc, const char **argv) {
(
*
init_method
)(
l
,
constant
);
(
*
init_method
)(
l
,
constant
);
// Calculate the specified number of steps
// Calculate the specified number of steps
calculate_steps
(
calc_steps
,
print_resolution
,
tau
);
calculate_steps
(
calc_steps
,
tau
);
// Free allocated memory
// Free allocated memory
for
(
i
=
0
;
i
<
3
;
i
++
)
for
(
i
=
0
;
i
<
3
;
i
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment