libidx
/home/rex/ebltrunk/core/libidx/include/matlab.h
00001 /***************************************************************************
00002  *   Copyright (C) 2011 by Soumith Chintala and Pierre Sermanet *
00003  *   soumith@gmail.com, pierre.sermanet@gmail.com *
00004  *   All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions are met:
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Redistribution under a license not approved by the Open Source
00014  *       Initiative (http://www.opensource.org) must display the
00015  *       following acknowledgement in all advertising material:
00016  *        This product includes software developed at the Courant
00017  *        Institute of Mathematical Sciences (http://cims.nyu.edu).
00018  *     * The names of the authors may not be used to endorse or promote products
00019  *       derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY
00025  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00028  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  ***************************************************************************/
00032 
00033 #ifndef MATLAB_H
00034 #define MATLAB_H
00035 
00036 #include "idx.h"
00037 
00038 #ifdef __MATLAB__
00039 
00040 // TODO: temporary dependency
00041 #include "mat.h" //mat.h from MATLAB/extern/include directory
00042 
00043 #else
00044 
00045 typedef enum {
00046   mxUNKNOWN_CLASS,
00047   mxCELL_CLASS,
00048   mxSTRUCT_CLASS,
00049   mxLOGICAL_CLASS,
00050   mxCHAR_CLASS,
00051   mxVOID_CLASS,
00052   mxDOUBLE_CLASS,
00053   mxSINGLE_CLASS,
00054   mxINT8_CLASS,
00055   mxUINT8_CLASS,
00056   mxINT16_CLASS,
00057   mxUINT16_CLASS,
00058   mxINT32_CLASS,
00059   mxUINT32_CLASS,
00060   mxINT64_CLASS,
00061   mxUINT64_CLASS,
00062   mxFUNCTION_CLASS
00063 } mxClassID;
00064 
00065 typedef FILE MATFile;
00066 typedef void mxArray;
00067 
00068 #endif
00069 
00070 namespace ebl {
00071   
00073   class matlab {
00074   public:
00077     matlab(const char *filename);
00079     virtual ~matlab();
00081     template <typename T> idx<T> load_matrix(const char *name);
00083     template <typename Tmatlab, typename T>
00084       void read_cast_matrix(mxArray *var, idx<T> &m);
00085     
00086   protected:
00087     const char* filename; 
00088     MATFile *fp; 
00089     int nvar; 
00090   };  
00091   
00092 }
00093 
00094 #include "matlab.hpp"
00095 
00096 #endif // MATLAB_H