Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
exercises
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
advanced_computer_architecture
exercises
Commits
097c0df4
Commit
097c0df4
authored
Apr 11, 2016
by
kuhnm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basicmath ohne prints
parent
691ed21c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
42 deletions
+45
-42
blatt01/exec/automotive/basicmath/basicmath_large
blatt01/exec/automotive/basicmath/basicmath_large
+0
-0
blatt01/exec/automotive/basicmath/basicmath_large.c
blatt01/exec/automotive/basicmath/basicmath_large.c
+45
-42
No files found.
blatt01/exec/automotive/basicmath/basicmath_large
View file @
097c0df4
No preview for this file type
blatt01/exec/automotive/basicmath/basicmath_large.c
View file @
097c0df4
#include "snipmath.h"
#include <math.h>
#include <stdio.h>
/* The printf's may be removed to isolate just the math calculations */
...
...
@@ -18,60 +19,60 @@ int main(void)
printf
(
"********* CUBIC FUNCTIONS ***********
\n
"
);
/* should get 3 solutions: 2, 6 & 2.5 */
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
1
.
0
;
b1
=
-
4
.
5
;
c1
=
17
.
0
;
d1
=
-
30
.
0
;
/* should get 1 solution: 2.5 */
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
1
.
0
;
b1
=
-
3
.
5
;
c1
=
22
.
0
;
d1
=
-
31
.
0
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
1
.
0
;
b1
=
-
13
.
7
;
c1
=
1
.
0
;
d1
=
-
35
.
0
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
3
.
0
;
b1
=
12
.
34
;
c1
=
5
.
0
;
d1
=
12
.
0
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
-
8
.
0
;
b1
=
-
67
.
89
;
c1
=
6
.
0
;
d1
=
-
23
.
6
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
45
.
0
;
b1
=
8
.
67
;
c1
=
7
.
5
;
d1
=
34
.
0
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1
=
-
12
.
0
;
b1
=
-
1
.
7
;
c1
=
5
.
3
;
d1
=
16
.
0
;
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
/* Now solve some random equations */
for
(
a1
=
1
;
a1
<
10
;
a1
+=
1
)
{
...
...
@@ -79,10 +80,10 @@ int main(void)
for
(
c1
=
5
;
c1
<
15
;
c1
+=
0
.
61
)
{
for
(
d1
=-
1
;
d1
>-
5
;
d1
-=
.
451
)
{
SolveCubic
(
a1
,
b1
,
c1
,
d1
,
&
solutions
,
x
);
printf
(
"Solutions:"
);
for
(
i
=
0
;
i
<
solutions
;
i
++
)
printf
(
" %f"
,
x
[
i
]);
printf
(
"
\n
"
);
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
}
}
}
...
...
@@ -96,27 +97,29 @@ int main(void)
usqrt
(
i
,
&
q
);
// remainder differs on some machines
// printf("sqrt(%3d) = %2d, remainder = %2d\n",
printf
(
"sqrt(%3d) = %2d
\n
"
,
i
,
q
.
sqrt
);
/* printf("sqrt(%3d) = %2d\n", */
/* i, q.sqrt); */
}
printf
(
"
\n
"
);
for
(
l
=
0x3fed0169L
;
l
<
0x3fed4169L
;
l
++
)
{
usqrt
(
l
,
&
q
);
//printf("\nsqrt(%lX) = %X, remainder = %X\n", l, q.sqrt, q.frac);
printf
(
"sqrt(%lX) = %X
\n
"
,
l
,
q
.
sqrt
);
/* printf("sqrt(%lX) = %X\n", l, q.sqrt); */
}
printf
(
"********* ANGLE CONVERSION ***********
\n
"
);
/* convert some rads to degrees */
/* for (X = 0.0; X <= 360.0; X += 1.0) */
/* for (X = 0.0; X <= 360.0; X += 1.0) */
for
(
X
=
0
.
0
;
X
<=
360
.
0
;
X
+=
.
001
)
printf
(
"%3.0f degrees = %.12f radians
\n
"
,
X
,
deg2rad
(
X
));
deg2rad
(
X
);
/* printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X)); */
puts
(
""
);
/* for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 180)) */
for
(
X
=
0
.
0
;
X
<=
(
2
*
PI
+
1e-6
);
X
+=
(
PI
/
5760
))
printf
(
"%.12f radians = %3.0f degrees
\n
"
,
X
,
rad2deg
(
X
));
rad2deg
(
X
);
/* printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X)); */
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