70 lines
2.9 KiB
C
70 lines
2.9 KiB
C
/*
|
|
* SymClaw C FFI — public API header.
|
|
*
|
|
* Link against libsymclaw_ffi.so (dynamic) or libsymclaw_ffi.a (static).
|
|
*/
|
|
|
|
#ifndef SYMCLAW_H
|
|
#define SYMCLAW_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Opaque expression handle. */
|
|
typedef struct SymclawExpr symclaw_expr_t;
|
|
|
|
/* ── Lifecycle ──────────────────────────────────────────────── */
|
|
|
|
/* Parse a math expression string. Returns NULL on failure. */
|
|
symclaw_expr_t* symclaw_parse(const char* input);
|
|
|
|
/* Free an expression handle. Safe to call with NULL. */
|
|
void symclaw_free_expr(symclaw_expr_t* expr);
|
|
|
|
/* Free a string returned by SymClaw. Safe to call with NULL. */
|
|
void symclaw_free_string(char* s);
|
|
|
|
/* ── Conversion ─────────────────────────────────────────────── */
|
|
|
|
/* Convert expression to ASCII string. Caller frees with symclaw_free_string. */
|
|
char* symclaw_to_string(const symclaw_expr_t* expr);
|
|
|
|
/* Convert expression to LaTeX. Caller frees with symclaw_free_string. */
|
|
char* symclaw_to_latex(const symclaw_expr_t* expr);
|
|
|
|
/* ── Operations ─────────────────────────────────────────────── */
|
|
|
|
symclaw_expr_t* symclaw_simplify(const symclaw_expr_t* expr);
|
|
symclaw_expr_t* symclaw_differentiate(const symclaw_expr_t* expr, const char* var);
|
|
symclaw_expr_t* symclaw_integrate(const symclaw_expr_t* expr, const char* var);
|
|
double symclaw_eval(const symclaw_expr_t* expr, const char* var, double value);
|
|
symclaw_expr_t* symclaw_expand(const symclaw_expr_t* expr);
|
|
|
|
/* Solve expr=0 for var. Returns JSON array string. Caller frees. */
|
|
char* symclaw_solve(const symclaw_expr_t* expr, const char* var);
|
|
|
|
symclaw_expr_t* symclaw_series(const symclaw_expr_t* expr, const char* var,
|
|
double point, uint32_t order);
|
|
symclaw_expr_t* symclaw_limit(const symclaw_expr_t* expr, const char* var,
|
|
double point);
|
|
|
|
/* ── Arithmetic ─────────────────────────────────────────────── */
|
|
|
|
symclaw_expr_t* symclaw_add(const symclaw_expr_t* a, const symclaw_expr_t* b);
|
|
symclaw_expr_t* symclaw_mul(const symclaw_expr_t* a, const symclaw_expr_t* b);
|
|
symclaw_expr_t* symclaw_pow(const symclaw_expr_t* base, const symclaw_expr_t* exp);
|
|
|
|
/* ── Code Generation ────────────────────────────────────────── */
|
|
|
|
/* Generate code in target language ("python", "c", "rust", etc). Caller frees. */
|
|
char* symclaw_to_code(const symclaw_expr_t* expr, const char* language);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SYMCLAW_H */
|