triangle_reflection_complex/qext.h
2022-06-11 17:36:32 +02:00

38 lines
1.0 KiB
C

#ifndef QEXT_H
#define QEXT_H
#include <gmp.h>
struct qext_type {
int rank;
const int *integer_coeffs;
mpq_t *coeffs;
};
struct qext_number_internal {
struct qext_type *type;
mpq_t *a;
};
typedef struct qext_number_internal qext_number[1];
extern struct qext_type *QT_TRIVIAL;
extern struct qext_type *QT_SQRT5;
struct qext_type *qext_newtype(int rank, const int *coeffs);
void qext_init(qext_number x, struct qext_type *type);
void qext_clear(qext_number x);
void qext_set(qext_number x, qext_number y);
void qext_set_int(qext_number x, int y);
void qext_set_q(qext_number x, mpq_t y);
void qext_add(qext_number result, qext_number x, qext_number y);
void qext_sub(qext_number result, qext_number x, qext_number y);
void qext_neg(qext_number result, qext_number x);
void qext_mul(qext_number out, qext_number x, qext_number y);
void qext_div(qext_number out, qext_number x, qext_number y);
int qext_cmp(qext_number x, qext_number y);
void qext_print(qext_number x);
void qext_snprint(char *str, size_t len, qext_number x);
#endif