Xmipp  v3.23.11-Nereus
Public Member Functions | Protected Attributes | Friends | List of all members

#include <som.h>

Public Member Functions

 Descent (const double _initial=1, const double _final=0)
 
virtual ~Descent ()
 
virtual double operator() (const unsigned _step, const unsigned _nSteps) const
 
virtual void printSelf (std::ostream &_os) const
 
virtual void readSelf (std::istream &_is)
 
virtual void saveObject (std::ostream &_os) const
 
virtual void loadObject (std::istream &_is)
 

Protected Attributes

double initial
 
double final
 

Friends

std::ostream & operator<< (std::ostream &_os, const Descent &_desc)
 
std::istream & operator>> (std::istream &_is, Descent &_desc)
 

Detailed Description

This class implements a descent from an initial value to a final one in a number of steps. The transition is linear by default. It's used to decrease alpha and the radius of neighborhood during training of SOM.

Definition at line 48 of file som.h.

Constructor & Destructor Documentation

◆ Descent()

Descent::Descent ( const double  _initial = 1,
const double  _final = 0 
)
inline

Constructor Parameter: _initial Parameter: _final

Definition at line 56 of file som.h.

57  : initial(_initial), final(_final)
58  {}
double initial
Definition: som.h:123

◆ ~Descent()

virtual Descent::~Descent ( )
inlinevirtual

Destructor

Definition at line 62 of file som.h.

62 {}

Member Function Documentation

◆ loadObject()

void Descent::loadObject ( std::istream &  _is)
virtual

Loads the Descent class from a stream. this method can be used to load the status of the class. Parameter: _is The output stream

Definition at line 325 of file som.cpp.

326 {
327  readSelf(_is);
328 }
virtual void readSelf(std::istream &_is)
Definition: som.cpp:290

◆ operator()()

double Descent::operator() ( const unsigned  _step,
const unsigned  _nSteps 
) const
virtual

Returns the function value associated a step if the transition from the initial value to the final value es made in _nSteps steps Parameter: _step The actual step Parameter: _nsteps The number of steps to reach the final val from the initial one

Definition at line 266 of file som.cpp.

267 {
268  if (_nSteps == 0 || initial == final || _step >= _nSteps)
269  return final;
270  else
271  return final + ((initial - final) *
272  ((double)(_nSteps - _step) / (double)_nSteps));
273 }
double initial
Definition: som.h:123

◆ printSelf()

void Descent::printSelf ( std::ostream &  _os) const
virtual

Standard output for a Descent class Parameter: _os The output stream

Definition at line 280 of file som.cpp.

281 {
282  _os << initial << std::endl;
283  _os << final << std::endl;
284 }
double initial
Definition: som.h:123

◆ readSelf()

void Descent::readSelf ( std::istream &  _is)
virtual

Standard input for a Descent class Parameter: _is The input stream

Definition at line 290 of file som.cpp.

291 {
292  try
293  {
294  if (_is)
295  _is >> initial;
296  if (_is)
297  _is >> final;
298  }
299  catch (std::exception& e)
300  {
301  std::stringstream msg;
302  msg << e.what() << std::endl << "Error reading Descent class";
303  throw std::runtime_error(msg.str());
304  }
305 
306 }
double initial
Definition: som.h:123

◆ saveObject()

void Descent::saveObject ( std::ostream &  _os) const
virtual

Saves the Descent class into a stream. this method can be used to save the status of the class. Parameter: _os The output stream

Definition at line 314 of file som.cpp.

315 {
316  printSelf(_os);
317 }
virtual void printSelf(std::ostream &_os) const
Definition: som.cpp:280

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  _os,
const Descent _desc 
)
friend

Standard output for a Descent class Parameter: _os The output stream Parameter: _desc The class

Definition at line 108 of file som.h.

109  {
110  _desc.printSelf(_os);
111  return _os;
112  };
virtual void printSelf(std::ostream &_os) const
Definition: som.cpp:280

◆ operator>>

std::istream& operator>> ( std::istream &  _is,
Descent _desc 
)
friend

Standard input for a Descent class Parameter: _is The input stream Parameter: _desc The class

Definition at line 119 of file som.h.

120  {
121  _desc.readSelf(_is);
122  return _is;
123  };
virtual void readSelf(std::istream &_is)
Definition: som.cpp:290

Member Data Documentation

◆ final

double Descent::final
protected

Definition at line 128 of file som.h.

◆ initial

double Descent::initial
protected

Definition at line 123 of file som.h.


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