src/seq_mv/vector.c
HYPRE_Int hypre_SeqVectorSetRandomValues(hypre_Vector *v, HYPRE_Int seed) {
  HYPRE_Complex *vector_data = hypre_VectorData(v);
  HYPRE_Int size = hypre_VectorSize(v);
  HYPRE_Int i;
  HYPRE_Int ierr = 0;
  hypre_SeedRand(seed);

  size *= hypre_VectorNumVectors(v);

  if (hypre_GetActualMemLocation(hypre_VectorMemoryLocation(v)) ==
      hypre_MEMORY_HOST) {
    /* RDF: threading this loop may cause problems because of hypre_Rand() */
    for (i = 0; i < size; i++) {
      vector_data[i] = 2.0 * hypre_Rand() - 1.0;
    }
  } else {
    HYPRE_Complex *h_data =
        hypre_TAlloc(HYPRE_Complex, size, HYPRE_MEMORY_HOST);
    for (i = 0; i < size; i++) {
      h_data[i] = 2.0 * hypre_Rand() - 1.0;
    }
    hypre_TMemcpy(vector_data, h_data, HYPRE_Complex, size,
                  hypre_VectorMemoryLocation(v), HYPRE_MEMORY_HOST);
    hypre_TFree(h_data, HYPRE_MEMORY_HOST);
  }

  return ierr;
}
/*--------------------------------------------------------------------------
 * hypre_SeqVectorSetRandomValues
 *
 *     returns vector of values randomly distributed between -1.0 and +1.0
 *--------------------------------------------------------------------------*/
hypre_SeqVectorSetRandomValues
returns vector of values randomly distributed between -1.0 and +1.0
hypre_SeqVectorSetRandomValues returns vector of values randomly distributed between - 1 . 0 and + 1 . 0
HYPRE_Int hypre_SeqVectorSetRandomValues(hypre_Vector *v, HYPRE_Int seed) {
  HYPRE_Complex *vector_data = hypre_VectorData(v);
  HYPRE_Int size = hypre_VectorSize(v);
  HYPRE_Int i;
  HYPRE_Int ierr = 0;
  hypre_SeedRand(seed);
  size *= hypre_VectorNumVectors(v);
  if (hypre_GetActualMemLocation(hypre_VectorMemoryLocation(v)) ==
      hypre_MEMORY_HOST) {
    for (i = 0; i < size; i++) {
      vector_data[i] = 2.0 * hypre_Rand() - 1.0;
    }
  } else {
    HYPRE_Complex *h_data =
        hypre_TAlloc(HYPRE_Complex, size, HYPRE_MEMORY_HOST);
    for (i = 0; i < size; i++) {
      h_data[i] = 2.0 * hypre_Rand() - 1.0;
    }
    hypre_TMemcpy(vector_data, h_data, HYPRE_Complex, size,
                  hypre_VectorMemoryLocation(v), HYPRE_MEMORY_HOST);
    hypre_TFree(h_data, HYPRE_MEMORY_HOST);
  }
  return ierr;
}
HYPRE_Int hypre_SeqVectorSetRandomValues ( hypre_Vector * v , HYPRE_Int seed ) { HYPRE_Complex * vector_data = hypre_VectorData ( v ) ; HYPRE_Int size = hypre_VectorSize ( v ) ; HYPRE_Int i ; HYPRE_Int ierr = 0 ; hypre_SeedRand ( seed ) ; size *= hypre_VectorNumVectors ( v ) ; if ( hypre_GetActualMemLocation ( hypre_VectorMemoryLocation ( v ) ) == hypre_MEMORY_HOST ) { for ( i = 0 ; i < size ; i ++ ) { vector_data [ i ] = 2.0 * hypre_Rand ( ) - 1.0 ; } } else { HYPRE_Complex * h_data = hypre_TAlloc ( HYPRE_Complex , size , HYPRE_MEMORY_HOST ) ; for ( i = 0 ; i < size ; i ++ ) { h_data [ i ] = 2.0 * hypre_Rand ( ) - 1.0 ; } hypre_TMemcpy ( vector_data , h_data , HYPRE_Complex , size , hypre_VectorMemoryLocation ( v ) , HYPRE_MEMORY_HOST ) ; hypre_TFree ( h_data , HYPRE_MEMORY_HOST ) ; } return ierr ; }
hypre_SeqVectorSetRandomValues
     returns vector of values randomly distributed between -1.0 and +1.0
hypre_SeqVectorSetRandomValues returns vector of values randomly distributed between - 1 . 0 and + 1 . 0
/* RDF: threading this loop may cause problems because of hypre_Rand() */