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

📄 sumsqr.c

📁 nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的一组神经网络算法函数库
💻 C
字号:
/*
 * MATLAB Compiler: 3.0
 * Date: Sun May 13 16:47:41 2007
 * 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" "-M" "-silentsetup" "-d"
 * "d:/MATLAB6p5/work/nnToolKit/src" "-B" "csglcom:nnToolKit,nnToolKit,2.0"
 * "-B" "sgl" "-m" "-W" "main" "-L" "C" "-t" "-T" "link:exe" "-h"
 * "libmmfile.mlib" "-W" "mainhg" "libmwsglm.mlib" "-t" "-W"
 * "comhg:nnToolKit,nnToolKit,2.0" "-T" "link:lib" "-h" "libmmfile.mlib" "-i"
 * "-i" "D:/MATLAB6p5/work/nnToolKit/lmnet/LmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/lmnet/LmTrain.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmSimu.m"
 * "D:/MATLAB6p5/work/nnToolKit/sofm/SofmTrain.m" 
 */
#include "sumsqr.h"
#include "libmatlbm.h"

static mxChar _array1_[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 * _mxarray0_;

void InitializeModule_sumsqr(void) {
    _mxarray0_ = mclInitializeString(27, _array1_);
}

void TerminateModule_sumsqr(void) {
    mxDestroyArray(_mxarray0_);
}

static mxArray * Msumsqr(int nargout_, mxArray * a);

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

/*
 * The function "mlfSumsqr" contains the normal interface for the "sumsqr"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\sumsqr.m" (lines 1-23).
 * This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
mxArray * mlfSumsqr(mxArray * a) {
    int nargout = 1;
    mxArray * s = NULL;
    mlfEnterNewContext(0, 1, a);
    s = Msumsqr(nargout, a);
    mlfRestorePreviousContext(0, 1, a);
    return mlfReturnValue(s);
}

/*
 * The function "mlxSumsqr" contains the feval interface for the "sumsqr"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\sumsqr.m" (lines 1-23).
 * The feval function calls the implementation version of sumsqr through this
 * function. This function processes any input arguments and passes them to the
 * implementation version of the function, appearing above.
 */
void mlxSumsqr(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
    mxArray * mprhs[1];
    mxArray * mplhs[1];
    int i;
    if (nlhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: sumsqr Line: 1 Column: "
            "1 The function \"sumsqr\" was called with mor"
            "e than the declared number of outputs (1)."),
          NULL);
    }
    if (nrhs > 1) {
        mlfError(
          mxCreateString(
            "Run-time Error: File: sumsqr Line: 1 Column: "
            "1 The function \"sumsqr\" was called with mor"
            "e than the declared number of inputs (1)."),
          NULL);
    }
    for (i = 0; i < 1; ++i) {
        mplhs[i] = NULL;
    }
    for (i = 0; i < 1 && i < nrhs; ++i) {
        mprhs[i] = prhs[i];
    }
    for (; i < 1; ++i) {
        mprhs[i] = NULL;
    }
    mlfEnterNewContext(0, 1, mprhs[0]);
    mplhs[0] = Msumsqr(nlhs, mprhs[0]);
    mlfRestorePreviousContext(0, 1, mprhs[0]);
    plhs[0] = mplhs[0];
}

/*
 * The function "Msumsqr" is the implementation version of the "sumsqr"
 * M-function from file "d:\matlab6p5\toolbox\nnet\nnet\sumsqr.m" (lines 1-23).
 * 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 s = sumsqr(a)
 */
static mxArray * Msumsqr(int nargout_, mxArray * a) {
    mexLocalFunctionTable save_local_function_table_
      = mclSetCurrentLocalFunctionTable(&_local_function_table_sumsqr);
    int nargin_ = mclNargin(1, a, NULL);
    mxArray * s = NULL;
    mxArray * ans = NULL;
    mclCopyArray(&a);
    /*
     * %SUMSQR Sum squared elements of a matrix.
     * %
     * %  Synopsis
     * %
     * %    sumsqr(m)
     * %
     * %  Description
     * %
     * %    SUMSQR(M) returns the sum of the squared elements in M.
     * %
     * %  Examples
     * %
     * %    s = sumsqr([1 2;3 4])
     * 
     * % Mark Beale, 1-31-92
     * % Copyright 1992-2002 The MathWorks, Inc.
     * % $Revision: 1.10 $  $Date: 2002/03/25 16:52:35 $
     * 
     * if nargin < 1,error('Not enough input arguments.');end
     */
    if (nargin_ < 1) {
        mlfError(_mxarray0_, NULL);
    }
    /*
     * 
     * s = sum(sum(a.*a));
     */
    mlfAssign(
      &s, mlfSum(mlfSum(mclTimes(mclVa(a, "a"), mclVa(a, "a")), NULL), NULL));
    mclValidateOutput(s, 1, nargout_, "s", "sumsqr");
    mxDestroyArray(ans);
    mxDestroyArray(a);
    mclSetCurrentLocalFunctionTable(save_local_function_table_);
    return s;
}

⌨️ 快捷键说明

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