Browse Source
bpo-41369: Finish updating the vendored libmpdec to version 2.5.1 (GH-24962)
bpo-41369: Finish updating the vendored libmpdec to version 2.5.1 (GH-24962)
Complete the update to libmpdec-2.5.1. Co-authored-by: Stefan Krah <skrah@bytereef.org>pull/25100/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 1970 additions and 117 deletions
-
2Misc/NEWS.d/next/Library/2021-03-21-17-50-42.bpo-41369.-fpmYZ.rst
-
4Modules/_decimal/_decimal.c
-
1Modules/_decimal/libmpdec/README.txt
-
137Modules/_decimal/libmpdec/bench.c
-
193Modules/_decimal/libmpdec/bench_full.c
-
5Modules/_decimal/libmpdec/constants.c
-
6Modules/_decimal/libmpdec/context.c
-
18Modules/_decimal/libmpdec/crt.c
-
2Modules/_decimal/libmpdec/crt.h
-
8Modules/_decimal/libmpdec/examples/README.txt
-
77Modules/_decimal/libmpdec/examples/compare.c
-
77Modules/_decimal/libmpdec/examples/div.c
-
82Modules/_decimal/libmpdec/examples/divmod.c
-
77Modules/_decimal/libmpdec/examples/multiply.c
-
77Modules/_decimal/libmpdec/examples/pow.c
-
80Modules/_decimal/libmpdec/examples/powmod.c
-
77Modules/_decimal/libmpdec/examples/shift.c
-
74Modules/_decimal/libmpdec/examples/sqrt.c
-
28Modules/_decimal/libmpdec/io.c
-
7Modules/_decimal/libmpdec/mpalloc.c
-
10Modules/_decimal/libmpdec/mpalloc.h
-
7Modules/_decimal/libmpdec/mpdecimal.c
-
63Modules/_decimal/libmpdec/mpdecimal.h
-
967Modules/_decimal/libmpdec/mpsignal.c
-
6Modules/_decimal/libmpdec/typearith.h
-
2setup.py
@ -0,0 +1,2 @@ |
|||
Finish updating the vendored libmpdec to version 2.5.1. Patch by Stefan |
|||
Krah. |
|||
@ -0,0 +1,137 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include "mpdecimal.h" |
|||
|
|||
#include <stdint.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
|
|||
|
|||
static void |
|||
err_exit(const char *msg) |
|||
{ |
|||
fprintf(stderr, "%s\n", msg); |
|||
exit(1); |
|||
} |
|||
|
|||
static mpd_t * |
|||
new_mpd(void) |
|||
{ |
|||
mpd_t *x = mpd_qnew(); |
|||
if (x == NULL) { |
|||
err_exit("out of memory"); |
|||
} |
|||
|
|||
return x; |
|||
} |
|||
|
|||
/* Nonsense version of escape-time algorithm for calculating a mandelbrot |
|||
* set. Just for benchmarking. */ |
|||
static void |
|||
color_point(mpd_t *x0, mpd_t *y0, long maxiter, mpd_context_t *ctx) |
|||
{ |
|||
mpd_t *x, *y, *sq_x, *sq_y; |
|||
mpd_t *two; |
|||
|
|||
x = new_mpd(); |
|||
y = new_mpd(); |
|||
mpd_set_u32(x, 0, ctx); |
|||
mpd_set_u32(y, 0, ctx); |
|||
|
|||
sq_x = new_mpd(); |
|||
sq_y = new_mpd(); |
|||
mpd_set_u32(sq_x, 0, ctx); |
|||
mpd_set_u32(sq_y, 0, ctx); |
|||
|
|||
two = new_mpd(); |
|||
mpd_set_u32(two, 2, ctx); |
|||
|
|||
for (long i = 0; i < maxiter; i++) { |
|||
mpd_mul(y, x, y, ctx); |
|||
mpd_mul(y, y, two, ctx); |
|||
mpd_add(y, y, y0, ctx); |
|||
|
|||
mpd_sub(x, sq_x, sq_y, ctx); |
|||
mpd_add(x, x, x0, ctx); |
|||
|
|||
mpd_mul(sq_x, x, x, ctx); |
|||
mpd_mul(sq_y, y, y, ctx); |
|||
} |
|||
|
|||
mpd_copy(x0, x, ctx); |
|||
|
|||
mpd_del(two); |
|||
mpd_del(sq_y); |
|||
mpd_del(sq_x); |
|||
mpd_del(y); |
|||
mpd_del(x); |
|||
} |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *x0, *y0; |
|||
uint32_t prec = 19; |
|||
long iter = 10000000; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
err_exit("usage: bench prec iter\n"); |
|||
} |
|||
prec = strtoul(argv[1], NULL, 10); |
|||
iter = strtol(argv[2], NULL, 10); |
|||
|
|||
mpd_init(&ctx, prec); |
|||
/* no more MPD_MINALLOC changes after here */ |
|||
|
|||
x0 = new_mpd(); |
|||
y0 = new_mpd(); |
|||
mpd_set_string(x0, "0.222", &ctx); |
|||
mpd_set_string(y0, "0.333", &ctx); |
|||
if (ctx.status & MPD_Errors) { |
|||
mpd_del(y0); |
|||
mpd_del(x0); |
|||
err_exit("unexpected error during conversion"); |
|||
} |
|||
|
|||
start_clock = clock(); |
|||
color_point(x0, y0, iter, &ctx); |
|||
end_clock = clock(); |
|||
|
|||
mpd_print(x0); |
|||
fprintf(stderr, "time: %f\n\n", (double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
mpd_del(y0); |
|||
mpd_del(x0); |
|||
|
|||
return 0; |
|||
} |
|||
@ -0,0 +1,193 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include "mpdecimal.h" |
|||
|
|||
#include <stdint.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
|
|||
|
|||
static void |
|||
err_exit(const char *msg) |
|||
{ |
|||
fprintf(stderr, "%s\n", msg); |
|||
exit(1); |
|||
} |
|||
|
|||
static mpd_t * |
|||
new_mpd(void) |
|||
{ |
|||
mpd_t *x = mpd_qnew(); |
|||
if (x == NULL) { |
|||
err_exit("out of memory"); |
|||
} |
|||
|
|||
return x; |
|||
} |
|||
|
|||
/* |
|||
* Example from: http://en.wikipedia.org/wiki/Mandelbrot_set |
|||
* |
|||
* Escape time algorithm for drawing the set: |
|||
* |
|||
* Point x0, y0 is deemed to be in the Mandelbrot set if the return |
|||
* value is maxiter. Lower return values indicate how quickly points |
|||
* escaped and can be used for coloring. |
|||
*/ |
|||
static int |
|||
color_point(const mpd_t *x0, const mpd_t *y0, const long maxiter, mpd_context_t *ctx) |
|||
{ |
|||
mpd_t *x, *y, *sq_x, *sq_y; |
|||
mpd_t *two, *four, *c; |
|||
long i; |
|||
|
|||
x = new_mpd(); |
|||
y = new_mpd(); |
|||
mpd_set_u32(x, 0, ctx); |
|||
mpd_set_u32(y, 0, ctx); |
|||
|
|||
sq_x = new_mpd(); |
|||
sq_y = new_mpd(); |
|||
mpd_set_u32(sq_x, 0, ctx); |
|||
mpd_set_u32(sq_y, 0, ctx); |
|||
|
|||
two = new_mpd(); |
|||
four = new_mpd(); |
|||
mpd_set_u32(two, 2, ctx); |
|||
mpd_set_u32(four, 4, ctx); |
|||
|
|||
c = new_mpd(); |
|||
mpd_set_u32(c, 0, ctx); |
|||
|
|||
for (i = 0; i < maxiter && mpd_cmp(c, four, ctx) <= 0; i++) { |
|||
mpd_mul(y, x, y, ctx); |
|||
mpd_mul(y, y, two, ctx); |
|||
mpd_add(y, y, y0, ctx); |
|||
|
|||
mpd_sub(x, sq_x, sq_y, ctx); |
|||
mpd_add(x, x, x0, ctx); |
|||
|
|||
mpd_mul(sq_x, x, x, ctx); |
|||
mpd_mul(sq_y, y, y, ctx); |
|||
mpd_add(c, sq_x, sq_y, ctx); |
|||
} |
|||
|
|||
mpd_del(c); |
|||
mpd_del(four); |
|||
mpd_del(two); |
|||
mpd_del(sq_y); |
|||
mpd_del(sq_x); |
|||
mpd_del(y); |
|||
mpd_del(x); |
|||
|
|||
return i; |
|||
} |
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *x0, *y0; |
|||
mpd_t *sqrt_2, *xstep, *ystep; |
|||
mpd_ssize_t prec = 19; |
|||
|
|||
long iter = 1000; |
|||
int points[40][80]; |
|||
int i, j; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "usage: ./bench prec iter\n"); |
|||
exit(1); |
|||
} |
|||
prec = strtoll(argv[1], NULL, 10); |
|||
iter = strtol(argv[2], NULL, 10); |
|||
|
|||
mpd_init(&ctx, prec); |
|||
/* no more MPD_MINALLOC changes after here */ |
|||
|
|||
sqrt_2 = new_mpd(); |
|||
xstep = new_mpd(); |
|||
ystep = new_mpd(); |
|||
x0 = new_mpd(); |
|||
y0 = new_mpd(); |
|||
|
|||
mpd_set_u32(sqrt_2, 2, &ctx); |
|||
mpd_sqrt(sqrt_2, sqrt_2, &ctx); |
|||
mpd_div_u32(xstep, sqrt_2, 40, &ctx); |
|||
mpd_div_u32(ystep, sqrt_2, 20, &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_copy(y0, sqrt_2, &ctx); |
|||
for (i = 0; i < 40; i++) { |
|||
mpd_copy(x0, sqrt_2, &ctx); |
|||
mpd_set_negative(x0); |
|||
for (j = 0; j < 80; j++) { |
|||
points[i][j] = color_point(x0, y0, iter, &ctx); |
|||
mpd_add(x0, x0, xstep, &ctx); |
|||
} |
|||
mpd_sub(y0, y0, ystep, &ctx); |
|||
} |
|||
end_clock = clock(); |
|||
|
|||
#ifdef BENCH_VERBOSE |
|||
for (i = 0; i < 40; i++) { |
|||
for (j = 0; j < 80; j++) { |
|||
if (points[i][j] == iter) { |
|||
putchar('*'); |
|||
} |
|||
else if (points[i][j] >= 10) { |
|||
putchar('+'); |
|||
} |
|||
else if (points[i][j] >= 5) { |
|||
putchar('.'); |
|||
} |
|||
else { |
|||
putchar(' '); |
|||
} |
|||
} |
|||
putchar('\n'); |
|||
} |
|||
putchar('\n'); |
|||
#else |
|||
(void)points; /* suppress gcc warning */ |
|||
#endif |
|||
|
|||
printf("time: %f\n\n", (double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
mpd_del(y0); |
|||
mpd_del(x0); |
|||
mpd_del(ystep); |
|||
mpd_del(xstep); |
|||
mpd_del(sqrt_2); |
|||
|
|||
return 0; |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
|
|||
|
|||
This directory contains a number of examples. In order to compile, run |
|||
(for example): |
|||
|
|||
gcc -Wall -W -O2 -o powmod powmod.c -lmpdec -lm |
|||
|
|||
|
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "compare: usage: ./compare x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_compare(result, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "div: usage: ./div x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_div(result, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,82 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *q, *r; |
|||
char *qs, *rs; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "divmod: usage: ./divmod x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
q = mpd_new(&ctx); |
|||
r = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_divmod(q, r, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
qs = mpd_to_sci(q, 1); |
|||
rs = mpd_to_sci(r, 1); |
|||
|
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s %s\n", qs, rs, status_str); |
|||
|
|||
mpd_del(q); |
|||
mpd_del(r); |
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_free(qs); |
|||
mpd_free(rs); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "multiply: usage: ./multiply x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_mul(result, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "pow: usage: ./pow x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_pow(result, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,80 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b, *c; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 4) { |
|||
fprintf(stderr, "powmod: usage: ./powmod x y z\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
c = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
mpd_set_string(c, argv[3], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_powmod(result, a, b, c, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(c); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,77 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <time.h> |
|||
#include <mpdecimal.h> |
|||
|
|||
|
|||
int |
|||
main(int argc, char **argv) |
|||
{ |
|||
mpd_context_t ctx; |
|||
mpd_t *a, *b; |
|||
mpd_t *result; |
|||
char *rstring; |
|||
char status_str[MPD_MAX_FLAG_STRING]; |
|||
clock_t start_clock, end_clock; |
|||
|
|||
if (argc != 3) { |
|||
fprintf(stderr, "shift: usage: ./shift x y\n"); |
|||
exit(1); |
|||
} |
|||
|
|||
mpd_init(&ctx, 38); |
|||
ctx.traps = 0; |
|||
|
|||
result = mpd_new(&ctx); |
|||
a = mpd_new(&ctx); |
|||
b = mpd_new(&ctx); |
|||
mpd_set_string(a, argv[1], &ctx); |
|||
mpd_set_string(b, argv[2], &ctx); |
|||
|
|||
start_clock = clock(); |
|||
mpd_shift(result, a, b, &ctx); |
|||
end_clock = clock(); |
|||
fprintf(stderr, "time: %f\n\n", |
|||
(double)(end_clock-start_clock)/(double)CLOCKS_PER_SEC); |
|||
|
|||
rstring = mpd_to_sci(result, 1); |
|||
mpd_snprint_flags(status_str, MPD_MAX_FLAG_STRING, ctx.status); |
|||
printf("%s %s\n", rstring, status_str); |
|||
|
|||
mpd_del(a); |
|||
mpd_del(b); |
|||
mpd_del(result); |
|||
mpd_free(rstring); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,967 @@ |
|||
/* |
|||
* Copyright (c) 2008-2020 Stefan Krah. 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. |
|||
*/ |
|||
|
|||
|
|||
#include "mpdecimal.h" |
|||
|
|||
#include <stddef.h> |
|||
#include <stdint.h> |
|||
|
|||
|
|||
/* Signaling wrappers for the quiet functions in mpdecimal.c. */ |
|||
|
|||
|
|||
char * |
|||
mpd_format(const mpd_t *dec, const char *fmt, mpd_context_t *ctx) |
|||
{ |
|||
char *ret; |
|||
uint32_t status = 0; |
|||
ret = mpd_qformat(dec, fmt, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
void |
|||
mpd_import_u16(mpd_t *result, const uint16_t *srcdata, size_t srclen, |
|||
uint8_t srcsign, uint32_t base, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qimport_u16(result, srcdata, srclen, srcsign, base, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_import_u32(mpd_t *result, const uint32_t *srcdata, size_t srclen, |
|||
uint8_t srcsign, uint32_t base, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qimport_u32(result, srcdata, srclen, srcsign, base, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
size_t |
|||
mpd_export_u16(uint16_t **rdata, size_t rlen, uint32_t base, const mpd_t *src, |
|||
mpd_context_t *ctx) |
|||
{ |
|||
size_t n; |
|||
uint32_t status = 0; |
|||
n = mpd_qexport_u16(rdata, rlen, base, src, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return n; |
|||
} |
|||
|
|||
size_t |
|||
mpd_export_u32(uint32_t **rdata, size_t rlen, uint32_t base, const mpd_t *src, |
|||
mpd_context_t *ctx) |
|||
{ |
|||
size_t n; |
|||
uint32_t status = 0; |
|||
n = mpd_qexport_u32(rdata, rlen, base, src, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return n; |
|||
} |
|||
|
|||
void |
|||
mpd_finalize(mpd_t *result, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qfinalize(result, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
int |
|||
mpd_check_nan(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (mpd_qcheck_nan(result, a, ctx, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
return 1; |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
int |
|||
mpd_check_nans(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (mpd_qcheck_nans(result, a, b, ctx, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
return 1; |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
void |
|||
mpd_set_string(mpd_t *result, const char *s, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_string(result, s, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_maxcoeff(mpd_t *result, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmaxcoeff(result, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
/* set static mpd from signed integer */ |
|||
void |
|||
mpd_sset_ssize(mpd_t *result, mpd_ssize_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_ssize(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sset_i32(mpd_t *result, int32_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_i32(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifdef CONFIG_64 |
|||
void |
|||
mpd_sset_i64(mpd_t *result, int64_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_i64(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
/* set static mpd from unsigned integer */ |
|||
void |
|||
mpd_sset_uint(mpd_t *result, mpd_uint_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_uint(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sset_u32(mpd_t *result, uint32_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_u32(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifdef CONFIG_64 |
|||
void |
|||
mpd_sset_u64(mpd_t *result, uint64_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsset_u64(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
/* set mpd from signed integer */ |
|||
void |
|||
mpd_set_ssize(mpd_t *result, mpd_ssize_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_ssize(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_set_i32(mpd_t *result, int32_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_i32(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_set_i64(mpd_t *result, int64_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_i64(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
/* set mpd from unsigned integer */ |
|||
void |
|||
mpd_set_uint(mpd_t *result, mpd_uint_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_uint(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_set_u32(mpd_t *result, uint32_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_u32(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_set_u64(mpd_t *result, uint64_t a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qset_u64(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
/* convert mpd to signed integer */ |
|||
mpd_ssize_t |
|||
mpd_get_ssize(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_ssize_t ret; |
|||
|
|||
ret = mpd_qget_ssize(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
int32_t |
|||
mpd_get_i32(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
int32_t ret; |
|||
|
|||
ret = mpd_qget_i32(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
int64_t |
|||
mpd_get_i64(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
int64_t ret; |
|||
|
|||
ret = mpd_qget_i64(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
#endif |
|||
|
|||
mpd_uint_t |
|||
mpd_get_uint(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_uint_t ret; |
|||
|
|||
ret = mpd_qget_uint(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
mpd_uint_t |
|||
mpd_abs_uint(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_uint_t ret; |
|||
|
|||
ret = mpd_qabs_uint(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
uint32_t |
|||
mpd_get_u32(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
uint32_t ret; |
|||
|
|||
ret = mpd_qget_u32(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
uint64_t |
|||
mpd_get_u64(const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
uint64_t ret; |
|||
|
|||
ret = mpd_qget_u64(a, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return ret; |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_and(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qand(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_copy(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (!mpd_qcopy(result, a, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
} |
|||
|
|||
void |
|||
mpd_canonical(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
mpd_copy(result, a, ctx); |
|||
} |
|||
|
|||
void |
|||
mpd_copy_abs(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (!mpd_qcopy_abs(result, a, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
} |
|||
|
|||
void |
|||
mpd_copy_negate(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (!mpd_qcopy_negate(result, a, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
} |
|||
|
|||
void |
|||
mpd_copy_sign(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
if (!mpd_qcopy_sign(result, a, b, &status)) { |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
} |
|||
|
|||
void |
|||
mpd_invert(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qinvert(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_logb(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qlogb(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_or(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qor(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_rotate(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qrotate(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_scaleb(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qscaleb(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_shiftl(mpd_t *result, const mpd_t *a, mpd_ssize_t n, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qshiftl(result, a, n, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
mpd_uint_t |
|||
mpd_shiftr(mpd_t *result, const mpd_t *a, mpd_ssize_t n, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_uint_t rnd; |
|||
|
|||
rnd = mpd_qshiftr(result, a, n, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return rnd; |
|||
} |
|||
|
|||
void |
|||
mpd_shiftn(mpd_t *result, const mpd_t *a, mpd_ssize_t n, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qshiftn(result, a, n, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_shift(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qshift(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_xor(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qxor(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_abs(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qabs(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
int |
|||
mpd_cmp(const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
int c; |
|||
c = mpd_qcmp(a, b, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return c; |
|||
} |
|||
|
|||
int |
|||
mpd_compare(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
int c; |
|||
c = mpd_qcompare(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return c; |
|||
} |
|||
|
|||
int |
|||
mpd_compare_signal(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
int c; |
|||
c = mpd_qcompare_signal(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
return c; |
|||
} |
|||
|
|||
void |
|||
mpd_add(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sub(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_add_ssize(mpd_t *result, const mpd_t *a, mpd_ssize_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_ssize(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_add_i32(mpd_t *result, const mpd_t *a, int32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_i32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_add_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_i64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_add_uint(mpd_t *result, const mpd_t *a, mpd_uint_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_uint(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_add_u32(mpd_t *result, const mpd_t *a, uint32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_u32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_add_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qadd_u64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_sub_ssize(mpd_t *result, const mpd_t *a, mpd_ssize_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_ssize(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sub_i32(mpd_t *result, const mpd_t *a, int32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_i32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_sub_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_i64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_sub_uint(mpd_t *result, const mpd_t *a, mpd_uint_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_uint(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sub_u32(mpd_t *result, const mpd_t *a, uint32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_u32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_sub_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsub_u64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_div(mpd_t *q, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv(q, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_div_ssize(mpd_t *result, const mpd_t *a, mpd_ssize_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_ssize(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_div_i32(mpd_t *result, const mpd_t *a, int32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_i32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_div_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_i64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_div_uint(mpd_t *result, const mpd_t *a, mpd_uint_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_uint(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_div_u32(mpd_t *result, const mpd_t *a, uint32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_u32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_div_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdiv_u64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_divmod(mpd_t *q, mpd_t *r, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdivmod(q, r, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_divint(mpd_t *q, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qdivint(q, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_exp(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qexp(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_fma(mpd_t *result, const mpd_t *a, const mpd_t *b, const mpd_t *c, |
|||
mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qfma(result, a, b, c, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_ln(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qln(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_log10(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qlog10(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_max(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmax(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_max_mag(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmax_mag(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_min(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmin(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_min_mag(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmin_mag(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_minus(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qminus(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_mul(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_mul_ssize(mpd_t *result, const mpd_t *a, mpd_ssize_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_ssize(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_mul_i32(mpd_t *result, const mpd_t *a, int32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_i32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_mul_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_i64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_mul_uint(mpd_t *result, const mpd_t *a, mpd_uint_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_uint(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_mul_u32(mpd_t *result, const mpd_t *a, uint32_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_u32(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
#ifndef LEGACY_COMPILER |
|||
void |
|||
mpd_mul_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qmul_u64(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
#endif |
|||
|
|||
void |
|||
mpd_next_minus(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qnext_minus(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_next_plus(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qnext_plus(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_next_toward(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qnext_toward(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_plus(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qplus(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_pow(mpd_t *result, const mpd_t *base, const mpd_t *exp, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qpow(result, base, exp, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_powmod(mpd_t *result, const mpd_t *base, const mpd_t *exp, const mpd_t *mod, |
|||
mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qpowmod(result, base, exp, mod, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_quantize(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qquantize(result, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_rescale(mpd_t *result, const mpd_t *a, mpd_ssize_t exp, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qrescale(result, a, exp, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_reduce(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qreduce(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_rem(mpd_t *r, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qrem(r, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_rem_near(mpd_t *r, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qrem_near(r, a, b, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_round_to_intx(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qround_to_intx(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_round_to_int(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qround_to_int(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_trunc(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qtrunc(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_floor(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qfloor(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_ceil(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qceil(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_sqrt(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qsqrt(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
|
|||
void |
|||
mpd_invroot(mpd_t *result, const mpd_t *a, mpd_context_t *ctx) |
|||
{ |
|||
uint32_t status = 0; |
|||
mpd_qinvroot(result, a, ctx, &status); |
|||
mpd_addstatus_raise(ctx, status); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue