Go to the documentation of this file.
76 "VectorTripleProduct",
193 va_start(arguments, child_count);
195 for (i = 0; i < child_count; i++) {
291 if (source == NULL)
return NULL;
294 if (source->
children[i] == NULL)
continue;
319 if (source == NULL) {
324 if (source->
children[i] == NULL)
continue;
343 va_start(arguments, expression_count);
345 for (i = 0; i < expression_count; i++) {
409 if (source->
children[i] == NULL)
continue;
429 for (i = 0; i < source->
child_count && recursive; i++) {
460 if (source->
children[i] == NULL)
continue;
471 if (a == NULL || b == NULL) {
677 if (haystack->
children[i] == NULL)
continue;
693 if (source->
children[i] == NULL)
continue;
722 if (a == NULL || b == NULL)
return RETS_ERROR;
788 expressions[i] = source->
children[i];
798 if (scores[i] < min_score && scores[i] != 0) {
800 min_score = scores[i];
805 scores[min_index] = 0;
820 if (source->
children[i] == NULL)
continue;
838 for (i = 0; custom_priorities[i] !=
'\0'; i++) {
901 dtoa(buffer, 10, source);
918 if (source->
children[i] == 0)
continue;
991 char* lowercase_keyword;
995 if (strcmp(
string, lowercase_keyword) == 0) {
1040 case ETSF_TIKZ: strcat(buffer,
"\\begin{tikzpicture}");
expression_to_tikz(buffer, temp_source); strcat(buffer,
";\\end{tikzpicture}");
break;
1051 char temp_buffer[30];
1056 if (temp_source->
sign == -1) strcat(buffer,
"(-");
1058 strcat(buffer, temp_buffer);
1059 if (temp_source->
sign == -1) strcat(buffer,
")");
1061 strcat(buffer,
"(");
1062 if (temp_source->
sign == -1) strcat(buffer,
"-");
1064 strcat(buffer, temp_buffer);
1067 strcat(buffer, temp_buffer);
1068 strcat(buffer,
")");
1085 strcat(buffer,
"(");
1092 strcat(buffer,
")");
1098 strcat(buffer,
"(");
1103 strcat(buffer,
")");
1125 char temp_buffer[30];
1129 strcat(buffer,
"child{node{$");
1130 if (temp_source->
sign == -1) strcat(buffer,
"- ");
1133 strcat(buffer, temp_buffer);
1135 strcat(buffer,
"\\frac{");
1137 strcat(buffer, temp_buffer);
1138 strcat(buffer,
"}{");
1140 strcat(buffer, temp_buffer);
1141 strcat(buffer,
"}");
1143 strcat(buffer,
"$}}");
1147 strcat(buffer,
"child{node{$");
1148 if (temp_source->
sign == -1) strcat(buffer,
"- ");
1150 strcat(buffer,
"$}}");
1154 strcat(buffer, (temp_source->
parent) ?
"child{node[operator_node]{$" :
"\\node[operator_node]{$");
1155 if (temp_source->
sign == -1) strcat(buffer,
"- ");
1157 strcat(buffer,
"$}");
1159 if (temp_source->
parent) strcat(buffer,
"}");
1163 strcat(buffer, (temp_source->
parent) ?
"child{node[function_node]{" :
"\\node[function_node]{");
1164 if (temp_source->
sign == -1) strcat(buffer,
"- ");
1166 strcat(buffer,
"}");
1168 if (temp_source->
parent) strcat(buffer,
"}");
1176 void print_expression(
const expression* source) {
1178 memset(buffer,
'\0', 500);
1180 printf(
"%s\n", buffer);
void merge_nested_lists(expression *source, bool recursive)
void smart_free_all(void)
Frees all pointers.
uint8_t get_symbol_order_score(const expression *source)
int8_t expression_contains_division(const expression *source)
bool expression_is_numerical(const expression *source)
void embed_in_list_if_necessary(expression *source)
bool expression_is_smaller_than(const expression *a, expression *b, bool persistent)
char * default_priorities
void replace_expression(expression *a, expression *b)
expression_identifier identifier
void literal_to_double_symbol(expression *source)
expression_identifier get_expression_identifier(const char *string)
Returns the identifier corresponding to the keyword string.
double literal_to_double(expression *source)
void replace_occurences(expression *source, const expression *child, const expression *replacement)
void smart_free(void *pointer)
Frees a pointer.
void collect_symbols(expression *symbols, const expression *source)
expression * new_symbol(expression_identifier identifier, const char *value)
Allocates and initializes a new symbol/variable expression.
expression * get_symbol(const expression *source)
union expression::@0 value
void expression_to_tikz(char *buffer, const expression *source)
expression * double_to_literal(double source)
void dtoa(char *buffer, uint8_t length, double source)
void expression_to_infix(char *buffer, const expression *souce)
bool use_spaces
Determines if spaces should be used in the result string (such as "x + y * z" instead of "x+y*z")
void order_children(expression *source)
bool expressions_are_identical(const expression *a, expression *b, bool persistent)
double uintmax_max_value(void)
void itoa(char *buffer, uintmax_t source)
void remove_child_at_index(expression *source, uint8_t index)
char * string_to_lower(const char *string)
Converts a string to lowercase.
void free_expression(expression *source, bool persistent)
uint8_t string_to_literal(expression **result, const char *source)
uint8_t swap_expressions(expression *a, expression *b)
void free_expressions(uint8_t expression_count,...)
uint8_t count_occurrences(const expression *haystack, expression *needle, bool persistent)
double get_order_score(const expression *source)
struct expression * parent
bool smart_alloc_is_recording
void expression_to_string(char *buffer, const expression *source, expression_to_string_format format)
Serializes an expression into a specified format.
#define ALLOCATED_POINTERS_LENGTH
bool expression_is_constant(const expression *source)
expression * copy_expression(const expression *source)
Returns a deep copy of an expression.
void free_all_except(expression *source)
uint8_t simplify(expression *source, bool recursive)
void any_expression_to_expression_recursive(expression *source)
const char * get_expression_string(expression_identifier identifier)
Returns the keyword string corresponding to the identifier.
void append_child(expression *parent, expression *child)
Appends a child to an expression.
expression * new_expression(expression_type type, expression_identifier identifier, uint8_t child_count,...)
Allocates and initializes a new expression with the arguments provided.
bool expression_is_greater_than(const expression *a, expression *b, bool persistent)
void remove_null_children(expression *source)
void replace_null_with_zero(expression *source)
expression_identifier keyword_identifiers[]
expression * guess_symbol(const expression *source, const char *custom_priorities, uint8_t rank)
expression * new_literal(int8_t sign, uintmax_t numerator, uintmax_t denominator)
Allocates and initializes a new literal expression.
void * smart_realloc(void *source, uint8_t length, size_t size)
Resizes a pointer.
expression_to_string_format
void ** allocated_pointers
expression * new_trigonometic_periodicity(uint8_t period)
bool expressions_are_equivalent(const expression *a, expression *b, bool persistent)
struct expression ** children
bool expression_is_reziprocal(const expression *source)
bool use_abbrevations
Determines if abbrevations should be used in the result string (such as "Deriv" instead of "Derivativ...
bool symbol_is_constant(const expression *source)
void set_parents(expression *source)
void * smart_alloc(uint8_t length, size_t size)
Allocates and keeps track of memory.