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

📄 meshgrid.c

📁 《精通Matlab6.5版》张志勇等编著
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * MATLAB Compiler: 2.2
 * Date: Tue Jun 25 15:00:23 2002
 * Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
 * "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
 * "array_indexing:on" "-O" "optimize_conditionals:on" "-t" "-W" "lib:Templib"
 * "-T" "link:exe" "-h" "fileinc.c" "mrank" 
 */
#include "meshgrid.h"
#include "libmatlbm.h"

static mxChar _array1_[134] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'm', 'e', 's', 'h', 'g',
                                'r', 'i', 'd', ' ', 'L', 'i', 'n', 'e', ':',
                                ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n',
                                ':', ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f',
                                'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', '"',
                                'm', 'e', 's', 'h', 'g', 'r', 'i', 'd', '"',
                                ' ', 'w', 'a', 's', ' ', 'c', 'a', 'l', 'l',
                                'e', 'd', ' ', 'w', 'i', 't', 'h', ' ', 'm',
                                'o', 'r', 'e', ' ', 't', 'h', 'a', 'n', ' ',
                                't', 'h', 'e', ' ', 'd', 'e', 'c', 'l', 'a',
                                'r', 'e', 'd', ' ', 'n', 'u', 'm', 'b', 'e',
                                'r', ' ', 'o', 'f', ' ', 'o', 'u', 't', 'p',
                                'u', 't', 's', ' ', '(', '3', ')', '.' };
static mxArray * _mxarray0_;

static mxChar _array3_[133] = { 'R', 'u', 'n', '-', 't', 'i', 'm', 'e', ' ',
                                'E', 'r', 'r', 'o', 'r', ':', ' ', 'F', 'i',
                                'l', 'e', ':', ' ', 'm', 'e', 's', 'h', 'g',
                                'r', 'i', 'd', ' ', 'L', 'i', 'n', 'e', ':',
                                ' ', '1', ' ', 'C', 'o', 'l', 'u', 'm', 'n',
                                ':', ' ', '1', ' ', 'T', 'h', 'e', ' ', 'f',
                                'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', '"',
                                'm', 'e', 's', 'h', 'g', 'r', 'i', 'd', '"',
                                ' ', 'w', 'a', 's', ' ', 'c', 'a', 'l', 'l',
                                'e', 'd', ' ', 'w', 'i', 't', 'h', ' ', 'm',
                                'o', 'r', 'e', ' ', 't', 'h', 'a', 'n', ' ',
                                't', 'h', 'e', ' ', 'd', 'e', 'c', 'l', 'a',
                                'r', 'e', 'd', ' ', 'n', 'u', 'm', 'b', 'e',
                                'r', ' ', 'o', 'f', ' ', 'i', 'n', 'p', 'u',
                                't', 's', ' ', '(', '3', ')', '.' };
static mxArray * _mxarray2_;
static mxArray * _mxarray4_;
static mxArray * _mxarray5_;

static mxChar _array7_[27] = { 'N', 'o', 't', ' ', 'e', 'n', 'o', 'u', 'g',
                               'h', ' ', 'i', 'n', 'p', 'u', 't', ' ', 'a',
                               'r', 'g', 'u', 'm', 'e', 'n', 't', 's', '.' };
static mxArray * _mxarray6_;

void InitializeModule_meshgrid(void) {
    _mxarray0_ = mclInitializeString(134, _array1_);
    _mxarray2_ = mclInitializeString(133, _array3_);
    _mxarray4_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
    _mxarray5_ = mclInitializeDouble(1.0);
    _mxarray6_ = mclInitializeString(27, _array7_);
}

void TerminateModule_meshgrid(void) {
    mxDestroyArray(_mxarray6_);
    mxDestroyArray(_mxarray5_);
    mxDestroyArray(_mxarray4_);
    mxDestroyArray(_mxarray2_);
    mxDestroyArray(_mxarray0_);
}

static mxArray * Mmeshgrid(mxArray * * yy,
                           mxArray * * zz,
                           int nargout_,
                           mxArray * x,
                           mxArray * y,
                           mxArray * z);

_mexLocalFunctionTable _local_function_table_meshgrid
  = { 0, (mexFunctionTableEntry *)NULL };

/*
 * The function "mlfNMeshgrid" contains the nargout interface for the
 * "meshgrid" M-function from file
 * "d:\MATLAB6p1\toolbox\matlab\elmat\meshgrid.m" (lines 1-60). This interface
 * is only produced if the M-function uses the special variable "nargout". The
 * nargout interface allows the number of requested outputs to be specified via
 * the nargout argument, as opposed to the normal interface which dynamically
 * calculates the number of outputs based on the number of non-NULL inputs it
 * receives. This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfNMeshgrid(int nargout,
                       mxArray * * yy,
                       mxArray * * zz,
                       mxArray * x,
                       mxArray * y,
                       mxArray * z) {
    mxArray * xx = mclGetUninitializedArray();
    mxArray * yy__ = mclGetUninitializedArray();
    mxArray * zz__ = mclGetUninitializedArray();
    mlfEnterNewContext(2, 3, yy, zz, x, y, z);
    xx = Mmeshgrid(&yy__, &zz__, nargout, x, y, z);
    mlfRestorePreviousContext(2, 3, yy, zz, x, y, z);
    if (yy != NULL) {
        mclCopyOutputArg(yy, yy__);
    } else {
        mxDestroyArray(yy__);
    }
    if (zz != NULL) {
        mclCopyOutputArg(zz, zz__);
    } else {
        mxDestroyArray(zz__);
    }
    return mlfReturnValue(xx);
}

/*
 * The function "mlfMeshgrid" contains the normal interface for the "meshgrid"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\elmat\meshgrid.m" (lines
 * 1-60). This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfMeshgrid(mxArray * * yy,
                      mxArray * * zz,
                      mxArray * x,
                      mxArray * y,
                      mxArray * z) {
    int nargout = 1;
    mxArray * xx = mclGetUninitializedArray();
    mxArray * yy__ = mclGetUninitializedArray();
    mxArray * zz__ = mclGetUninitializedArray();
    mlfEnterNewContext(2, 3, yy, zz, x, y, z);
    if (yy != NULL) {
        ++nargout;
    }
    if (zz != NULL) {
        ++nargout;
    }
    xx = Mmeshgrid(&yy__, &zz__, nargout, x, y, z);
    mlfRestorePreviousContext(2, 3, yy, zz, x, y, z);
    if (yy != NULL) {
        mclCopyOutputArg(yy, yy__);
    } else {
        mxDestroyArray(yy__);
    }
    if (zz != NULL) {
        mclCopyOutputArg(zz, zz__);
    } else {
        mxDestroyArray(zz__);
    }
    return mlfReturnValue(xx);
}

/*
 * The function "mlfVMeshgrid" contains the void interface for the "meshgrid"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\elmat\meshgrid.m" (lines
 * 1-60). The void interface is only produced if the M-function uses the
 * special variable "nargout", and has at least one output. The void interface
 * function specifies zero output arguments to the implementation version of
 * the function, and in the event that the implementation version still returns
 * an output (which, in MATLAB, would be assigned to the "ans" variable), it
 * deallocates the output. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlfVMeshgrid(mxArray * x, mxArray * y, mxArray * z) {
    mxArray * xx = NULL;
    mxArray * yy = NULL;
    mxArray * zz = NULL;
    mlfEnterNewContext(0, 3, x, y, z);
    xx = Mmeshgrid(&yy, &zz, 0, x, y, z);
    mlfRestorePreviousContext(0, 3, x, y, z);
    mxDestroyArray(xx);
    mxDestroyArray(yy);
    mxDestroyArray(zz);
}

/*
 * The function "mlxMeshgrid" contains the feval interface for the "meshgrid"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\elmat\meshgrid.m" (lines
 * 1-60). The feval function calls the implementation version of meshgrid
 * through this function. This function processes any input arguments and
 * passes them to the implementation version of the function, appearing above.
 */
void mlxMeshgrid(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[3];
    mxArray * mplhs[3];
    int i;
    if (nlhs > 3) {
        mlfError(_mxarray0_);
    }
    if (nrhs > 3) {
        mlfError(_mxarray2_);
    }
    for (i = 0; i < 3; ++i) {
        mplhs[i] = mclGetUninitializedArray();
    }
    for (i = 0; i < 3 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 3; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
    mplhs[0]
      = Mmeshgrid(&mplhs[1], &mplhs[2], nlhs, mprhs[0], mprhs[1], mprhs[2]);
    mlfRestorePreviousContext(0, 3, mprhs[0], mprhs[1], mprhs[2]);
    plhs[0] = mplhs[0];
    for (i = 1; i < 3 && i < nlhs; ++i) {
        plhs[i] = mplhs[i];
    }
    for (; i < 3; ++i) {
        mxDestroyArray(mplhs[i]);
    }
}

/*
 * The function "Mmeshgrid" is the implementation version of the "meshgrid"
 * M-function from file "d:\MATLAB6p1\toolbox\matlab\elmat\meshgrid.m" (lines
 * 1-60). It contains the actual compiled code for that M-function. It is a
 * static function and must only be called from one of the interface functions,
 * appearing below.
 */
/*
 * function [xx,yy,zz] = meshgrid(x,y,z)
 */
static mxArray * Mmeshgrid(mxArray * * yy,
                           mxArray * * zz,
                           int nargout_,
                           mxArray * x,
                           mxArray * y,
                           mxArray * z) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_meshgrid);
    int nargin_ = mclNargin(3, x, y, z, NULL);
    mxArray * xx = mclGetUninitializedArray();
    mxArray * nz = mclGetUninitializedArray();
    mxArray * ans = mclGetUninitializedArray();
    mxArray * ny = mclGetUninitializedArray();
    mxArray * nx = mclGetUninitializedArray();
    mclCopyArray(&x);
    mclCopyArray(&y);
    mclCopyArray(&z);
    /*
     * %MESHGRID   X and Y arrays for 3-D plots.
     * %   [X,Y] = MESHGRID(x,y) transforms the domain specified by vectors
     * %   x and y into arrays X and Y that can be used for the evaluation
     * %   of functions of two variables and 3-D surface plots.
     * %   The rows of the output array X are copies of the vector x and
     * %   the columns of the output array Y are copies of the vector y.
     * %
     * %   [X,Y] = MESHGRID(x) is an abbreviation for [X,Y] = MESHGRID(x,x).
     * %   [X,Y,Z] = MESHGRID(x,y,z) produces 3-D arrays that can be used to
     * %   evaluate functions of three variables and 3-D volumetric plots.

⌨️ 快捷键说明

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