contrib/mul/mcal/mcal_var_basis_cost.h
Go to the documentation of this file.
00001 #ifndef mcal_var_basis_cost_h_
00002 #define mcal_var_basis_cost_h_
00003 //:
00004 // \file
00005 // \author Tim Cootes
00006 // \brief Cost function returning variance along given vector
00007 
00008 #include <mcal/mcal_single_basis_cost.h>
00009 #include <vnl/io/vnl_io_vector.h>
00010 #include <vnl/io/vnl_io_matrix.h>
00011 #include <vcl_iosfwd.h>
00012 
00013 //: Cost function returning variance along given vector
00014 class mcal_var_basis_cost : public mcal_single_basis_cost
00015 {
00016  private:
00017  public:
00018 
00019   //: Dflt ctor
00020   mcal_var_basis_cost();
00021 
00022   //: Destructor
00023   virtual ~mcal_var_basis_cost();
00024 
00025   //: Returns true since cost can be computed from the variance.
00026   virtual bool can_use_variance() const;
00027 
00028   //: Compute component of the cost function from given basis vector
00029   // \param[in] unit_basis   Unit vector defining basis direction
00030   // \param[in] projections  Projections of the dataset onto this basis vector
00031   virtual double cost(const vnl_vector<double>& unit_basis,
00032                       const vnl_vector<double>& projections);
00033 
00034   //: Compute component of the cost function from given basis vector
00035   // \param[in] unit_basis Unit vector defining basis direction
00036   // \param[in] variance   Variance of projections of the dataset onto this basis vector
00037   virtual double cost_from_variance(const vnl_vector<double>& unit_basis,
00038                                     double variance);
00039 
00040   //: Version number for I/O
00041   short version_no() const;
00042 
00043   //: Name of the class
00044   virtual vcl_string is_a() const;
00045 
00046   //: Create a copy on the heap and return base class pointer
00047   virtual  mcal_single_basis_cost*  clone()  const;
00048 
00049   //: Print class to os
00050   virtual void print_summary(vcl_ostream& os) const;
00051 
00052   //: Save class to binary file stream
00053   virtual void b_write(vsl_b_ostream& bfs) const;
00054 
00055   //: Load class from binary file stream
00056   virtual void b_read(vsl_b_istream& bfs);
00057 
00058   //: Read initialisation settings from a stream.
00059   // Parameters:
00060   // \verbatim
00061   // {
00062   //   alpha: 1.0
00063   // }
00064   // \endverbatim
00065   // \throw mbl_exception_parse_error if the parse fails.
00066   virtual void config_from_stream(vcl_istream & is);
00067 };
00068 
00069 #endif // mcal_var_basis_cost_h_