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
c9d726c9
Commit
c9d726c9
authored
Feb 18, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ass4 and another header file.
parent
65f2a370
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
5 deletions
+47
-5
modsim/ass2/Makefile
modsim/ass2/Makefile
+1
-1
modsim/ass2/bisec.h
modsim/ass2/bisec.h
+2
-2
modsim/ass2/func_ptr.h
modsim/ass2/func_ptr.h
+1
-0
modsim/ass2/q1.c
modsim/ass2/q1.c
+1
-2
modsim/ass2/q4.c
modsim/ass2/q4.c
+42
-0
No files found.
modsim/ass2/Makefile
View file @
c9d726c9
...
@@ -2,7 +2,7 @@ CC=clang
...
@@ -2,7 +2,7 @@ CC=clang
CFLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c99
-D_GNU_SOURCE
CFLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c99
-D_GNU_SOURCE
LFLAGS
=
-lm
LFLAGS
=
-lm
all
:
q1 q2 q3
all
:
q1 q2 q3
q4
q%
:
q%.o
q%
:
q%.o
$(CC)
$(CFLAGS)
$(LFLAGS)
-o
$@
$^
$(CC)
$(CFLAGS)
$(LFLAGS)
-o
$@
$^
...
...
modsim/ass2/bisec.h
View file @
c9d726c9
#
define EPSILON 1e-11
#
include "func_ptr.h"
typedef
double
(
*
func_ptr
)(
double
x
);
#define EPSILON 1e-11
double
bisec
(
func_ptr
f
,
double
left
,
double
right
,
int
*
steps
)
{
double
bisec
(
func_ptr
f
,
double
left
,
double
right
,
int
*
steps
)
{
int
i
;
int
i
;
...
...
modsim/ass2/func_ptr.h
0 → 100644
View file @
c9d726c9
typedef
double
(
*
func_ptr
)(
double
x
);
modsim/ass2/q1.c
View file @
c9d726c9
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <math.h>
#include <math.h>
#include "func_ptr.h"
#define H 1e-3
#define H 1e-3
#define TABLE_LINE(func, x) (printf("%-24s%.12f\t%.12f\n", #x, \
#define TABLE_LINE(func, x) (printf("%-24s%.12f\t%.12f\n", #x, \
slope_right(func, x, H), slope_central(func, x, H)))
slope_right(func, x, H), slope_central(func, x, H)))
typedef
double
(
*
func_ptr
)(
double
x
);
double
slope_right
(
func_ptr
func
,
double
x
,
double
h
)
{
double
slope_right
(
func_ptr
func
,
double
x
,
double
h
)
{
return
(
func
(
x
+
h
)
-
func
(
x
))
/
h
;
return
(
func
(
x
+
h
)
-
func
(
x
))
/
h
;
}
}
...
...
modsim/ass2/q4.c
0 → 100644
View file @
c9d726c9
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "func_ptr.h"
double
newton
(
func_ptr
f
,
func_ptr
df
,
double
x_start
)
{
return
0
;
}
double
f1
(
double
x
)
{
return
x
*
x
-
x
+
2
;
}
double
df1
(
double
x
)
{
return
x
/
2
-
1
;
}
double
f2
(
double
x
)
{
return
x
*
x
*
x
-
3
*
x
-
2
;
}
double
df2
(
double
x
)
{
return
(
x
*
x
)
/
3
-
3
;
}
double
f3
(
double
x
)
{
return
(
x
*
x
+
1
)
*
(
x
-
4
);
}
double
df3
(
double
x
)
{
return
(
x
*
x
+
1
)
+
(
x
/
2
)
*
(
x
-
4
);
}
#define TEST(i) (printf("f1: %.11f\n", &f(i), &df(i), 1))
int
main
(
void
)
{
printf
(
"f1: %.11f
\n
"
,
newton
(
&
f1
,
&
df1
,
1
));
return
0
;
}
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