Fuzzy Logic Tools  v1.0.5.1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
aux_matlab.hpp
Go to the documentation of this file.
1 /* Copyright (C) 2004-2011
2  ANTONIO JAVIER BARRAGAN, antonio.barragan@diesia.uhu.es
3  http://uhu.es/antonio.barragan
4 
5  Collaborators:
6  JOSE MANUEL ANDUJAR, andujar@diesia.uhu.es
7  MARIANO J. AZNAR, marianojose.aznar@alu.uhu.es
8 
9  DPTO. DE ING. ELECTRONICA, DE SISTEMAS INFORMATICOS Y AUTOMATICA
10  ETSI, UNIVERSITY OF HUELVA (SPAIN)
11 
12  For more information, please contact with authors.
13 
14  This software is free software: you can redistribute it and/or modify
15  it under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  This software is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #ifndef _AUX_MATLAB_HPP_
29 #define _AUX_MATLAB_HPP_
30 
38 #include "mex.h" // MATLABĀ© API
39 #include <flt/utilities.hpp>
40 
41 namespace FLT // Use the FTL (Fuzzy Logic Tools) namespace
42 {
48  inline void col2row_major(const double * const colM, double *rowM, size_t num_rows, size_t num_cols)
49  {
50  double *p = rowM;
51  for (size_t i=0; i<num_rows; i++)
52  for (size_t j=0; j<num_cols; j++, p++)
53  *p = colM[i+j*num_rows];
54  };
55 
61  inline TNT::Array2D<double> col2row_major(const double * const colM, size_t num_rows, size_t num_cols)
62  {
63  TNT::Array2D<double> M (num_rows, num_cols);
64  double *p = M[0];
65  for (size_t i=0; i<num_rows; i++)
66  for (size_t j=0; j<num_cols; j++, p++)
67  *p = colM[i+j*num_rows];
68  return M;
69  };
70 
76  inline void row2col_major(const double * const rowM, double *colM, size_t num_rows, size_t num_cols)
77  {
78  double *p = colM;
79  for (size_t i=0; i<num_cols; i++)
80  for (size_t j=0; j<num_rows; j++, p++)
81  *p = rowM[i+j*num_cols];
82 /* for (i=0;i<n;i++)
83  {
84  for (q=0;q<n;q++)
85  {
86  *J = Jac[q][i];
87  J++;
88  }
89  }*/
90  };
91 
97  int readModel(const mxArray *model, System &S);
98 
104  int FIS2System(const mxArray *FIS, System &S);
105 
111  int System2FIS(System &S, mxArray *FIS);
112 
113 } // FLT
114 #endif
Fuzzy Logic Tools (FLT) namespace.
Definition: derivatives.hpp:41
void col2row_major(const double *const colM, double *rowM, size_t num_rows, size_t num_cols)
Converts a column-major matrix in a row-major one.
Definition: aux_matlab.hpp:48
int System2FIS(System &S, mxArray *FIS)
Writes the Fuzzy Model in a FIS variable.
Definition: aux_matlab.cpp:535
void row2col_major(const double *const rowM, double *colM, size_t num_rows, size_t num_cols)
Converts a row-major matrix in a column-major one.
Definition: aux_matlab.hpp:76
int readModel(const mxArray *model, System &S)
Reads a Fuzzy Model (TXT, FIS file or FIS variable)
Definition: aux_matlab.cpp:6
int FIS2System(const mxArray *FIS, System &S)
Reads the Fuzzy Model from a FIS variable.
Definition: aux_matlab.cpp:68
Implements useful functions for fuzzy systems.