Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
mirror
ccan
Commits
e7e9d300
Commit
e7e9d300
authored
Apr 08, 2009
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete moved file.
parent
9e837118
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
132 deletions
+0
-132
junkcode/iasoule32@gmail.com-polynomial/polynomial_adt_test.c
...code/iasoule32@gmail.com-polynomial/polynomial_adt_test.c
+0
-132
No files found.
junkcode/iasoule32@gmail.com-polynomial/polynomial_adt_test.c
deleted
100644 → 0
View file @
9e837118
/*
** polynomial_adt_test.c
** Test (minimalistic) for the polynomial module
* More of a display of functionality
* Copyright (c) 2009 I. Soule
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
** iasoule32@gmail.com
*/
#include <stdio.h>
#include "polynomial_adt.h"
int
main
()
{
PolyAdt
*
p
=
create_adt
(
5
),
*
q
=
create_adt
(
4
);
PolyAdt
*
sum
,
*
diff
,
*
prod
;
insert_term
(
p
,
1
,
5
);
insert_term
(
p
,
3
,
4
);
insert_term
(
p
,
1
,
3
);
insert_term
(
p
,
9
,
2
);
insert_term
(
p
,
8
,
1
);
insert_term
(
q
,
2
,
4
);
insert_term
(
q
,
8
,
3
);
insert_term
(
q
,
7
,
2
);
insert_term
(
q
,
6
,
1
);
printf
(
"Displaying Polynomials ...
\n
"
);
display_poly
(
p
);
display_poly
(
q
);
sum
=
add
(
p
,
q
);
printf
(
"P(x) + Q(x) = "
);
display_poly
(
sum
);
diff
=
subtract
(
p
,
q
);
printf
(
"P(x) - Q(x) = "
);
display_poly
(
diff
);
prod
=
multiply
(
p
,
q
);
printf
(
"P(x)*Q(x) = "
);
display_poly
(
prod
);
PolyAdt
*
quad
=
create_adt
(
2
);
insert_term
(
quad
,
10
,
2
);
insert_term
(
quad
,
30
,
1
);
insert_term
(
quad
,
2
,
0
);
quadratic_roots
(
quad
,
NULL
,
NULL
);
//print out the roots
float
real
,
cplx
;
quadratic_roots
(
quad
,
&
real
,
&
cplx
);
printf
(
"X1 = %f, X2 = %f
\n\n
"
,
real
,
cplx
);
PolyAdt
*
deriv
,
*
integral
;
deriv
=
derivative
(
p
);
printf
(
"The derivitive of p = "
);
display_poly
(
deriv
);
integral
=
integrate
(
q
);
printf
(
"The integral of q = "
);
display_poly
(
integral
);
printf
(
"
\n
Computing P(x)^3
\n
"
);
PolyAdt
*
expo
;
expo
=
exponentiate
(
p
,
3
);
display_poly
(
expo
);
printf
(
"
\n
"
);
printf
(
"Computing Integral[Q(x)^2]
\n
"
);
expo
=
exponentiate
(
q
,
2
);
integral
=
integrate
(
expo
);
display_poly
(
integral
);
printf
(
" Differentiating and Integrating P
\n
"
);
display_poly
(
integrate
(
derivative
(
p
)));
PolyAdt
*
L
,
*
M
;
L
=
create_adt
(
3
),
M
=
create_adt
(
2
);
insert_term
(
L
,
4
,
3
);
insert_term
(
L
,
10
,
2
);
insert_term
(
L
,
15
,
1
);
insert_term
(
M
,
4
,
2
);
printf
(
"L = "
);
display_poly
(
L
);
printf
(
"M = "
);
display_poly
(
M
);
printf
(
"Computing composition L(M(X))
\n
"
);
display_poly
(
compose
(
L
,
M
));
printf
(
"Freed memory back to heap for allocated polys'"
);
destroy_poly
(
sum
);
destroy_poly
(
diff
);
destroy_poly
(
prod
);
destroy_poly
(
L
);
destroy_poly
(
M
);
destroy_poly
(
q
);
destroy_poly
(
p
);
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