Example #1
0
 def random(self,
            count=1,
            distribution='uniform',
            random_state=None,
            seed=None,
            reserve=0,
            **kwargs):
     assert count >= 0
     assert reserve >= 0
     assert random_state is None or seed is None
     random_state = get_random_state(random_state, seed)
     va = self.zeros(count, reserve)
     va._array[:count] = _create_random_values(
         (count, self.dim), distribution, random_state, **kwargs)
     return va
Example #2
0
 def real_random_vector(self, distribution, random_state, **kwargs):
     impl = df.Function(self.V).vector()
     values = _create_random_values(impl.local_size(), distribution,
                                    random_state, **kwargs)
     impl[:] = np.ascontiguousarray(values)
     return FenicsVector(impl)
Example #3
0
 def real_random_vector(self, distribution, random_state, **kwargs):
     values = _create_random_values(self.dim, distribution, random_state,
                                    **kwargs)
     return self.real_vector_from_numpy(values)