From 9f46fd1133632dc3fa6057799323038acaf97a5c Mon Sep 17 00:00:00 2001 From: Fredrik Johansson Date: Mon, 19 Jan 2015 16:52:15 +0100 Subject: [PATCH] add poly_set_round methods --- acb_poly.h | 2 ++ acb_poly/set_round.c | 37 +++++++++++++++++++++++++++++++++++++ arb_poly.h | 2 ++ arb_poly/set_round.c | 37 +++++++++++++++++++++++++++++++++++++ doc/source/acb_poly.rst | 4 ++++ doc/source/arb_poly.rst | 8 ++++++++ 6 files changed, 90 insertions(+) create mode 100644 acb_poly/set_round.c create mode 100644 arb_poly/set_round.c diff --git a/acb_poly.h b/acb_poly.h index be7bd16c..59aac425 100644 --- a/acb_poly.h +++ b/acb_poly.h @@ -155,6 +155,8 @@ void acb_poly_integral(acb_poly_t res, const acb_poly_t poly, long prec); void acb_poly_set(acb_poly_t dest, const acb_poly_t src); +void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec); + void acb_poly_set_arb_poly(acb_poly_t poly, const arb_poly_t re); void acb_poly_set2_arb_poly(acb_poly_t poly, const arb_poly_t re, const arb_poly_t im); diff --git a/acb_poly/set_round.c b/acb_poly/set_round.c new file mode 100644 index 00000000..9abb0d69 --- /dev/null +++ b/acb_poly/set_round.c @@ -0,0 +1,37 @@ +/*============================================================================= + + This file is part of ARB. + + ARB is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ARB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ARB; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +=============================================================================*/ +/****************************************************************************** + + Copyright (C) 2012 Fredrik Johansson + +******************************************************************************/ + +#include "acb_poly.h" + +void +acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec) +{ + long len = acb_poly_length(src); + + acb_poly_fit_length(dest, len); + _acb_vec_set_round(dest->coeffs, src->coeffs, len, prec); + _acb_poly_set_length(dest, len); +} + diff --git a/arb_poly.h b/arb_poly.h index 99e79240..48ca1ed4 100644 --- a/arb_poly.h +++ b/arb_poly.h @@ -76,6 +76,8 @@ arb_poly_swap(arb_poly_t poly1, arb_poly_t poly2) void arb_poly_set(arb_poly_t poly, const arb_poly_t src); +void arb_poly_set_round(arb_poly_t poly, const arb_poly_t src, long prec); + /* Basic manipulation */ ARB_POLY_INLINE long arb_poly_length(const arb_poly_t poly) diff --git a/arb_poly/set_round.c b/arb_poly/set_round.c new file mode 100644 index 00000000..f90b39c1 --- /dev/null +++ b/arb_poly/set_round.c @@ -0,0 +1,37 @@ +/*============================================================================= + + This file is part of ARB. + + ARB is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + ARB is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ARB; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +=============================================================================*/ +/****************************************************************************** + + Copyright (C) 2012 Fredrik Johansson + +******************************************************************************/ + +#include "arb_poly.h" + +void +arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, long prec) +{ + long len = arb_poly_length(src); + + arb_poly_fit_length(dest, len); + _arb_vec_set_round(dest->coeffs, src->coeffs, len, prec); + _arb_poly_set_length(dest, len); +} + diff --git a/doc/source/acb_poly.rst b/doc/source/acb_poly.rst index c77d3a1a..61300852 100644 --- a/doc/source/acb_poly.rst +++ b/doc/source/acb_poly.rst @@ -88,6 +88,10 @@ Basic properties and manipulation Sets *dest* to a copy of *src*. +.. function:: void acb_poly_set_round(acb_poly_t dest, const acb_poly_t src, long prec) + + Sets *dest* to a copy of *src*, rounded to *prec* bits. + .. function:: void acb_poly_set_coeff_si(acb_poly_t poly, long n, long c) .. function:: void acb_poly_set_coeff_acb(acb_poly_t poly, long n, const acb_t c) diff --git a/doc/source/arb_poly.rst b/doc/source/arb_poly.rst index 5913c8cc..e0d55a23 100644 --- a/doc/source/arb_poly.rst +++ b/doc/source/arb_poly.rst @@ -63,6 +63,14 @@ Basic manipulation Sets *poly* to the constant 0 respectively 1. +.. function:: void arb_poly_set(arb_poly_t dest, const arb_poly_t src) + + Sets *dest* to a copy of *src*. + +.. function:: void arb_poly_set_round(arb_poly_t dest, const arb_poly_t src, long prec) + + Sets *dest* to a copy of *src*, rounded to *prec* bits. + .. function:: void arb_poly_set_coeff_si(arb_poly_t poly, long n, long c) .. function:: void arb_poly_set_coeff_arb(arb_poly_t poly, long n, const arb_t c)