/* mpcx_out_str outputs a polynomial to a stream Copyright (C) 2009 Andreas Enge This file is part of the MPFRCX Library. The MPFRCX Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The MPFRCX Library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the MPFRCX library; see the file COPYING.LESSER. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "mpfrcx-impl.h" size_t mpcx_out_str (FILE* stream, int base, size_t n_digits, mpcx_srcptr f) { if (stream == NULL) stream = stdout; if (f->deg == -1) { fprintf (stream, "(-1 0)"); return (size_t) 6u; } else { size_t s = f->deg + 3u; /* for '(', ')' and the spaces */ int i; fprintf (stream, "("); s += fprintf (stream, "%i ", f->deg); for (i = f->deg; i >= 0; i--) { s += mpc_out_str (stream, base, n_digits, f->coeff [i], MPC_RNDNN); if (i > 0) fprintf (stream, " "); else fprintf (stream, ")"); } return s; } }