--- mexUnitSelection.cpp --

mexUnitselection.cpp can be compiled using matlab :

1. Open Matlab
2. you can type either :
      mex mexUnitSelection.cpp
or
      mex c:\\nameOfYourDirectory\\mexUnitSelection.cpp

depending whether mexUnitSelection.cpp is in your current directory
(default value : '..\matlab\work' or something like that)
or in another directory named 'nameOfYourDirectory'.

A file named mexUnitSelection.dll (under windows) is created.
This file is created inside of your current directory,
wherever the *.cpp file is.

If you use another OS than Window$ the mex command
will create a file with another extension than *.dll
(type '>> help mex' in matlab for further information)
The compatibility of the cpp file with other OS than Window$ still has to be checked

--- mexUnitSelection.m ---

This file simply contains the help to the mexUnitSelection dll so that if you type :

>> help mexUnitSelection

the .m file is called and display the help

on the other and, if you type :

>> mexUnitSelection

the .dll is called (priority of the .dll over the .m) and it also an help text.

--- mexUnitSelection.dll ---

******************************************************************************************************************
* IMPORTANT NOTE :                                                                                               *
*                                                                                                                *
* From time to time, matlab give "memory segmentation violation" errors while using this dll for the first time. *
* If this happens to you, do not panic.                                                                          *
* Wait a few second and try again to launch the program. it will generally work without any problems.            *
* If the problem persists, simply recompile and retest.                                                          *
* It seems that Matlab has some trouble to manage the memory of large mex-files (.dll)                           *
* The other solution is a problem in my program, but as it generally works without any problem                   *
* and crash only from time to time, I don't think so.                                                            *
*                                                                                                                *
******************************************************************************************************************

in matlab, type :

>> [stateSequence] = mexUnitSelection(source,cluster,target,weights,NBEST);

where
  
      source is a 2D matrix containing the features (e.g. MFCC) of the source (y_prime)
          dimension : [numberOfFeatures x numberOfFrames]
  
      cluster is an array of cells containing information about the clustering of the target database :
          dimension : [1 x numberOfClusters]
          each cell represents one cluster and contains 3 fields :
              center : 1D matrix of double [numberOfMFCC x 1] containing the features of 
                       the center of the cluster
              frames : 1D matrix of int [numberOfFramesInTheCluster] 
                       containing the index of the database (awb) frames which are in this cluster.
              size : int [1 x 1] containing the number of database frames which are in this cluster.
  
      target is an array of cells containing information about the features of the target database :
          dimension : [1 x numberOfFramesInDatabase]
          each cell represents one frame and contains 3 fields :
              mfcc : 1D matrix of double [numberOfMFCC x 1] containing the features (mfcc) 
                     of each frame of the database.
              name : a string containing the name of the file from which the frame comes from 
                     (e.g. : 'a0082.wav')
              index : an integer value [1 x 1] containing the index of that frame in that file 
                     (e.g. : 123, meaning the 123rd frame of 'a0082.wav')
  
      weights (optional): a 1D matrix of double value containing the weights for the weighted euclidian distance
  
      NBEST (optional) : an integer value. It's the number of states to select for the n-best 
  
      out : a 1D matrix [numberOfFrames x 1]
            It contains the index of the frames of the database selected by the Viterbi algorithm
            (e.g. : 1234 means the 1234th frame of the database 
             --> the 1234th element of the target structure
             --> you can get the frame using target.name(1234) and target.index(1234)
