         {
             CURAND_CALL_GOTO(curandGenerateUniformDouble(gen,
                         (double *)valptr,
-                        compactvec->traits.nrowspadded*compactvec->traits.ncols*2),err,ret);
+                        compactvec->traits.nrows*compactvec->traits.ncolspadded*2),err,ret);
         } 
         else 
         {
             CURAND_CALL_GOTO(curandGenerateUniform(gen,
                         (float *)valptr,
-                        compactvec->traits.nrowspadded*compactvec->traits.ncols*2),err,ret);
+                        compactvec->traits.nrows*compactvec->traits.ncolspadded*2),err,ret);
         }
     }
     else

{
    GHOST_FUNC_ENTER(GHOST_FUNCTYPE_MATH);
    ghost_error_t ret = GHOST_SUCCESS;
    
    if (vec->traits.datatype != vec2->traits.datatype)
    {
        ERROR_LOG("Cannot DOT vectors with different data types (%s and %s)",ghost_datatype_string(vec->traits.datatype),ghost_datatype_string(vec2->traits.datatype));

        {
            CURAND_CALL_GOTO(curandGenerateUniformDouble(gen,
                        (double *)valptr,
                        compactvec->traits.nrows*compactvec->traits.ncolspadded),err,ret);
        } 
        else 
        {
            CURAND_CALL_GOTO(curandGenerateUniform(gen,
                        (float *)valptr,
                        compactvec->traits.nrows*compactvec->traits.ncolspadded),err,ret);
        }
    }
    if (compactvec->traits.datatype & GHOST_DT_DOUBLE) {
