Changeset 792 for trunk/yat/classifier


Ignore:
Timestamp:
Mar 11, 2007, 1:14:24 AM (14 years ago)
Author:
Jari Häkkinen
Message:

Addresses #193. matrix now works as outlined in the ticket
discussion. Added support for const views. Added a clone function that
facilitates resizing of matrices. clone is needed since assignement
operator functionality is changed.

Location:
trunk/yat/classifier
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/Kernel_SEV.cc

    r746 r792  
    4747    : Kernel(data,kf, own)
    4848  {
    49     kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
     49    kernel_matrix_.clone(utility::matrix(data_->columns(),data_->columns()));
    5050    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    5151      for (size_t j=i; j<kernel_matrix_.columns(); j++)
     
    6666  void Kernel_SEV::build_kernel(void)
    6767  {
    68     kernel_matrix_ = utility::matrix(data_->columns(),data_->columns());
     68    kernel_matrix_.clone(utility::matrix(data_->columns(),data_->columns()));
    6969    for (size_t i=0; i<kernel_matrix_.rows(); i++)
    7070      for (size_t j=i; j<kernel_matrix_.columns(); j++)
  • trunk/yat/classifier/NCC.cc

    r789 r792  
    8787  bool NCC::train()
    8888  {   
    89     centroids_=utility::matrix(data_.rows(), target_.nof_classes());
     89    centroids_.clone(utility::matrix(data_.rows(), target_.nof_classes()));
    9090    utility::matrix nof_in_class(data_.rows(), target_.nof_classes());
    9191    for(size_t i=0; i<data_.rows(); i++) {
     
    101101      }
    102102    }   
    103     centroids_.div_elements(nof_in_class);
     103    centroids_.div(nof_in_class);
    104104    trained_=true;
    105105    return trained_;
     
    118118    // take care of nan's in centroids
    119119    for(size_t j=0; j<centroids_.columns(); j++) {
    120       const utility::vector centroid=utility::vector(centroids_,j,false);
     120      const utility::vector centroid(utility::vector(centroids_,j,false));
    121121      utility::vector wc(centroid.size(),0);
    122122      for(size_t i=0; i<centroid.size(); i++)  {
     
    132132                    utility::matrix& prediction) const
    133133  {   
    134     prediction=utility::matrix(centroids_.columns(), input.columns());   
     134    prediction.clone(utility::matrix(centroids_.columns(), input.columns()));
    135135    try {   
    136136      const MatrixLookupWeighted& data=
  • trunk/yat/classifier/SVM.cc

    r747 r792  
    146146
    147147    assert(input.rows()==alpha_.size());
    148     prediction = utility::matrix(2,input.columns(),0);
     148    prediction.clone(utility::matrix(2,input.columns(),0));
    149149    for (size_t i = 0; i<input.columns(); i++){
    150150      for (size_t j = 0; j<input.rows(); j++){
     
    182182  {
    183183    trained_=false;
    184     alpha_=utility::vector(target_.size(), 0);
     184    alpha_.clone(utility::vector(target_.size(), 0));
    185185  }
    186186
     
    413413  }
    414414
    415 
    416415}}} // of namespace classifier, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.