Loading...
Searching...
No Matches
cwrapper.h
1#ifndef CWRAPPER_H
2#define CWRAPPER_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include "symengine/symengine_config.h"
7
8#ifdef HAVE_SYMENGINE_GMP
9#include <gmp.h>
10#endif
11
12#ifdef HAVE_SYMENGINE_MPFR
13#include <mpfr.h>
14#endif // HAVE_SYMENGINE_MPFR
15
16#include "symengine/symengine_exception.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22// Use SYMENGINE_C_ASSERT in C tests
23#define SYMENGINE_C_ASSERT(cond) \
24 { \
25 if (0 == (cond)) { \
26 printf("SYMENGINE_C_ASSERT failed: %s \nfunction %s (), line " \
27 "number %d at\n%s\n", \
28 __FILE__, __func__, __LINE__, #cond); \
29 abort(); \
30 } \
31 }
32
33typedef symengine_exceptions_t CWRAPPER_OUTPUT_TYPE;
34
35typedef enum {
36#define SYMENGINE_INCLUDE_ALL
37#define SYMENGINE_ENUM(type, Class) type,
38#include "symengine/type_codes.inc"
39#undef SYMENGINE_ENUM
40#undef SYMENGINE_INCLUDE_ALL
41 SYMENGINE_TypeID_Count
42} TypeID;
43
46typedef struct dcomplex {
47 double real;
48 double imag;
49} dcomplex;
50
51// The size of 'CRCPBasic_C' must be the same as CRCPBasic (which contains a
52// single RCP<const Basic> member) *and* they must have the same alignment
53// (because we allocate CRCPBasic into the memory occupied by this struct in
54// cwrapper.cpp). We cannot use C++ in this file, so we need to use C tools to
55// arrive at the correct size and alignment. The size of the RCP object on
56// most platforms (with WITH_SYMENGINE_RCP on) should be just the size of the
57// 'T *ptr_' pointer that it contains (as there is no virtual function table)
58// and the alignment should also be of a pointer. So we just put 'void *data'
59// as the only member of the struct, that should have the correct size and
60// alignment. With WITH_SYMENGINE_RCP off (i.e. using Teuchos::RCP), we have to
61// add additional members into the structure.
62//
63// However, this is checked at compile time in cwrapper.cpp, so if the size or
64// alignment is different on some platform, the compilation will fail --- in
65// that case one needs to modify the contents of this struct to adjust its size
66// and/or alignment.
68 void *data;
69#if !defined(WITH_SYMENGINE_RCP)
70 void *teuchos_handle;
71 int teuchos_strength;
72#endif
73};
74
76// CRCPBasic, which has the same size and alignment as RCP<const Basic> (see
77// the above comment for details). That is then used by the user to allocate
78// the memory needed for RCP<const Basic> on the stack. A 'basic' type should
79// be initialized using basic_new_stack(), before any function is called.
80// Assignment should be done only by using basic_assign(). Before the variable
81// goes out of scope, basic_free_stack() must be called.
82//
83// For C, define a dummy struct with the right size, so that it can be
84// allocated on the stack. For C++, the CRCPBasic is declared in cwrapper.cpp.
85#ifdef __cplusplus
86typedef struct CRCPBasic basic_struct;
87#else
88typedef struct CRCPBasic_C basic_struct;
89#endif
90
91typedef struct CSetBasic CSetBasic;
92
95typedef basic_struct basic[1];
96
98// 'basic' type, this function initializes an RCP<const Basic> on the stack
99// allocated variable. The 's' variable must be freed using basic_free_stack()
100void basic_new_stack(basic s);
102void basic_free_stack(basic s);
103
104// Use these two functions to allocate and free 'basic' on a heap. The pointer
105// can then be used in all the other methods below (i.e. the methods that
106// accept 'basic s' work no matter if 's' is stack or heap allocated).
107basic_struct *basic_new_heap();
108void basic_free_heap(basic_struct *s);
109
110const char *symengine_version();
111
113
118void basic_const_set(basic s, const char *c);
119
120void basic_const_zero(basic s);
121void basic_const_one(basic s);
122void basic_const_minus_one(basic s);
123void basic_const_I(basic s);
124
125void basic_const_pi(basic s);
126void basic_const_E(basic s);
127void basic_const_EulerGamma(basic s);
128void basic_const_Catalan(basic s);
129void basic_const_GoldenRatio(basic s);
130
133void basic_const_infinity(basic s);
134void basic_const_neginfinity(basic s);
135void basic_const_complex_infinity(basic s);
136
138void basic_const_nan(basic s);
139
141CWRAPPER_OUTPUT_TYPE basic_assign(basic a, const basic b);
142
144CWRAPPER_OUTPUT_TYPE basic_parse(basic b, const char *str);
147CWRAPPER_OUTPUT_TYPE basic_parse2(basic b, const char *str, int convert_xor);
148
150TypeID basic_get_type(const basic s);
152TypeID basic_get_class_id(const char *c);
155char *basic_get_class_from_id(TypeID id);
156
160CWRAPPER_OUTPUT_TYPE symbol_set(basic s, const char *c);
161
163int number_is_zero(const basic s);
165int number_is_negative(const basic s);
167int number_is_positive(const basic s);
169int number_is_complex(const basic s);
170
172CWRAPPER_OUTPUT_TYPE integer_set_si(basic s, long i);
174CWRAPPER_OUTPUT_TYPE integer_set_ui(basic s, unsigned long i);
176#ifdef HAVE_SYMENGINE_GMP
177CWRAPPER_OUTPUT_TYPE integer_set_mpz(basic s, const mpz_t i);
178#endif
180CWRAPPER_OUTPUT_TYPE integer_set_str(basic s, const char *c);
182CWRAPPER_OUTPUT_TYPE real_double_set_d(basic s, double d);
184double real_double_get_d(const basic s);
185
186#ifdef HAVE_SYMENGINE_MPFR
188CWRAPPER_OUTPUT_TYPE real_mpfr_set_d(basic s, double d, int prec);
191CWRAPPER_OUTPUT_TYPE real_mpfr_set_str(basic s, const char *c, int prec);
193double real_mpfr_get_d(const basic s);
195CWRAPPER_OUTPUT_TYPE real_mpfr_set(basic s, mpfr_srcptr m);
197CWRAPPER_OUTPUT_TYPE real_mpfr_get(mpfr_ptr m, const basic s);
199mpfr_prec_t real_mpfr_get_prec(const basic s);
200#endif // HAVE_SYMENGINE_MPFR
201
203CWRAPPER_OUTPUT_TYPE complex_base_real_part(basic s, const basic com);
205CWRAPPER_OUTPUT_TYPE complex_base_imaginary_part(basic s, const basic com);
206
208signed long integer_get_si(const basic s);
210unsigned long integer_get_ui(const basic s);
212#ifdef HAVE_SYMENGINE_GMP
213CWRAPPER_OUTPUT_TYPE integer_get_mpz(mpz_t a, const basic s);
214#endif
215
218CWRAPPER_OUTPUT_TYPE rational_set(basic s, const basic i, const basic j);
220CWRAPPER_OUTPUT_TYPE rational_set_si(basic s, long i, long j);
222CWRAPPER_OUTPUT_TYPE rational_set_ui(basic s, unsigned long i, unsigned long j);
223#ifdef HAVE_SYMENGINE_GMP
225CWRAPPER_OUTPUT_TYPE rational_get_mpq(mpq_t a, const basic s);
227CWRAPPER_OUTPUT_TYPE rational_set_mpq(basic s, const mpq_t i);
228#endif
229
231CWRAPPER_OUTPUT_TYPE complex_set(basic s, const basic re, const basic im);
233CWRAPPER_OUTPUT_TYPE complex_set_rat(basic s, const basic re, const basic im);
234#ifdef HAVE_SYMENGINE_GMP
236CWRAPPER_OUTPUT_TYPE complex_set_mpq(basic s, const mpq_t re, const mpq_t im);
237#endif
238
241dcomplex complex_double_get(const basic s);
242
244CWRAPPER_OUTPUT_TYPE basic_add(basic s, const basic a, const basic b);
246CWRAPPER_OUTPUT_TYPE basic_sub(basic s, const basic a, const basic b);
248CWRAPPER_OUTPUT_TYPE basic_mul(basic s, const basic a, const basic b);
250CWRAPPER_OUTPUT_TYPE basic_div(basic s, const basic a, const basic b);
252CWRAPPER_OUTPUT_TYPE basic_pow(basic s, const basic a, const basic b);
255CWRAPPER_OUTPUT_TYPE basic_diff(basic s, const basic expr, const basic sym);
257int basic_eq(const basic a, const basic b);
259int basic_neq(const basic a, const basic b);
260
262CWRAPPER_OUTPUT_TYPE basic_expand(basic s, const basic a);
264CWRAPPER_OUTPUT_TYPE basic_neg(basic s, const basic a);
265
267CWRAPPER_OUTPUT_TYPE basic_abs(basic s, const basic a);
268
270CWRAPPER_OUTPUT_TYPE basic_erf(basic s, const basic a);
272CWRAPPER_OUTPUT_TYPE basic_erfc(basic s, const basic a);
273
275CWRAPPER_OUTPUT_TYPE basic_sin(basic s, const basic a);
277CWRAPPER_OUTPUT_TYPE basic_cos(basic s, const basic a);
279CWRAPPER_OUTPUT_TYPE basic_tan(basic s, const basic a);
280
282CWRAPPER_OUTPUT_TYPE basic_asin(basic s, const basic a);
284CWRAPPER_OUTPUT_TYPE basic_acos(basic s, const basic a);
286CWRAPPER_OUTPUT_TYPE basic_atan(basic s, const basic a);
287
289CWRAPPER_OUTPUT_TYPE basic_csc(basic s, const basic a);
291CWRAPPER_OUTPUT_TYPE basic_sec(basic s, const basic a);
293CWRAPPER_OUTPUT_TYPE basic_cot(basic s, const basic a);
294
296CWRAPPER_OUTPUT_TYPE basic_acsc(basic s, const basic a);
298CWRAPPER_OUTPUT_TYPE basic_asec(basic s, const basic a);
300CWRAPPER_OUTPUT_TYPE basic_acot(basic s, const basic a);
301
303CWRAPPER_OUTPUT_TYPE basic_sinh(basic s, const basic a);
305CWRAPPER_OUTPUT_TYPE basic_cosh(basic s, const basic a);
307CWRAPPER_OUTPUT_TYPE basic_tanh(basic s, const basic a);
308
310CWRAPPER_OUTPUT_TYPE basic_asinh(basic s, const basic a);
312CWRAPPER_OUTPUT_TYPE basic_acosh(basic s, const basic a);
314CWRAPPER_OUTPUT_TYPE basic_atanh(basic s, const basic a);
315
317CWRAPPER_OUTPUT_TYPE basic_csch(basic s, const basic a);
319CWRAPPER_OUTPUT_TYPE basic_sech(basic s, const basic a);
321CWRAPPER_OUTPUT_TYPE basic_coth(basic s, const basic a);
322
324CWRAPPER_OUTPUT_TYPE basic_acsch(basic s, const basic a);
326CWRAPPER_OUTPUT_TYPE basic_asech(basic s, const basic a);
328CWRAPPER_OUTPUT_TYPE basic_acoth(basic s, const basic a);
329
331CWRAPPER_OUTPUT_TYPE basic_lambertw(basic s, const basic a);
333CWRAPPER_OUTPUT_TYPE basic_zeta(basic s, const basic a);
335CWRAPPER_OUTPUT_TYPE basic_dirichlet_eta(basic s, const basic a);
337CWRAPPER_OUTPUT_TYPE basic_gamma(basic s, const basic a);
339CWRAPPER_OUTPUT_TYPE basic_loggamma(basic s, const basic a);
341CWRAPPER_OUTPUT_TYPE basic_sqrt(basic s, const basic a);
343CWRAPPER_OUTPUT_TYPE basic_cbrt(basic s, const basic a);
345CWRAPPER_OUTPUT_TYPE basic_exp(basic s, const basic a);
347CWRAPPER_OUTPUT_TYPE basic_log(basic s, const basic a);
349CWRAPPER_OUTPUT_TYPE basic_floor(basic s, const basic a);
351CWRAPPER_OUTPUT_TYPE basic_ceiling(basic s, const basic a);
352
354CWRAPPER_OUTPUT_TYPE basic_atan2(basic s, const basic a, const basic b);
356CWRAPPER_OUTPUT_TYPE basic_kronecker_delta(basic s, const basic a,
357 const basic b);
359CWRAPPER_OUTPUT_TYPE basic_lowergamma(basic s, const basic a, const basic b);
361CWRAPPER_OUTPUT_TYPE basic_uppergamma(basic s, const basic a, const basic b);
363CWRAPPER_OUTPUT_TYPE basic_beta(basic s, const basic a, const basic b);
365CWRAPPER_OUTPUT_TYPE basic_polygamma(basic s, const basic a, const basic b);
366
368char *basic_dumps(const basic s, unsigned long *size);
370CWRAPPER_OUTPUT_TYPE basic_loads(basic s, const char *c, unsigned long size);
371
373char *basic_str(const basic s);
376char *basic_str_julia(const basic s);
378char *basic_str_mathml(const basic s);
380char *basic_str_latex(const basic s);
382char *basic_str_ccode(const basic s);
384char *basic_str_jscode(const basic s);
386void basic_str_free(char *s);
387
389void bool_set_true(basic s);
391void bool_set_false(basic s);
392
394void basic_set_emptyset(basic s);
396void basic_set_universalset(basic s);
398void basic_set_complexes(basic s);
400void basic_set_reals(basic s);
402void basic_set_rationals(basic s);
404void basic_set_integers(basic s);
406CWRAPPER_OUTPUT_TYPE basic_set_interval(basic s, const basic start,
407 const basic end, int left_open,
408 int right_open);
410CWRAPPER_OUTPUT_TYPE basic_set_finiteset(basic s, const CSetBasic *container);
412CWRAPPER_OUTPUT_TYPE basic_set_union(basic s, const basic a, const basic b);
414CWRAPPER_OUTPUT_TYPE basic_set_intersection(basic s, const basic a,
415 const basic b);
417CWRAPPER_OUTPUT_TYPE basic_set_complement(basic s, const basic a,
418 const basic b);
420CWRAPPER_OUTPUT_TYPE basic_set_contains(basic s, const basic a, const basic b);
422int basic_set_is_subset(const basic a, const basic b);
424int basic_set_is_proper_subset(const basic a, const basic b);
426int basic_set_is_superset(const basic a, const basic b);
428int basic_set_is_proper_superset(const basic a, const basic b);
430CWRAPPER_OUTPUT_TYPE basic_set_inf(basic s, const basic a);
432CWRAPPER_OUTPUT_TYPE basic_set_sup(basic s, const basic a);
434CWRAPPER_OUTPUT_TYPE basic_set_boundary(basic s, const basic a);
436CWRAPPER_OUTPUT_TYPE basic_set_interior(basic s, const basic a);
438CWRAPPER_OUTPUT_TYPE basic_set_closure(basic s, const basic a);
439
449int symengine_have_component(const char *c);
450
452int is_a_Number(const basic s);
454int is_a_Integer(const basic s);
456int is_a_Rational(const basic s);
458int is_a_Symbol(const basic s);
460int is_a_Complex(const basic s);
462int is_a_RealDouble(const basic c);
464int is_a_ComplexDouble(const basic c);
466int is_a_RealMPFR(const basic c);
468int is_a_ComplexMPC(const basic c);
470int is_a_Set(const basic c);
471
473
474typedef struct CVectorInt CVectorInt;
475
476CVectorInt *vectorint_new();
477
478// 'data' must point to allocated memory of size 'size'. The function returns 0
479// if std::vector<int> can be initialized using placement new into 'data',
480// otherwise 1 if 'size' is too small or 2 if 'data' is not properly aligned.
481// No memory is leaked either way. Use vectorint_placement_new_check() to check
482// that the 'data' and 'size' is properly allocated and aligned. Use
483// vectorint_placement_new() to do the actual allocation.
484int vectorint_placement_new_check(void *data, size_t size);
485CVectorInt *vectorint_placement_new(void *data);
486
487void vectorint_placement_free(CVectorInt *self);
488
489void vectorint_free(CVectorInt *self);
490void vectorint_push_back(CVectorInt *self, int value);
491int vectorint_get(CVectorInt *self, int n);
492
494
495typedef struct CVecBasic CVecBasic;
496
497CVecBasic *vecbasic_new();
498void vecbasic_free(CVecBasic *self);
499CWRAPPER_OUTPUT_TYPE vecbasic_push_back(CVecBasic *self, const basic value);
500CWRAPPER_OUTPUT_TYPE vecbasic_get(CVecBasic *self, size_t n, basic result);
501CWRAPPER_OUTPUT_TYPE vecbasic_set(CVecBasic *self, size_t n, const basic s);
502CWRAPPER_OUTPUT_TYPE vecbasic_erase(CVecBasic *self, size_t n);
503size_t vecbasic_size(CVecBasic *self);
504
506CWRAPPER_OUTPUT_TYPE basic_max(basic s, const CVecBasic *d);
508CWRAPPER_OUTPUT_TYPE basic_min(basic s, const CVecBasic *d);
510CWRAPPER_OUTPUT_TYPE basic_add_vec(basic s, const CVecBasic *d);
511
513CWRAPPER_OUTPUT_TYPE basic_mul_vec(basic s, const CVecBasic *d);
514
516
517typedef struct CDenseMatrix CDenseMatrix;
518typedef struct CSparseMatrix CSparseMatrix;
519
520CDenseMatrix *dense_matrix_new();
521CSparseMatrix *sparse_matrix_new();
522
523void dense_matrix_free(CDenseMatrix *self);
525CDenseMatrix *dense_matrix_new_vec(unsigned rows, unsigned cols, CVecBasic *l);
527CDenseMatrix *dense_matrix_new_rows_cols(unsigned r, unsigned c);
528
529void sparse_matrix_free(CSparseMatrix *self);
530
532CWRAPPER_OUTPUT_TYPE dense_matrix_set(CDenseMatrix *s, const CDenseMatrix *d);
533
536char *dense_matrix_str(const CDenseMatrix *s);
538CWRAPPER_OUTPUT_TYPE dense_matrix_rows_cols(CDenseMatrix *mat, unsigned r,
539 unsigned c);
541CWRAPPER_OUTPUT_TYPE dense_matrix_get_basic(basic s, const CDenseMatrix *mat,
542 unsigned long int r,
543 unsigned long int c);
545CWRAPPER_OUTPUT_TYPE dense_matrix_set_basic(CDenseMatrix *mat,
546 unsigned long int r,
547 unsigned long int c, basic s);
549CWRAPPER_OUTPUT_TYPE sparse_matrix_get_basic(basic s, const CSparseMatrix *mat,
550 unsigned long int r,
551 unsigned long int c);
553CWRAPPER_OUTPUT_TYPE sparse_matrix_set_basic(CSparseMatrix *mat,
554 unsigned long int r,
555 unsigned long int c, basic s);
557CWRAPPER_OUTPUT_TYPE dense_matrix_det(basic s, const CDenseMatrix *mat);
559CWRAPPER_OUTPUT_TYPE dense_matrix_inv(CDenseMatrix *s, const CDenseMatrix *mat);
561CWRAPPER_OUTPUT_TYPE dense_matrix_transpose(CDenseMatrix *s,
562 const CDenseMatrix *mat);
565CWRAPPER_OUTPUT_TYPE
566dense_matrix_submatrix(CDenseMatrix *s, const CDenseMatrix *mat,
567 unsigned long int r1, unsigned long int c1,
568 unsigned long int r2, unsigned long int c2,
569 unsigned long int r, unsigned long int c);
571CWRAPPER_OUTPUT_TYPE dense_matrix_row_join(CDenseMatrix *A,
572 const CDenseMatrix *B);
574CWRAPPER_OUTPUT_TYPE dense_matrix_col_join(CDenseMatrix *A,
575 const CDenseMatrix *B);
577CWRAPPER_OUTPUT_TYPE dense_matrix_row_del(CDenseMatrix *C, unsigned k);
579CWRAPPER_OUTPUT_TYPE dense_matrix_col_del(CDenseMatrix *C, unsigned k);
580
582unsigned long int dense_matrix_cols(const CDenseMatrix *s);
584unsigned long int dense_matrix_rows(const CDenseMatrix *s);
586CWRAPPER_OUTPUT_TYPE dense_matrix_add_matrix(CDenseMatrix *s,
587 const CDenseMatrix *matA,
588 const CDenseMatrix *matB);
590CWRAPPER_OUTPUT_TYPE dense_matrix_mul_matrix(CDenseMatrix *s,
591 const CDenseMatrix *matA,
592 const CDenseMatrix *matB);
594CWRAPPER_OUTPUT_TYPE dense_matrix_add_scalar(CDenseMatrix *s,
595 const CDenseMatrix *matA,
596 const basic b);
598CWRAPPER_OUTPUT_TYPE dense_matrix_mul_scalar(CDenseMatrix *s,
599 const CDenseMatrix *matA,
600 const basic b);
602CWRAPPER_OUTPUT_TYPE dense_matrix_LU(CDenseMatrix *l, CDenseMatrix *u,
603 const CDenseMatrix *mat);
605CWRAPPER_OUTPUT_TYPE dense_matrix_LDL(CDenseMatrix *l, CDenseMatrix *d,
606 const CDenseMatrix *mat);
608CWRAPPER_OUTPUT_TYPE dense_matrix_FFLU(CDenseMatrix *lu,
609 const CDenseMatrix *mat);
611CWRAPPER_OUTPUT_TYPE dense_matrix_FFLDU(CDenseMatrix *l, CDenseMatrix *d,
612 CDenseMatrix *u,
613 const CDenseMatrix *mat);
615CWRAPPER_OUTPUT_TYPE dense_matrix_LU_solve(CDenseMatrix *x,
616 const CDenseMatrix *A,
617 const CDenseMatrix *b);
619CWRAPPER_OUTPUT_TYPE dense_matrix_ones(CDenseMatrix *s, unsigned long int r,
620 unsigned long int c);
622CWRAPPER_OUTPUT_TYPE dense_matrix_zeros(CDenseMatrix *s, unsigned long int r,
623 unsigned long int c);
626CWRAPPER_OUTPUT_TYPE dense_matrix_diag(CDenseMatrix *s, CVecBasic *d,
627 long int k);
629CWRAPPER_OUTPUT_TYPE dense_matrix_eye(CDenseMatrix *s, unsigned long int N,
630 unsigned long int M, int k);
633CWRAPPER_OUTPUT_TYPE dense_matrix_diff(CDenseMatrix *result,
634 const CDenseMatrix *A, basic const x);
636CWRAPPER_OUTPUT_TYPE dense_matrix_jacobian(CDenseMatrix *result,
637 const CDenseMatrix *A,
638 const CDenseMatrix *x);
639
641void sparse_matrix_init(CSparseMatrix *s);
643void sparse_matrix_rows_cols(CSparseMatrix *s, unsigned long int r,
644 unsigned long int c);
646char *sparse_matrix_str(const CSparseMatrix *s);
647
649int is_a_DenseMatrix(const CDenseMatrix *c);
651int is_a_SparseMatrix(const CSparseMatrix *c);
652
654int dense_matrix_eq(CDenseMatrix *lhs, CDenseMatrix *rhs);
656int sparse_matrix_eq(CSparseMatrix *lhs, CSparseMatrix *rhs);
657
659
660CSetBasic *setbasic_new();
661void setbasic_free(CSetBasic *self);
664int setbasic_insert(CSetBasic *self, const basic value);
665void setbasic_get(CSetBasic *self, int n, basic result);
667int setbasic_find(CSetBasic *self, basic value);
669int setbasic_erase(CSetBasic *self, const basic value);
670size_t setbasic_size(CSetBasic *self);
671
673
674typedef struct CMapBasicBasic CMapBasicBasic;
675
676CMapBasicBasic *mapbasicbasic_new();
677void mapbasicbasic_free(CMapBasicBasic *self);
678void mapbasicbasic_insert(CMapBasicBasic *self, const basic key,
679 const basic mapped);
681int mapbasicbasic_get(CMapBasicBasic *self, const basic key, basic mapped);
682size_t mapbasicbasic_size(CMapBasicBasic *self);
683
684// -------------------------------------
685
687CWRAPPER_OUTPUT_TYPE basic_get_args(const basic self, CVecBasic *args);
689CWRAPPER_OUTPUT_TYPE basic_free_symbols(const basic self, CSetBasic *symbols);
691CWRAPPER_OUTPUT_TYPE basic_function_symbols(CSetBasic *symbols,
692 const basic self);
694size_t basic_hash(const basic self);
697CWRAPPER_OUTPUT_TYPE basic_subs(basic s, const basic e,
698 const CMapBasicBasic *mapbb);
701CWRAPPER_OUTPUT_TYPE basic_subs2(basic s, const basic e, const basic a,
702 const basic b);
703
706CWRAPPER_OUTPUT_TYPE function_symbol_set(basic s, const char *c,
707 const CVecBasic *arg);
710char *function_symbol_get_name(const basic b);
712CWRAPPER_OUTPUT_TYPE basic_coeff(basic c, const basic b, const basic x,
713 const basic n);
714
716
718CWRAPPER_OUTPUT_TYPE vecbasic_linsolve(CVecBasic *sol, const CVecBasic *sys,
719 const CVecBasic *sym);
721CWRAPPER_OUTPUT_TYPE basic_solve_poly(CSetBasic *r, const basic f,
722 const basic s);
723
725
728char *ascii_art_str();
729
732CWRAPPER_OUTPUT_TYPE ntheory_gcd(basic s, const basic a, const basic b);
734CWRAPPER_OUTPUT_TYPE ntheory_lcm(basic s, const basic a, const basic b);
736CWRAPPER_OUTPUT_TYPE ntheory_gcd_ext(basic g, basic s, basic t, const basic a,
737 const basic b);
739CWRAPPER_OUTPUT_TYPE ntheory_nextprime(basic s, const basic a);
741CWRAPPER_OUTPUT_TYPE ntheory_mod(basic s, const basic n, const basic d);
743CWRAPPER_OUTPUT_TYPE ntheory_quotient(basic s, const basic n, const basic d);
745CWRAPPER_OUTPUT_TYPE ntheory_quotient_mod(basic q, basic r, const basic n,
746 const basic d);
748CWRAPPER_OUTPUT_TYPE ntheory_mod_f(basic s, const basic n, const basic d);
750CWRAPPER_OUTPUT_TYPE ntheory_quotient_f(basic s, const basic n, const basic d);
752CWRAPPER_OUTPUT_TYPE ntheory_quotient_mod_f(basic q, basic r, const basic n,
753 const basic d);
755int ntheory_mod_inverse(basic b, const basic a, const basic m);
757CWRAPPER_OUTPUT_TYPE ntheory_fibonacci(basic s, unsigned long a);
759CWRAPPER_OUTPUT_TYPE ntheory_fibonacci2(basic g, basic s, unsigned long a);
761CWRAPPER_OUTPUT_TYPE ntheory_lucas(basic s, unsigned long a);
763CWRAPPER_OUTPUT_TYPE ntheory_lucas2(basic g, basic s, unsigned long a);
765CWRAPPER_OUTPUT_TYPE ntheory_binomial(basic s, const basic a, unsigned long b);
767CWRAPPER_OUTPUT_TYPE ntheory_factorial(basic s, unsigned long n);
769CWRAPPER_OUTPUT_TYPE basic_evalf(basic s, const basic b, unsigned long bits,
770 int real);
771
773CWRAPPER_OUTPUT_TYPE basic_as_numer_denom(basic numer, basic denom,
774 const basic x);
775
778CLambdaRealDoubleVisitor *lambda_real_double_visitor_new();
779void lambda_real_double_visitor_init(CLambdaRealDoubleVisitor *self,
780 const CVecBasic *args,
781 const CVecBasic *exprs, int perform_cse);
782void lambda_real_double_visitor_call(CLambdaRealDoubleVisitor *self,
783 double *const outs,
784 const double *const inps);
785void lambda_real_double_visitor_free(CLambdaRealDoubleVisitor *self);
786
788#ifdef HAVE_SYMENGINE_LLVM
789// double
790typedef struct CLLVMDoubleVisitor CLLVMDoubleVisitor;
791CLLVMDoubleVisitor *llvm_double_visitor_new();
792void llvm_double_visitor_init(CLLVMDoubleVisitor *self, const CVecBasic *args,
793 const CVecBasic *exprs, int perform_cse,
794 int opt_level);
795void llvm_double_visitor_call(CLLVMDoubleVisitor *self, double *const outs,
796 const double *const inps);
797void llvm_double_visitor_free(CLLVMDoubleVisitor *self);
798// float
799typedef struct CLLVMFloatVisitor CLLVMFloatVisitor;
800CLLVMFloatVisitor *llvm_float_visitor_new();
801void llvm_float_visitor_init(CLLVMFloatVisitor *self, const CVecBasic *args,
802 const CVecBasic *exprs, int perform_cse,
803 int opt_level);
804void llvm_float_visitor_call(CLLVMFloatVisitor *self, float *const outs,
805 const float *const inps);
806void llvm_float_visitor_free(CLLVMFloatVisitor *self);
807
808#ifdef SYMENGINE_HAVE_LLVM_LONG_DOUBLE
809// long double
810typedef struct CLLVMLongDoubleVisitor CLLVMLongDoubleVisitor;
811CLLVMLongDoubleVisitor *llvm_long_double_visitor_new();
812void llvm_long_double_visitor_init(CLLVMLongDoubleVisitor *self,
813 const CVecBasic *args,
814 const CVecBasic *exprs, int perform_cse,
815 int opt_level);
816void llvm_long_double_visitor_call(CLLVMLongDoubleVisitor *self,
817 long double *const outs,
818 const long double *const inps);
819void llvm_long_double_visitor_free(CLLVMLongDoubleVisitor *self);
820#endif
821#endif
822
823CWRAPPER_OUTPUT_TYPE basic_cse(CVecBasic *replacement_syms,
824 CVecBasic *replacement_exprs,
825 CVecBasic *reduced_exprs,
826 const CVecBasic *exprs);
827
829void symengine_print_stack_on_segfault();
830
831#ifdef __cplusplus
832}
833#endif
834#endif