init solver
This commit is contained in:
@@ -15,33 +15,9 @@ static void print_context_tokens()
|
||||
i = 0;
|
||||
while (tokens_g_err[i].type != TOKEN_END)
|
||||
{
|
||||
ft_dprintf(STDERR_FILENO, "token[%2i] - type : ", i);
|
||||
|
||||
if (tokens_g_err[i].type == TOKEN_VARIABLE)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_VARIABLE");
|
||||
else if (tokens_g_err[i].type == TOKEN_NUMBER_INT)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_NUMBER_INT");
|
||||
else if (tokens_g_err[i].type == TOKEN_NUMBER_INT_SUPER)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_NUMBER_INT_SUPER");
|
||||
else if (tokens_g_err[i].type == TOKEN_NUMBER_DOUBLE)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_NUMBER_DOUBLE");
|
||||
else if (tokens_g_err[i].type == TOKEN_POWER)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_POWER");
|
||||
else if (tokens_g_err[i].type == TOKEN_SIGN_PLUS)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_SIGN_PLUS");
|
||||
else if (tokens_g_err[i].type == TOKEN_SIGN_MINUS)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_SIGN_MINUS");
|
||||
else if (tokens_g_err[i].type == TOKEN_FACTOR_MULT)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_FACTOR_MULT");
|
||||
else if (tokens_g_err[i].type == TOKEN_FACTOR_DIV)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_FACTOR_DIV");
|
||||
else if (tokens_g_err[i].type == TOKEN_EQUAL)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_EQUAL");
|
||||
else if (tokens_g_err[i].type == TOKEN_END)
|
||||
ft_dprintf(STDERR_FILENO, "%22s", "TOKEN_END");
|
||||
ft_dprintf(STDERR_FILENO, "token[%2i] - type : %22s", i, token_type_to_str(tokens_g_err[i].type));
|
||||
|
||||
ft_putstr(" - value : ");
|
||||
|
||||
if (tokens_g_err[i].type == TOKEN_NUMBER_INT)
|
||||
{
|
||||
ft_dprintf(STDERR_FILENO, "%i\n", tokens_g_err[i].value_int);
|
||||
@@ -71,29 +47,9 @@ static void print_context_terms()
|
||||
while (terms_g_err[i].position != TERM_END)
|
||||
{
|
||||
ft_dprintf(STDERR_FILENO, "term[%2i] - ", i);
|
||||
|
||||
// position
|
||||
ft_dprintf(STDERR_FILENO, "%8s : ", "position");
|
||||
if (terms_g_err[i].position == TERM_LEFT)
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "TERM_LEFT");
|
||||
else if (terms_g_err[i].position == TERM_RIGHT)
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "TERM_RIGHT");
|
||||
else
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "");
|
||||
|
||||
// sign
|
||||
ft_dprintf(STDERR_FILENO, " | %4s : ", "sign");
|
||||
if (terms_g_err[i].sign == TERM_PLUS)
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "TERM_PLUS");
|
||||
else if (terms_g_err[i].sign == TERM_MINUS)
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "TERM_MINUS");
|
||||
else
|
||||
ft_dprintf(STDERR_FILENO, "%10s", "");
|
||||
|
||||
// coefficient
|
||||
ft_dprintf(STDERR_FILENO, "%8s : %10s", "position", term_position_to_str(terms_g_err[i].position));
|
||||
ft_dprintf(STDERR_FILENO, " | %4s : %10s", "sign", term_sign_to_str(terms_g_err[i].sign));
|
||||
dprintf(STDERR_FILENO, " | %10s : %13g", "coefficient", terms_g_err[i].coefficient);
|
||||
|
||||
// exponent
|
||||
ft_dprintf(STDERR_FILENO, " | %8s : %d\n", "exponent", terms_g_err[i].exponent);
|
||||
i++;
|
||||
}
|
||||
@@ -110,6 +66,25 @@ static void print_context_polynom()
|
||||
dprintf(STDERR_FILENO, "polynom[%i]: %10g\n", i, polynom_g_err[i]);
|
||||
i++;
|
||||
}
|
||||
ft_putchar_fd('\n', STDERR_FILENO);
|
||||
}
|
||||
|
||||
static void print_context_solution()
|
||||
{
|
||||
dprintf(STDERR_FILENO, "delta_sign : %25s\n", delta_sign_to_str(solution_g_err->delta_sign));
|
||||
dprintf(STDERR_FILENO, "delta_absolute : %25g\n", solution_g_err->delta_absolute);
|
||||
// dprintf(STDERR_FILENO, "first_term_pgcd : %25g\n", solution_g_err->first_term_pgcd);
|
||||
// dprintf(STDERR_FILENO, "first_term_numerator : %25g\n", solution_g_err->first_term_numerator);
|
||||
// dprintf(STDERR_FILENO, "first_term_denominator : %25g\n", solution_g_err->first_term_denominator);
|
||||
// dprintf(STDERR_FILENO, "first_term : %25g\n", solution_g_err->first_term);
|
||||
// dprintf(STDERR_FILENO, "second_term_pgcd : %25g\n", solution_g_err->second_term_pgcd);
|
||||
// dprintf(STDERR_FILENO, "second_term_numerator : %25g\n", solution_g_err->second_term_numerator);
|
||||
// dprintf(STDERR_FILENO, "second_term_denominator: %25g\n", solution_g_err->second_term_denominator);
|
||||
// dprintf(STDERR_FILENO, "second_term : %25g\n", solution_g_err->second_term);
|
||||
// dprintf(STDERR_FILENO, "solution1 : %25g\n", solution_g_err->solution1);
|
||||
// dprintf(STDERR_FILENO, "solution2 : %25g\n", solution_g_err->solution2);
|
||||
|
||||
ft_putchar_fd('\n', STDERR_FILENO);
|
||||
}
|
||||
|
||||
void print_state()
|
||||
@@ -125,6 +100,8 @@ void print_state()
|
||||
print_context_terms();
|
||||
if (polynom_g_err)
|
||||
print_context_polynom();
|
||||
if (solution_g_err)
|
||||
print_context_solution();
|
||||
}
|
||||
|
||||
void stop_errors(const char *description, ...)
|
||||
|
||||
@@ -11,6 +11,7 @@ const char *token_type_to_str(e_token_type enum_value)
|
||||
[TOKEN_VARIABLE] = "TOKEN_VARIABLE",
|
||||
[TOKEN_NUMBER_INT] = "TOKEN_NUMBER_INT",
|
||||
[TOKEN_NUMBER_DOUBLE] = "TOKEN_NUMBER_DOUBLE",
|
||||
[TOKEN_NUMBER_INT_SUPER] = "TOKEN_NUMBER_INT_SUPER",
|
||||
[TOKEN_POWER] = "TOKEN_POWER",
|
||||
[TOKEN_SIGN_PLUS] = "TOKEN_SIGN_PLUS",
|
||||
[TOKEN_SIGN_MINUS] = "TOKEN_SIGN_MINUS",
|
||||
@@ -56,4 +57,16 @@ const char *term_sign_to_str(e_term_sign enum_value)
|
||||
[TERM_MINUS] = "TERM_MINUS",
|
||||
[TERM_NULL] = "TERM_NULL"};
|
||||
return term_sign_str[enum_value];
|
||||
}
|
||||
|
||||
const char *delta_sign_to_str(e_delta_sign enum_value)
|
||||
{
|
||||
if (enum_value > DELTA_ZERO || enum_value < DELTA_PLUS)
|
||||
return "invalid enum value";
|
||||
|
||||
static const char *const delta_sign_str[DELTA_ZERO + 1] = {
|
||||
[DELTA_PLUS] = "DELTA_PLUS",
|
||||
[DELTA_MINUS] = "DELTA_MINUS",
|
||||
[DELTA_ZERO] = "DELTA_ZERO"};
|
||||
return delta_sign_str[enum_value];
|
||||
}
|
||||
@@ -10,7 +10,7 @@ void print_debug(const char *description, ...)
|
||||
// print the formatted description
|
||||
va_list args;
|
||||
va_start(args, description);
|
||||
// ft_vdprintf(STDOUT_FILENO, description, args);
|
||||
// ft_vdprintf(STDOUT_FILENO, description, args); // it's not handling floats for the moment
|
||||
vdprintf(STDOUT_FILENO, description, args);
|
||||
va_end(args);
|
||||
}
|
||||
Reference in New Issue
Block a user