MATLAB.MexTools
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MATLAB.MexTools --version 1.0.2
NuGet\Install-Package MATLAB.MexTools -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MATLAB.MexTools" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MATLAB.MexTools --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MATLAB.MexTools, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MATLAB.MexTools as a Cake Addin #addin nuget:?package=MATLAB.MexTools&version=1.0.2 // Install MATLAB.MexTools as a Cake Tool #tool nuget:?package=MATLAB.MexTools&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
使用本工具快速生成 MATLAB C++ MEX 数据API文件函数。
MATLAB C++ MEX 数据API文件函数本质上就是个实现了一套MEX标准接口的动态链接库,扩展名mexw64。你只需要在 Visual Studio 中新建一个C++动态链接库项目,将输出扩展名改为mexw64,包含【Mex工具.h】,然后实现其中声明的MexFunction::operator(),就可以生成出合法的MEX文件函数。此外,本工具还额外提供万能转码函数,用于常见的MATLAB与C++数据类型转换。
Mex工具.h公开接口
extern ArrayFactory 数组工厂;
template <typename T>
concept 数值 = std::is_arithmetic<T>::value;
//MATLAB转C++
//一般标量转换
template<typename T>
inline T 万能转码(Array& 输入);
//一般指针转换自uint64
template <typename T>
requires std::is_pointer<T>::value
inline T 万能转码(Array& 输入);
template<>
String 万能转码<String>(Array& 输入);
template<>
CharArray 万能转码<CharArray>(Array& 输入);
template<>
std::string 万能转码<std::string>(Array& 输入);
//C++转MATLAB
template <typename T>
inline buffer_ptr_t<T> 万能转码(const T* 指针, UINT64 尺寸);
inline TypedArray<uint64_t>万能转码(const void*指针);
template <数值 T>
inline TypedArray<T> 万能转码(T 输入);
template<class T>
requires std::_Is_any_of_v<T,String,MATLABString,CharArray>
T 万能转码(const char*);
template<>
String 万能转码<String>(const char*);
template<>
inline MATLABString 万能转码<MATLABString>(const char* UTF8);
template<>
inline CharArray 万能转码<CharArray>(const char* UTF8);
class MexFunction :public Function
{
public:
//用户实现此方法作为MEX文件函数体
void operator()(ArgumentList& outputs, ArgumentList& inputs)override;
};
//增强功能,可以使用如下三个宏定义在一个MEX文件函数中定义多个API
#define API声明(函数名) void 函数名(ArgumentList& outputs,ArgumentList& inputs)
#define API索引 constexpr void (*(API[]))(ArgumentList&, ArgumentList&) =
#define API调用 API[万能转码<UINT8>(inputs[0])](outputs, inputs);
//增强功能,可以返回一个异常值并补齐额外的输出值
void 异常输出补全(ArgumentList& outputs);
一个示例实现,用单个MEX文件实现一个OirReader类,通过CreateOirReader创建对象,DestroyOirReader销毁对象。该示例的完整代码参见此处。
API声明(CreateOirReader)
{
const String 文件路径 = 万能转码<String>(inputs[1]);
//Oir读入器是另外实现的C++类构造
outputs[0] = 万能转码(new Oir读入器((wchar_t*)文件路径.c_str()));
}
API声明(DestroyOirReader)
{
delete 万能转码<Oir读入器*>(inputs[1]);
//成功结构是返回一个表示操作成功的MATLAB类型
outputs[0] = 成功结构;
}
void MexFunction::operator()(ArgumentList& outputs, ArgumentList& inputs)
{
API索引
{
CreateOirReader,
DestroyOirReader,
};
try
{
API调用;
}
//Image5D异常是内部异常类型
catch (Image5D异常 异常)
{
//异常转换将内部异常转换为MATLAB类型
outputs[0] = 异常转换(异常);
//由于函数可能有多个输出,将其他输出补齐
异常输出补全(outputs);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
native | native is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
7.0.2 | 86 | 10/25/2024 | |
7.0.1 | 111 | 8/29/2024 | |
7.0.0 | 77 | 7/29/2024 | |
6.2.0 | 219 | 4/13/2024 | |
6.1.1 | 324 | 11/30/2023 | |
6.1.0 | 126 | 11/30/2023 | |
6.0.0 | 263 | 9/1/2023 | |
5.0.0 | 339 | 8/21/2023 | |
4.0.0 | 374 | 8/4/2023 | |
3.0.0 | 220 | 7/15/2023 | |
2.0.1 | 309 | 3/12/2023 | |
2.0.0 | 271 | 3/5/2023 | |
1.2.3 | 367 | 12/17/2022 | |
1.2.2 | 442 | 9/17/2022 | |
1.2.1 | 405 | 8/30/2022 | |
1.1.0 | 382 | 8/22/2022 | |
1.0.3 | 459 | 8/12/2022 | |
1.0.2 | 400 | 8/10/2022 | |
1.0.1 | 433 | 8/10/2022 | |
1.0.0 | 416 | 8/10/2022 |