for debugging: for printing numbers to the console DELETE LATER */
| 573 | for printing numbers to the console |
| 574 | DELETE LATER */ |
| 575 | void printSolutions(const int a, const int b, const int c) |
| 576 | { |
| 577 | printf("\n------\n"); |
| 578 | /* build the polynomial a*x^2 + b*x + c: */ |
| 579 | poly p = NULL; poly q = NULL; poly r = NULL; |
| 580 | if (a != 0) |
| 581 | { p = pOne(); pSetExp(p, 1, 2); pSetm(p); pSetCoeff(p, nInit(a)); } |
| 582 | if (b != 0) |
| 583 | { q = pOne(); pSetExp(q, 1, 1); pSetm(q); pSetCoeff(q, nInit(b)); } |
| 584 | if (c != 0) |
| 585 | { r = pOne(); pSetCoeff(r, nInit(c)); } |
| 586 | p = pAdd(p, q); p = pAdd(p, r); |
| 587 | printf("poly = %s\n", pString(p)); |
| 588 | number tol = tenToTheMinus(20); |
| 589 | number s1; number s2; int nSol = quadraticSolve(p, s1, s2, tol); |
| 590 | nDelete(&tol); |
| 591 | printf("solution code = %d\n", nSol); |
| 592 | if ((1 <= nSol) && (nSol <= 3)) |
| 593 | { |
| 594 | if (nSol != 3) { printNumber(s1); nDelete(&s1); } |
| 595 | else { printNumber(s1); nDelete(&s1); printNumber(s2); nDelete(&s2); } |
| 596 | } |
| 597 | printf("------\n"); |
| 598 | pDelete(&p); |
| 599 | } |
| 600 | |
| 601 | bool realSqrt(const number n, const number tolerance, number &root) |
| 602 | { |
nothing calls this directly
no test coverage detected