triangle_reflection_complex/qext.h

40 lines
1.2 KiB
C
Raw Normal View History

2022-04-15 16:23:27 +00:00
#ifndef QEXT_H
#define QEXT_H
#include <gmp.h>
2022-06-11 15:36:32 +00:00
struct qext_type {
int rank;
2022-06-14 12:22:22 +00:00
const int *integer_coeffs; // actually the rank+1 coefficients of the polynomial
mpq_t *coeffs; // components of a^rank
2022-06-11 15:36:32 +00:00
};
2022-04-15 16:23:27 +00:00
struct qext_number_internal {
2022-06-11 15:36:32 +00:00
struct qext_type *type;
2022-04-15 16:23:27 +00:00
mpq_t *a;
};
typedef struct qext_number_internal qext_number[1];
2022-06-11 15:36:32 +00:00
extern struct qext_type *QT_TRIVIAL;
extern struct qext_type *QT_SQRT5;
2022-06-14 12:22:22 +00:00
extern struct qext_type *QT_GAUSS_SQRT5;
2022-06-11 15:36:32 +00:00
struct qext_type *qext_newtype(int rank, const int *coeffs);
void qext_init(qext_number x, struct qext_type *type);
2022-04-15 16:23:27 +00:00
void qext_clear(qext_number x);
void qext_set(qext_number x, qext_number y);
void qext_set_int(qext_number x, int y);
2022-04-25 19:09:45 +00:00
void qext_set_q(qext_number x, mpq_t y);
2022-04-15 16:23:27 +00:00
void qext_add(qext_number result, qext_number x, qext_number y);
void qext_sub(qext_number result, qext_number x, qext_number y);
2022-06-11 15:36:32 +00:00
void qext_neg(qext_number result, qext_number x);
2022-04-15 16:23:27 +00:00
void qext_mul(qext_number out, qext_number x, qext_number y);
2022-06-14 12:22:22 +00:00
void qext_inv(qext_number out, qext_number in);
2022-04-15 16:23:27 +00:00
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);
2022-04-25 19:09:45 +00:00
void qext_snprint(char *str, size_t len, qext_number x);
2022-04-15 16:23:27 +00:00
#endif