Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
f3bdbf3b
Commit
f3bdbf3b
authored
Dec 19, 2014
by
Davis King
Browse files
Added license statements and also converted line endings to unix format
parent
d8dc5965
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2878 additions
and
2873 deletions
+2878
-2873
dlib/matlab/CMakeLists.txt
dlib/matlab/CMakeLists.txt
+15
-15
dlib/matlab/README.txt
dlib/matlab/README.txt
+20
-20
dlib/matlab/call_matlab.h
dlib/matlab/call_matlab.h
+458
-458
dlib/matlab/cmake_mex_wrapper
dlib/matlab/cmake_mex_wrapper
+70
-70
dlib/matlab/example_mex_callback.cpp
dlib/matlab/example_mex_callback.cpp
+52
-51
dlib/matlab/example_mex_function.cpp
dlib/matlab/example_mex_function.cpp
+72
-71
dlib/matlab/mex_wrapper.cpp
dlib/matlab/mex_wrapper.cpp
+2191
-2188
No files found.
dlib/matlab/CMakeLists.txt
View file @
f3bdbf3b
cmake_minimum_required
(
VERSION 2.8.4
)
cmake_minimum_required
(
VERSION 2.8.4
)
PROJECT
(
mex_functions
)
PROJECT
(
mex_functions
)
include
(
cmake_mex_wrapper
)
include
(
cmake_mex_wrapper
)
include
(
../cmake
)
include
(
../cmake
)
# Compile the example_mex_function.cpp file and link it to dlib. Note
# Compile the example_mex_function.cpp file and link it to dlib. Note
# that you can give a list of things to link to here. E.g.
# that you can give a list of things to link to here. E.g.
# add_mex_function(some_other_mex_function pthread dlib fftw)
# add_mex_function(some_other_mex_function pthread dlib fftw)
add_mex_function
(
example_mex_function dlib
)
add_mex_function
(
example_mex_function dlib
)
add_mex_function
(
example_mex_callback dlib
)
add_mex_function
(
example_mex_callback dlib
)
dlib/matlab/README.txt
View file @
f3bdbf3b
This folder contains a set of tools which make it easy to create MATLAB mex
This folder contains a set of tools which make it easy to create MATLAB mex
functions. To understand how they work, you should read the
functions. To understand how they work, you should read the
example_mex_function.cpp and example_mex_callback.cpp examples.
example_mex_function.cpp and example_mex_callback.cpp examples.
To compile them, you can use CMake. In particular, from this folder execute
To compile them, you can use CMake. In particular, from this folder execute
these commands:
these commands:
mkdir build
mkdir build
cd build
cd build
cmake ..
cmake ..
cmake --build . --config release --target install
cmake --build . --config release --target install
That should build the mex files on any platform.
That should build the mex files on any platform.
Note that on windows you will probably need to tell CMake to use a 64bit
Note that on windows you will probably need to tell CMake to use a 64bit
version of visual studio. You can do this by using a command like:
version of visual studio. You can do this by using a command like:
cmake -G "Visual Studio 10 Win64" ..
cmake -G "Visual Studio 10 Win64" ..
instead of
instead of
cmake ..
cmake ..
dlib/matlab/call_matlab.h
View file @
f3bdbf3b
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
// License: Boost Software License See LICENSE.txt for the full license.
// License: Boost Software License See LICENSE.txt for the full license.
// Authors: Davis E. King (davis@dlib.net)
// Authors: Davis E. King (davis@dlib.net)
#ifndef MIT_LL_CALL_MATLAB_H__
#ifndef MIT_LL_CALL_MATLAB_H__
#define MIT_LL_CALL_MATLAB_H__
#define MIT_LL_CALL_MATLAB_H__
#include <string>
#include <string>
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
template
<
typename
T
>
struct
output_decorator
struct
output_decorator
{
{
output_decorator
(
T
&
item_
)
:
item
(
item_
){}
output_decorator
(
T
&
item_
)
:
item
(
item_
){}
T
&
item
;
T
&
item
;
};
};
template
<
typename
T
>
template
<
typename
T
>
output_decorator
<
T
>
returns
(
T
&
item
)
{
return
output_decorator
<
T
>
(
item
);
}
output_decorator
<
T
>
returns
(
T
&
item
)
{
return
output_decorator
<
T
>
(
item
);
}
/*!
/*!
ensures
ensures
- decorates item as an output type. This stuff is used by the call_matlab()
- decorates item as an output type. This stuff is used by the call_matlab()
functions to tell if an argument is an input to the function or is supposed
functions to tell if an argument is an input to the function or is supposed
to be bound to one of the return arguments.
to be bound to one of the return arguments.
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
struct
function_handle
struct
function_handle
{
{
/*!
/*!
WHAT THIS OBJECT REPRESENTS
WHAT THIS OBJECT REPRESENTS
This type is used to represent function handles passed from MATLAB into a
This type is used to represent function handles passed from MATLAB into a
mex function. You can call the function referenced by the handle by
mex function. You can call the function referenced by the handle by
saying:
saying:
call_matlab(my_handle);
call_matlab(my_handle);
!*/
!*/
// These two lines are just implementation details, ignore them.
// These two lines are just implementation details, ignore them.
function_handle
()
:
h
(
0
){}
function_handle
()
:
h
(
0
){}
void
*
const
h
;
void
*
const
h
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
const
std
::
string
&
function_name
);
);
/*!
/*!
ensures
ensures
- Calls MATLAB's function of the given name
- Calls MATLAB's function of the given name
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
const
function_handle
&
funct
);
);
/*!
/*!
ensures
ensures
- Calls MATLAB's function represented by the handle funct
- Calls MATLAB's function represented by the handle funct
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
typename
T1
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
const
T1
&
A1
);
);
/*!
/*!
ensures
ensures
- calls MATLAB's function of the given name.
- calls MATLAB's function of the given name.
- if (A1 is not decorated as an output by returns()) then
- if (A1 is not decorated as an output by returns()) then
- A1 is passed as an argument into the MATLAB function
- A1 is passed as an argument into the MATLAB function
- else
- else
- A1 is treated as the first return value from the MATLAB function.
- A1 is treated as the first return value from the MATLAB function.
!*/
!*/
template
<
template
<
typename
T1
typename
T1
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
const
T1
&
A1
)
{
call_matlab
(
"feval"
,
funct
,
A1
);
}
)
{
call_matlab
(
"feval"
,
funct
,
A1
);
}
/*!
/*!
ensures
ensures
- Calls MATLAB's function represented by the handle funct
- Calls MATLAB's function represented by the handle funct
- if (A1 is not decorated as an output by returns()) then
- if (A1 is not decorated as an output by returns()) then
- A1 is passed as an argument into the MATLAB function
- A1 is passed as an argument into the MATLAB function
- else
- else
- A1 is treated as the first return value from the MATLAB function.
- A1 is treated as the first return value from the MATLAB function.
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
/*
/*
The rest of this file is just overloads of call_matlab() for up to 10 arguments (or
The rest of this file is just overloads of call_matlab() for up to 10 arguments (or
just 9 arguments if function_handle is used). They all do the same thing as the above
just 9 arguments if function_handle is used). They all do the same thing as the above
version of call_matlab(). Generally, any argument not decorated by returns() is an
version of call_matlab(). Generally, any argument not decorated by returns() is an
input to the MATLAB function. On the other hand, all arguments decorated by returns()
input to the MATLAB function. On the other hand, all arguments decorated by returns()
are treated as outputs.
are treated as outputs.
*/
*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
typename
T2
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
const
T2
&
A2
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
typename
T3
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
const
T3
&
A3
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
typename
T4
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
const
T4
&
A4
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
typename
T5
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
const
T5
&
A5
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
typename
T6
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
const
T6
&
A6
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
typename
T7
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
const
T7
&
A7
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
,
typename
T7
,
typename
T8
typename
T8
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
,
const
T7
&
A7
,
const
T8
&
A8
const
T8
&
A8
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
,
typename
T7
,
typename
T8
,
typename
T8
,
typename
T9
typename
T9
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
,
const
T7
&
A7
,
const
T8
&
A8
,
const
T8
&
A8
,
const
T9
&
A9
const
T9
&
A9
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
,
typename
T7
,
typename
T8
,
typename
T8
,
typename
T9
,
typename
T9
,
typename
T10
typename
T10
>
>
void
call_matlab
(
void
call_matlab
(
const
std
::
string
&
function_name
,
const
std
::
string
&
function_name
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
,
const
T7
&
A7
,
const
T8
&
A8
,
const
T8
&
A8
,
const
T9
&
A9
,
const
T9
&
A9
,
const
T10
&
A10
const
T10
&
A10
);
);
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
typename
T2
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
const
T2
&
A2
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
typename
T3
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
const
T3
&
A3
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
typename
T4
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
const
T4
&
A4
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
typename
T5
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
const
T5
&
A5
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
typename
T6
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
const
T6
&
A6
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
typename
T7
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
const
T7
&
A7
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
,
typename
T7
,
typename
T8
typename
T8
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
,
const
T7
&
A7
,
const
T8
&
A8
const
T8
&
A8
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
}
}
template
<
template
<
typename
T1
,
typename
T1
,
typename
T2
,
typename
T2
,
typename
T3
,
typename
T3
,
typename
T4
,
typename
T4
,
typename
T5
,
typename
T5
,
typename
T6
,
typename
T6
,
typename
T7
,
typename
T7
,
typename
T8
,
typename
T8
,
typename
T9
typename
T9
>
>
void
call_matlab
(
void
call_matlab
(
const
function_handle
&
funct
,
const
function_handle
&
funct
,
const
T1
&
A1
,
const
T1
&
A1
,
const
T2
&
A2
,
const
T2
&
A2
,
const
T3
&
A3
,
const
T3
&
A3
,
const
T4
&
A4
,
const
T4
&
A4
,
const
T5
&
A5
,
const
T5
&
A5
,
const
T6
&
A6
,
const
T6
&
A6
,
const
T7
&
A7
,
const
T7
&
A7
,
const
T8
&
A8
,
const
T8
&
A8
,
const
T9
&
A9
const
T9
&
A9
)
)
{
{
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
call_matlab
(
"feval"
,
funct
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
#endif // MIT_LL_CALL_MATLAB_H__
#endif // MIT_LL_CALL_MATLAB_H__
dlib/matlab/cmake_mex_wrapper
View file @
f3bdbf3b
# This file figure
d
out where MATLAB is and then defines a macro, add_mex_function(name)
# This file figure
s
out where MATLAB is and then defines a macro, add_mex_function(name)
# which when called instructs CMake to build a mex file from a file called name.cpp. Note
# which when called instructs CMake to build a mex file from a file called name.cpp. Note
# that additional library dependencies can be added like this: add_mex_function(name lib1 dlib libetc).
# that additional library dependencies can be added like this: add_mex_function(name lib1 dlib libetc).
# That is, just add more libraries after the name and they will be build into the mex file.
# That is, just add more libraries after the name and they will be build into the mex file.
cmake_minimum_required(VERSION 2.8.4)
cmake_minimum_required(VERSION 2.8.4)
# Find MATLAB's include directory and needed libraries
# Find MATLAB's include directory and needed libraries
find_program(MATLAB_EXECUTABLE matlab PATHS
find_program(MATLAB_EXECUTABLE matlab PATHS
"C:/Program Files/MATLAB/*/bin"
"C:/Program Files/MATLAB/*/bin"
"C:/Program Files (x86)/MATLAB/*/bin"
"C:/Program Files (x86)/MATLAB/*/bin"
)
)
# Resolve symbolic links to try and get the real path to the MATLAB executable
# Resolve symbolic links to try and get the real path to the MATLAB executable
get_filename_component(MATLAB_EXECUTABLE ${MATLAB_EXECUTABLE} REALPATH)
get_filename_component(MATLAB_EXECUTABLE ${MATLAB_EXECUTABLE} REALPATH)
# Now get MATLAB root directory
# Now get MATLAB root directory
get_filename_component(MATLAB_HOME ${MATLAB_EXECUTABLE} PATH)
get_filename_component(MATLAB_HOME ${MATLAB_EXECUTABLE} PATH)
get_filename_component(MATLAB_HOME ${MATLAB_HOME} PATH)
get_filename_component(MATLAB_HOME ${MATLAB_HOME} PATH)
set(MATLAB_LIB_FOLDERS
set(MATLAB_LIB_FOLDERS
"${MATLAB_HOME}/extern/lib/win64/microsoft"
"${MATLAB_HOME}/extern/lib/win64/microsoft"
"${MATLAB_HOME}/bin/glnxa64"
"${MATLAB_HOME}/bin/glnxa64"
)
)
# Find the MATLAB libraries that need to get linked into the mex file
# Find the MATLAB libraries that need to get linked into the mex file
if (WIN32)
if (WIN32)
find_library(MATLAB_MEX_LIBRARY libmex PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MEX_LIBRARY libmex PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MX_LIBRARY libmx PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MX_LIBRARY libmx PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_ENG_LIBRARY libeng PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_ENG_LIBRARY libeng PATHS ${MATLAB_LIB_FOLDERS} )
else()
else()
find_library(MATLAB_MEX_LIBRARY mex PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MEX_LIBRARY mex PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MX_LIBRARY mx PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_MX_LIBRARY mx PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_ENG_LIBRARY eng PATHS ${MATLAB_LIB_FOLDERS} )
find_library(MATLAB_ENG_LIBRARY eng PATHS ${MATLAB_LIB_FOLDERS} )
endif()
endif()
set(MATLAB_LIBRARIES ${MATLAB_MEX_LIBRARY} ${MATLAB_MX_LIBRARY} ${MATLAB_ENG_LIBRARY})
set(MATLAB_LIBRARIES ${MATLAB_MEX_LIBRARY} ${MATLAB_MX_LIBRARY} ${MATLAB_ENG_LIBRARY})
INCLUDE_DIRECTORIES("${MATLAB_HOME}/extern/include")
INCLUDE_DIRECTORIES("${MATLAB_HOME}/extern/include")
# Determine the path to cmake_mex_wrapper file so we can add it to the include search path..
# Determine the path to cmake_mex_wrapper file so we can add it to the include search path..
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_matlab_binding_path ${CMAKE_CURRENT_LIST_FILE})
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_matlab_binding_path ${CMAKE_CURRENT_LIST_FILE})
INCLUDE_DIRECTORIES("${dlib_matlab_binding_path}")
INCLUDE_DIRECTORIES("${dlib_matlab_binding_path}")
# Determine the path to dlib so we can add it to the include search path.
# Determine the path to dlib so we can add it to the include search path.
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
string(REGEX REPLACE "cmake_mex_wrapper$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
INCLUDE_DIRECTORIES(${dlib_path}/../..)
INCLUDE_DIRECTORIES(${dlib_path}/../..)
ADD_DEFINITIONS(-DMATLAB_MEX_FILE)
ADD_DEFINITIONS(-DMATLAB_MEX_FILE)
# Determine the path to our CMakeLists.txt file. This is the file that
# Determine the path to our CMakeLists.txt file. This is the file that
# includeded the one you are reading right now. So here we make it so that
# includeded the one you are reading right now. So here we make it so that
# when you run the install target it will copy the compiled mex files into the
# when you run the install target it will copy the compiled mex files into the
# same folder as the parent CMakeLists.txt file.
# same folder as the parent CMakeLists.txt file.
string(REGEX REPLACE "CMakeLists.txt$" "" install_dir ${CMAKE_PARENT_LIST_FILE})
string(REGEX REPLACE "CMakeLists.txt$" "" install_dir ${CMAKE_PARENT_LIST_FILE})
set(CMAKE_INSTALL_PREFIX "${install_dir}")
set(CMAKE_INSTALL_PREFIX "${install_dir}")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${install_dir}")
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${install_dir}")
INCLUDE(InstallRequiredSystemLibraries)
INCLUDE(InstallRequiredSystemLibraries)
MACRO(add_mex_function name )
MACRO(add_mex_function name )
ADD_LIBRARY(${name} MODULE ${name}.cpp )
ADD_LIBRARY(${name} MODULE ${name}.cpp )
# Change the output file extension to a mex extension.
# Change the output file extension to a mex extension.
if (WIN32)
if (WIN32)
set_target_properties(${name} PROPERTIES SUFFIX ".mexw64")
set_target_properties(${name} PROPERTIES SUFFIX ".mexw64")
elseif(APPLE)
elseif(APPLE)
set_target_properties(${name} PROPERTIES SUFFIX ".mexmaci64")
set_target_properties(${name} PROPERTIES SUFFIX ".mexmaci64")
else()
else()
set_target_properties(${name} PROPERTIES SUFFIX ".mexa64")
set_target_properties(${name} PROPERTIES SUFFIX ".mexa64")
endif()
endif()
set_target_properties(${name} PROPERTIES PREFIX "")
set_target_properties(${name} PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(${name} ${MATLAB_LIBRARIES} ${ARGN})
TARGET_LINK_LIBRARIES(${name} ${MATLAB_LIBRARIES} ${ARGN})
install(TARGETS ${name} DESTINATION "${install_dir}")
install(TARGETS ${name} DESTINATION "${install_dir}")
ENDMACRO()
ENDMACRO()
dlib/matlab/example_mex_callback.cpp
View file @
f3bdbf3b
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#include "call_matlab.h"
#include "dlib/matrix.h"
#include "call_matlab.h"
#include "dlib/matrix.h"
using
namespace
dlib
;
using
namespace
std
;
using
namespace
dlib
;
using
namespace
std
;
/*
This mex function takes a MATLAB function handle, calls it, and
/*
returns the results.
This mex function takes a MATLAB function handle, calls it, and
returns the results.
For example, you can call this function in MATLAB like so:
A = magic(3)
For example, you can call this function in MATLAB like so:
y = example_mex_callback(A, @(x)x+x)
A = magic(3)
y = example_mex_callback(A, @(x)x+x)
This will result in y containing the value 2*A.
*/
This will result in y containing the value 2*A.
*/
void
mex_function
(
const
matrix
<
double
>&
A
,
void
mex_function
(
const
function_handle
&
f
,
const
matrix
<
double
>&
A
,
matrix
<
double
>&
result
const
function_handle
&
f
,
)
matrix
<
double
>&
result
{
)
// The f argument to this function is a function handle passed from MATLAB. To
{
// call it we use the following syntax:
// The f argument to this function is a function handle passed from MATLAB. To
call_matlab
(
f
,
A
,
returns
(
result
));
// call it we use the following syntax:
// This is equivalent to result = f(A). Therefore, the returns(variable) syntax
call_matlab
(
f
,
A
,
returns
(
result
));
// is used to indicate which variables are outputs of the function.
// This is equivalent to result = f(A). Therefore, the returns(variable) syntax
// is used to indicate which variables are outputs of the function.
// Another thing we can do is call MATLAB functions based on their string name
// rather than a function_handle. Here is an example of calling eigs().
// Another thing we can do is call MATLAB functions based on their string name
matrix
<
double
>
m
(
2
,
2
);
// rather than a function_handle. Here is an example of calling eigs().
m
=
1
,
2
,
matrix
<
double
>
m
(
2
,
2
);
3
,
4
;
m
=
1
,
2
,
matrix
<
double
>
v
,
d
;
3
,
4
;
matrix
<
double
>
v
,
d
;
// This is equivalent to [v,d] = eigs(m);
call_matlab
(
"eigs"
,
m
,
returns
(
v
),
returns
(
d
));
// This is equivalent to [v,d] = eigs(m);
cout
<<
"eigenvectors:
\n
"
<<
v
<<
endl
;
call_matlab
(
"eigs"
,
m
,
returns
(
v
),
returns
(
d
));
cout
<<
"eigenvalues:
\n
"
<<
d
<<
endl
;
cout
<<
"eigenvectors:
\n
"
<<
v
<<
endl
;
}
cout
<<
"eigenvalues:
\n
"
<<
d
<<
endl
;
}
// #including this brings in all the mex boiler plate needed by MATLAB.
#include "mex_wrapper.cpp"
// #including this brings in all the mex boiler plate needed by MATLAB.
#include "mex_wrapper.cpp"
dlib/matlab/example_mex_function.cpp
View file @
f3bdbf3b
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#include "dlib/matrix.h"
using
namespace
dlib
;
#include "dlib/matrix.h"
using
namespace
std
;
using
namespace
dlib
;
using
namespace
std
;
/*!
This file defines a function callable from MATLAB once you mex it.
/*!
This file defines a function callable from MATLAB once you mex it.
It computes the same thing as the following MATLAB function:
It computes the same thing as the following MATLAB function:
function [A, B] = example_mex_function(x, y, some_number)
A = x+y;
function [A, B] = example_mex_function(x, y, some_number)
B = sum(sum(x+y));
A = x+y;
disp(['some_number: ' num2str(some_number)])
B = sum(sum(x+y));
end
disp(['some_number: ' num2str(some_number)])
end
VALID INPUT AND OUTPUT ARGUMENTS
The mex wrapper can handle the following kinds of input and output arguments:
VALID INPUT AND OUTPUT ARGUMENTS
- Types corresponding to a MATLAB matrix
The mex wrapper can handle the following kinds of input and output arguments:
- a dlib::matrix containing any kind of scalar value.
- Types corresponding to a MATLAB matrix
- a dlib::array2d containing any kind of scalar value.
- a dlib::matrix containing any kind of scalar value.
- a dlib::vector containing any kind of scalar value.
- a dlib::array2d containing any kind of scalar value.
- a dlib::point
- a dlib::vector containing any kind of scalar value.
- a dlib::point
- RGB color images
- dlib::array2d<dlib::rgb_pixel> can be used to represent
- RGB color images
MATLAB uint8 MxNx3 images.
- dlib::array2d<dlib::rgb_pixel> can be used to represent
MATLAB uint8 MxNx3 images.
- Types corresponding to a MATLAB scalar
- any kind of scalar value, e.g. double, int, etc.
- Types corresponding to a MATLAB scalar
- any kind of scalar value, e.g. double, int, etc.
- Types corresponding to a MATLAB string
- std::string
- Types corresponding to a MATLAB string
- std::string
- Types corresponding to a MATLAB cell array
- a std::vector or dlib::array containing any of the above
- Types corresponding to a MATLAB cell array
types of objects or std::vector or dlib::array objects.
- a std::vector or dlib::array containing any of the above
!*/
types of objects or std::vector or dlib::array objects.
!*/
// You can also define default values for your input arguments. So
// here we say that if the user in MATLAB doesn't provide the "some_number"
// You can also define default values for your input arguments. So
// then it will get a value of 3.141.
// here we say that if the user in MATLAB doesn't provide the "some_number"
#define ARG_5_DEFAULT 3.141
// then it will get a value of 3.141.
#define ARG_5_DEFAULT 3.141
// Make a function named mex_function() and put your code inside it.
// Note that the return type should be void. Use non-const reference
// Make a function named mex_function() and put your code inside it.
// arguments to return outputs. Finally, mex_function() must have no
// Note that the return type should be void. Use non-const reference
// more than 10 arguments.
// arguments to return outputs. Finally, mex_function() must have no
void
mex_function
(
// more than 10 arguments.
const
matrix
<
double
>&
x
,
void
mex_function
(
const
matrix
<
double
>&
y
,
const
matrix
<
double
>&
x
,
matrix
<
double
>&
out1
,
const
matrix
<
double
>&
y
,
double
&
out2
,
matrix
<
double
>&
out1
,
double
some_number
double
&
out2
,
)
double
some_number
{
)
out1
=
x
+
y
;
{
out2
=
sum
(
x
+
y
);
out1
=
x
+
y
;
out2
=
sum
(
x
+
y
);
// we can also use cout to print things as usual:
cout
<<
"some_number: "
<<
some_number
<<
endl
;
// we can also use cout to print things as usual:
}
cout
<<
"some_number: "
<<
some_number
<<
endl
;
}
// #including this brings in all the mex boiler plate needed by MATLAB.
#include "mex_wrapper.cpp"
// #including this brings in all the mex boiler plate needed by MATLAB.
#include "mex_wrapper.cpp"
dlib/matlab/mex_wrapper.cpp
View file @
f3bdbf3b
/*
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
READ THIS FIRST
// License: Boost Software License See LICENSE.txt for the full license.
######
// Authors: Davis E. King (davis@dlib.net)
######
/*
######
READ THIS FIRST
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
\############/
######
\##########/
######
\########/
######
\######/
\############/
\####/
\##########/
\##/
\########/
\/
\######/
\####/
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\##/
\/
See example_mex_function.cpp for a discussion of how to use the mex wrapper.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
See example_mex_function.cpp for a discussion of how to use the mex wrapper.
/\
/##\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/####\
/######\
/\
/########\
/##\
/##########\
/####\
/############\
/######\
######
/########\
######
/##########\
######
/############\
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
######
READ THIS FIRST
######
*/
######
######
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
READ THIS FIRST
// License: Boost Software License See LICENSE.txt for the full license.
*/
// Authors: Davis E. King (davis@dlib.net)
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
// License: Boost Software License See LICENSE.txt for the full license.
// Authors: Davis E. King (davis@dlib.net)
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// BEGIN IMPLEMENTATION DETAILS
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// BEGIN IMPLEMENTATION DETAILS
#include "../matrix.h"
// ----------------------------------------------------------------------------------------
#include "../array2d.h"
// ----------------------------------------------------------------------------------------
#include "../array.h"
#include "../image_transforms.h"
#include "../matrix.h"
#include "../is_kind.h"
#include "../array2d.h"
#include "../any.h" // for sig_traits
#include "../array.h"
#include "../image_transforms.h"
#if defined(_MSC_VER)
#include "../is_kind.h"
#define DLL_EXPORT_SYM __declspec(dllexport)
#include "../any.h" // for sig_traits
#endif
#include "mex.h"
#if defined(_MSC_VER)
#include <sstream>
#define DLL_EXPORT_SYM __declspec(dllexport)
#include "call_matlab.h"
#endif
#include "mex.h"
// ----------------------------------------------------------------------------------------
#include <sstream>
#include "call_matlab.h"
#ifdef ARG_1_DEFAULT
#define ELSE_ASSIGN_ARG_1 else A1 = ARG_1_DEFAULT;
// ----------------------------------------------------------------------------------------
#else
#define ELSE_ASSIGN_ARG_1
#ifdef ARG_1_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_1 else A1 = ARG_1_DEFAULT;
#else
#ifdef ARG_2_DEFAULT
#define ELSE_ASSIGN_ARG_1
#define ELSE_ASSIGN_ARG_2 else A2 = ARG_2_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_2
#ifdef ARG_2_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_2 else A2 = ARG_2_DEFAULT;
#else
#ifdef ARG_3_DEFAULT
#define ELSE_ASSIGN_ARG_2
#define ELSE_ASSIGN_ARG_3 else A3 = ARG_3_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_3
#ifdef ARG_3_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_3 else A3 = ARG_3_DEFAULT;
#else
#ifdef ARG_4_DEFAULT
#define ELSE_ASSIGN_ARG_3
#define ELSE_ASSIGN_ARG_4 else A4 = ARG_4_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_4
#ifdef ARG_4_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_4 else A4 = ARG_4_DEFAULT;
#else
#ifdef ARG_5_DEFAULT
#define ELSE_ASSIGN_ARG_4
#define ELSE_ASSIGN_ARG_5 else A5 = ARG_5_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_5
#ifdef ARG_5_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_5 else A5 = ARG_5_DEFAULT;
#else
#ifdef ARG_6_DEFAULT
#define ELSE_ASSIGN_ARG_5
#define ELSE_ASSIGN_ARG_6 else A6 = ARG_6_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_6
#ifdef ARG_6_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_6 else A6 = ARG_6_DEFAULT;
#else
#ifdef ARG_7_DEFAULT
#define ELSE_ASSIGN_ARG_6
#define ELSE_ASSIGN_ARG_7 else A7 = ARG_7_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_7
#ifdef ARG_7_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_7 else A7 = ARG_7_DEFAULT;
#else
#ifdef ARG_8_DEFAULT
#define ELSE_ASSIGN_ARG_7
#define ELSE_ASSIGN_ARG_8 else A8 = ARG_8_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_8
#ifdef ARG_8_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_8 else A8 = ARG_8_DEFAULT;
#else
#ifdef ARG_9_DEFAULT
#define ELSE_ASSIGN_ARG_8
#define ELSE_ASSIGN_ARG_9 else A9 = ARG_9_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_9
#ifdef ARG_9_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_9 else A9 = ARG_9_DEFAULT;
#else
#ifdef ARG_10_DEFAULT
#define ELSE_ASSIGN_ARG_9
#define ELSE_ASSIGN_ARG_10 else A10 = ARG_10_DEFAULT;
#endif
#else
#define ELSE_ASSIGN_ARG_10
#ifdef ARG_10_DEFAULT
#endif
#define ELSE_ASSIGN_ARG_10 else A10 = ARG_10_DEFAULT;
#else
// ----------------------------------------------------------------------------------------
#define ELSE_ASSIGN_ARG_10
#endif
namespace
mex_binding
{
// ----------------------------------------------------------------------------------------
using
namespace
dlib
;
namespace
mex_binding
template
<
typename
T
>
{
struct
is_input_type
using
namespace
dlib
;
{
const
static
unsigned
long
value
=
(
!
is_same_type
<
void
,
T
>::
value
&&
(
!
is_reference_type
<
T
>::
value
||
is_const_type
<
T
>::
value
))
?
1
:
0
;
template
<
typename
T
>
};
struct
is_input_type
template
<
typename
T
>
{
struct
is_output_type
const
static
unsigned
long
value
=
(
!
is_same_type
<
void
,
T
>::
value
&&
(
!
is_reference_type
<
T
>::
value
||
is_const_type
<
T
>::
value
))
?
1
:
0
;
{
};
const
static
unsigned
long
value
=
(
!
is_same_type
<
void
,
T
>::
value
&&
is_reference_type
<
T
>::
value
&&
!
is_const_type
<
T
>::
value
)
?
1
:
0
;
template
<
typename
T
>
};
struct
is_output_type
{
const
static
unsigned
long
value
=
(
!
is_same_type
<
void
,
T
>::
value
&&
is_reference_type
<
T
>::
value
&&
!
is_const_type
<
T
>::
value
)
?
1
:
0
;
template
<
typename
funct
>
};
struct
funct_traits
{
const
static
unsigned
long
num_inputs
=
is_input_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
+
template
<
typename
funct
>
is_input_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
+
struct
funct_traits
is_input_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
+
{
is_input_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
+
const
static
unsigned
long
num_inputs
=
is_input_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
;
is_input_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
+
const
static
unsigned
long
num_outputs
=
is_output_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
+
is_input_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
;
is_output_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
+
const
static
unsigned
long
num_outputs
=
is_output_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
;
is_output_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
+
};
is_output_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
+
is_output_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
+
// ----------------------------------------------------------------------------------------
is_output_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
;
};
template
<
typename
T
>
struct
is_array_type
// ----------------------------------------------------------------------------------------
{
// true if T is std::vector or dlib::array
template
<
typename
T
>
const
static
bool
value
=
is_std_vector
<
T
>::
value
||
dlib
::
is_array
<
T
>::
value
;
struct
is_array_type
{
};
// true if T is std::vector or dlib::array
const
static
bool
value
=
is_std_vector
<
T
>::
value
||
dlib
::
is_array
<
T
>::
value
;
// ----------------------------------------------------------------------------------------
};
template
<
typename
T
,
// ----------------------------------------------------------------------------------------
typename
enabled
=
void
>
template
<
struct
inner_type
typename
T
,
{
typename
enabled
=
void
typedef
T
type
;
>
};
struct
inner_type
{
template
<
typename
T
>
typedef
T
type
;
struct
inner_type
<
T
,
typename
dlib
::
enable_if_c
<
is_matrix
<
T
>::
value
||
is_array2d
<
T
>::
value
||
dlib
::
is_array
<
T
>::
value
>::
type
>
};
{
typedef
typename
T
::
type
type
;
template
<
typename
T
>
};
struct
inner_type
<
T
,
typename
dlib
::
enable_if_c
<
is_matrix
<
T
>::
value
||
is_array2d
<
T
>::
value
||
dlib
::
is_array
<
T
>::
value
>::
type
>
{
template
<
typename
T
>
typedef
typename
T
::
type
type
;
struct
inner_type
<
T
,
typename
dlib
::
enable_if
<
is_std_vector
<
T
>
>::
type
>
};
{
typedef
typename
T
::
value_type
type
;
template
<
typename
T
>
};
struct
inner_type
<
T
,
typename
dlib
::
enable_if
<
is_std_vector
<
T
>
>::
type
>
{
typedef
typename
T
::
value_type
type
;
// -------------------------------------------------------
};
struct
invalid_args_exception
{
// -------------------------------------------------------
invalid_args_exception
(
const
std
::
string
&
msg_
)
:
msg
(
msg_
)
{}
std
::
string
msg
;
struct
invalid_args_exception
};
{
invalid_args_exception
(
const
std
::
string
&
msg_
)
:
msg
(
msg_
)
{}
// -------------------------------------------------------
std
::
string
msg
;
};
template
<
typename
matrix_type
,
// -------------------------------------------------------
typename
EXP
>
template
<
typename
dlib
::
enable_if_c
<
is_matrix
<
matrix_type
>::
value
&&
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
typename
matrix_type
,
assign_mat
(
typename
EXP
const
long
arg_idx
,
>
matrix_type
&
m
,
typename
dlib
::
enable_if_c
<
is_matrix
<
matrix_type
>::
value
&&
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
const
matrix_exp
<
EXP
>&
src
assign_mat
(
)
const
long
arg_idx
,
{
matrix_type
&
m
,
if
(
matrix_type
::
NR
!=
0
&&
matrix_type
::
NR
!=
src
.
nc
())
const
matrix_exp
<
EXP
>&
src
{
)
std
::
ostringstream
sout
;
{
sout
<<
"Argument "
<<
arg_idx
+
1
<<
" expects a matrix with "
<<
matrix_type
::
NR
<<
" rows but got one with "
<<
src
.
nc
();
if
(
matrix_type
::
NR
!=
0
&&
matrix_type
::
NR
!=
src
.
nc
())
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"Argument "
<<
arg_idx
+
1
<<
" expects a matrix with "
<<
matrix_type
::
NR
<<
" rows but got one with "
<<
src
.
nc
();
if
(
matrix_type
::
NC
!=
0
&&
matrix_type
::
NC
!=
src
.
nr
())
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"Argument "
<<
arg_idx
+
1
<<
" expects a matrix with "
<<
matrix_type
::
NC
<<
" columns but got one with "
<<
src
.
nr
();
if
(
matrix_type
::
NC
!=
0
&&
matrix_type
::
NC
!=
src
.
nr
())
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"Argument "
<<
arg_idx
+
1
<<
" expects a matrix with "
<<
matrix_type
::
NC
<<
" columns but got one with "
<<
src
.
nr
();
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
sout
.
str
().
c_str
());
m
=
trans
(
src
);
}
}
template
<
m
=
trans
(
src
);
typename
matrix_type
,
}
typename
EXP
>
template
<
typename
dlib
::
enable_if_c
<
is_array2d
<
matrix_type
>::
value
&&
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
typename
matrix_type
,
assign_mat
(
typename
EXP
const
long
arg_idx
,
>
matrix_type
&
m
,
typename
dlib
::
enable_if_c
<
is_array2d
<
matrix_type
>::
value
&&
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
const
matrix_exp
<
EXP
>&
src
assign_mat
(
)
const
long
arg_idx
,
{
matrix_type
&
m
,
assign_image
(
m
,
trans
(
src
));
const
matrix_exp
<
EXP
>&
src
}
)
{
template
<
assign_image
(
m
,
trans
(
src
));
typename
matrix_type
,
}
typename
EXP
>
template
<
typename
disable_if_c
<
(
is_array2d
<
matrix_type
>::
value
||
is_matrix
<
matrix_type
>::
value
)
&&
typename
matrix_type
,
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
typename
EXP
assign_mat
(
>
const
long
arg_idx
,
typename
disable_if_c
<
(
is_array2d
<
matrix_type
>::
value
||
is_matrix
<
matrix_type
>::
value
)
&&
matrix_type
&
,
is_same_type
<
typename
inner_type
<
matrix_type
>::
type
,
typename
EXP
::
type
>::
value
>::
type
const
matrix_exp
<
EXP
>&
assign_mat
(
)
const
long
arg_idx
,
{
matrix_type
&
,
std
::
ostringstream
sout
;
const
matrix_exp
<
EXP
>&
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
sout
.
str
().
c_str
());
// -------------------------------------------------------
}
template
<
typename
T
,
// -------------------------------------------------------
typename
U
>
template
<
typename
dlib
::
enable_if_c
<
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
>::
type
typename
T
,
assign_scalar
(
typename
U
const
long
arg_idx
,
>
T
&
dest
,
typename
dlib
::
enable_if_c
<
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
>::
type
const
U
&
src
assign_scalar
(
)
const
long
arg_idx
,
{
T
&
dest
,
if
(
is_signed_type
<
U
>::
value
&&
src
<
0
&&
is_unsigned_type
<
T
>::
value
)
const
U
&
src
{
)
std
::
ostringstream
sout
;
{
sout
<<
"Error, input argument "
<<
arg_idx
+
1
<<
" must be a non-negative number."
;
if
(
is_signed_type
<
U
>::
value
&&
src
<
0
&&
is_unsigned_type
<
T
>::
value
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"Error, input argument "
<<
arg_idx
+
1
<<
" must be a non-negative number."
;
else
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
dest
=
src
;
}
}
else
}
{
dest
=
src
;
template
<
}
typename
T
,
}
typename
U
>
template
<
typename
dlib
::
disable_if_c
<
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
>::
type
typename
T
,
assign_scalar
(
typename
U
const
long
arg_idx
,
>
T
&
,
typename
dlib
::
disable_if_c
<
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
>::
type
const
U
&
assign_scalar
(
)
const
long
arg_idx
,
{
T
&
,
std
::
ostringstream
sout
;
const
U
&
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
sout
.
str
().
c_str
());
// -------------------------------------------------------
}
void
assign_function_handle
(
const
long
arg_idx
,
// -------------------------------------------------------
function_handle
&
dest
,
const
mxArray
*
src
void
assign_function_handle
(
)
const
long
arg_idx
,
{
function_handle
&
dest
,
const_cast
<
void
*&>
(
dest
.
h
)
=
(
void
*
)
src
;
const
mxArray
*
src
}
)
{
template
<
const_cast
<
void
*&>
(
dest
.
h
)
=
(
void
*
)
src
;
typename
T
}
>
void
assign_function_handle
(
template
<
const
long
arg_idx
,
typename
T
T
&
,
>
const
mxArray
*
void
assign_function_handle
(
)
const
long
arg_idx
,
{
T
&
,
std
::
ostringstream
sout
;
const
mxArray
*
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
sout
.
str
().
c_str
());
// -------------------------------------------------------
}
template
<
typename
T
// -------------------------------------------------------
>
typename
dlib
::
enable_if
<
is_array_type
<
T
>
>::
type
template
<
assign_std_vector
(
typename
T
const
long
arg_idx
,
>
T
&
dest
,
typename
dlib
::
enable_if
<
is_array_type
<
T
>
>::
type
const
mxArray
*
src
assign_std_vector
(
)
const
long
arg_idx
,
{
T
&
dest
,
const
long
nr
=
mxGetM
(
src
);
const
mxArray
*
src
const
long
nc
=
mxGetN
(
src
);
)
{
typedef
typename
inner_type
<
T
>::
type
type
;
const
long
nr
=
mxGetM
(
src
);
const
long
nc
=
mxGetN
(
src
);
if
(
!
mxIsCell
(
src
))
{
typedef
typename
inner_type
<
T
>::
type
type
;
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a cell array"
;
if
(
!
mxIsCell
(
src
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
if
(
nr
!=
1
&&
nc
!=
1
)
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a cell array"
;
{
throw
invalid_args_exception
(
sout
.
str
());
std
::
ostringstream
sout
;
}
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a cell array with exactly 1 row or 1 column (i.e. a row or column vector)"
;
if
(
nr
!=
1
&&
nc
!=
1
)
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a cell array with exactly 1 row or 1 column (i.e. a row or column vector)"
;
const
long
size
=
nr
*
nc
;
throw
invalid_args_exception
(
sout
.
str
());
dest
.
resize
(
size
);
}
for
(
unsigned
long
i
=
0
;
i
<
dest
.
size
();
++
i
)
const
long
size
=
nr
*
nc
;
{
dest
.
resize
(
size
);
try
{
for
(
unsigned
long
i
=
0
;
i
<
dest
.
size
();
++
i
)
validate_and_populate_arg
(
i
,
mxGetCell
(
src
,
i
),
dest
[
i
]);
{
}
try
catch
(
invalid_args_exception
&
e
)
{
{
validate_and_populate_arg
(
i
,
mxGetCell
(
src
,
i
),
dest
[
i
]);
std
::
ostringstream
sout
;
}
sout
<<
"Error in argument "
<<
arg_idx
+
1
<<
": element "
<<
i
+
1
<<
" of cell array not the expected type.
\n
"
;
catch
(
invalid_args_exception
&
e
)
sout
<<
"
\t
"
<<
e
.
msg
;
{
throw
invalid_args_exception
(
sout
.
str
());
std
::
ostringstream
sout
;
}
sout
<<
"Error in argument "
<<
arg_idx
+
1
<<
": element "
<<
i
+
1
<<
" of cell array not the expected type.
\n
"
;
}
sout
<<
"
\t
"
<<
e
.
msg
;
throw
invalid_args_exception
(
sout
.
str
());
}
}
}
template
<
typename
T
}
>
typename
disable_if
<
is_array_type
<
T
>
>::
type
template
<
assign_std_vector
(
typename
T
const
long
arg_idx
,
>
T
&
,
typename
disable_if
<
is_array_type
<
T
>
>::
type
const
mxArray
*
assign_std_vector
(
)
const
long
arg_idx
,
{
T
&
,
std
::
ostringstream
sout
;
const
mxArray
*
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
// -------------------------------------------------------
sout
.
str
().
c_str
());
}
template
<
typename
T
>
void
assign_image
(
// -------------------------------------------------------
const
long
arg_idx
,
T
&
,
template
<
typename
T
>
const
dlib
::
uint8
*
data
,
void
assign_image
(
long
nr
,
const
long
arg_idx
,
long
nc
T
&
,
)
const
dlib
::
uint8
*
data
,
{
long
nr
,
std
::
ostringstream
sout
;
long
nc
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
sout
.
str
().
c_str
());
std
::
ostringstream
sout
;
}
sout
<<
"mex_function has some bug in it related to processing input argument "
<<
arg_idx
+
1
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
template
<
typename
MM
>
sout
.
str
().
c_str
());
void
assign_image
(
}
const
long
,
array2d
<
dlib
::
rgb_pixel
,
MM
>&
img
,
template
<
typename
MM
>
const
dlib
::
uint8
*
data
,
void
assign_image
(
long
nr
,
const
long
,
long
nc
array2d
<
dlib
::
rgb_pixel
,
MM
>&
img
,
)
const
dlib
::
uint8
*
data
,
{
long
nr
,
img
.
set_size
(
nr
,
nc
);
long
nc
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
{
img
[
r
][
c
].
red
=
*
data
++
;
img
.
set_size
(
nr
,
nc
);
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
img
[
r
][
c
].
green
=
*
data
++
;
img
[
r
][
c
].
red
=
*
data
++
;
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
img
[
r
][
c
].
blue
=
*
data
++
;
img
[
r
][
c
].
green
=
*
data
++
;
}
for
(
long
c
=
0
;
c
<
img
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
img
.
nr
();
++
r
)
// -------------------------------------------------------
img
[
r
][
c
].
blue
=
*
data
++
;
}
template
<
typename
T
>
void
validate_and_populate_arg
(
// -------------------------------------------------------
long
arg_idx
,
const
mxArray
*
prhs
,
template
<
typename
T
>
T
&
arg
void
validate_and_populate_arg
(
)
long
arg_idx
,
{
const
mxArray
*
prhs
,
using
namespace
mex_binding
;
T
&
arg
if
(
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
)
)
{
{
if
(
!
(
mxIsDouble
(
prhs
)
||
mxIsSingle
(
prhs
)
||
mxIsLogical
(
prhs
)
)
||
using
namespace
mex_binding
;
mxIsComplex
(
prhs
)
||
if
(
is_built_in_scalar_type
<
T
>::
value
||
is_same_type
<
T
,
bool
>::
value
)
mxGetNumberOfElements
(
prhs
)
!=
1
)
{
{
if
(
!
(
mxIsDouble
(
prhs
)
||
mxIsSingle
(
prhs
)
||
mxIsLogical
(
prhs
)
)
||
std
::
ostringstream
sout
;
mxIsComplex
(
prhs
)
||
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a scalar"
;
mxGetNumberOfElements
(
prhs
)
!=
1
)
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a scalar"
;
assign_scalar
(
arg_idx
,
arg
,
mxGetScalar
(
prhs
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_matrix
<
T
>::
value
||
is_array2d
<
T
>::
value
)
{
assign_scalar
(
arg_idx
,
arg
,
mxGetScalar
(
prhs
));
typedef
typename
inner_type
<
T
>::
type
type
;
}
else
if
(
is_matrix
<
T
>::
value
||
is_array2d
<
T
>::
value
)
const
int
num_dims
=
mxGetNumberOfDimensions
(
prhs
);
{
const
long
nr
=
mxGetM
(
prhs
);
typedef
typename
inner_type
<
T
>::
type
type
;
const
long
nc
=
mxGetN
(
prhs
);
const
int
num_dims
=
mxGetNumberOfDimensions
(
prhs
);
if
(
is_same_type
<
type
,
dlib
::
rgb_pixel
>::
value
)
const
long
nr
=
mxGetM
(
prhs
);
{
const
long
nc
=
mxGetN
(
prhs
);
if
(
!
(
num_dims
==
3
&&
mxGetDimensions
(
prhs
)[
2
]
==
3
&&
mxIsUint8
(
prhs
)))
{
if
(
is_same_type
<
type
,
dlib
::
rgb_pixel
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a 3-D NxMx3 image matrix of uint8"
;
if
(
!
(
num_dims
==
3
&&
mxGetDimensions
(
prhs
)[
2
]
==
3
&&
mxIsUint8
(
prhs
)))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a 3-D NxMx3 image matrix of uint8"
;
const
long
rows
=
mxGetDimensions
(
prhs
)[
0
];
throw
invalid_args_exception
(
sout
.
str
());
const
long
cols
=
mxGetDimensions
(
prhs
)[
1
];
}
assign_image
(
arg_idx
,
arg
,
(
const
dlib
::
uint8
*
)
mxGetData
(
prhs
),
rows
,
cols
);
return
;
const
long
rows
=
mxGetDimensions
(
prhs
)[
0
];
}
const
long
cols
=
mxGetDimensions
(
prhs
)[
1
];
assign_image
(
arg_idx
,
arg
,
(
const
dlib
::
uint8
*
)
mxGetData
(
prhs
),
rows
,
cols
);
if
(
num_dims
!=
2
)
return
;
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a 2-D matrix (got a "
<<
num_dims
<<
"-D matrix)"
;
if
(
num_dims
!=
2
)
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a 2-D matrix (got a "
<<
num_dims
<<
"-D matrix)"
;
throw
invalid_args_exception
(
sout
.
str
());
if
(
is_same_type
<
type
,
double
>::
value
)
}
{
if
(
!
mxIsDouble
(
prhs
)
||
mxIsComplex
(
prhs
))
{
if
(
is_same_type
<
type
,
double
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of doubles"
;
if
(
!
mxIsDouble
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
(
mxGetPr
(
prhs
),
nc
,
nr
));
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of doubles"
;
}
throw
invalid_args_exception
(
sout
.
str
());
else
if
(
is_same_type
<
type
,
float
>::
value
)
}
{
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
(
mxGetPr
(
prhs
),
nc
,
nr
));
if
(
!
mxIsSingle
(
prhs
)
||
mxIsComplex
(
prhs
))
}
{
else
if
(
is_same_type
<
type
,
float
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of single/float"
;
if
(
!
mxIsSingle
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of single/float"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
float
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
bool
>::
value
)
{
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
float
*
)
mxGetData
(
prhs
),
nc
,
nr
));
if
(
!
mxIsLogical
(
prhs
))
}
{
else
if
(
is_same_type
<
type
,
bool
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of logical elements."
;
if
(
!
mxIsLogical
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of logical elements."
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
bool
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
uint8
>::
value
)
{
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
bool
*
)
mxGetData
(
prhs
),
nc
,
nr
));
if
(
!
mxIsUint8
(
prhs
)
||
mxIsComplex
(
prhs
))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
uint8
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint8"
;
if
(
!
mxIsUint8
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint8"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
dlib
::
uint8
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
int8
>::
value
)
{
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
dlib
::
uint8
*
)
mxGetData
(
prhs
),
nc
,
nr
));
if
(
!
mxIsInt8
(
prhs
)
||
mxIsComplex
(
prhs
))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
int8
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int8"
;
if
(
!
mxIsInt8
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int8"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
dlib
::
int8
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
int16
>::
value
||
(
is_same_type
<
type
,
short
>::
value
&&
sizeof
(
short
)
==
sizeof
(
dlib
::
int16
)))
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
dlib
::
int8
*
)
mxGetData
(
prhs
),
nc
,
nr
));
{
}
if
(
!
mxIsInt16
(
prhs
)
||
mxIsComplex
(
prhs
))
else
if
(
is_same_type
<
type
,
dlib
::
int16
>::
value
||
{
(
is_same_type
<
type
,
short
>::
value
&&
sizeof
(
short
)
==
sizeof
(
dlib
::
int16
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int16"
;
if
(
!
mxIsInt16
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int16"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
uint16
>::
value
||
(
is_same_type
<
type
,
unsigned
short
>::
value
&&
sizeof
(
unsigned
short
)
==
sizeof
(
dlib
::
uint16
)))
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
{
}
if
(
!
mxIsUint16
(
prhs
)
||
mxIsComplex
(
prhs
))
else
if
(
is_same_type
<
type
,
dlib
::
uint16
>::
value
||
{
(
is_same_type
<
type
,
unsigned
short
>::
value
&&
sizeof
(
unsigned
short
)
==
sizeof
(
dlib
::
uint16
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint16"
;
if
(
!
mxIsUint16
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint16"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
int32
>::
value
||
(
is_same_type
<
type
,
int
>::
value
&&
sizeof
(
int
)
==
sizeof
(
dlib
::
int32
))
||
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
(
is_same_type
<
type
,
long
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int32
)))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
int32
>::
value
||
if
(
!
mxIsInt32
(
prhs
)
||
mxIsComplex
(
prhs
))
(
is_same_type
<
type
,
int
>::
value
&&
sizeof
(
int
)
==
sizeof
(
dlib
::
int32
))
||
{
(
is_same_type
<
type
,
long
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int32
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int32"
;
if
(
!
mxIsInt32
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int32"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
uint32
>::
value
||
(
is_same_type
<
type
,
unsigned
int
>::
value
&&
sizeof
(
unsigned
int
)
==
sizeof
(
dlib
::
uint32
))
||
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
(
is_same_type
<
type
,
unsigned
long
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint32
)))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
uint32
>::
value
||
if
(
!
mxIsUint32
(
prhs
)
||
mxIsComplex
(
prhs
))
(
is_same_type
<
type
,
unsigned
int
>::
value
&&
sizeof
(
unsigned
int
)
==
sizeof
(
dlib
::
uint32
))
||
{
(
is_same_type
<
type
,
unsigned
long
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint32
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint32"
;
if
(
!
mxIsUint32
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint32"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
uint64
>::
value
||
(
is_same_type
<
type
,
unsigned
int
>::
value
&&
sizeof
(
unsigned
int
)
==
sizeof
(
dlib
::
uint64
))
||
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
(
is_same_type
<
type
,
unsigned
long
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint64
)))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
uint64
>::
value
||
if
(
!
mxIsUint64
(
prhs
)
||
mxIsComplex
(
prhs
))
(
is_same_type
<
type
,
unsigned
int
>::
value
&&
sizeof
(
unsigned
int
)
==
sizeof
(
dlib
::
uint64
))
||
{
(
is_same_type
<
type
,
unsigned
long
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint64
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint64"
;
if
(
!
mxIsUint64
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of uint64"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
if
(
is_same_type
<
type
,
dlib
::
int64
>::
value
||
(
is_same_type
<
type
,
int
>::
value
&&
sizeof
(
int
)
==
sizeof
(
dlib
::
int64
))
||
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
(
is_same_type
<
type
,
long
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int64
)))
}
{
else
if
(
is_same_type
<
type
,
dlib
::
int64
>::
value
||
if
(
!
mxIsInt64
(
prhs
)
||
mxIsComplex
(
prhs
))
(
is_same_type
<
type
,
int
>::
value
&&
sizeof
(
int
)
==
sizeof
(
dlib
::
int64
))
||
{
(
is_same_type
<
type
,
long
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int64
)))
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int64"
;
if
(
!
mxIsInt64
(
prhs
)
||
mxIsComplex
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a matrix of int64"
;
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
throw
invalid_args_exception
(
sout
.
str
());
}
}
else
{
assign_mat
(
arg_idx
,
arg
,
pointer_to_matrix
((
const
type
*
)
mxGetData
(
prhs
),
nc
,
nr
));
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
}
"mex_function uses unsupported matrix type"
);
else
}
{
}
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
else
if
(
is_array_type
<
T
>::
value
)
"mex_function uses unsupported matrix type"
);
{
}
assign_std_vector
(
arg_idx
,
arg
,
prhs
);
}
else
if
(
is_array_type
<
T
>::
value
)
}
{
else
if
(
is_same_type
<
T
,
function_handle
>::
value
)
assign_std_vector
(
arg_idx
,
arg
,
prhs
);
{
if
(
!
mxIsClass
(
prhs
,
"function_handle"
))
}
{
else
if
(
is_same_type
<
T
,
function_handle
>::
value
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a function handle."
;
if
(
!
mxIsClass
(
prhs
,
"function_handle"
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
assign_function_handle
(
arg_idx
,
arg
,
prhs
);
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a function handle."
;
}
throw
invalid_args_exception
(
sout
.
str
());
else
}
{
assign_function_handle
(
arg_idx
,
arg
,
prhs
);
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
}
"mex_function uses unsupported input argument type"
);
else
}
{
}
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
"mex_function uses unsupported input argument type"
);
void
validate_and_populate_arg
(
}
long
arg_idx
,
}
const
mxArray
*
prhs
,
std
::
string
&
arg
void
validate_and_populate_arg
(
)
long
arg_idx
,
{
const
mxArray
*
prhs
,
if
(
!
mxIsChar
(
prhs
))
std
::
string
&
arg
{
)
std
::
ostringstream
sout
;
{
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a char string"
;
if
(
!
mxIsChar
(
prhs
))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
sout
<<
" argument "
<<
arg_idx
+
1
<<
" must be a char string"
;
const
long
nr
=
mxGetM
(
prhs
);
throw
invalid_args_exception
(
sout
.
str
());
const
long
nc
=
mxGetN
(
prhs
);
}
const
long
size
=
nr
*
nc
;
arg
.
resize
(
size
+
1
);
const
long
nr
=
mxGetM
(
prhs
);
if
(
mxGetString
(
prhs
,
&
arg
[
0
],
arg
.
size
()))
const
long
nc
=
mxGetN
(
prhs
);
{
const
long
size
=
nr
*
nc
;
std
::
ostringstream
sout
;
arg
.
resize
(
size
+
1
);
sout
<<
" argument "
<<
arg_idx
+
1
<<
" encountered an error while calling mxGetString()"
;
if
(
mxGetString
(
prhs
,
&
arg
[
0
],
arg
.
size
()))
throw
invalid_args_exception
(
sout
.
str
());
{
}
std
::
ostringstream
sout
;
arg
.
resize
(
size
);
sout
<<
" argument "
<<
arg_idx
+
1
<<
" encountered an error while calling mxGetString()"
;
}
throw
invalid_args_exception
(
sout
.
str
());
}
arg
.
resize
(
size
);
// ----------------------------------------------------------------------------------------
}
template
<
typename
EXP
>
typename
dlib
::
enable_if
<
is_same_type
<
dlib
::
rgb_pixel
,
typename
EXP
::
type
>
>::
type
assign_image_to_matlab
(
// ----------------------------------------------------------------------------------------
dlib
::
uint8
*
mat
,
const
matrix_exp
<
EXP
>&
item
template
<
typename
EXP
>
)
typename
dlib
::
enable_if
<
is_same_type
<
dlib
::
rgb_pixel
,
typename
EXP
::
type
>
>::
type
assign_image_to_matlab
(
{
dlib
::
uint8
*
mat
,
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
const
matrix_exp
<
EXP
>&
item
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
)
*
mat
++
=
item
(
r
,
c
).
red
;
{
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
*
mat
++
=
item
(
r
,
c
).
green
;
*
mat
++
=
item
(
r
,
c
).
red
;
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
*
mat
++
=
item
(
r
,
c
).
blue
;
*
mat
++
=
item
(
r
,
c
).
green
;
}
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
template
<
typename
T
,
typename
EXP
>
*
mat
++
=
item
(
r
,
c
).
blue
;
typename
disable_if
<
is_same_type
<
dlib
::
rgb_pixel
,
typename
EXP
::
type
>
>::
type
assign_image_to_matlab
(
}
T
*
mat
,
const
matrix_exp
<
EXP
>&
template
<
typename
T
,
typename
EXP
>
)
typename
disable_if
<
is_same_type
<
dlib
::
rgb_pixel
,
typename
EXP
::
type
>
>::
type
assign_image_to_matlab
(
{
T
*
mat
,
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
const
matrix_exp
<
EXP
>&
"mex_function uses unsupported output image argument type"
);
)
}
{
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
template
<
typename
T
>
"mex_function uses unsupported output image argument type"
);
typename
dlib
::
enable_if
<
is_matrix
<
T
>
>::
type
assign_to_matlab
(
}
mxArray
*&
plhs
,
const
T
&
item
template
<
typename
T
>
)
typename
dlib
::
enable_if
<
is_matrix
<
T
>
>::
type
assign_to_matlab
(
{
mxArray
*&
plhs
,
typedef
typename
T
::
type
type
;
const
T
&
item
)
type
*
mat
=
0
;
{
typedef
typename
T
::
type
type
;
if
(
is_same_type
<
double
,
type
>::
value
)
{
type
*
mat
=
0
;
plhs
=
mxCreateDoubleMatrix
(
item
.
nr
(),
item
.
nc
(),
if
(
is_same_type
<
double
,
type
>::
value
)
mxREAL
);
{
plhs
=
mxCreateDoubleMatrix
(
item
.
nr
(),
mat
=
(
type
*
)
mxGetPr
(
plhs
);
item
.
nc
(),
}
mxREAL
);
else
if
(
is_same_type
<
float
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetPr
(
plhs
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
}
item
.
nc
(),
else
if
(
is_same_type
<
float
,
type
>::
value
)
mxSINGLE_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxSINGLE_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
bool
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetData
(
plhs
);
plhs
=
mxCreateLogicalMatrix
(
item
.
nr
(),
}
item
.
nc
());
else
if
(
is_same_type
<
bool
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetData
(
plhs
);
plhs
=
mxCreateLogicalMatrix
(
item
.
nr
(),
}
item
.
nc
());
else
if
(
is_same_type
<
dlib
::
uint8
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetData
(
plhs
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
}
item
.
nc
(),
else
if
(
is_same_type
<
dlib
::
uint8
,
type
>::
value
)
mxUINT8_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxUINT8_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
int8
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetData
(
plhs
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
}
item
.
nc
(),
else
if
(
is_same_type
<
dlib
::
int8
,
type
>::
value
)
mxINT8_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxINT8_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
int16
,
type
>::
value
||
(
is_same_type
<
short
,
type
>::
value
&&
sizeof
(
short
)
==
sizeof
(
dlib
::
int16
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
int16
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
short
,
type
>::
value
&&
sizeof
(
short
)
==
sizeof
(
dlib
::
int16
)))
mxINT16_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxINT16_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
uint16
,
type
>::
value
||
(
is_same_type
<
unsigned
short
,
type
>::
value
&&
sizeof
(
unsigned
short
)
==
sizeof
(
dlib
::
uint16
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
uint16
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
unsigned
short
,
type
>::
value
&&
sizeof
(
unsigned
short
)
==
sizeof
(
dlib
::
uint16
)))
mxUINT16_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxUINT16_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
int32
,
type
>::
value
||
(
is_same_type
<
long
,
type
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int32
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
int32
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
long
,
type
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int32
)))
mxINT32_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxINT32_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
uint32
,
type
>::
value
||
(
is_same_type
<
unsigned
long
,
type
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint32
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
uint32
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
unsigned
long
,
type
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint32
)))
mxUINT32_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxUINT32_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
uint64
,
type
>::
value
||
(
is_same_type
<
unsigned
long
,
type
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint64
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
uint64
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
unsigned
long
,
type
>::
value
&&
sizeof
(
unsigned
long
)
==
sizeof
(
dlib
::
uint64
)))
mxUINT64_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxUINT64_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
int64
,
type
>::
value
||
(
is_same_type
<
long
,
type
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int64
)))
mat
=
(
type
*
)
mxGetData
(
plhs
);
{
}
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
else
if
(
is_same_type
<
dlib
::
int64
,
type
>::
value
||
item
.
nc
(),
(
is_same_type
<
long
,
type
>::
value
&&
sizeof
(
long
)
==
sizeof
(
dlib
::
int64
)))
mxINT64_CLASS
,
{
mxREAL
);
plhs
=
mxCreateNumericMatrix
(
item
.
nr
(),
item
.
nc
(),
mat
=
(
type
*
)
mxGetData
(
plhs
);
mxINT64_CLASS
,
}
mxREAL
);
else
if
(
is_same_type
<
dlib
::
rgb_pixel
,
type
>::
value
)
{
mat
=
(
type
*
)
mxGetData
(
plhs
);
mwSize
dims
[
3
]
=
{
item
.
nr
(),
item
.
nc
(),
3
};
}
plhs
=
mxCreateNumericArray
(
3
,
dims
,
mxUINT8_CLASS
,
mxREAL
);
else
if
(
is_same_type
<
dlib
::
rgb_pixel
,
type
>::
value
)
{
assign_image_to_matlab
((
dlib
::
uint8
*
)
mxGetData
(
plhs
),
item
);
mwSize
dims
[
3
]
=
{
item
.
nr
(),
item
.
nc
(),
3
};
return
;
plhs
=
mxCreateNumericArray
(
3
,
dims
,
mxUINT8_CLASS
,
mxREAL
);
}
else
assign_image_to_matlab
((
dlib
::
uint8
*
)
mxGetData
(
plhs
),
item
);
{
return
;
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
}
"mex_function uses unsupported output argument type"
);
else
}
{
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
"mex_function uses unsupported output argument type"
);
}
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
{
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
item
.
nc
();
++
c
)
*
mat
++
=
item
(
r
,
c
);
{
}
for
(
long
r
=
0
;
r
<
item
.
nr
();
++
r
)
}
{
}
*
mat
++
=
item
(
r
,
c
);
}
void
assign_to_matlab
(
}
mxArray
*&
plhs
,
}
const
std
::
string
&
item
)
void
assign_to_matlab
(
{
mxArray
*&
plhs
,
plhs
=
mxCreateString
(
item
.
c_str
());
const
std
::
string
&
item
}
)
{
template
<
typename
T
,
typename
MM
>
plhs
=
mxCreateString
(
item
.
c_str
());
void
assign_to_matlab
(
}
mxArray
*&
plhs
,
const
array2d
<
T
,
MM
>&
item
template
<
typename
T
,
typename
MM
>
)
void
assign_to_matlab
(
{
mxArray
*&
plhs
,
assign_to_matlab
(
plhs
,
array_to_matrix
(
item
));
const
array2d
<
T
,
MM
>&
item
}
)
{
template
<
typename
T
>
assign_to_matlab
(
plhs
,
array_to_matrix
(
item
));
typename
dlib
::
enable_if
<
is_array_type
<
T
>
>::
type
assign_to_matlab
(
}
mxArray
*&
plhs
,
const
T
&
item
template
<
typename
T
>
)
typename
dlib
::
enable_if
<
is_array_type
<
T
>
>::
type
assign_to_matlab
(
{
mxArray
*&
plhs
,
mwSize
dims
[
1
]
=
{
item
.
size
()};
const
T
&
item
plhs
=
mxCreateCellArray
(
1
,
dims
);
)
for
(
unsigned
long
i
=
0
;
i
<
item
.
size
();
++
i
)
{
{
mwSize
dims
[
1
]
=
{
item
.
size
()};
mxArray
*
next
=
0
;
plhs
=
mxCreateCellArray
(
1
,
dims
);
assign_to_matlab
(
next
,
item
[
i
]);
for
(
unsigned
long
i
=
0
;
i
<
item
.
size
();
++
i
)
mxSetCell
(
plhs
,
i
,
next
);
{
}
mxArray
*
next
=
0
;
}
assign_to_matlab
(
next
,
item
[
i
]);
mxSetCell
(
plhs
,
i
,
next
);
template
<
typename
T
>
}
typename
dlib
::
disable_if_c
<
is_matrix
<
T
>::
value
||
is_array_type
<
T
>::
value
||
}
is_same_type
<
T
,
function_handle
>::
value
>::
type
assign_to_matlab
(
mxArray
*&
plhs
,
template
<
typename
T
>
const
T
&
item
typename
dlib
::
disable_if_c
<
is_matrix
<
T
>::
value
||
is_array_type
<
T
>::
value
||
)
is_same_type
<
T
,
function_handle
>::
value
>::
type
assign_to_matlab
(
{
mxArray
*&
plhs
,
plhs
=
mxCreateDoubleScalar
(
item
);
const
T
&
item
}
)
{
plhs
=
mxCreateDoubleScalar
(
item
);
void
assign_to_matlab
(
}
mxArray
*&
plhs
,
const
char
*
str
)
void
assign_to_matlab
(
{
mxArray
*&
plhs
,
assign_to_matlab
(
plhs
,
std
::
string
(
str
));
const
char
*
str
}
)
{
void
assign_to_matlab
(
assign_to_matlab
(
plhs
,
std
::
string
(
str
));
mxArray
*&
plhs
,
}
const
function_handle
&
h
)
void
assign_to_matlab
(
{
mxArray
*&
plhs
,
}
const
function_handle
&
h
)
// ----------------------------------------------------------------------------------------
{
}
template
<
unsigned
long
num_args
// ----------------------------------------------------------------------------------------
>
struct
call_mex_function_helper
;
template
<
unsigned
long
num_args
template
<
>
>
struct
call_mex_function_helper
<
1
>
struct
call_mex_function_helper
;
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
1
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
)
const
typename
basic_type
<
arg1_type
>::
type
A1
;
{
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg1_type
>::
type
A1
;
mex_function
(
A1
);
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
i
=
0
;
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
mex_function
(
A1
);
}
};
i
=
0
;
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
template
<
>
}
struct
call_mex_function_helper
<
2
>
};
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
2
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
{
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
int
i
=
0
;
typename
basic_type
<
arg1_type
>::
type
A1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg2_type
>::
type
A2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
int
i
=
0
;
mex_function
(
A1
,
A2
);
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
i
=
0
;
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
mex_function
(
A1
,
A2
);
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
}
i
=
0
;
};
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
template
<
>
}
struct
call_mex_function_helper
<
3
>
};
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
3
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg1_type
>::
type
A1
;
int
i
=
0
;
typename
basic_type
<
arg2_type
>::
type
A2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg3_type
>::
type
A3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
mex_function
(
A1
,
A2
,
A3
);
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
i
=
0
;
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
mex_function
(
A1
,
A2
,
A3
);
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
};
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
template
<
>
}
struct
call_mex_function_helper
<
4
>
};
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
4
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg2_type
>::
type
A2
;
int
i
=
0
;
typename
basic_type
<
arg3_type
>::
type
A3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg4_type
>::
type
A4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
mex_function
(
A1
,
A2
,
A3
,
A4
);
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
};
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
template
<
>
}
struct
call_mex_function_helper
<
5
>
};
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
5
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg3_type
>::
type
A3
;
int
i
=
0
;
typename
basic_type
<
arg4_type
>::
type
A4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
);
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
};
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
}
template
<
>
};
struct
call_mex_function_helper
<
6
>
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
6
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
int
i
=
0
;
typename
basic_type
<
arg5_type
>::
type
A5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg6_type
>::
type
A6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
};
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
}
template
<
>
};
struct
call_mex_function_helper
<
7
>
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
7
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg7_type
>::
type
A7
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg5_type
>::
type
A5
;
int
i
=
0
;
typename
basic_type
<
arg6_type
>::
type
A6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg7_type
>::
type
A7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
};
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
}
template
<
>
};
struct
call_mex_function_helper
<
8
>
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
8
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg7_type
>::
type
A7
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg8_type
>::
type
A8
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg6_type
>::
type
A6
;
int
i
=
0
;
typename
basic_type
<
arg7_type
>::
type
A7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg8_type
>::
type
A8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
};
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
}
template
<
>
};
struct
call_mex_function_helper
<
9
>
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
9
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg9_type
arg9_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg9_type
arg9_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg7_type
>::
type
A7
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg8_type
>::
type
A8
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg9_type
>::
type
A9
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg7_type
>::
type
A7
;
int
i
=
0
;
typename
basic_type
<
arg8_type
>::
type
A8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg9_type
>::
type
A9
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg9_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A9
);
++
i
;}
ELSE_ASSIGN_ARG_9
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg9_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A9
);
++
i
;}
ELSE_ASSIGN_ARG_9
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg9_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A9
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
};
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
if
(
is_output_type
<
arg9_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A9
);
++
i
;}
}
};
template
<
>
struct
call_mex_function_helper
<
10
>
{
template
<
typename
funct
>
template
<
>
void
callit
(
struct
call_mex_function_helper
<
10
>
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
funct
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
callit
(
)
const
const
funct
&
,
{
int
nlhs
,
mxArray
*
plhs
[],
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
int
nrhs
,
const
mxArray
*
prhs
[]
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
)
const
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
{
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg1_type
arg1_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg2_type
arg2_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg3_type
arg3_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typedef
typename
sig_traits
<
funct
>::
arg4_type
arg4_type
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typedef
typename
sig_traits
<
funct
>::
arg5_type
arg5_type
;
typedef
typename
sig_traits
<
funct
>::
arg9_type
arg9_type
;
typedef
typename
sig_traits
<
funct
>::
arg6_type
arg6_type
;
typedef
typename
sig_traits
<
funct
>::
arg10_type
arg10_type
;
typedef
typename
sig_traits
<
funct
>::
arg7_type
arg7_type
;
typedef
typename
sig_traits
<
funct
>::
arg8_type
arg8_type
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typedef
typename
sig_traits
<
funct
>::
arg9_type
arg9_type
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typedef
typename
sig_traits
<
funct
>::
arg10_type
arg10_type
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg1_type
>::
type
A1
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg2_type
>::
type
A2
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg3_type
>::
type
A3
;
typename
basic_type
<
arg7_type
>::
type
A7
;
typename
basic_type
<
arg4_type
>::
type
A4
;
typename
basic_type
<
arg8_type
>::
type
A8
;
typename
basic_type
<
arg5_type
>::
type
A5
;
typename
basic_type
<
arg9_type
>::
type
A9
;
typename
basic_type
<
arg6_type
>::
type
A6
;
typename
basic_type
<
arg10_type
>::
type
A10
;
typename
basic_type
<
arg7_type
>::
type
A7
;
typename
basic_type
<
arg8_type
>::
type
A8
;
int
i
=
0
;
typename
basic_type
<
arg9_type
>::
type
A9
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
typename
basic_type
<
arg10_type
>::
type
A10
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
int
i
=
0
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg1_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A1
);
++
i
;}
ELSE_ASSIGN_ARG_1
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg2_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A2
);
++
i
;}
ELSE_ASSIGN_ARG_2
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg3_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A3
);
++
i
;}
ELSE_ASSIGN_ARG_3
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg4_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A4
);
++
i
;}
ELSE_ASSIGN_ARG_4
;
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
if
(
i
<
nrhs
&&
is_input_type
<
arg5_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A5
);
++
i
;}
ELSE_ASSIGN_ARG_5
;
if
(
i
<
nrhs
&&
is_input_type
<
arg9_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A9
);
++
i
;}
ELSE_ASSIGN_ARG_9
;
if
(
i
<
nrhs
&&
is_input_type
<
arg6_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A6
);
++
i
;}
ELSE_ASSIGN_ARG_6
;
if
(
i
<
nrhs
&&
is_input_type
<
arg10_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A10
);
++
i
;}
ELSE_ASSIGN_ARG_10
;
if
(
i
<
nrhs
&&
is_input_type
<
arg7_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A7
);
++
i
;}
ELSE_ASSIGN_ARG_7
;
if
(
i
<
nrhs
&&
is_input_type
<
arg8_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A8
);
++
i
;}
ELSE_ASSIGN_ARG_8
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
);
if
(
i
<
nrhs
&&
is_input_type
<
arg9_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A9
);
++
i
;}
ELSE_ASSIGN_ARG_9
;
if
(
i
<
nrhs
&&
is_input_type
<
arg10_type
>::
value
)
{
validate_and_populate_arg
(
i
,
prhs
[
i
],
A10
);
++
i
;}
ELSE_ASSIGN_ARG_10
;
i
=
0
;
mex_function
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
);
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
i
=
0
;
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg1_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A1
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg2_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A2
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg3_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A3
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
if
(
is_output_type
<
arg4_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A4
);
++
i
;}
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
if
(
is_output_type
<
arg5_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A5
);
++
i
;}
if
(
is_output_type
<
arg9_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A9
);
++
i
;}
if
(
is_output_type
<
arg6_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A6
);
++
i
;}
if
(
is_output_type
<
arg10_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A10
);
++
i
;}
if
(
is_output_type
<
arg7_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A7
);
++
i
;}
}
if
(
is_output_type
<
arg8_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A8
);
++
i
;}
};
if
(
is_output_type
<
arg9_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A9
);
++
i
;}
if
(
is_output_type
<
arg10_type
>::
value
)
{
assign_to_matlab
(
plhs
[
i
],
A10
);
++
i
;}
// ----------------------------------------------------------------------------------------
}
};
template
<
typename
funct
// ----------------------------------------------------------------------------------------
>
void
call_mex_function
(
template
<
const
funct
&
f
,
typename
funct
int
nlhs
,
mxArray
*
plhs
[],
>
int
nrhs
,
const
mxArray
*
prhs
[]
void
call_mex_function
(
)
const
funct
&
f
,
{
int
nlhs
,
mxArray
*
plhs
[],
const
long
expected_nrhs
=
funct_traits
<
funct
>::
num_inputs
;
int
nrhs
,
const
mxArray
*
prhs
[]
const
long
expected_nlhs
=
funct_traits
<
funct
>::
num_outputs
;
)
const
long
expected_args
=
expected_nrhs
+
expected_nlhs
;
{
const
long
expected_nrhs
=
funct_traits
<
funct
>::
num_inputs
;
long
defaulted_args
=
0
;
const
long
expected_nlhs
=
funct_traits
<
funct
>::
num_outputs
;
const
long
expected_args
=
expected_nrhs
+
expected_nlhs
;
#ifdef ARG_1_DEFAULT
++
defaulted_args
;
long
defaulted_args
=
0
;
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
);
#ifdef ARG_1_DEFAULT
#ifndef ARG_2_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 1 if you don't define one for argument 2 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
2
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg1_type
>::
value
);
#endif
#ifndef ARG_2_DEFAULT
COMPILE_TIME_ASSERT
(
1
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 1 if you don't define one for argument 2 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
2
);
#ifdef ARG_2_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
1
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
);
#ifdef ARG_2_DEFAULT
#ifndef ARG_3_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 2 if you don't define one for argument 3 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
3
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg2_type
>::
value
);
#endif
#ifndef ARG_3_DEFAULT
COMPILE_TIME_ASSERT
(
2
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 2 if you don't define one for argument 3 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
3
);
#ifdef ARG_3_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
2
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
);
#ifdef ARG_3_DEFAULT
#ifndef ARG_4_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 3 if you don't define one for argument 4 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
4
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg3_type
>::
value
);
#endif
#ifndef ARG_4_DEFAULT
COMPILE_TIME_ASSERT
(
3
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 3 if you don't define one for argument 4 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
4
);
#ifdef ARG_4_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
3
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
);
#ifdef ARG_4_DEFAULT
#ifndef ARG_5_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 4 if you don't define one for argument 5 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
5
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg4_type
>::
value
);
#endif
#ifndef ARG_5_DEFAULT
COMPILE_TIME_ASSERT
(
4
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 4 if you don't define one for argument 5 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
5
);
#ifdef ARG_5_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
4
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
);
#ifdef ARG_5_DEFAULT
#ifndef ARG_6_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 5 if you don't define one for argument 6 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
6
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg5_type
>::
value
);
#endif
#ifndef ARG_6_DEFAULT
COMPILE_TIME_ASSERT
(
5
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 5 if you don't define one for argument 6 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
6
);
#ifdef ARG_6_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
5
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
);
#ifdef ARG_6_DEFAULT
#ifndef ARG_7_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 6 if you don't define one for argument 7 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
7
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg6_type
>::
value
);
#endif
#ifndef ARG_7_DEFAULT
COMPILE_TIME_ASSERT
(
6
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 6 if you don't define one for argument 7 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
7
);
#ifdef ARG_7_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
6
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
);
#ifdef ARG_7_DEFAULT
#ifndef ARG_8_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 7 if you don't define one for argument 8 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
8
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg7_type
>::
value
);
#endif
#ifndef ARG_8_DEFAULT
COMPILE_TIME_ASSERT
(
7
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 7 if you don't define one for argument 8 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
8
);
#ifdef ARG_8_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
7
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
);
#ifdef ARG_8_DEFAULT
#ifndef ARG_9_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 8 if you don't define one for argument 9 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
9
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg8_type
>::
value
);
#endif
#ifndef ARG_9_DEFAULT
COMPILE_TIME_ASSERT
(
8
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 8 if you don't define one for argument 9 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
9
);
#ifdef ARG_9_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
8
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
);
#ifdef ARG_9_DEFAULT
#ifndef ARG_10_DEFAULT
++
defaulted_args
;
// You can't define a default for argument 9 if you don't define one for argument 10 also.
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
expected_args
<
10
);
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg9_type
>::
value
);
#endif
#ifndef ARG_10_DEFAULT
COMPILE_TIME_ASSERT
(
9
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can't define a default for argument 9 if you don't define one for argument 10 also.
#endif
COMPILE_TIME_ASSERT
(
expected_args
<
10
);
#ifdef ARG_10_DEFAULT
#endif
++
defaulted_args
;
COMPILE_TIME_ASSERT
(
9
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
// You can only set an argument's default value if it is an input argument.
#endif
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
);
#ifdef ARG_10_DEFAULT
COMPILE_TIME_ASSERT
(
10
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
++
defaulted_args
;
#endif
// You can only set an argument's default value if it is an input argument.
COMPILE_TIME_ASSERT
(
is_input_type
<
typename
sig_traits
<
funct
>::
arg10_type
>::
value
);
COMPILE_TIME_ASSERT
(
10
<=
expected_args
);
// You can't define a default for an argument that doesn't exist.
#endif
/* check for proper number of arguments */
if
(
nrhs
>
expected_nrhs
||
nrhs
<
expected_nrhs
-
defaulted_args
)
{
std
::
ostringstream
sout
;
/* check for proper number of arguments */
sout
<<
"Expected between "
<<
expected_nrhs
-
defaulted_args
if
(
nrhs
>
expected_nrhs
||
nrhs
<
expected_nrhs
-
defaulted_args
)
<<
" and "
<<
expected_nrhs
<<
" input arguments, got "
<<
nrhs
<<
"."
;
{
std
::
ostringstream
sout
;
mexErrMsgIdAndTxt
(
"mex_function:nrhs"
,
sout
<<
"Expected between "
<<
expected_nrhs
-
defaulted_args
sout
.
str
().
c_str
());
<<
" and "
<<
expected_nrhs
<<
" input arguments, got "
<<
nrhs
<<
"."
;
}
mexErrMsgIdAndTxt
(
"mex_function:nrhs"
,
if
(
nlhs
>
expected_nlhs
)
sout
.
str
().
c_str
());
{
}
std
::
ostringstream
sout
;
sout
<<
"Expected at most "
<<
expected_nlhs
<<
" output arguments, got "
<<
nlhs
<<
"."
;
if
(
nlhs
>
expected_nlhs
)
{
mexErrMsgIdAndTxt
(
"mex_function:nlhs"
,
std
::
ostringstream
sout
;
sout
.
str
().
c_str
());
sout
<<
"Expected at most "
<<
expected_nlhs
<<
" output arguments, got "
<<
nlhs
<<
"."
;
}
mexErrMsgIdAndTxt
(
"mex_function:nlhs"
,
try
sout
.
str
().
c_str
());
{
}
call_mex_function_helper
<
sig_traits
<
funct
>::
num_args
>
helper
;
helper
.
callit
(
f
,
nlhs
,
plhs
,
nrhs
,
prhs
);
try
}
{
catch
(
invalid_args_exception
&
e
)
call_mex_function_helper
<
sig_traits
<
funct
>::
num_args
>
helper
;
{
helper
.
callit
(
f
,
nlhs
,
plhs
,
nrhs
,
prhs
);
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
}
(
"Input"
+
e
.
msg
).
c_str
());
catch
(
invalid_args_exception
&
e
)
}
{
catch
(
dlib
::
error
&
e
)
mexErrMsgIdAndTxt
(
"mex_function:validate_and_populate_arg"
,
{
(
"Input"
+
e
.
msg
).
c_str
());
mexErrMsgIdAndTxt
(
"mex_function:error"
,
}
e
.
what
());
catch
(
dlib
::
error
&
e
)
}
{
mexErrMsgIdAndTxt
(
"mex_function:error"
,
}
e
.
what
());
}
// ----------------------------------------------------------------------------------------
}
class
mex_streambuf
:
public
std
::
streambuf
{
// ----------------------------------------------------------------------------------------
public:
class
mex_streambuf
:
public
std
::
streambuf
mex_streambuf
(
{
)
{
public:
buf
.
resize
(
1000
);
mex_streambuf
(
setp
(
&
buf
[
0
],
&
buf
[
0
]
+
buf
.
size
()
-
2
);
)
{
// make cout send data to mex_streambuf
buf
.
resize
(
1000
);
std
::
cout
.
rdbuf
(
this
);
setp
(
&
buf
[
0
],
&
buf
[
0
]
+
buf
.
size
()
-
2
);
}
// make cout send data to mex_streambuf
std
::
cout
.
rdbuf
(
this
);
protected:
}
int
sync
(
protected:
)
{
int
num
=
static_cast
<
int
>
(
pptr
()
-
pbase
());
int
sync
(
if
(
num
!=
0
)
)
{
{
buf
[
num
]
=
0
;
// null terminate the string
int
num
=
static_cast
<
int
>
(
pptr
()
-
pbase
());
mexPrintf
(
"%s"
,
&
buf
[
0
]);
if
(
num
!=
0
)
mexEvalString
(
"drawnow"
);
// flush print to screen
{
pbump
(
-
num
);
buf
[
num
]
=
0
;
// null terminate the string
}
mexPrintf
(
"%s"
,
&
buf
[
0
]);
return
0
;
mexEvalString
(
"drawnow"
);
// flush print to screen
}
pbump
(
-
num
);
}
int_type
overflow
(
return
0
;
int_type
c
}
)
{
int_type
overflow
(
if
(
c
!=
EOF
)
int_type
c
{
)
*
pptr
()
=
c
;
{
pbump
(
1
);
if
(
c
!=
EOF
)
}
{
sync
();
*
pptr
()
=
c
;
return
c
;
pbump
(
1
);
}
}
sync
();
private:
return
c
;
std
::
vector
<
char
>
buf
;
}
};
private:
std
::
vector
<
char
>
buf
;
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
};
template
<
typename
T
>
// ----------------------------------------------------------------------------------------
void
setup_input_args
(
// ----------------------------------------------------------------------------------------
mxArray
*&
array
,
const
T
&
item
,
template
<
typename
T
>
int
&
nrhs
void
setup_input_args
(
)
mxArray
*&
array
,
{
const
T
&
item
,
assign_to_matlab
(
array
,
item
);
int
&
nrhs
++
nrhs
;
)
}
{
assign_to_matlab
(
array
,
item
);
void
setup_input_args
(
++
nrhs
;
mxArray
*&
array
,
}
const
function_handle
&
item
,
int
&
nrhs
void
setup_input_args
(
)
mxArray
*&
array
,
{
const
function_handle
&
item
,
array
=
static_cast
<
mxArray
*>
(
item
.
h
);
int
&
nrhs
++
nrhs
;
)
}
{
array
=
static_cast
<
mxArray
*>
(
item
.
h
);
template
<
typename
T
>
++
nrhs
;
void
setup_input_args
(
}
mxArray
*&
array
,
const
output_decorator
<
T
>&
item
,
template
<
typename
T
>
int
&
nrhs
void
setup_input_args
(
)
mxArray
*&
array
,
{
const
output_decorator
<
T
>&
item
,
}
int
&
nrhs
)
template
<
typename
T
>
{
void
setup_output_args
(
}
const
std
::
string
&
function_name
,
mxArray
*
array
,
template
<
typename
T
>
const
T
&
item
,
void
setup_output_args
(
int
&
nrhs
const
std
::
string
&
function_name
,
)
mxArray
*
array
,
{
const
T
&
item
,
}
int
&
nrhs
)
template
<
typename
T
>
{
void
setup_output_args
(
}
const
std
::
string
&
function_name
,
mxArray
*
array
,
template
<
typename
T
>
const
output_decorator
<
T
>&
item
,
void
setup_output_args
(
int
&
i
const
std
::
string
&
function_name
,
)
mxArray
*
array
,
{
const
output_decorator
<
T
>&
item
,
try
int
&
i
{
)
validate_and_populate_arg
(
i
,
array
,
const_cast
<
T
&>
(
item
.
item
));
{
++
i
;
try
}
{
catch
(
invalid_args_exception
&
e
)
validate_and_populate_arg
(
i
,
array
,
const_cast
<
T
&>
(
item
.
item
));
{
++
i
;
throw
dlib
::
error
(
"Error occurred calling MATLAB function '"
+
function_name
+
"' from mex file.
\n
"
}
"The MATLAB function didn't return what we expected it to.
\n
In particular, return"
+
e
.
msg
);
catch
(
invalid_args_exception
&
e
)
}
{
}
throw
dlib
::
error
(
"Error occurred calling MATLAB function '"
+
function_name
+
"' from mex file.
\n
"
"The MATLAB function didn't return what we expected it to.
\n
In particular, return"
+
e
.
msg
);
void
call_matlab_for_real
(
}
int
nlhs
,
}
mxArray
*
plhs
[],
int
nrhs
,
void
call_matlab_for_real
(
mxArray
*
prhs
[],
int
nlhs
,
const
std
::
string
&
function_name
mxArray
*
plhs
[],
)
int
nrhs
,
{
mxArray
*
prhs
[],
int
status
=
mexCallMATLAB
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
.
c_str
());
const
std
::
string
&
function_name
if
(
status
)
)
{
{
throw
dlib
::
error
(
"Error, an exception was thrown when we tried to call the MATLAB function '"
+
function_name
+
"'."
);
int
status
=
mexCallMATLAB
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
.
c_str
());
}
if
(
status
)
}
{
throw
dlib
::
error
(
"Error, an exception was thrown when we tried to call the MATLAB function '"
+
function_name
+
"'."
);
// ----------------------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------------------
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
void
call_matlab
(
// ----------------------------------------------------------------------------------------
const
std
::
string
&
function_name
// ----------------------------------------------------------------------------------------
)
{
void
call_matlab
(
using
namespace
mex_binding
;
const
std
::
string
&
function_name
)
call_matlab_for_real
(
0
,
NULL
,
0
,
NULL
,
function_name
);
{
}
using
namespace
mex_binding
;
template
<
typename
T1
>
call_matlab_for_real
(
0
,
NULL
,
0
,
NULL
,
function_name
);
void
free_callback_resources
(
}
int
nlhs
,
mxArray
*
plhs
[],
template
<
typename
T1
>
int
nrhs
,
void
free_callback_resources
(
mxArray
*
prhs
[]
int
nlhs
,
)
mxArray
*
plhs
[],
{
int
nrhs
,
// free resources
mxArray
*
prhs
[]
for
(
int
i
=
0
;
i
<
nlhs
;
++
i
)
)
mxDestroyArray
(
plhs
[
i
]);
{
// free resources
for
(
int
i
=
0
;
i
<
nrhs
;
++
i
)
for
(
int
i
=
0
;
i
<
nlhs
;
++
i
)
{
mxDestroyArray
(
plhs
[
i
]);
// don't call mxDestroyArray() on function handles (which should only ever be in prhs[0])
if
(
i
==
0
&&
dlib
::
is_same_type
<
T1
,
function_handle
>::
value
)
for
(
int
i
=
0
;
i
<
nrhs
;
++
i
)
continue
;
{
mxDestroyArray
(
prhs
[
i
]);
// don't call mxDestroyArray() on function handles (which should only ever be in prhs[0])
}
if
(
i
==
0
&&
dlib
::
is_same_type
<
T1
,
function_handle
>::
value
)
}
continue
;
mxDestroyArray
(
prhs
[
i
]);
template
<
}
typename
T1
}
>
void
call_matlab
(
template
<
const
std
::
string
&
function_name
,
typename
T1
const
T1
&
A1
>
)
void
call_matlab
(
{
const
std
::
string
&
function_name
,
using
namespace
mex_binding
;
const
T1
&
A1
const
int
num_args
=
1
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
1
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
const
int
nlhs
=
num_args
-
nrhs
;
int
nrhs
=
0
;
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
int
i
=
0
;
}
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
template
<
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
typename
T1
,
}
typename
T2
>
template
<
void
call_matlab
(
typename
T1
,
const
std
::
string
&
function_name
,
typename
T2
const
T1
&
A1
,
>
const
T2
&
A2
void
call_matlab
(
)
const
std
::
string
&
function_name
,
{
const
T1
&
A1
,
using
namespace
mex_binding
;
const
T2
&
A2
const
int
num_args
=
2
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
2
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
int
nrhs
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
int
i
=
0
;
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
template
<
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
typename
T1
,
}
typename
T2
,
typename
T3
template
<
>
typename
T1
,
void
call_matlab
(
typename
T2
,
const
std
::
string
&
function_name
,
typename
T3
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
const
std
::
string
&
function_name
,
)
const
T1
&
A1
,
{
const
T2
&
A2
,
using
namespace
mex_binding
;
const
T3
&
A3
const
int
num_args
=
3
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
3
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
typename
T1
,
>
typename
T2
,
void
call_matlab
(
typename
T3
,
const
std
::
string
&
function_name
,
typename
T4
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
const
T1
&
A1
,
)
const
T2
&
A2
,
{
const
T3
&
A3
,
using
namespace
mex_binding
;
const
T4
&
A4
const
int
num_args
=
4
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
4
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
typename
T2
,
>
typename
T3
,
void
call_matlab
(
typename
T4
,
const
std
::
string
&
function_name
,
typename
T5
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
const
T2
&
A2
,
)
const
T3
&
A3
,
{
const
T4
&
A4
,
using
namespace
mex_binding
;
const
T5
&
A5
const
int
num_args
=
5
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
5
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
,
typename
T2
,
typename
T6
typename
T3
,
>
typename
T4
,
void
call_matlab
(
typename
T5
,
const
std
::
string
&
function_name
,
typename
T6
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
,
const
T2
&
A2
,
const
T6
&
A6
const
T3
&
A3
,
)
const
T4
&
A4
,
{
const
T5
&
A5
,
using
namespace
mex_binding
;
const
T6
&
A6
const
int
num_args
=
6
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
6
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
,
typename
T2
,
typename
T6
,
typename
T3
,
typename
T7
typename
T4
,
>
typename
T5
,
void
call_matlab
(
typename
T6
,
const
std
::
string
&
function_name
,
typename
T7
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
,
const
T2
&
A2
,
const
T6
&
A6
,
const
T3
&
A3
,
const
T7
&
A7
const
T4
&
A4
,
)
const
T5
&
A5
,
{
const
T6
&
A6
,
using
namespace
mex_binding
;
const
T7
&
A7
const
int
num_args
=
7
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
7
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
,
typename
T2
,
typename
T6
,
typename
T3
,
typename
T7
,
typename
T4
,
typename
T8
typename
T5
,
>
typename
T6
,
void
call_matlab
(
typename
T7
,
const
std
::
string
&
function_name
,
typename
T8
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
,
const
T2
&
A2
,
const
T6
&
A6
,
const
T3
&
A3
,
const
T7
&
A7
,
const
T4
&
A4
,
const
T8
&
A8
const
T5
&
A5
,
)
const
T6
&
A6
,
{
const
T7
&
A7
,
using
namespace
mex_binding
;
const
T8
&
A8
const
int
num_args
=
8
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
8
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
,
typename
T2
,
typename
T6
,
typename
T3
,
typename
T7
,
typename
T4
,
typename
T8
,
typename
T5
,
typename
T9
typename
T6
,
>
typename
T7
,
void
call_matlab
(
typename
T8
,
const
std
::
string
&
function_name
,
typename
T9
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
,
const
T2
&
A2
,
const
T6
&
A6
,
const
T3
&
A3
,
const
T7
&
A7
,
const
T4
&
A4
,
const
T8
&
A8
,
const
T5
&
A5
,
const
T9
&
A9
const
T6
&
A6
,
)
const
T7
&
A7
,
{
const
T8
&
A8
,
using
namespace
mex_binding
;
const
T9
&
A9
const
int
num_args
=
9
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
9
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A9
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A9
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A9
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A9
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
template
<
}
typename
T1
,
typename
T2
,
typename
T3
,
template
<
typename
T4
,
typename
T1
,
typename
T5
,
typename
T2
,
typename
T6
,
typename
T3
,
typename
T7
,
typename
T4
,
typename
T8
,
typename
T5
,
typename
T9
,
typename
T6
,
typename
T10
typename
T7
,
>
typename
T8
,
void
call_matlab
(
typename
T9
,
const
std
::
string
&
function_name
,
typename
T10
const
T1
&
A1
,
>
const
T2
&
A2
,
void
call_matlab
(
const
T3
&
A3
,
const
std
::
string
&
function_name
,
const
T4
&
A4
,
const
T1
&
A1
,
const
T5
&
A5
,
const
T2
&
A2
,
const
T6
&
A6
,
const
T3
&
A3
,
const
T7
&
A7
,
const
T4
&
A4
,
const
T8
&
A8
,
const
T5
&
A5
,
const
T9
&
A9
,
const
T6
&
A6
,
const
T10
&
A10
const
T7
&
A7
,
)
const
T8
&
A8
,
{
const
T9
&
A9
,
using
namespace
mex_binding
;
const
T10
&
A10
const
int
num_args
=
10
;
)
mxArray
*
plhs
[
num_args
]
=
{
0
};
{
mxArray
*
prhs
[
num_args
]
=
{
0
};
using
namespace
mex_binding
;
const
int
num_args
=
10
;
int
nrhs
=
0
;
mxArray
*
plhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
mxArray
*
prhs
[
num_args
]
=
{
0
};
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
int
nrhs
=
0
;
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A1
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A2
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A3
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A4
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A5
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A10
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A6
,
nrhs
);
setup_input_args
(
prhs
[
nrhs
],
A7
,
nrhs
);
const
int
nlhs
=
num_args
-
nrhs
;
setup_input_args
(
prhs
[
nrhs
],
A8
,
nrhs
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_input_args
(
prhs
[
nrhs
],
A10
,
nrhs
);
int
i
=
0
;
const
int
nlhs
=
num_args
-
nrhs
;
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
call_matlab_for_real
(
nlhs
,
plhs
,
nrhs
,
prhs
,
function_name
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
int
i
=
0
;
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A1
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A2
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A3
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A4
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A5
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A10
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A6
,
i
);
setup_output_args
(
function_name
,
plhs
[
i
],
A7
,
i
);
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
setup_output_args
(
function_name
,
plhs
[
i
],
A8
,
i
);
}
setup_output_args
(
function_name
,
plhs
[
i
],
A10
,
i
);
// ----------------------------------------------------------------------------------------
free_callback_resources
<
T1
>
(
nlhs
,
plhs
,
nrhs
,
prhs
);
// ----------------------------------------------------------------------------------------
}
void
call_matlab
(
// ----------------------------------------------------------------------------------------
const
function_handle
&
funct
// ----------------------------------------------------------------------------------------
)
{
void
call_matlab
(
call_matlab
(
"feval"
,
funct
);
const
function_handle
&
funct
}
)
{
// ----------------------------------------------------------------------------------------
call_matlab
(
"feval"
,
funct
);
// ----------------------------------------------------------------------------------------
}
/* The gateway function called by MATLAB*/
// ----------------------------------------------------------------------------------------
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
// ----------------------------------------------------------------------------------------
int
nrhs
,
const
mxArray
*
prhs
[])
{
/* The gateway function called by MATLAB*/
// Only remap cout if we aren't using octave since octave already does this.
void
mexFunction
(
int
nlhs
,
mxArray
*
plhs
[],
#if !defined(OCTAVE_IMPORT) && !defined(OCTAVE_API)
int
nrhs
,
const
mxArray
*
prhs
[])
// make it so cout prints to mexPrintf()
{
static
mex_binding
::
mex_streambuf
sb
;
// Only remap cout if we aren't using octave since octave already does this.
#endif
#if !defined(OCTAVE_IMPORT) && !defined(OCTAVE_API)
// make it so cout prints to mexPrintf()
mex_binding
::
call_mex_function
(
mex_function
,
nlhs
,
plhs
,
nrhs
,
prhs
);
static
mex_binding
::
mex_streambuf
sb
;
}
#endif
// ----------------------------------------------------------------------------------------
mex_binding
::
call_mex_function
(
mex_function
,
nlhs
,
plhs
,
nrhs
,
prhs
);
}
// ----------------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment