wip implemented new union for solve
This commit is contained in:
@@ -115,11 +115,19 @@ int reduce(s_term *terms, s_polynom *polynom, int max_exponent);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DELTA_PLUS, // +
|
||||
DELTA_MINUS, // -
|
||||
DELTA_ZERO, // 0
|
||||
DELTA_PLUS = 1,
|
||||
DELTA_MINUS = -1,
|
||||
DELTA_ZERO = 0,
|
||||
} e_delta_sign;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int solution_gcd; // gcd(b, a)
|
||||
int solution_numerator; // -b / gcd
|
||||
int solution_denominator; // a / gcd
|
||||
double solution; // double (-b / a)
|
||||
} s_solution_degree_1;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
e_delta_sign delta_sign; // DELTA_PLUS or DELTA_MINUS or DELTA_ZERO
|
||||
@@ -133,7 +141,17 @@ typedef struct
|
||||
int second_term_denominator; // 2a / gcd
|
||||
double second_term; // double (√|Δ| / 2a)
|
||||
double solution1; // first_term + second_term
|
||||
double solution2; // first_term - second_term
|
||||
double solution2; // first_term - second_term (not if DELTA_ZERO)
|
||||
} s_solution_degree_2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int degree;
|
||||
union
|
||||
{
|
||||
s_solution_degree_1 solution_degree_1;
|
||||
s_solution_degree_2 solution_degree_2;
|
||||
};
|
||||
} s_solution;
|
||||
|
||||
void solve(const s_polynom *polynom, s_solution *solution);
|
||||
|
||||
Reference in New Issue
Block a user