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

📄 bias_add.c

📁 Interval Arithmetic Toolbox for Matlab
💻 C
字号:
/**********************************************************************
 *  bias_add - add with appropiate use of i/o MATLAB - BIAS - MATLAB
 *   -- interval --  PROFIL/BIAS storage (ultimate fast version)
 *
 *  Version: 1.00
 *  Date: 23.1.1998
 *  Author(s): Jens Zemke
 *********************************************************************/

#include <mex.h>
#include "Bias1.h"
#include "types.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  BIASINTERVAL *pR;
  BIASINTERVAL *pA;
  BIASINTERVAL *pB;
  double *pa;
  double *pb;
  unsigned int Arows, Acols, Brows, Bcols;
  int Aclass, Bclass;

  BiasInit();

  Aclass = (int) *mxGetPr(prhs[0]);
  Bclass = (int) *mxGetPr(prhs[2]);

  if ((Aclass == DouBLe) && (Bclass == INTerval))
  {
    Arows = mxGetM(prhs[1]);
    Acols = mxGetN(prhs[1]);
    Brows = mxGetM(prhs[3])/2;
    Bcols = mxGetN(prhs[3]);

    if ((Acols != Bcols) || (Arows != Brows)) 
    {
      plhs[0] = mxCreateString("Matrix dimensions must agree.");
      return;
    }

    pa =                  mxGetPr(prhs[1]);
    pB = (BIASINTERVAL *) mxGetPr(prhs[3]);

    plhs[0] = mxCreateDoubleMatrix(Arows * 2, Acols, mxREAL);
    pR = (BIASINTERVAL *) mxGetPr(plhs[0]);

    BiasAddVRVI(pR, pa, pB, Arows * Acols);

    return;
  }

  if ((Aclass == DouBLe) && (Bclass == DouBLe))
  {

    Arows = mxGetM(prhs[1]);
    Acols = mxGetN(prhs[1]);
    Brows = mxGetM(prhs[3]);
    Bcols = mxGetN(prhs[3]);

    if ((Acols != Bcols) || (Arows != Brows)) 
    {
      plhs[0] = mxCreateString("Matrix dimensions must agree.");
      return;
    }

    pa =                  mxGetPr(prhs[1]);
    pb =                  mxGetPr(prhs[3]);

    plhs[0] = mxCreateDoubleMatrix(Arows * 2, Acols, mxREAL);
    pR = (BIASINTERVAL *) mxGetPr(plhs[0]);

    BiasAddVRVR(pR, pa, pb, Arows * Acols);

    return;
  }

  if ((Aclass == INTerval) && (Bclass == INTerval))
  {
    Arows = mxGetM(prhs[1])/2;
    Acols = mxGetN(prhs[1]);
    Brows = mxGetM(prhs[3])/2;
    Bcols = mxGetN(prhs[3]);

    if ((Acols != Bcols) || (Arows != Brows)) 
    {
      plhs[0] = mxCreateString("Matrix dimensions must agree.");
      return;
    }

    pA = (BIASINTERVAL *) mxGetPr(prhs[1]);
    pB = (BIASINTERVAL *) mxGetPr(prhs[3]);

    plhs[0] = mxCreateDoubleMatrix(Arows * 2, Acols, mxREAL);
    pR = (BIASINTERVAL *) mxGetPr(plhs[0]);

    BiasAddVIVI(pR, pA, pB, Arows * Acols);

    return;
  }

  if ((Aclass == INTerval) && (Bclass == DouBLe))
  {
    Arows = mxGetM(prhs[1])/2;
    Acols = mxGetN(prhs[1]);
    Brows = mxGetM(prhs[3]);
    Bcols = mxGetN(prhs[3]);

    if ((Acols != Bcols) || (Arows != Brows)) 
    {
      plhs[0] = mxCreateString("Matrix dimensions must agree.");
      return;
    }

    pA = (BIASINTERVAL *) mxGetPr(prhs[1]);
    pb =                  mxGetPr(prhs[3]);

    plhs[0] = mxCreateDoubleMatrix(Arows * 2, Acols, mxREAL);
    pR = (BIASINTERVAL *) mxGetPr(plhs[0]);

    BiasAddVIVR(pR, pA, pb, Arows * Acols);

    return;
  }

  mexErrMsgTxt("Unknown class or too few arguments."); return;

} /* mexFunction */

⌨️ 快捷键说明

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