/*
  K M Briggs 2004 Sep 03

*/

#include <stdlib.h>
#include <stdio.h>
#include </usr/local/include/gmp.h>
#include "scalar.h"

extern const char* fps_version;
struct _fps;
typedef struct _fps* fps_t;

int phi(const int n);
fps_t fps_init(int n);
void fps_timing(int k);
void fps_zero(fps_t f) ;
void fps_clear(fps_t f);
void fps_set(fps_t h, fps_t f);
void fps_setterm_z(fps_t f, const int i, mpz_t x);
void fps_setterm(fps_t z,  const int i, mpq_t w);
void fps_setterm_q(fps_t f, int i, long fin, long fid);
void fps_setterm_si(fps_t z,  const int i, int w);
void fps_getterm(mpq_t w, fps_t z, const int i);
unsigned int fps_len(fps_t z);
void fps_space(fps_t h, fps_t f, unsigned int k); // h(x)=f(x^k)
void fps_show(fps_t f);
void fps_list(fps_t f) ;
void fps_list_f(FILE* fl, fps_t f);
void fps_list_egf(fps_t g);
void fps_egf_to_ogf(fps_t h, fps_t g);
void fps_neg(fps_t h,fps_t f);
void fps_add(fps_t h,fps_t f,fps_t g) ;
void fps_sub(fps_t h,fps_t f,fps_t g);
void fps_mul(fps_t h,fps_t f,fps_t g) ;
void fps_div(fps_t h,fps_t f,fps_t g);
void fps_div_si(fps_t h,fps_t f,int a) ;
void fps_mul_q(fps_t h,fps_t f,int a,int b);
void fps_mul_si(fps_t h,fps_t f,int a);
void fps_div_si(fps_t h,fps_t f,int k);
void fps_div_ui(fps_t h,fps_t f,unsigned int a);
void fps_divexact_ui(fps_t h,fps_t f,unsigned int a);
void fps_powi(fps_t h,fps_t f,int a);
void fps_powq(fps_t h,fps_t f,scalar a);
void fps_log(fps_t w, fps_t v) ;
void fps_log_1mfxk(fps_t w, fps_t v, unsigned k);
void fps_set_T(fps_t T, int n) ;
void fps_set_Wm1(fps_t Wm1, int n);
void fps_get_W(fps_t Wm1,fps_t W0,fps_t W1,int n);
struct _fps {
  scalar *f;
  int n;
};

#define fps_termref(x,i) (((x)->f[(i)]))
#define fps_termnumref(x,i) (mpq_numref((x)->f[(i)]))
#define fps_termdenref(x,i) (mpq_denref((x)->f[(i)]))

