示例#1
0
void funcmethods(int nlhs, mxArray* plhs[],
                 int nrhs, const mxArray* prhs[])
{
    int job = getInt(prhs[1]);
    int nn;
    double* ptr = 0;

    // constructor
    if (job == 0) {
        int type = getInt(prhs[2]);
        int n = getInt(prhs[3]);
        if (type < 20) {
            ptr = mxGetPr(prhs[4]);
            size_t msize = mxGetM(prhs[4]);
            size_t nsize = mxGetN(prhs[4]);
            size_t lenp = msize*nsize;
            nn = func_new(type, n, lenp, ptr);
        } else if (type < 45) {
            int m = getInt(prhs[4]);
            nn = func_new(type, n, m, ptr);
        } else {
            ptr = mxGetPr(prhs[4]);
            nn = func_new(type, n, 0, ptr);
        }
        plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
        double* h = mxGetPr(plhs[0]);
        *h = double(nn);
        if (nn < 0) {
            reportError();
        }
        return;
    }

    else {
        int nn = 0;
        double t;
        double v = 0.0;
        int i = getInt(prhs[2]);
        if (job == 1) {
            nn = func_del(i);
            if (nn < 0) {
                reportError();
            }
            v = double(nn);
        } else if (job == 2) {
            t = getDouble(prhs[3]);
            v = func_value(i, t);
            if (v == Undef) {
                reportError();
            }
        } else {
            mexErrMsgTxt("unknown job parameter");
        }
        plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
        double* h = mxGetPr(plhs[0]);
        *h = v;
        return;
    }
}
double LoadHistoryPlugin::getValueAt(unsigned int time_step) throw (LibHandleError)
{
	if(func_value!=NULL)
		return func_value(time_step);
	else{
		throw (LibHandleError ("LoadHistoryPlugin::constrainLoadHeight --- for some reason we got here without having loaded the library function before. SMRT!") );
	}
}
示例#3
0
	bool japi_func_add(const char* proc_name, uintptr_t new_proc)
	{
		func_value const* nf = jass_func(proc_name);
		if (!nf)
		{
			return false;
		}

		return japi_mapping.insert(std::make_pair(proc_name, func_value(*nf, new_proc))).second;
	}
示例#4
0
		static mapping initialize_from_register()
		{
			mapping m;

			uintptr_t ptr_Deg2Rad = get_war3_searcher().search_string("Deg2Rad");
			if (ptr_Deg2Rad)
			{
				for (detail::asm_register_native_function* ptr = (detail::asm_register_native_function*)(ptr_Deg2Rad - 6); ptr->verify(); ++ptr)
				{
					m.insert(std::make_pair(ptr->get_name(), func_value(ptr->get_param(), ptr->get_address())));
				}
			}

			return std::move(m);
		}
示例#5
0
Real
PiecewiseConstant::value(Real t, const Point & p)
{
  Real func_value(0);
  Real x = t;
  if (_has_axis)
  {
    x = p(_axis);
  }

  unsigned i = 1;
  const unsigned len = functionSize();
  const Real toler = 1e-14;

  // endpoint cases
  if ( (_direction == LEFT  && x < (1+toler) * domain(0)) ||
       (_direction == RIGHT && x < (1-toler) * domain(0)) )
  {
    func_value = range(0);
    i = len;
  }
  if ( (_direction == LEFT  && x > (1+toler) * domain(len-1)) ||
       (_direction == RIGHT && x > (1-toler) * domain(len-1)) )
  {
    func_value = range(len-1);
    i = len;
  }

  for ( ; i < len; ++i )
  {
    if ( _direction == LEFT &&
         x < (1+toler) * domain(i) )
    {
      func_value = range(i-1);
      break;
    }
    else if ( (_direction == RIGHT &&
               x < (1-toler) * domain(i)) )
    {
      func_value = range(i);
      break;
    }
  }

  return _scale_factor * func_value;
}
示例#6
0
	bool japi_func_add(const char* proc_name, uintptr_t new_proc, const char* param)
	{
		return japi_mapping.insert(std::make_pair(proc_name, func_value(param, new_proc))).second;
	}