MCPcopy Create free account
hub / github.com/PX4/eigen / main

Function main

bench/sparse_setter.cpp:61–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59EIGEN_DONT_INLINE Scalar* setrand_mtl(const Coordinates& coords, const Values& vals);
60
61int main(int argc, char *argv[])
62{
63 int rows = SIZE;
64 int cols = SIZE;
65 bool fullyrand = true;
66
67 BenchTimer timer;
68 Coordinates coords;
69 Values values;
70 if(fullyrand)
71 {
72 Coordinates pool;
73 pool.reserve(cols*NBPERROW);
74 std::cerr << "fill pool" << "\n";
75 for (int i=0; i<cols*NBPERROW; )
76 {
77// DynamicSparseMatrix<int> stencil(SIZE,SIZE);
78 Vector2i ij(internal::random<int>(0,rows-1),internal::random<int>(0,cols-1));
79// if(stencil.coeffRef(ij.x(), ij.y())==0)
80 {
81// stencil.coeffRef(ij.x(), ij.y()) = 1;
82 pool.push_back(ij);
83
84 }
85 ++i;
86 }
87 std::cerr << "pool ok" << "\n";
88 int n = cols*NBPERROW*KK;
89 coords.reserve(n);
90 values.reserve(n);
91 for (int i=0; i<n; ++i)
92 {
93 int i = internal::random<int>(0,pool.size());
94 coords.push_back(pool[i]);
95 values.push_back(internal::random<Scalar>());
96 }
97 }
98 else
99 {
100 for (int j=0; j<cols; ++j)
101 for (int i=0; i<NBPERROW; ++i)
102 {
103 coords.push_back(Vector2i(internal::random<int>(0,rows-1),j));
104 values.push_back(internal::random<Scalar>());
105 }
106 }
107 std::cout << "nnz = " << coords.size() << "\n";
108 CHECK_MEM
109
110 // dense matrices
111 #ifdef DENSEMATRIX
112 {
113 BENCH(setrand_eigen_dense(coords,values);)
114 std::cout << "Eigen Dense\t" << timer.value() << "\n";
115 }
116 #endif
117
118 // eigen sparse matrices

Callers

nothing calls this directly

Calls 10

setrand_eigen_dynamicFunction · 0.85
setrand_eigen_sumeqFunction · 0.85
setrand_scipyFunction · 0.85
setrand_ublas_genvecFunction · 0.85
reserveMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected