DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testLabelledMap-benchmark.cpp
1 
29 //#define TRACE_BITS
30 
31 #include <cstdio>
32 #include <cmath>
33 #include <iostream>
34 #include <algorithm>
35 #include <vector>
36 #include <map>
37 #ifdef CPP11_FORWARD_LIST
38 #include <forward_list>
39 #endif
40 #include <boost/version.hpp>
41 #include <boost/random/mersenne_twister.hpp>
42 #include <boost/random/uniform_smallint.hpp>
43 #include <boost/random/uniform_01.hpp>
44 #include <boost/random/geometric_distribution.hpp>
45 #include <boost/random/variate_generator.hpp>
46 
47 #include "DGtal/base/Common.h"
48 #include "DGtal/base/LabelledMap.h"
49 
50 // Before 1.47, random number generation in boost.
51 // Since 1.47, random number generation in boost::random.
52 #define BOOST_MAJOR_VERSION (BOOST_VERSION / 100000)
53 #define BOOST_MINOR_VERSION (( BOOST_VERSION / 100) % 1000)
54 #define BOOST_SUBMINOR_VERSION (BOOST_VERSION % 100)
55 
56 
57 using namespace DGtal;
58 using namespace std;
59 
60 // A comparer en 2D
61 // Array[L][X][Y] of value
62 // Array[X][Y] of map<L,Value>
63 // map< <L,X,Y>, Value>
64 // Array[X][Y] of LabelledMap<L>
65 // Array[X][Y] of forward_list< pair<L, Value> >
66 
74 template <typename Value, unsigned int L, unsigned int X, unsigned int Y>
75 class ArrayLXY {
76  Value _data[ L ][ X ][ Y ];
77  Value _invalid;
78 
79 public:
80  inline
81  ArrayLXY( Value invalid )
82  {
83  _invalid = invalid;
84  clear();
85  }
86 
87  inline
88  void clear()
89  {
90  for ( unsigned int l = 0; l < L; ++l )
91  for ( unsigned int y = 0; y < Y; ++y )
92  for ( unsigned int x = 0; x < X; ++x )
93  setValue( _invalid, l, x, y );
94  }
95 
96  inline
97  const Value & value( unsigned int l, unsigned int x, unsigned int y ) const
98  {
99  return _data[ l ][ x ][ y ];
100  }
101  inline
102  unsigned int erase( unsigned int l, unsigned int x, unsigned int y )
103  {
104  if ( _data[ l ][ x ][ y ] != _invalid )
105  {
106  _data[ l ][ x ][ y ] = _invalid;
107  return 1;
108  }
109  return 0;
110  }
111 
112  inline
113  void setValue( const Value & val, unsigned int l, unsigned int x, unsigned int y )
114  {
115  _data[ l ][ x ][ y ] = val;
116  }
117  inline
118  void setValueNoNewLabel( const Value & val, unsigned int l, unsigned int x, unsigned int y )
119  {
120  _data[ l ][ x ][ y ] = val;
121  }
122  inline
123  bool hasLabel( unsigned int l, unsigned int x, unsigned int y ) const
124  {
125  return value( l, x, y ) != _invalid;
126  }
127  inline
128  void getLabels( std::vector<unsigned int> & labels,
129  unsigned int x, unsigned int y ) const
130  {
131  labels.clear();
132  for ( unsigned int l = 0; l < L; ++l )
133  if ( hasLabel( l, x, y ) )
134  labels.push_back( l );
135  }
136  inline
137  unsigned int nbLabels( unsigned int x, unsigned int y ) const
138  {
139  unsigned int nb = 0;
140  for ( unsigned int l = 0; l < L; ++l )
141  if ( hasLabel( l, x, y ) ) ++nb;
142  return nb;
143  }
144  inline
145  void display ( ostream & out, unsigned int l, unsigned int x, unsigned int y )
146  {}
147 
148  inline
149  unsigned long long area() const
150  {
151  return L * X * Y * sizeof( Value );
152  }
153 };
154 
162 template <typename Value, unsigned int L, unsigned int X, unsigned int Y>
164  typedef typename std::map<unsigned int, Value> MyMap;
165  typedef typename MyMap::const_iterator ConstIterator;
166  MyMap _data[ X ][ Y ];
167 
168 public:
169  inline
171  {
172  }
173 
174  inline
175  void clear()
176  {
177  for ( unsigned int y = 0; y < Y; ++y )
178  for ( unsigned int x = 0; x < X; ++x )
179  _data[ x ][ y ].clear();
180  }
181 
182  inline
183  const Value & value( unsigned int l, unsigned int x, unsigned int y )
184  {
185  return _data[ x ][ y ][ l ];
186  }
187  inline
188  unsigned int erase( unsigned int l, unsigned int x, unsigned int y )
189  {
190  return _data[ x ][ y ].erase( l );
191  }
192 
193  inline
194  void setValue( const Value & val, unsigned int l, unsigned int x, unsigned int y )
195  {
196  _data[ x ][ y ][ l ] = val;
197  }
198  inline
199  void setValueNoNewLabel( const Value & val, unsigned int l, unsigned int x, unsigned int y )
200  {
201  _data[ x ][ y ][ l ] = val;
202  }
203  inline
204  bool hasLabel( unsigned int l, unsigned int x, unsigned int y ) const
205  {
206  return _data[ x ][ y ].count( l ) != 0;
207  }
208  inline
209  void getLabels( std::vector<unsigned int> & labels,
210  unsigned int x, unsigned int y ) const
211  {
212  labels.clear();
213  for ( ConstIterator it = _data[ x ][ y ].begin(), it_end = _data[ x ][ y ].end();
214  it != it_end; ++it )
215  labels.push_back( (*it).first );
216  }
217  inline
218  unsigned int nbLabels( unsigned int x, unsigned int y ) const
219  {
220  return _data[ x ][ y ].size();
221  }
222  inline
223  void display ( ostream & out, unsigned int l, unsigned int x, unsigned int y )
224  {}
225 
226 
227  inline
228  unsigned long long area() const
229  {
230  unsigned long long total = 0;
231  for ( unsigned int y = 0; y < Y; ++y )
232  for ( unsigned int x = 0; x < X; ++x )
233  {
234  unsigned int size = nbLabels( x, y );
235  total += ( size + 1 ) *
236  ( sizeof( Value ) // one value per node
237  + 3 * sizeof( Value* ) // three pointers
238  + 2 //_RbTreeColor { _S_red = false, _S_black = true };
239  + 8 // dynamic allocation );
240  );
241  }
242  return total;
243  }
244 };
245 
246 
247 #ifdef CPP11_FORWARD_LIST
248 
259 template <typename Value, unsigned int L, unsigned int X, unsigned int Y>
260 class ArrayXYOfList {
261  typedef typename std::pair<uint16_t, Value> MyPair;
262  typedef typename std::forward_list<MyPair> MyList;
263  typedef typename MyList::iterator Iterator;
264  typedef typename MyList::const_iterator ConstIterator;
265  MyList _data[ X ][ Y ];
266 
267 public:
268  inline
269  ArrayXYOfList()
270  {
271  }
272 
273  inline
274  void clear()
275  {
276  for ( unsigned int y = 0; y < Y; ++y )
277  for ( unsigned int x = 0; x < X; ++x )
278  _data[ x ][ y ].clear();
279  }
280 
281  inline
282  const Value & value( unsigned int l, unsigned int x, unsigned int y )
283  {
284  MyList & list = _data[ x ][ y ];
285  Iterator it = list.begin(), it_end = list.end();
286  for ( ; it != it_end; ++it )
287  {
288  if ( it->first == l ) return it->second;
289  }
290  ASSERT ( it == it_end ) ;
291  list.emplace_front( std::make_pair( l, Value() ) );
292  return list.front().second;
293  }
294  inline
295  unsigned int erase( unsigned int l, unsigned int x, unsigned int y )
296  {
297  MyList & list = _data[ x ][ y ];
298  Iterator it_prev = list.before_begin();
299  Iterator it = list.begin(), it_end = list.end();
300  for ( ; it != it_end; ++it )
301  {
302  if ( it->first == l )
303  {
304  list.erase_after( it_prev );
305  return 1;
306  }
307  it_prev = it;
308  }
309  return 0;
310  }
311 
312  inline
313  void setValue( const Value & val, unsigned int l, unsigned int x, unsigned int y )
314  {
315  MyList & list = _data[ x ][ y ];
316  Iterator it = list.begin(), it_end = list.end();
317  for ( ; it != it_end; ++it )
318  {
319  if ( it->first == l )
320  {
321  it->second = val;
322  return;
323  }
324  }
325  if ( it == it_end )
326  list.emplace_front( std::make_pair( l, val ) );
327  }
328  inline
329  void setValueNoNewLabel( const Value & val, unsigned int l, unsigned int x, unsigned int y )
330  {
331  MyList & list = _data[ x ][ y ];
332  Iterator it = list.begin(), it_end = list.end();
333  for ( ; it != it_end; ++it )
334  {
335  if ( it->first == l )
336  {
337  it->second = val;
338  return;
339  }
340  }
341  if ( it == it_end )
342  list.emplace_front( std::make_pair( l, val ) );
343  }
344  inline
345  bool hasLabel( unsigned int l, unsigned int x, unsigned int y ) const
346  {
347  const MyList & list = _data[ x ][ y ];
348  ConstIterator it = list.begin(), it_end = list.end();
349  for ( ; it != it_end; ++it )
350  {
351  if ( it->first == l ) return true;
352  }
353  return false;
354  }
355  inline
356  void getLabels( std::vector<unsigned int> & labels,
357  unsigned int x, unsigned int y ) const
358  {
359  labels.clear();
360  const MyList & list = _data[ x ][ y ];
361  ConstIterator it = list.begin(), it_end = list.end();
362  for ( ; it != it_end; ++it )
363  {
364  labels.push_back( (*it).first );
365  }
366  }
367  inline
368  unsigned int nbLabels( unsigned int x, unsigned int y ) const
369  {
370  const MyList & list = _data[ x ][ y ];
371  ConstIterator it = list.begin(), it_end = list.end();
372  unsigned int n = 0;
373  for ( ; it != it_end; ++it )
374  ++n;
375  return n;
376  }
377  inline
378  void display ( ostream & out, unsigned int l, unsigned int x, unsigned int y )
379  {}
380 
381 
382  inline
383  unsigned long long area() const
384  {
385  unsigned long long total = 0;
386  for ( unsigned int y = 0; y < Y; ++y )
387  for ( unsigned int x = 0; x < X; ++x )
388  {
389  unsigned int size = nbLabels( x, y );
390  total += sizeof( Value* )
391  + ( size ) *
392  ( sizeof( Value ) // one value per node
393  + sizeof( Value* ) // one pointers
394  + 2 // uint16_t
395  + 8 // dynamic allocation );
396  );
397  }
398  return total;
399  }
400 };
401 
402 #endif
403 
415 template < typename Value, unsigned int L, unsigned int X, unsigned int Y,
416  typename TWord, unsigned int N, unsigned int M >
419  MyLabelledMap _data[ X ][ Y ];
420 
421 public:
422  inline
424 
425  inline
426  const Value & value( unsigned int l, unsigned int x, unsigned int y ) const
427  {
428  return _data[ x ][ y ].fastAt( l );
429  }
430 
431  inline
432  void setValue( const Value & val, unsigned int l, unsigned int x, unsigned int y )
433  {
434  _data[ x ][ y ][ l ] = val;
435  }
436 
437  inline
438  unsigned int erase( unsigned int l, unsigned int x, unsigned int y )
439  {
440  return _data[ x ][ y ].erase( l );
441  }
442 
443  inline
444  void setValueNoNewLabel( const Value & val, unsigned int l, unsigned int x, unsigned int y )
445  {
446  _data[ x ][ y ].fastAt( l ) = val;
447  }
448 
449  inline
450  bool hasLabel( unsigned int l, unsigned int x, unsigned int y ) const
451  {
452  return _data[ x ][ y ].count( l );
453  }
454 
455  inline
456  void getLabels( std::vector<unsigned int> & labels,
457  unsigned int x, unsigned int y ) const
458  {
459  _data[ x ][ y ].labels().getLabels( labels );
460  }
461 
462  inline
463  unsigned int nbLabels( unsigned int x, unsigned int y ) const
464  {
465  return _data[ x ][ y ].size();
466  }
467  inline void display ( ostream & out, unsigned int l, unsigned int x, unsigned int y )
468  {
469  std::cerr << _data[ x ][ y ] << endl;
470  }
471 
472  inline
473  unsigned long long area() const
474  {
475  unsigned long long total = 0;
476  for ( unsigned int y = 0; y < Y; ++y )
477  for ( unsigned int x = 0; x < X; ++x )
478  {
479  unsigned int size = nbLabels( x, y );
480  total += sizeof( MyLabelledMap );
481  if ( size > (N+1) )
482  total += ( 1 + ( size - N - 1 ) / M ) * ( M * sizeof( Value ) + 8 );
483  }
484  return total;
485  }
486 
487 };
488 
489 // boost::random is different since 1.47
490 #if (BOOST_MAJOR_VERSION >= 1 ) && (BOOST_MINOR_VERSION >= 47 )
491 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
492 unsigned int
493 generateData( MapLXY & m, double proba_no_label, double proba_label )
494 {
495  boost::random::mt19937 rng; // produces randomness out of thin air
496  rng.seed( 0 );
497  boost::random::uniform_smallint<> diceL(0, L-1);
498  boost::random::uniform_01<> diceDouble;
499  boost::random::geometric_distribution<> diceNbLabels( proba_label ); // Y
500  // E(Y) = (1-p)/p, Var(Y) = (1-p)/p^2
501  std::cerr << "E(Y)=" << ( (1-proba_label)/proba_label )
502  << " Var(Y)=" << ( (1-proba_label)/(proba_label*proba_label) )
503  << std::endl;
504  unsigned int total = 0;
505  for ( unsigned int y = 0; y < Y; ++y )
506  for ( unsigned int x = 0; x < X; ++x )
507  {
508  if ( diceDouble( rng ) >= proba_no_label )
509  {
510  unsigned int nb = diceNbLabels( rng );
511  for ( unsigned int i = 0; i < nb; ++i )
512  {
513  unsigned int l = diceL( rng );
514  double v = diceDouble( rng );
515  m.setValue( v, l, x, y );
516  }
517  total += nb;
518  }
519  }
520  std::cerr << "- " << total << " insertions." << endl;
521  return total;
522 }
523 #else
524 // boost::random is different since 1.47, below <= 1.46
525 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
526 unsigned int
527 generateData( MapLXY & m, double proba_no_label, double proba_label )
528 {
529  boost::mt19937 rng; // produces randomness out of thin air
530  rng.seed( 0 );
531  boost::uniform_smallint<> diceL(0, L-1);
532  boost::uniform_01<> diceDouble;
533  boost::geometric_distribution<> nbLabelsDist( proba_label ); // Y
534  boost::variate_generator
535  <boost::mt19937&,
536  boost::geometric_distribution<> > diceNbLabels( rng, nbLabelsDist);
537  // E(Y) = (1-p)/p, Var(Y) = (1-p)/p^2
538  std::cerr << "E(Y)=" << ( (1-proba_label)/proba_label )
539  << " Var(Y)=" << ( (1-proba_label)/(proba_label*proba_label) )
540  << std::endl;
541  unsigned int total = 0;
542  for ( unsigned int y = 0; y < Y; ++y )
543  for ( unsigned int x = 0; x < X; ++x )
544  {
545  if ( diceDouble( rng ) >= proba_no_label )
546  {
547  unsigned int nb = diceNbLabels();
548  for ( unsigned int i = 0; i < nb; ++i )
549  {
550  unsigned int l = diceL( rng );
551  double v = diceDouble( rng );
552  m.setValue( v, l, x, y );
553  }
554  total += nb;
555  }
556  }
557  std::cerr << "- " << total << " insertions." << endl;
558  return total;
559 }
560 #endif
561 
562 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
563 double
564 sumAllData( MapLXY & m )
565 {
566  double sum = 0.0;
567  std::vector<unsigned int> labels;
568  for ( unsigned int y = 0; y < Y; ++y )
569  for ( unsigned int x = 0; x < X; ++x )
570  {
571  m.getLabels( labels, x, y );
572  for ( unsigned int i = 0; i < labels.size(); ++i )
573  sum += m.value( labels[ i ], x, y );
574  }
575  std::cerr << "- sum = " << sum << "." << endl;
576  return sum;
577 }
578 
579 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
580 double
581 sumOneData( MapLXY & m, unsigned int l )
582 {
583  double sum = 0.0;
584  for ( unsigned int y = 0; y < Y; ++y )
585  for ( unsigned int x = 0; x < X; ++x )
586  {
587  if ( m.hasLabel( l, x, y ) )
588  sum += m.value( l, x, y );
589  }
590  std::cerr << "- sum = " << sum << "." << endl;
591  return sum;
592 }
593 
594 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
595 unsigned int
596 locateThreeData( MapLXY & m, unsigned int l1, unsigned int l2, unsigned int l3 )
597 {
598  unsigned int loc3 = 0;
599  for ( unsigned int y = 0; y < Y; ++y )
600  for ( unsigned int x = 0; x < X; ++x )
601  {
602  if ( ( m.hasLabel( l1, x, y ) )
603  && ( m.hasLabel( l2, x, y ) )
604  && ( m.hasLabel( l3, x, y ) ) )
605  ++loc3;
606  }
607  std::cerr << "- " << loc3 << " places with " << l1 << ", " << l2 << " ," << l3 << endl;
608  return loc3;
609 }
610 
611 template <typename MapLXY, unsigned int L, unsigned int X, unsigned int Y>
612 unsigned int
613 eraseOneData( MapLXY & m, unsigned int l )
614 {
615  unsigned int nb = 0;
616  for ( unsigned int y = 0; y < Y; ++y )
617  for ( unsigned int x = 0; x < X; ++x )
618  {
619  nb += m.erase( l, x, y );
620  }
621  std::cerr << "- " << nb << " values deleted." << endl;
622  return nb;
623 }
624 
625 int main()
626 {
627  typedef double Value;
628  static const unsigned int X = 100;
629  static const unsigned int Y = 100;
630  static const unsigned int L = 16;
631  typedef DGtal::uint8_t Word;
632  static const unsigned int N = 1;
633  static const unsigned int M = 5;
635  static const double PROBA_NO_LABEL = 0.75;
640  static const double PROBA_LABEL = 0.5;
641 
642  typedef ArrayLXY<Value, L, X, Y> MyArrayLXY;
643  typedef ArrayXYOfMap<Value, L, X, Y> MyArrayXYOfMap;
644 #if CPP11_FORWARD_LIST
645  typedef ArrayXYOfList<Value, L, X, Y> MyArrayXYOfList;
646 #endif
647  typedef ArrayXYOfLabelledMap<Value, L, X, Y, Word, N, M > MyArrayXYOfLabelledMap;
648 
649  //----------------------------------------------------------------------
650  trace.beginBlock ( "---------- ArrayLXY ---------------" );
651  trace.beginBlock ( "Generating ArrayLXY" );
652  MyArrayLXY* arrayLXY = new MyArrayLXY( -1.0 );
653  generateData< MyArrayLXY, L, X, Y> ( *arrayLXY, PROBA_NO_LABEL, PROBA_LABEL );
654  trace.endBlock();
655 
656  trace.beginBlock ( "Memory usage in ArrayLXY" );
657  std::cerr << arrayLXY->area() << " bytes." << std::endl;
658  trace.endBlock();
659 
660  trace.beginBlock ( "Sum all values ArrayLXY" );
661  sumAllData< MyArrayLXY, L, X, Y> ( *arrayLXY );
662  trace.endBlock();
663 
664  trace.beginBlock ( "Sum label 0 values ArrayLXY" );
665  sumOneData< MyArrayLXY, L, X, Y> ( *arrayLXY, 0 );
666  trace.endBlock();
667 
668  trace.beginBlock ( "Sum label 15 values ArrayLXY" );
669  sumOneData< MyArrayLXY, L, X, Y> ( *arrayLXY, 15 );
670  trace.endBlock();
671 
672  trace.beginBlock ( "Locate places (3, 7, 8) in ArrayLXY" );
673  locateThreeData< MyArrayLXY, L, X, Y> ( *arrayLXY, 3, 7, 8 );
674  trace.endBlock();
675 
676  trace.beginBlock ( "Erase label 9 in ArrayLXY" );
677  eraseOneData< MyArrayLXY, L, X, Y> ( *arrayLXY, 9 );
678  trace.endBlock();
679 
680  trace.beginBlock ( "Delete ArrayLXY" );
681  delete arrayLXY;
682  trace.endBlock();
683  trace.endBlock();
684 
685  //----------------------------------------------------------------------
686  trace.beginBlock ( "---------- ArrayXYOfMap ---------------" );
687  trace.beginBlock ( "Generating ArrayXYOfMap" );
688  MyArrayXYOfMap* arrayXYOfMap = new MyArrayXYOfMap();
689  generateData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap, PROBA_NO_LABEL, PROBA_LABEL );
690  trace.endBlock();
691 
692  trace.beginBlock ( "Memory usage in ArrayXYOfMap" );
693  std::cerr << arrayXYOfMap->area() << " bytes." << std::endl;
694  trace.endBlock();
695 
696  trace.beginBlock ( "Sum all values ArrayXYOfMap" );
697  sumAllData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap );
698  trace.endBlock();
699 
700  trace.beginBlock ( "Sum label 0 values ArrayXYOfMap" );
701  sumOneData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap, 0 );
702  trace.endBlock();
703 
704  trace.beginBlock ( "Sum label 15 values ArrayXYOfMap" );
705  sumOneData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap, 15 );
706  trace.endBlock();
707 
708  trace.beginBlock ( "Locate places (3, 7, 8) in ArrayXYOfMap" );
709  locateThreeData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap, 3, 7, 8 );
710  trace.endBlock();
711 
712  trace.beginBlock ( "Erase label 9 in ArrayXYOfMap" );
713  eraseOneData< MyArrayXYOfMap, L, X, Y> ( *arrayXYOfMap, 9 );
714  trace.endBlock();
715 
716  trace.beginBlock ( "Delete ArrayXYOfMap" );
717  delete arrayXYOfMap;
718  trace.endBlock();
719  trace.endBlock();
720 
721 #if CPP11_FORWARD_LIST
722  //----------------------------------------------------------------------
723  trace.beginBlock ( "---------- ArrayXYOfList ---------------" );
724  trace.beginBlock ( "Generating ArrayXYOfList" );
725  MyArrayXYOfList* arrayXYOfList = new MyArrayXYOfList();
726  generateData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList, PROBA_NO_LABEL, PROBA_LABEL );
727  trace.endBlock();
728 
729  trace.beginBlock ( "Memory usage in ArrayXYOfList" );
730  std::cerr << arrayXYOfList->area() << " bytes." << std::endl;
731  trace.endBlock();
732 
733  trace.beginBlock ( "Sum all values ArrayXYOfList" );
734  sumAllData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList );
735  trace.endBlock();
736 
737  trace.beginBlock ( "Sum label 0 values ArrayXYOfList" );
738  sumOneData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList, 0 );
739  trace.endBlock();
740 
741  trace.beginBlock ( "Sum label 15 values ArrayXYOfList" );
742  sumOneData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList, 15 );
743  trace.endBlock();
744 
745  trace.beginBlock ( "Locate places (3, 7, 8) in ArrayXYOfList" );
746  locateThreeData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList, 3, 7, 8 );
747  trace.endBlock();
748 
749  trace.beginBlock ( "Erase label 9 in ArrayXYOfList" );
750  eraseOneData< MyArrayXYOfList, L, X, Y> ( *arrayXYOfList, 9 );
751  trace.endBlock();
752 
753  trace.beginBlock ( "Delete ArrayXYOfList" );
754  delete arrayXYOfList;
755  trace.endBlock();
756  trace.endBlock();
757 #endif
758 
759  //----------------------------------------------------------------------
760  trace.beginBlock ( "---------- ArrayXYOfLabelledMap ---------------" );
761  trace.beginBlock ( "Generating ArrayXYOfLabelledMap" );
762  MyArrayXYOfLabelledMap* arrayXYOfLabelledMap = new MyArrayXYOfLabelledMap;
763  generateData< MyArrayXYOfLabelledMap, L, X, Y > ( *arrayXYOfLabelledMap, PROBA_NO_LABEL, PROBA_LABEL );
764  trace.endBlock();
765 
766  trace.beginBlock ( "Memory usage in ArrayXYOfLabelledMap" );
767  std::cerr << arrayXYOfLabelledMap->area() << " bytes." << std::endl;
768  trace.endBlock();
769 
770  trace.beginBlock ( "Sum all values ArrayXYOfLabelledMap" );
771  sumAllData< MyArrayXYOfLabelledMap, L, X, Y> ( *arrayXYOfLabelledMap );
772  trace.endBlock();
773 
774  trace.beginBlock ( "Sum label 0 values ArrayXYOfLabelledMap" );
775  sumOneData< MyArrayXYOfLabelledMap, L, X, Y> ( *arrayXYOfLabelledMap, 0 );
776  trace.endBlock();
777 
778  trace.beginBlock ( "Sum label 15 values ArrayXYOfLabelledMap" );
779  sumOneData< MyArrayXYOfLabelledMap, L, X, Y> ( *arrayXYOfLabelledMap, 15 );
780  trace.endBlock();
781 
782  trace.beginBlock ( "Locate places (3, 7, 8) in ArrayXYOfLabelledMap" );
783  locateThreeData< MyArrayXYOfLabelledMap, L, X, Y> ( *arrayXYOfLabelledMap, 3, 7, 8 );
784  trace.endBlock();
785 
786  trace.beginBlock ( "Erase label 9 in ArrayXYOfLabelledMap" );
787  eraseOneData< MyArrayXYOfLabelledMap, L, X, Y> ( *arrayXYOfLabelledMap, 9 );
788  trace.endBlock();
789 
790  trace.beginBlock ( "Delete ArrayXYOfLabelledMap" );
791  delete arrayXYOfLabelledMap;
792  trace.endBlock();
793  trace.endBlock();
794 
795  return 0;
796 }