Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ppann
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Boston University PhD
IPFRE
ppann
Commits
07fafae9
Commit
07fafae9
authored
Feb 25, 2023
by
Weiqi
Browse files
Options
Downloads
Patches
Plain Diff
update field
parent
9d518858
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/field.h
+2
-0
2 additions, 0 deletions
include/field.h
src/field.c
+5
-1
5 additions, 1 deletion
src/field.c
tests/test_field.c
+19
-10
19 additions, 10 deletions
tests/test_field.c
with
26 additions
and
11 deletions
include/field.h
+
2
−
0
View file @
07fafae9
...
...
@@ -17,6 +17,8 @@ void zp_from_int(zp x, int x_int);
void
zp_add
(
zp
r
,
zp
x
,
zp
y
);
void
zp_neg
(
zp
nx
,
zp
x
);
void
zp_multiply
(
zp
p
,
zp
x
,
zp
y
);
void
zp_inverse
(
zp
xi
,
zp
x
);
...
...
This diff is collapsed.
Click to expand it.
src/field.c
+
5
−
1
View file @
07fafae9
...
...
@@ -24,6 +24,10 @@ void zp_add(dig_t *r, dig_t *x, dig_t *y) {
fp_add
(
r
,
x
,
y
);
}
void
zp_neg
(
dig_t
*
nx
,
dig_t
*
x
)
{
fp_neg
(
nx
,
x
);
}
void
zp_multiply
(
dig_t
*
p
,
dig_t
*
x
,
dig_t
*
y
)
{
fp_mul
(
p
,
x
,
y
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_field.c
+
19
−
10
View file @
07fafae9
...
...
@@ -16,13 +16,13 @@ int test_zp_copy() {
zp
x
,
y
;
zp_from_int
(
x
,
3
);
zp_copy
(
y
,
x
);
return
f
p_
cmp_dig
(
y
,
3
);
return
z
p_
is_int
(
y
,
3
);
}
int
test_zp_from_int
()
{
zp
x
;
zp_from_int
(
x
,
3
);
return
f
p_
cmp_dig
(
x
,
3
);
return
z
p_
is_int
(
x
,
3
);
}
int
test_zp_add
()
{
...
...
@@ -30,7 +30,15 @@ int test_zp_add() {
zp_from_int
(
x
,
10
);
zp_from_int
(
y
,
20
);
zp_add
(
r
,
x
,
y
);
return
fp_cmp_dig
(
r
,
30
);
return
zp_is_int
(
r
,
30
);
}
int
test_zp_neg
()
{
zp
x
,
y
,
r
;
rand_zp
(
x
);
zp_neg
(
y
,
x
);
zp_add
(
r
,
x
,
y
);
return
zp_is_int
(
r
,
0
);
}
int
test_zp_multiply
()
{
...
...
@@ -38,7 +46,7 @@ int test_zp_multiply() {
zp_from_int
(
x
,
10
);
zp_from_int
(
y
,
20
);
zp_multiply
(
r
,
x
,
y
);
return
f
p_
cmp_dig
(
r
,
200
);
return
z
p_
is_int
(
r
,
200
);
}
int
test_zp_inverse
()
{
...
...
@@ -46,7 +54,7 @@ int test_zp_inverse() {
rand_zp
(
x
);
zp_inverse
(
xi
,
x
);
zp_multiply
(
r
,
x
,
xi
);
return
f
p_
cmp_dig
(
r
,
1
);
return
z
p_
is_int
(
r
,
1
);
}
...
...
@@ -58,11 +66,12 @@ int main() {
// Perform tests.
if
(
test_zp_zero
()
!=
1
)
return
1
;
if
(
test_zp_one
()
!=
1
)
return
1
;
if
(
test_zp_copy
()
!=
RLC_EQ
)
return
1
;
if
(
test_zp_from_int
()
!=
RLC_EQ
)
return
1
;
if
(
test_zp_add
()
!=
RLC_EQ
)
return
1
;
if
(
test_zp_multiply
()
!=
RLC_EQ
)
return
1
;
if
(
test_zp_inverse
()
!=
RLC_EQ
)
return
1
;
if
(
test_zp_copy
()
!=
1
)
return
1
;
if
(
test_zp_from_int
()
!=
1
)
return
1
;
if
(
test_zp_add
()
!=
1
)
return
1
;
if
(
test_zp_neg
()
!=
1
)
return
1
;
if
(
test_zp_multiply
()
!=
1
)
return
1
;
if
(
test_zp_inverse
()
!=
1
)
return
1
;
return
0
;
}
\ No newline at end of file
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