             }
         }
     }
-
-    return GHOST_SUCCESS;
-}
+    if (vec->traits.datatype & GHOST_DT_DOUBLE) {
+        vec->axpby(vec,onevec,minusahalf,one);
+    } else {
+        vec->axpby(vec,onevec,fminusahalf,fone);
+    }
+
+    onvec->destroy(onevec);
+
+    return GHOST_SUCCESS;
+}


extern "C" ghost_error_t ghost_densemat_cm_cu_fromRand(ghost_densemat_t *vec)
{
    long pid = getpid();
    double time;
    ghost_timing_wcmilli(&time);

    CURAND_CALL_RETURN(curandCreateGenerator(&gen,CURAND_RNG_PSEUDO_DEFAULT));
    CURAND_CALL_RETURN(curandSetPseudoRandomGeneratorSeed(gen,ghost_hash(int(time),clock(),pid)));

    vec->clone(vec,&onevec,vec->traits.nrows,0,vec->traits.ncols,0);
    double one[] = {1.,1.};
    onevec->fromScalar(onevec,one);

    one[1] = 0.;
    float fone[] = {1.,0.};
    double minusahalf[] = {-0.5,0.};
    float fminusahalf[] = {-0.5,0.};

    ghost_idx_t v;
    for (v=0; v<vec->traits.ncols; v++)
    {
