📄 magicsquare.cs
字号:
/*
* MATLAB Compiler: 4.4 (R2006a)
* Date: Wed Mar 28 11:03:07 2007
* Arguments: "-B" "macro_default" "-M" "-silentsetup" "-S" "-v" "-B"
* "dotnet:MagicDemoComp,MagicSquare,1.0,private" "-W"
* "dotnet:MagicDemoComp,MagicSquare,1.0,private" "-T" "link:lib" "-d"
* "C:/work/MagicSquareExample/MagicDemoComp/src"
* "C:/work/MagicSquareExample/MagicDemoComp/makesquare.m"
*/
using System;
using System.Reflection;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;
[assembly: System.Reflection.AssemblyVersion("1.0.*")]
#if SHARED
[assembly: System.Reflection.AssemblyKeyFile(@"")]
#endif
namespace MagicDemoComp
{
/// <summary>
/// The MagicSquare class provides a CLS compliant interface to the M-functions
/// contained in the files:
/// <newpara></newpara>
/// C:/work/MagicSquareExample/MagicDemoComp/makesquare.m
/// <newpara></newpara>
/// matlabrc.m
/// <newpara></newpara>
/// dirname.m
/// <newpara></newpara>
/// deployprint.m
/// <newpara></newpara>
/// printdlg.m
/// </summary>
/// <remarks>
/// @Version 1.0
/// </remarks>
public class MagicSquare : IDisposable
{
#region Constructors
/// <summary internal= "true">
/// The static constructor instantiates and initializes the MATLAB Common Runtime
/// instance.
/// </summary>
static MagicSquare()
{
Assembly assembly= Assembly.GetExecutingAssembly();
string ctfFilePath= assembly.Location;
int lastDelimeter= ctfFilePath.LastIndexOf(@"\");
ctfFilePath= ctfFilePath.Remove(lastDelimeter, (ctfFilePath.Length - lastDelimeter));
if (MWMCR.InitializeApplication(new string[]{}))
{
mcr= new MWMCR(MCRComponentState.MCC_MagicDemoComp_name_data,
MCRComponentState.MCC_MagicDemoComp_root_data,
MCRComponentState.MCC_MagicDemoComp_public_data,
MCRComponentState.MCC_MagicDemoComp_session_data,
MCRComponentState.MCC_MagicDemoComp_matlabpath_data,
MCRComponentState.MCC_MagicDemoComp_classpath_data,
MCRComponentState.MCC_MagicDemoComp_libpath_data,
MCRComponentState.MCC_MagicDemoComp_mcr_application_options,
MCRComponentState.MCC_MagicDemoComp_mcr_runtime_options,
MCRComponentState.MCC_MagicDemoComp_mcr_pref_dir,
MCRComponentState.MCC_MagicDemoComp_set_warning_state,
ctfFilePath, true);
}
}
/// <summary>
/// Constructs a new instance of the MagicSquare class.
/// </summary>
public MagicSquare()
{
}
#endregion Constructors
#region Finalize
/// <summary internal= "true">
/// Class destructor called by the CLR garbage collector.
/// </summary>
~MagicSquare()
{
Dispose(false);
}
/// <summary>
/// Frees the native resources associated with this object
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary internal= "true">
/// Internal dispose function
/// </summary>
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
disposed= true;
if (disposing)
{
// Free managed resources;
}
// Free native resources
}
}
#endregion Finalize
#region Methods
/// <summary>
/// Provides a single output, 0-input interface to the makesquare M-function.
/// </summary>
/// <remarks>
/// M-Documentation:
/// MAKESQUARE Magic square of size x.
/// Y = MAKESQUARE(X) returns a magic square of size x.
/// This file is used as an example for the MATLAB
/// .NET Builder Language product.
/// </remarks>
/// <returns>An MWArray containing the first output argument.</returns>
///
public MWArray makesquare()
{
return mcr.EvaluateFunction("makesquare");
}
/// <summary>
/// Provides a single output, 1-input interface to the makesquare M-function.
/// </summary>
/// <remarks>
/// M-Documentation:
/// MAKESQUARE Magic square of size x.
/// Y = MAKESQUARE(X) returns a magic square of size x.
/// This file is used as an example for the MATLAB
/// .NET Builder Language product.
/// </remarks>
/// <param name="x">Input argument #1</param>
/// <returns>An MWArray containing the first output argument.</returns>
///
public MWArray makesquare(MWArray x)
{
return mcr.EvaluateFunction("makesquare", x);
}
/// <summary>
/// Provides the standard 0-input interface to the makesquare M-function.
/// </summary>
/// <remarks>
/// M-Documentation:
/// MAKESQUARE Magic square of size x.
/// Y = MAKESQUARE(X) returns a magic square of size x.
/// This file is used as an example for the MATLAB
/// .NET Builder Language product.
/// </remarks>
/// <param name="numArgsOut">The number of output arguments to return.</param>
/// <returns>An Array of length "numArgsOut" containing the output
/// arguments.</returns>
///
public MWArray[] makesquare(int numArgsOut)
{
return mcr.EvaluateFunction(numArgsOut, "makesquare");
}
/// <summary>
/// Provides the standard 1-input interface to the makesquare M-function.
/// </summary>
/// <remarks>
/// M-Documentation:
/// MAKESQUARE Magic square of size x.
/// Y = MAKESQUARE(X) returns a magic square of size x.
/// This file is used as an example for the MATLAB
/// .NET Builder Language product.
/// </remarks>
/// <param name="numArgsOut">The number of output arguments to return.</param>
/// <param name="x">Input argument #1</param>
/// <returns>An Array of length "numArgsOut" containing the output
/// arguments.</returns>
///
public MWArray[] makesquare(int numArgsOut, MWArray x)
{
return mcr.EvaluateFunction(numArgsOut, "makesquare", x);
}
/// <summary>
/// Provides an interface for the makesquare function in which the input and output
/// arguments are specified as an array of MWArrays.
/// </summary>
/// <remarks>
/// This method will allocate and return by reference the output argument
/// array.<newpara></newpara>
/// M-Documentation:
/// MAKESQUARE Magic square of size x.
/// Y = MAKESQUARE(X) returns a magic square of size x.
/// This file is used as an example for the MATLAB
/// .NET Builder Language product.
/// </remarks>
/// <param name="numArgsOut">The number of output arguments to return</param>
/// <param name= "argsOut">Array of MWArray output arguments</param>
/// <param name= "argsIn">Array of MWArray input arguments</param>
///
public void makesquare(int numArgsOut, ref MWArray[] argsOut, MWArray[] argsIn)
{
mcr.EvaluateFunction("makesquare", numArgsOut, ref argsOut, argsIn);
}
#endregion Methods
#region Class Members
private static MWMCR mcr= null;
private bool disposed= false;
#endregion Class Members
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -