Esempio n. 1
0
double JS_MakeDate(double day, double time)
{
	if (!_isfinite(day) ||!_isfinite(time))
		return GetNan();

	return day * 86400000 + time;
}
Esempio n. 2
0
double JS_MakeTime(int nHour, int nMin, int nSec, int nMs)
{
	if (!_isfinite(nHour) ||!_isfinite(nMin) ||!_isfinite(nSec) ||!_isfinite(nMs))
		return GetNan();

	double h = _toInteger(nHour);
	double m = _toInteger(nMin);
	double s = _toInteger(nSec);
	double milli = _toInteger(nMs);

	return h * 3600000 + m * 60000 + s * 1000 + milli;
}
Esempio n. 3
0
double JS_MakeDay(int nYear, int nMonth, int nDate)
{
	if (!_isfinite(nYear) || !_isfinite(nMonth) ||!_isfinite(nDate))
		return GetNan();
	double y = _toInteger(nYear);
	double m = _toInteger(nMonth);
	double dt = _toInteger(nDate);
	double ym = y + FXSYS_floor((double)m/12);
	double mn = _Mod(m ,12);

	double t = _TimeFromYearMonth((int)ym,(int)mn);

	if (_YearFromTime(t) != ym || _MonthFromTime(t) != mn ||_DateFromTime(t) != 1)
		return GetNan();
	return _Day(t)+dt-1;
}
Esempio n. 4
0
double JS_DateParse(const wchar_t* string)
{
	v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
	v8::Isolate::Scope isolate_scope(pIsolate);
	v8::HandleScope scope(pIsolate);

	v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
	
	//Use the built-in object method.
	v8::Local<v8::Value> v = context->Global()->Get(v8::String::NewFromUtf8(pIsolate, "Date"));
	if(v->IsObject())
	{
		v8::Local<v8::Object> o = v->ToObject();
		v = o->Get(v8::String::NewFromUtf8(pIsolate, "parse"));
		if(v->IsFunction())
		{
			v8::Local<v8::Function> funC = v8::Handle<v8::Function>::Cast(v);

			const int argc = 1;
			v8::Local<v8::String> timeStr = WSToJSString(pIsolate, string);
			v8::Handle<v8::Value> argv[argc] = {timeStr};
			v = funC->Call(context->Global(), argc, argv);
			if(v->IsNumber())
			{
				double date =  v->ToNumber()->Value();
				if(!_isfinite(date)) return date;
				return date + _getLocalTZA() + _getDaylightSavingTA(date);
			}

		}
	}
	return 0;
}
Esempio n. 5
0
extern void fixGemACF(double *ct, int len)
{
  int i, j, b, e;
  gmx_bool bBad;

  /* Let's separate two things:
   * - identification of bad parts
   * - patching of bad parts.
   */
  
  b = 0; /* Start of a bad stretch */
  e = 0; /* End of a bad stretch */
  bBad = FALSE;

  /* An acf of binary data must be one at t=0. */
  if (abs(ct[0]-1.0) > 1e-6)
    {
      ct[0] = 1.0;
      fprintf(stderr, "|ct[0]-1.0| = %1.6d. Setting ct[0] to 1.0.\n", abs(ct[0]-1.0));
    }

  for (i=0; i<len; i++)
    {
      
#ifdef HAS_ISFINITE
      if (isfinite(ct[i]))
#elif defined(HAS__ISFINITE)
      if (_isfinite(ct[i]))
#else
      if(1)
#endif
	{
	  if (!bBad)
	    {
	      /* Still on a good stretch. Proceed.*/
	      continue;
	    }

	  /* Patch up preceding bad stretch. */
	  if (i == (len-1))
	    {
	      /* It's the tail */
	      if (b <= 1)
		{
		  gmx_fatal(FARGS, "The ACF is mostly NaN or Inf. Aborting.");
		}
	      patchBadTail(&(ct[b-2]), (len-b)+1);
	    }

	  e = i;
	  patchBadPart(&(ct[b-1]), (e-b)+1);
	  bBad = FALSE;
	}
      else
	{
	  if (!bBad)
	    {
	      b = i;
	  
	      bBad = TRUE;
	    }
	}
    }
}
Esempio n. 6
0
static void lincs_warning(FILE *fplog,
                          gmx_domdec_t *dd,rvec *x,rvec *xprime,t_pbc *pbc,
                          int ncons,int *bla,real *bllen,real wangle,
                          int maxwarn,int *warncount)
{
    int b,i,j;
    rvec v0,v1;
    real wfac,d0,d1,cosine;
    char buf[STRLEN];
    
    wfac=cos(DEG2RAD*wangle);
    
    sprintf(buf,"bonds that rotated more than %g degrees:\n"
            " atom 1 atom 2  angle  previous, current, constraint length\n",
            wangle);
    fprintf(stderr,"%s",buf);
    if (fplog)
    {
        fprintf(fplog,"%s",buf);
    }
    
    for(b=0;b<ncons;b++)
    {
        i = bla[2*b];
        j = bla[2*b+1];
        if (pbc)
        {
            pbc_dx_aiuc(pbc,x[i],x[j],v0);
            pbc_dx_aiuc(pbc,xprime[i],xprime[j],v1);
        }
        else
        {
            rvec_sub(x[i],x[j],v0);
            rvec_sub(xprime[i],xprime[j],v1);
        }
        d0 = norm(v0);
        d1 = norm(v1);
        cosine = iprod(v0,v1)/(d0*d1);
        if (cosine < wfac)
        {
            sprintf(buf," %6d %6d  %5.1f  %8.4f %8.4f    %8.4f\n",
                    ddglatnr(dd,i),ddglatnr(dd,j),
                    RAD2DEG*acos(cosine),d0,d1,bllen[b]);
            fprintf(stderr,"%s",buf);
            if (fplog)
            {
                fprintf(fplog,"%s",buf);
            }
            #ifdef HAS_ISFINITE
            if (!isfinite(d1))	
                gmx_fatal(FARGS,"Bond length not finite.")
            #else
            #ifdef HAS__ISFINITE
            if (!_isfinite(d1))	
                gmx_fatal(FARGS,"Bond length not finite.")
            #endif
            #endif

            (*warncount)++;
        }
    }