Changeset View
Changeset View
Standalone View
Standalone View
intern/libmv/libmv/numeric/poly.h
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | int SolveCubicPolynomial(Real a, Real b, Real c, Real* x0, Real* x1, Real* x2) { | ||||
| Real Q3 = Q * Q * Q; | Real Q3 = Q * Q * Q; | ||||
| Real R2 = R * R; | Real R2 = R * R; | ||||
| Real CR2 = 729 * r * r; | Real CR2 = 729 * r * r; | ||||
| Real CQ3 = 2916 * q * q * q; | Real CQ3 = 2916 * q * q * q; | ||||
| if (R == 0 && Q == 0) { | if (R == 0 && Q == 0) { | ||||
| // Tripple root in one place. | // Triple root in one place. | ||||
| *x0 = *x1 = *x2 = -a / 3; | *x0 = *x1 = *x2 = -a / 3; | ||||
| return 3; | return 3; | ||||
| } else if (CR2 == CQ3) { | } else if (CR2 == CQ3) { | ||||
| // This test is actually R2 == Q3, written in a form suitable for exact | // This test is actually R2 == Q3, written in a form suitable for exact | ||||
| // computation with integers. | // computation with integers. | ||||
| // | // | ||||
| // Due to finite precision some double roots may be missed, and considered | // Due to finite precision some double roots may be missed, and considered | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||