MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / randomSyrMatrices

Function randomSyrMatrices

src/tests/include/blas-random.h:492–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490
491template <typename T>
492static void
493randomSyrMatrices(
494 clblasOrder order,
495 clblasUplo uplo,
496 size_t N,
497 bool useAlpha,
498 T *alpha,
499 T *A,
500 size_t lda,
501 T *X,
502 int incx
503 )
504{
505 size_t i, j;
506 size_t lengthX;
507 cl_double bound;
508
509 if (!useAlpha) {
510 *alpha = random<T>(100);
511 if (module(*alpha) == 0.0) {
512 *alpha = ONE<T>();
513 }
514 }
515 #ifdef DEBUG_SYR
516 printf("ALPHA in randomSyrMatrices %f\n", *alpha);
517 #endif
518
519 // bound is calculated by solving the equation (alpha*x^2 + x - UPPER_BOUND) < 0
520
521 bound = UPPER_BOUND<T>();
522
523 if(module(*alpha) > (sqrt(bound) / (2.0)))
524 *alpha = random<T>((sqrt(bound) / (2.0)));
525
526 #ifdef DEBUG_SYR
527 printf("ALPHA in randomSyrMatrices after check %f bound for alpha is %f\n", *alpha, (sqrt(bound) / (2.0)));
528 #endif
529
530 bound = bound / module(*alpha);
531
532 bound = sqrt( ((((1.0) / module(*alpha)) / (4.0)) / module(*alpha)) + bound) - ((1.0) / ((2.0) * (*alpha)));
533
534 #ifdef DEBUG_SYR
535 printf("BOUND : %f alpha %f \n", bound, *alpha);
536 #endif
537
538 if( lda )
539 {
540 for (i = 0; i < N; i++) {
541 for (j = 0; j < N; j++) {
542 setElement<T>(order, clblasNoTrans, i, j, A, lda, random<T>(bound));
543 }
544 }
545 } else {
546 for (i = 0; i < N; i++) {
547 for (j = 0; j < N; j++) {
548 setElementPacked<T>(order, clblasNoTrans, uplo, i, j, A, N, random<T>(bound));
549 }

Callers 3

prepareMethod · 0.85
prepareMethod · 0.85
generateDataMethod · 0.85

Calls 1

moduleFunction · 0.70

Tested by

no test coverage detected