⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matlab_for_mxarray.txt

📁 matlab中mxArray 的C#实现
💻 TXT
字号:
using System;
using System.Runtime.InteropServices;

namespace MATLIB
{
/// <summary>
/// MATLIB.
/// Author : zhu8jie_@msn.com
/// Copyright (c) 2004. 
/// All Rights Reserved.
/// </summary>
[ClassInterface(ClassInterfaceType.None)]
public class matLib
{
  
  [StructLayout(LayoutKind.Sequential)]
  public struct mxArray_flags
  {
    public uint data;

  }

  [StructLayout(LayoutKind.Sequential)]
  public struct mxArray_number_array
  {
    public IntPtr pdata;
    public IntPtr pimag_data;
    public IntPtr reserved5;
    [MarshalAs(UnmanagedType.ByValArray,SizeConst=3)]
    public int[] reserved6;
  }
  
  [StructLayout(LayoutKind.Explicit)]
  public struct mxArray_data
  {
    [FieldOffset(0)] public mxArray_number_array number_array;
  }

  [StructLayout(LayoutKind.Sequential)]
  public struct mxArray
  {
//    mxArray defination in matrix.h
//
//    struct mxArray_tag 
//    {
//    void *reserved;
//    int reserved1[2];
//    void *reserved2;
//    int number_of_dims;
//    unsigned int reserved3;
//    struct 
//    {
//      unsigned int scalar_flag : 1;
//      unsigned int  flag1 : 1; 
//      unsigned int flag2 : 1;
//      unsigned int flag3 : 1;
//      unsigned int flag4 : 1;
//      unsigned int flag5 : 1;
//      unsigned int flag6 : 1;
//      unsigned int flag7 : 1;
//      unsigned int private_data_flag : 1;
//      unsigned int flag8 : 1;
//      unsigned int flag9 : 1;
//      unsigned int flag10 : 1;
//      unsigned int flag11 : 4;
//      unsigned int flag12 : 8;
//      unsigned int flag13 : 8;
//    } flags;
//    unsigned int reserved4[2];
//    union 
//    {
//      struct 
//      {
//      void *pdata;
//      void *pimag_data;
//      void *reserved5;
//      int reserved6[3];
//      } number_array;
//    } data;
//    };

    public IntPtr reserved;
    [MarshalAs(UnmanagedType.ByValArray,SizeConst=2)]
    public int[] reserved1;
    public IntPtr reserved2;
    public int number_of_dims;
    public uint reserved3;
    public mxArray_flags flags;
    [MarshalAs(UnmanagedType.ByValArray,SizeConst=2)]
    public uint[] reserved4;
    public mxArray_data data;
  }
}
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -