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

Function doPopulate

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

Source from the content-addressed store, hash-verified

1013
1014template <typename T>
1015static void
1016doPopulate(T* data, size_t rows, size_t cols, size_t lda, int vectorLength, cl_double bound, int creationFlags = 0)
1017{
1018 bool triangularMatrix = ((creationFlags & LOWER_HALF_ONLY) ||
1019 (creationFlags & UPPER_HALF_ONLY));
1020
1021
1022 // Non-Square Matrix
1023 if( rows != cols)
1024 {
1025 // Row-Major
1026 if (creationFlags & ROW_MAJOR_ORDER)
1027 {
1028 for( size_t i=0; i < rows; i++)
1029 {
1030 for(size_t j=0; j < cols; j++)
1031 {
1032
1033 T *p = (T *)data + i* lda*vectorLength + j*vectorLength;
1034 setElementWithRandomData(p, vectorLength , bound);
1035
1036 if ( i == j)
1037 {
1038 if (creationFlags & UNIT_DIAGONAL)
1039 {
1040 setElementWithUnity(p, vectorLength);
1041 } else if (creationFlags & ZERO_DIAGONAL)
1042 {
1043 setElementWithZero(p, vectorLength);
1044 }
1045 }
1046 }
1047 }
1048 }
1049 else // Col-Major
1050 {
1051 for( size_t i=0; i < rows; i++)
1052 {
1053 for(size_t j=0; j < cols; j++)
1054 {
1055 T *p = (T *)data + j* lda*vectorLength + i*vectorLength;
1056 setElementWithRandomData(p, vectorLength, bound);
1057 if ( i == j)
1058 {
1059 if (creationFlags & UNIT_DIAGONAL)
1060 {
1061 setElementWithUnity(p, vectorLength);
1062 } else if (creationFlags & ZERO_DIAGONAL)
1063 {
1064 setElementWithZero(p, vectorLength);
1065 }
1066 }
1067
1068 }
1069 }
1070 }
1071 }
1072

Callers 3

populateFunction · 0.85
populate<FloatComplex>Function · 0.85
populate<DoubleComplex>Function · 0.85

Calls 5

setElementWithRandomDataFunction · 0.85
setElementWithUnityFunction · 0.85
setElementWithZeroFunction · 0.85
doTriangleOperationFunction · 0.85

Tested by

no test coverage detected