| 561 | |
| 562 | template <typename T> |
| 563 | static void |
| 564 | randomSyr2Matrices( |
| 565 | clblasOrder order, |
| 566 | clblasUplo uplo, |
| 567 | size_t N, |
| 568 | bool useAlpha, |
| 569 | T *alpha, |
| 570 | T *A, |
| 571 | size_t lda, |
| 572 | T *X, |
| 573 | int incx, |
| 574 | T *Y, |
| 575 | int incy |
| 576 | ) |
| 577 | { |
| 578 | size_t i, j; |
| 579 | size_t lengthX; |
| 580 | size_t lengthY; |
| 581 | cl_double bound; |
| 582 | |
| 583 | if (!useAlpha) { |
| 584 | *alpha = random<T>(100); |
| 585 | if (module(*alpha) == 0.0) { |
| 586 | *alpha = ONE<T>(); |
| 587 | } |
| 588 | } |
| 589 | #ifdef DEBUG_SYR2 |
| 590 | printf("ALPHA in randomSyr2Matrices %f\n", *alpha); |
| 591 | #endif |
| 592 | |
| 593 | // bound is calculated by solving the equation (2*alpha*x^2 + x - UPPER_BOUND) < 0 |
| 594 | |
| 595 | bound = UPPER_BOUND<T>(); |
| 596 | |
| 597 | if(module(*alpha) > (sqrt(bound) / (4.0))) |
| 598 | *alpha = random<T>((sqrt(bound) / (4.0))); |
| 599 | |
| 600 | #ifdef DEBUG_SYR2 |
| 601 | printf("ALPHA in randomSyrMatrices after check %f bound for alpha is %f\n", *alpha, (sqrt(bound) / (2.0))); |
| 602 | #endif |
| 603 | |
| 604 | bound = bound / ( 2 * module(*alpha)); |
| 605 | |
| 606 | bound = sqrt( ((((1.0) / module(*alpha)) / (16.0)) / module(*alpha)) + bound) - ((1.0) / ((4.0) * (*alpha))); |
| 607 | |
| 608 | #ifdef DEBUG_SYR2 |
| 609 | printf("BOUND : %f alpha %f \n", bound, *alpha); |
| 610 | #endif |
| 611 | |
| 612 | if( lda ) |
| 613 | { |
| 614 | for (i = 0; i < N; i++) { |
| 615 | for (j = 0; j < N; j++) { |
| 616 | setElement<T>(order, clblasNoTrans, i, j, A, lda, random<T>(bound)); |
| 617 | } |
| 618 | } |
| 619 | } else { |
| 620 | for (i = 0; i < N; i++) { |
no test coverage detected