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

Function setDiagonalUnityOrNonUnity

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

Source from the content-addressed store, hash-verified

801
802template <typename T>
803static void
804setDiagonalUnityOrNonUnity(int unity, T* data, size_t rows, size_t cols, size_t lda, int vectorLength, int creationFlags, cl_double bound)
805{
806
807 if (creationFlags & PACKED_MATRIX)
808 {
809
810 // Rows = Cols for PACKED Matrix
811 for(size_t i=0;i< rows;i++)
812 {
813 if (creationFlags & UPPER_HALF_ONLY)
814 {
815 (unity==1)? setElementWithUnity( ((creationFlags & ROW_MAJOR_ORDER))?RMUPacked(i,i):RMLPacked(i,i), vectorLength):
816 (unity == 0)? setElementWithZero( ((creationFlags & ROW_MAJOR_ORDER))?RMUPacked(i,i):RMLPacked(i,i), vectorLength):
817 setElementWithRandomData( ((creationFlags & ROW_MAJOR_ORDER))?RMUPacked(i,i):RMLPacked(i,i), vectorLength, bound);
818 }
819 else
820 {
821 (unity==1)? setElementWithUnity( (creationFlags & ROW_MAJOR_ORDER)?RMLPacked(i,i):RMUPacked(i,i), vectorLength):
822 (unity==0)? setElementWithZero( (creationFlags & ROW_MAJOR_ORDER)?RMLPacked(i,i):RMUPacked(i,i), vectorLength):
823 setElementWithRandomData( (creationFlags & ROW_MAJOR_ORDER)?RMLPacked(i,i):RMUPacked(i,i) , vectorLength, bound);
824 }
825 }
826 }
827 else
828 {
829 // Row Major - rows x lda
830 // Col major - lda x cols
831 size_t firstdimension;
832 T *p;
833
834 if (creationFlags & ROW_MAJOR_ORDER)
835 {
836 firstdimension = rows;
837 } else {
838 firstdimension = cols;
839 }
840
841 for(size_t i=0; i<firstdimension; i++)
842 {
843 p = (T *)data + (i*lda)*vectorLength;
844 p += i*vectorLength;
845
846 if (unity == 0)
847 {
848 setElementWithZero(p, vectorLength);
849 }
850 else if (unity == 1)
851 {
852 setElementWithUnity(p, vectorLength);
853 }
854 else
855 {
856 setElementWithRandomData(p, vectorLength, bound);
857 }
858 }
859 }
860}

Callers

nothing calls this directly

Calls 3

setElementWithUnityFunction · 0.85
setElementWithZeroFunction · 0.85
setElementWithRandomDataFunction · 0.85

Tested by

no test coverage detected