1 /*
2     Copyright (C) 2012 Fredrik Johansson
3 
4     This file is part of Arb.
5 
6     Arb is free software: you can redistribute it and/or modify it under
7     the terms of the GNU Lesser General Public License (LGPL) as published
8     by the Free Software Foundation; either version 2.1 of the License, or
9     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
10 */
11 
12 #include "acb_poly.h"
13 
14 void
_acb_poly_derivative(acb_ptr res,acb_srcptr poly,slong len,slong prec)15 _acb_poly_derivative(acb_ptr res, acb_srcptr poly, slong len, slong prec)
16 {
17     slong i;
18 
19     for (i = 1; i < len; i++)
20         acb_mul_ui(res + i - 1, poly + i, i, prec);
21 }
22 
23 void
acb_poly_derivative(acb_poly_t res,const acb_poly_t poly,slong prec)24 acb_poly_derivative(acb_poly_t res, const acb_poly_t poly, slong prec)
25 {
26     slong len = poly->length;
27 
28     if (len < 2)
29     {
30         acb_poly_zero(res);
31     }
32     else
33     {
34         acb_poly_fit_length(res, len - 1);
35         _acb_poly_derivative(res->coeffs, poly->coeffs, len, prec);
36         _acb_poly_set_length(res, len - 1);
37     }
38 }
39