File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
PhysicsTools/MVAComputer/src Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1919#include < iterator>
2020#include < vector>
2121#include < cmath>
22+ #include < cassert>
2223
2324#include " FWCore/Utilities/interface/Exception.h"
2425
@@ -100,14 +101,15 @@ namespace { // anonymous
100101 }
101102
102103 void ProcMLP::eval (ValueIterator iter, unsigned int n) const {
103- double *tmp = (double *)alloca (2 * maxTmp * sizeof (double ));
104+ double *tmp = (double *)calloc (2 * maxTmp, sizeof (double ));
104105 bool flip = false ;
105106
106107 for (double *pos = tmp; iter; iter++, pos++)
107108 *pos = *iter;
108109
109110 double *output = nullptr ;
110111 for (std::vector<Layer>::const_iterator layer = layers.begin (); layer != layers.end (); layer++, flip = !flip) {
112+ assert (maxTmp >= layer->inputs );
111113 const double *input = &tmp[flip ? maxTmp : 0 ];
112114 output = &tmp[flip ? 0 : maxTmp];
113115 std::vector<double >::const_iterator coeff = layer->coeffs .begin ();
@@ -123,6 +125,7 @@ namespace { // anonymous
123125
124126 for (const double *pos = &tmp[flip ? maxTmp : 0 ]; pos < output; pos++)
125127 iter (*pos);
128+ free (tmp);
126129 }
127130
128131 std::vector<double > ProcMLP::deriv (ValueIterator iter, unsigned int n) const {
You can’t perform that action at this time.
0 commit comments