Xmipp  v3.23.11-Nereus
Public Member Functions | Protected Member Functions | List of all members
RECTLayout Class Reference

#include <map.h>

Inheritance diagram for RECTLayout:
Inheritance graph
[legend]
Collaboration diagram for RECTLayout:
Collaboration graph
[legend]

Public Member Functions

 RECTLayout ()
 
virtual double dist (const SomPos &_center, const SomPos &_v) const
 
virtual void localAve (const FuzzyMap *_som, const SomPos &_center, std::vector< double > &_aveVector) const
 
virtual double numNeig (const FuzzyMap *_som, const SomPos &_center) const
 
- Public Member Functions inherited from Layout
 Layout (const std::string &_id="")
 
virtual ~Layout ()
 
std::vector< unsigned > neighborhood (const ClassificationMap *_som, const SomPos &_center, double _radius) const
 
std::vector< unsigned > neighborhood (const FuzzyMap *_som, const SomPos &_center, double _radius) const
 
virtual bool isIn (const SomPos &_center, const SomPos &_v, double _radius) const
 
const std::string & id () const
 

Protected Member Functions

 RECTLayout (const std::string &_id)
 

Detailed Description

This class manages a layout in this way:

RECTANGULAR:
O O O O O O O O O
O O O O & O O O O
O O O & @ & O O O
O O & @ + @ & O O
O O O & @ & O O O
O O O O & O O O O
O O O O O O O O O

Definition at line 673 of file map.h.

Constructor & Destructor Documentation

◆ RECTLayout() [1/2]

RECTLayout::RECTLayout ( )
inline

Generic constructor

Definition at line 680 of file map.h.

680  : Layout("rect")
681  {};
Layout(const std::string &_id="")
Definition: map.h:581

◆ RECTLayout() [2/2]

RECTLayout::RECTLayout ( const std::string &  _id)
inlineprotected

Definition at line 708 of file map.h.

708  : Layout(_id)
709  {};
Layout(const std::string &_id="")
Definition: map.h:581

Member Function Documentation

◆ dist()

double RECTLayout::dist ( const SomPos _center,
const SomPos _v 
) const
virtual

Returns the distance between two vectors in their given position Parameter: _center Position of the center of neighborhood Parameter: _v Position of the code vector

Implements Layout.

Definition at line 551 of file map.cpp.

552 {
553  return ((double) sqrt((double)(_center.first - _v.first)*(_center.first - _v.first) +
554  (_center.second - _v.second)*(_center.second - _v.second)));
555 }
void sqrt(Image< double > &op)

◆ localAve()

void RECTLayout::localAve ( const FuzzyMap _som,
const SomPos _center,
std::vector< double > &  _aveVector 
) const
virtual

Returns the local average of a neuron in a non-const reference. (average of the sourounding vectors) Parameter: _center Reference to the center of neighborhood Parameter: _aveVector: returns the average vector

Implements Layout.

Definition at line 563 of file map.cpp.

564 {
565  int j;
566  int dim = _som->itemAt(0).size();
567  double *ptrAveVector=&(_aveVector[0]);
568  memset(ptrAveVector,0,dim*sizeof(double));
569  int tmpi = _center.first;
570  int tmpj = _center.second;
571  int kk = 0;
572  if ((tmpi - 1) >= 0)
573  {
574  kk++;
575  const floatFeature *codevector=&(_som->itemAt(_som->PosToIndex(SomPos(tmpi - 1, tmpj)))[0]);
576  for (j = 0; j < dim; j++)
577  ptrAveVector[j] += codevector[j];
578  }
579  if ((tmpi + 1) < (int)_som->width())
580  {
581  kk++;
582  const floatFeature *codevector=&(_som->itemAt(_som->PosToIndex(SomPos(tmpi + 1, tmpj)))[0]);
583  for (j = 0; j < dim; j++)
584  ptrAveVector[j] += codevector[j];
585  }
586  if ((tmpj - 1) >= 0)
587  {
588  kk++;
589  const floatFeature *codevector=&(_som->itemAt(_som->PosToIndex(SomPos(tmpi, tmpj-1)))[0]);
590  for (j = 0; j < dim; j++)
591  ptrAveVector[j] += codevector[j];
592  }
593  if ((tmpj + 1) < (int)_som->height())
594  {
595  kk++;
596  const floatFeature *codevector=&(_som->itemAt(_som->PosToIndex(SomPos(tmpi, tmpj+1)))[0]);
597  for (j = 0; j < dim; j++)
598  ptrAveVector[j] += codevector[j];
599  }
600  if (_som->height() == 1 || _som->width() == 1)
601  for (j = 0; j < dim; j++)
602  ptrAveVector[j] *= 1.0/2.0;
603  else
604  for (j = 0; j < dim; j++)
605  ptrAveVector[j] *= 1.0/4.0;
606 }
float floatFeature
Definition: data_types.h:72
unsigned width() const
Definition: map.cpp:916
std::pair< long, long > SomPos
Definition: map.h:45
unsigned height() const
Definition: map.cpp:924
#define j
unsigned PosToIndex(const SomPos &_pos) const
Definition: map.cpp:1052
const Item & itemAt(unsigned _i) const
Definition: training_set.h:264

◆ numNeig()

double RECTLayout::numNeig ( const FuzzyMap _som,
const SomPos _center 
) const
virtual

Returns the average number of neighbors. Parameter: _center Reference to the center of neighborhood

Returns the average number of intermediate neighbors. Parameter: _center Reference to the center of neighborhood

Implements Layout.

Definition at line 612 of file map.cpp.

613 {
614  int tmpi = _center.first;
615  int tmpj = _center.second;
616  double kk = 0;
617  if ((tmpi - 1) >= 0)
618  {
619  kk++;
620  }
621  if ((tmpi + 1) < (int)_som->width())
622  {
623  kk++;
624  }
625  if ((tmpj - 1) >= 0)
626  {
627  kk++;
628  }
629  if ((tmpj + 1) < (int)_som->height())
630  {
631  kk++;
632  }
633  if (_som->height() == 1 || _som->width() == 1)
634  return (kk / 2.0);
635  else
636  return (kk / 4.0);
637 }
unsigned width() const
Definition: map.cpp:916
unsigned height() const
Definition: map.cpp:924

The documentation for this class was generated from the following files: