• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2018 Stefan Seefeld
3 // All rights reserved.
4 //
5 // This file is part of Boost.uBLAS. It is made available under the
6 // Boost Software License, Version 1.0.
7 // (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)
8 
9 #include <boost/numeric/ublas/vector.hpp>
10 #include <boost/numeric/ublas/matrix.hpp>
11 
12 namespace boost { namespace numeric { namespace ublas { namespace benchmark {
13 
14 template <typename T>
init(vector<T> & v,unsigned long size,int max_value)15 void init(vector<T> &v, unsigned long size, int max_value)
16 {
17   v = vector<T>(size);
18   for (unsigned long i = 0; i < v.size(); ++i)
19       v(i) = std::rand() % max_value;
20 }
21 
22 template <typename T, typename L>
init(matrix<T,L> & m,unsigned long size1,unsigned long size2,int max_value)23 void init(matrix<T, L> &m, unsigned long size1, unsigned long size2, int max_value)
24 {
25   m = matrix<T, L>(size1, size2);
26   for (unsigned long i = 0; i < m.size1(); ++i)
27     for (unsigned long j = 0; j < m.size2(); ++j)
28       m(i, j) = std::rand() % max_value;
29 }
30 
31 template <typename T, typename L>
init(matrix<T,L> & m,unsigned long size,int max_value)32 void init(matrix<T, L> &m, unsigned long size, int max_value)
33 {
34   return init(m, size, size, max_value);
35 }
36 
37 }}}}
38