Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
mcal_general_ca Class Reference

Class to perform general Component Analysis. More...

#include <mcal_general_ca.h>

Inheritance diagram for mcal_general_ca:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 mcal_general_ca ()
 Dflt ctor.
virtual ~mcal_general_ca ()
 Destructor.
void set (const mcal_component_analyzer &initial_ca, const mcal_single_basis_cost &basis_cost)
 Initialise, taking clones of supplied objects.
mcal_component_analyzerinitial_ca ()
 Object to perform initial component analysis (usually PCA).
mcal_single_basis_costbasis_cost ()
 Object to evaluate component of cost associated with each basis vector.
virtual void build_about_mean (mbl_data_wrapper< vnl_vector< double > > &data, const vnl_vector< double > &mean, vnl_matrix< double > &modes, vnl_vector< double > &mode_var)
 Compute modes of the supplied data relative to the supplied mean.
short version_no () const
 Version number for I/O.
virtual vcl_string is_a () const
 Name of the class.
virtual mcal_component_analyzerclone () const
 Create a copy on the heap and return base class pointer.
virtual void print_summary (vcl_ostream &os) const
 Print class to os.
virtual void b_write (vsl_b_ostream &bfs) const
 Save class to binary file stream.
virtual void b_read (vsl_b_istream &bfs)
 Load class from binary file stream.
virtual void config_from_stream (vcl_istream &is)
 Read initialisation settings from a stream.
void compute_mean (mbl_data_wrapper< vnl_vector< double > > &data, vnl_vector< double > &mean)
 Compute the mean of the supplied data.
virtual void build (mbl_data_wrapper< vnl_vector< double > > &data, vnl_vector< double > &mean, vnl_matrix< double > &modes, vnl_vector< double > &mode_var)
 Compute mean and modes from the supplied data.
virtual void build_from_array (const vnl_vector< double > *data, int n, vnl_vector< double > &mean, vnl_matrix< double > &modes, vnl_vector< double > &mode_var)
 Build mean and modes from data in array data[0..n-1].

Static Public Member Functions

static vcl_auto_ptr
< mcal_component_analyzer
create_from_stream (vcl_istream &is)
 Create a concrete mcal_component_analyzer object, from a text specification.

Private Member Functions

double optimise_mode_pair (vnl_vector< double > &proj1, vnl_vector< double > &proj2, vnl_vector< double > &mode1, vnl_vector< double > &mode2)
 Optimise the mode vectors so as to minimise the cost function.
double optimise_one_pass (vcl_vector< vnl_vector< double > > &proj, vnl_matrix< double > &modes)
 Optimise the mode vectors so as to minimise the cost function.
void optimise_about_mean (mbl_data_wrapper< vnl_vector< double > > &data, const vnl_vector< double > &mean, vnl_matrix< double > &modes, vnl_vector< double > &mode_var)
 Optimise the mode vectors so as to minimise the cost function.
void compute_projections (mbl_data_wrapper< vnl_vector< double > > &data, const vnl_vector< double > &mean, vnl_matrix< double > &modes, vcl_vector< vnl_vector< double > > &proj)
 Compute projections onto each mode.
void set_defaults ()
 Set parameters to default values.

Private Attributes

mbl_cloneable_ptr
< mcal_component_analyzer
initial_ca_
 Object to perform initial component analysis (usually PCA).
mbl_cloneable_ptr
< mcal_single_basis_cost
basis_cost_
 Object to evaluate component of cost associated with each basis vector.
unsigned max_passes_
 Maximum number of passes during optimisation.
double move_thresh_
 Threshold on angular movement, used to terminate optimisation.

Detailed Description

Class to perform general Component Analysis.

After an initial component analysis, this rotates pairs of basis vectors so as to optimise an objective function, which includes terms to do with the basis vectors themselves.

It assumes that the initial components are orthogonal.

Definition at line 22 of file mcal_general_ca.h.


Constructor & Destructor Documentation

mcal_general_ca::mcal_general_ca ( )

Dflt ctor.

Definition at line 26 of file mcal_general_ca.cxx.

mcal_general_ca::~mcal_general_ca ( ) [virtual]

Destructor.

Definition at line 49 of file mcal_general_ca.cxx.


Member Function Documentation

void mcal_general_ca::b_read ( vsl_b_istream bfs) [virtual]

Load class from binary file stream.

Implements mcal_component_analyzer.

Definition at line 374 of file mcal_general_ca.cxx.

void mcal_general_ca::b_write ( vsl_b_ostream bfs) const [virtual]

Save class to binary file stream.

Implements mcal_component_analyzer.

Definition at line 361 of file mcal_general_ca.cxx.

mcal_single_basis_cost& mcal_general_ca::basis_cost ( ) [inline]

Object to evaluate component of cost associated with each basis vector.

Definition at line 78 of file mcal_general_ca.h.

void mcal_component_analyzer::build ( mbl_data_wrapper< vnl_vector< double > > &  data,
vnl_vector< double > &  mean,
vnl_matrix< double > &  modes,
vnl_vector< double > &  mode_var 
) [virtual, inherited]

Compute mean and modes from the supplied data.

Model is x = mean + modes*b, where b is a vector of weights on each mode. mode_var[i] gives the variance of the data projected onto that mode. Default computes the mean, then calls build_about_mean

Computes the mean, then calls build_about_mean

Definition at line 41 of file mcal_component_analyzer.cxx.

void mcal_general_ca::build_about_mean ( mbl_data_wrapper< vnl_vector< double > > &  data,
const vnl_vector< double > &  mean,
vnl_matrix< double > &  modes,
vnl_vector< double > &  mode_var 
) [virtual]

Compute modes of the supplied data relative to the supplied mean.

Model is x = mean + modes*b, where b is a vector of weights on each mode. mode_var[i] gives the variance of the data projected onto that mode.

Implements mcal_component_analyzer.

Definition at line 284 of file mcal_general_ca.cxx.

void mcal_component_analyzer::build_from_array ( const vnl_vector< double > *  data,
int  n,
vnl_vector< double > &  mean,
vnl_matrix< double > &  modes,
vnl_vector< double > &  mode_var 
) [virtual, inherited]

Build mean and modes from data in array data[0..n-1].

Utility function - wraps data and uses build(data,mean,modes)

Definition at line 51 of file mcal_component_analyzer.cxx.

mcal_component_analyzer * mcal_general_ca::clone ( ) const [virtual]

Create a copy on the heap and return base class pointer.

Implements mcal_component_analyzer.

Definition at line 338 of file mcal_general_ca.cxx.

void mcal_component_analyzer::compute_mean ( mbl_data_wrapper< vnl_vector< double > > &  data,
vnl_vector< double > &  mean 
) [inherited]

Compute the mean of the supplied data.

Definition at line 25 of file mcal_component_analyzer.cxx.

void mcal_general_ca::compute_projections ( mbl_data_wrapper< vnl_vector< double > > &  data,
const vnl_vector< double > &  mean,
vnl_matrix< double > &  modes,
vcl_vector< vnl_vector< double > > &  proj 
) [private]

Compute projections onto each mode.

proj[j][i] is the projection of the i-th data sample onto the j-th mode

Definition at line 235 of file mcal_general_ca.cxx.

void mcal_general_ca::config_from_stream ( vcl_istream &  is) [virtual]

Read initialisation settings from a stream.

Parameters:

   {
     initial_ca: mcal_pca { ... }
     basis_cost: mcal_sparse_basis_cost { alpha: 0.1 }
     max_passes: 50
     move_thresh: 0.0001
   }
   
Exceptions:
mbl_exception_parse_errorif the parse fails.

Parameters:

   {
     initial_ca: mcal_pca { ... }
     basis_cost: mcal_sparse_basis_cost { alpha: 0.1 }
   }
   
Exceptions:
mbl_exception_parse_errorif the parse fails.

Reimplemented from mcal_component_analyzer.

Definition at line 403 of file mcal_general_ca.cxx.

vcl_auto_ptr< mcal_component_analyzer > mcal_component_analyzer::create_from_stream ( vcl_istream &  is) [static, inherited]

Create a concrete mcal_component_analyzer object, from a text specification.

Definition at line 84 of file mcal_component_analyzer.cxx.

mcal_component_analyzer& mcal_general_ca::initial_ca ( ) [inline]

Object to perform initial component analysis (usually PCA).

Definition at line 75 of file mcal_general_ca.h.

vcl_string mcal_general_ca::is_a ( ) const [virtual]

Name of the class.

Implements mcal_component_analyzer.

Definition at line 320 of file mcal_general_ca.cxx.

void mcal_general_ca::optimise_about_mean ( mbl_data_wrapper< vnl_vector< double > > &  data,
const vnl_vector< double > &  mean,
vnl_matrix< double > &  modes,
vnl_vector< double > &  mode_var 
) [private]

Optimise the mode vectors so as to minimise the cost function.

Definition at line 257 of file mcal_general_ca.cxx.

double mcal_general_ca::optimise_mode_pair ( vnl_vector< double > &  proj1,
vnl_vector< double > &  proj2,
vnl_vector< double > &  mode1,
vnl_vector< double > &  mode2 
) [private]

Optimise the mode vectors so as to minimise the cost function.

Definition at line 165 of file mcal_general_ca.cxx.

double mcal_general_ca::optimise_one_pass ( vcl_vector< vnl_vector< double > > &  proj,
vnl_matrix< double > &  modes 
) [private]

Optimise the mode vectors so as to minimise the cost function.

Definition at line 214 of file mcal_general_ca.cxx.

void mcal_general_ca::print_summary ( vcl_ostream &  os) const [virtual]

Print class to os.

Implements mcal_component_analyzer.

Definition at line 347 of file mcal_general_ca.cxx.

void mcal_general_ca::set ( const mcal_component_analyzer initial_ca,
const mcal_single_basis_cost basis_cost 
)

Initialise, taking clones of supplied objects.

Definition at line 32 of file mcal_general_ca.cxx.

void mcal_general_ca::set_defaults ( ) [private]

Set parameters to default values.

Definition at line 39 of file mcal_general_ca.cxx.

short mcal_general_ca::version_no ( ) const

Version number for I/O.

Reimplemented from mcal_component_analyzer.

Definition at line 329 of file mcal_general_ca.cxx.


Member Data Documentation

Object to evaluate component of cost associated with each basis vector.

Definition at line 29 of file mcal_general_ca.h.

Object to perform initial component analysis (usually PCA).

Definition at line 26 of file mcal_general_ca.h.

unsigned mcal_general_ca::max_passes_ [private]

Maximum number of passes during optimisation.

Definition at line 32 of file mcal_general_ca.h.

Threshold on angular movement, used to terminate optimisation.

Definition at line 35 of file mcal_general_ca.h.


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