Esempio n. 1
0
Flow::Flow(FP Other_Cp,FP OtherT0, FP OtherP0, FP OtherR,  FP Other_lam, FP Other_mu ) {
    Lambda = 0.01;
    C = Other_Cp;
    InitVar(C/(C-OtherR), OtherT0, OtherP0, OtherR);
    lam = Other_lam;
    mu  = Other_mu;
}
Esempio n. 2
0
extern "C" int __declspec(dllexport) Load(void) 
{
	mir_getLP(&pluginInfoEx);

	// initialize global variables
	InitVar();

	// load options and set defaults
	LoadOptions();

	// reset the weather data at startup for individual contacts
	EraseAllInfo();

	// load weather update data
	LoadWIData(true);

	// set status to online if "Do not display weather condition as protocol status" is enabled
	old_status = status = ID_STATUS_OFFLINE;

	// add an event on weather update and error
	hHookWeatherUpdated = CreateHookableEvent(ME_WEATHER_UPDATED);
	hHookWeatherError = CreateHookableEvent(ME_WEATHER_ERROR);

	// initialize options and network
	HookEvent(ME_OPT_INITIALISE, OptInit);
	HookEvent(ME_SYSTEM_MODULESLOADED, WeatherInit);
	HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
	HookEvent(ME_CLIST_DOUBLECLICKED, BriefInfo);
	HookEvent(ME_WEATHER_UPDATED, WeatherPopup);
	HookEvent(ME_WEATHER_ERROR, WeatherError);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, WeatherShutdown);
	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, BuildContactMenu);

	hDataWindowList = WindowList_Create();
	hWindowList = WindowList_Create();

	hUpdateMutex = CreateMutex(NULL, FALSE, NULL);

	// register weather protocol
	PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
	pd.szName = WEATHERPROTONAME;
	pd.type = (opt.NoProtoCondition) ? PROTOTYPE_VIRTUAL : PROTOTYPE_PROTOCOL;
	CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);

	// initialize weather protocol services
	InitServices();

	// add sound event
	SkinAddNewSoundExT("weatherupdated", _T(WEATHERPROTONAME), LPGENT("Weather Condition Changed"));
	SkinAddNewSoundExT("weatheralert", _T(WEATHERPROTONAME), LPGENT("Weather Alert Issued"));

	// window needed for popup commands
	TCHAR SvcFunc[100];
	mir_sntprintf(SvcFunc, SIZEOF(SvcFunc), _T("%s__PopupWindow"), _T(WEATHERPROTONAME));
	hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), SvcFunc, 0, CW_USEDEFAULT, CW_USEDEFAULT,
		CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
	SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
	return 0; 
}
Esempio n. 3
0
Flow::Flow () {
    Lambda = 0.01;
    InitVar();

    C = k*r/(k-1);
    lam = 0.01;
    mu  = 5.e-5;
}
Esempio n. 4
0
YPlayListItemUI::YPlayListItemUI()
{
	this->SetFixedHeight(ListItemHeight);
	CDialogBuilder builder;
	builder.Create(_T("play-list-item.xml"),0,NULL,NULL,this);

	InitVar();
}
Esempio n. 5
0
YSongListItemUI::YSongListItemUI(CPaintManagerUI* pManager)
{
	this->SetManager(pManager, this);
	this->SetFixedHeight(SongItemHeight);
	CDialogBuilder builder;
	builder.Create(_T("song-list-item.xml"), 0, NULL, pManager, this);

	InitVar();
}
Esempio n. 6
0
//void Conv2Bin()
void Conv2Bin(char *ifname,char *ofname)
{
//	char *ifname = "D:\\falcon4\\TOOLS\\tacref\\tacrefdb.txt";
//	char *ofname = "D:\\falcon4\\TOOLS\\tacref\\tacrefdb.bin";
	long bytesread;

	ifh = _open( ifname, _O_BINARY|_O_RDONLY );
	if( ifh == -1 ) {
		printf("Error: can't open input file (%s)\n",ifname);
		return;	// Error
	}
	//DrawText( gblhdc, "File Opened for Reading!", -1, &gblrect, DT_SINGLELINE);

	ofh = _open( ofname, _O_TRUNC|_O_CREAT|_O_BINARY|_O_WRONLY, _S_IREAD|_S_IWRITE );
	if( ofh == -1 ) {
		if ( ifh ) _close ( ifh );
		printf("Can't create output file (%s)\n",ofname);
		return;
	}

	// Get file length
	flen = _filelength( ifh );
	/* Allocate space for dumping database file  */
	trdata = NULL;
	trdata = (char *) malloc( flen );
	if( !trdata ) {
		// Error, printf( "Insufficient memory !\n" );
		if ( ifh ) _close ( ifh );
		if ( ofh ) _close ( ofh );
		return;
	}

	// reads in the database file
	if (( bytesread = (long) _read( ifh, trdata, flen )) <= 0 ) {
		// Error, perror( "Problem reading file" );
		if ( ifh )    _close ( ifh );
		if ( ofh )    _close ( ofh );
		if ( trdata ) { free( trdata ); trdata = NULL; }
		return;
	}

	startdata   = trdata;
	endingdata  = startdata+flen;

	trdata      = SkipJunk( trdata );
	startentity = trdata;
	InitVar();
	// Conversion
	DoParse();

	_close( ifh );
    _close( ofh );
	DrawText( gblhdc, "Both files are Closed !            ", -1, &gblrect, DT_SINGLELINE);

    free( startdata );
}
Esempio n. 7
0
void Init(void) {
    InitPort();
    InitTris();
    InitAnsel();
    InitMiscellaneous();
    InitTransmission();
    InitADC();
    InitVar();
    InitInterrupt();
}
Esempio n. 8
0
void InitVarList(
  struct TVariableList *ptVarList)
{
  if (ptVarList != NULL)
  {
    if (ptVarList->ptThis != NULL)
      InitVar(ptVarList->ptThis);
    if (ptVarList->ptNext != NULL)
      InitVarList(ptVarList->ptNext);
  }
}
Esempio n. 9
0
/*----------------------------------------------*
 * Main function -- program main entrance       *
 *----------------------------------------------*/
int main(int argc, char **argv)
{
    char title[MAXLEN] /*, lbuf[MAXLEN], prefix[SHORTLEN] = "" */ ;

    atexit(PreExit);
    if (InitVar() < 0)
        exit(1);
    if (0 != PhaseArgs(argc, argv)) {
        fprintf(pLogFile, "%s: Bad parameter.\n", argv[0]);
        exit(1);
    }
    if (gnDirDepth > MAXDEPTH) gnDirDepth = MAXDEPTH;
    sprintf(psIndent, "%*.*s", gnDirDepth * 3 + 2, gnDirDepth * 3 + 2, " ");
    fprintf(pOutFile, "\033[1;42;37m  %-14s%-54s%-9s\033[m\n" "-------------------------------------------------------------------------------\n", "序号", "精华区主题", "更新日期");
    if (0 != PhaseDir(psSrcDir, /* prefix, */ title, "SYSOP"))
        exit(1);
    exit(0);
}
Esempio n. 10
0
double VarMGCTM::Infer(DocC &doc, MGCTMC &m, MGVar* para) const {
  double c = 1;
  InitVar(doc, m, para);
  MGVar &p = *para;
  for(int it = 1; (c > converged_.var_converged_) && (it < 
                       converged_.var_max_iter_); ++it) {
    //indicate variable eta
    Vec g_theta_ep;
    GThetaEp(p.g_theta, &g_theta_ep);
    Mat l_theta_ep;
    LThetaEp(p.l_theta, &l_theta_ep);
    for (int j = 0; j < m.LTopicNum1(); j++) {
      p.eta[j] = log(m.pi[j]);
      int l_topic_num = m.LTopicNum2();
      p.eta[j] += lgamma(l_topic_num*m.l_alpha[j]);
      p.eta[j] -= l_topic_num*lgamma(m.l_alpha[j]);
      for (int k = 0; k < m.LTopicNum2(); k++) {
        p.eta[j] += (m.l_alpha[j] - 1)*l_theta_ep(k, j);
      }

      for (size_t n = 0; n < doc.ULen(); n++) {
        double a = 0;
        for (int k = 0; k < m.LTopicNum2(); k++) {
          a += p.l_z[j](k, n) * l_theta_ep(k, j);
          a += p.l_z[j](k, n) * m.l_ln_w[j](k, doc.Word(n));
        }
        p.eta[j] += p.delta[n]*a*doc.Count(n);
      }
    }

    double ln_eta_sum = LogSum(p.eta);
    for (int j = 0; j < m.LTopicNum1(); j++) { //normalize eta
      p.eta[j] = exp(p.eta[j] - ln_eta_sum);
    }

    //omega
    p.omega[1] = m.gamma[1];
    for (size_t n = 0; n < doc.ULen(); n++) {
      p.omega[1] += p.delta(n)*doc.Count(n);
    }

    p.omega[0] = m.gamma[0];
    for (size_t n = 0; n < doc.ULen(); n++) {
      p.omega[0] += (1 - p.delta(n))*doc.Count(n);
    }

    //local theta
    for (int j = 0; j < m.LTopicNum1(); j++) {
      for (int k = 0; k < m.LTopicNum2(); k++) {
        p.l_theta(k, j) = p.eta[j] * m.l_alpha[j];
      }
    }
    for (int j = 0; j < m.LTopicNum1(); j++) {
      for (int k = 0; k < m.LTopicNum2(); k++) {
        for (size_t n = 0; n < doc.ULen(); n++) {
          p.l_theta(k, j) += doc.Count(n)* p.delta[n]*p.eta[j]* p.l_z[j](k, n);
        }
        p.l_theta(k, j) += 1 - p.eta[j];
      }
    }

    //global theta
    p.g_theta.setConstant(m.g_alpha);
    for (size_t n = 0; n < doc.ULen(); n++) {
      for (int k = 0; k < m.GTopicNum(); k++) {
        p.g_theta[k] += doc.Count(n) * p.g_z(k, n) * (1 - p.delta[n]);
      }
    }
 
    for (size_t n = 0; n < doc.ULen(); n++) {
      //variable delta
      double tmp = DiGamma(m.gamma[1]) - DiGamma(m.gamma[0]);
      for (int j = 0; j < m.LTopicNum1(); j++) {
        for (int k = 0; k < m.LTopicNum2(); k++) {
          tmp += p.eta[j]*p.l_z[j](k, n)*l_theta_ep(k,j); 
          tmp += p.eta[j]*p.l_z[j](k, n)*m.l_ln_w[j](k, doc.Word(n));
        }
      }
      for (int k = 0; k < m.GTopicNum(); k++) {
        tmp -= p.g_z(k, n) * g_theta_ep[k];
        tmp -= p.g_z(k, n) * m.g_ln_w(k, doc.Word(n));
      }
      p.delta[n] = Sigmoid(tmp);

      //local z
      for (int j = 0; j < m.LTopicNum1(); j++) {
        for (int k = 0; k < m.LTopicNum2(); k++) {
          p.l_z[j](k, n) = p.delta[n]*p.eta[j]*(l_theta_ep(k, j) +
                           m.l_ln_w[j](k, doc.Word(n)));
        }
        double ln_local_z_sum = LogSum(p.l_z[j].col(n));
        for (int k = 0; k < m.LTopicNum2(); k++) {
          p.l_z[j](k, n) = exp(p.l_z[j](k, n) - ln_local_z_sum);
        }
      }

      //global z
      for (int k = 0; k < m.GTopicNum(); k++) {
        p.g_z(k, n) = (1 - p.delta[n])*(g_theta_ep[k] + m.g_ln_w(k, doc.Word(n)));
      }
      double ln_z_sum = LogSum(p.g_z.col(n));
      for (int k = 0; k < m.GTopicNum(); k++) { //normalize g_z
        p.g_z(k, n) = exp(p.g_z(k, n) - ln_z_sum);
      }
    }

  }
  return Likelihood(doc, p, m);
}
Esempio n. 11
0
CWavFile::CWavFile()
{
	InitVar();
}
Esempio n. 12
0
BOOL CWavFile::Open(LPCTSTR lpszFilePath)
{
	// release resource
	Relesae();
	
	// initialize variables
	InitVar();

	m_strWavePath = lpszFilePath;

	// load the wave file
	FILE* file = fopen(lpszFilePath, "rb");

	if(file != NULL)
	{
		// get the size of file
		fseek(file, 0L, SEEK_END); 
		m_dwFileSize = ftell(file);
		fseek(file, 0L, SEEK_SET);

		// read RIFF WAVE chunk
		fread(&m_RiffChunk, sizeof(_RIFFCHUNK), 1, file);

		// check the riff type, WAVE or not
		if(strncmp((LPCSTR)m_RiffChunk.byRiffType , "WAVE", 4) == 0)
		{
			// read the format chunk
			fread(&m_WaveFormat, sizeof(_WAVEFORMAT), 1, file);

			// check the format is PCM or not
			if((strncmp((LPCSTR)m_WaveFormat.byChunkId, "fmt ", 4) == 0) && 
				(m_WaveFormat.wFormatTag == WAVE_FORMAT_PCM))
			{	
				m_wChannels		  = m_WaveFormat.wChannels;
				m_dwSamplesPerSec = m_WaveFormat.dwSamplePerSec;
				m_wBitPerSample	  = m_WaveFormat.wBitsPerSample;
				
				// read next chunk
				BYTE  byId[4];
				DWORD dwSize = 0;
				fread(byId, sizeof(BYTE), 4, file);
				fread(&dwSize, sizeof(DWORD), 1, file);
				DWORD dwOffset = ftell(file);
				LPBYTE lpTemp = (LPBYTE)malloc(m_RiffChunk.dwSize * sizeof(BYTE));

				while(dwOffset < m_RiffChunk.dwSize)
				{
					// see if the data chunk or not
					if(strncmp((LPCSTR)byId, "data", 4) == 0)
					{	
						m_lpData = (LPBYTE)malloc(dwSize * sizeof(BYTE));
						m_lpDataWord = (LPWORD)malloc((dwSize / 2) * sizeof(WORD));
						
						long lBack = dwSize;
						fread(m_lpData, sizeof(BYTE), dwSize, file);
						fseek(file, -lBack, SEEK_CUR);
						fread(m_lpDataWord, sizeof(WORD), dwSize / 2, file);

						m_dwDataSize = dwSize;
					}
					
					// see if the "smpl" chunk or not
					else if(strncmp((LPCSTR)byId, "smpl", 4) == 0)
					{
						// the minimum size of smpl struct is 36
						if(dwSize >= (4 * 9))
						{
							m_bSmpl = true;

							m_lpSampler = (LPBYTE)malloc(dwSize * sizeof(BYTE));
							fread(m_lpSampler, sizeof(BYTE), 36, file);

							memcpy(&m_dwSamplePeriod, m_lpSampler + 8, 4);
							memcpy(&m_dwMidiUnityNote, m_lpSampler + 12, 4);
							memcpy(&m_dwMidiPitchFraction, m_lpSampler + 16, 4);

							DWORD dwSampleLoops = 0;
							memcpy(&dwSampleLoops, m_lpSampler + 28, 4);
							
							// make sure the struct of SampleLoop exist
							if(dwSampleLoops > 0)
							{
								m_bLoop = true;

								for(int i = 0; i < dwSampleLoops; i++)
								{
									fread(&m_SampleLoop, sizeof(_SAMPLELOOP), 1, file);
									m_dwLoopStart = m_SampleLoop.dwStart;
									m_dwLoopEnd	  = m_SampleLoop.dwEnd;
									m_dwPlayCount = m_SampleLoop.dwPlayCount;
									m_dwLoopType  = m_SampleLoop.dwType;
								}
							}
							// sometimes the SampleLoops is zero
							// but the struct of SampleLoop still exist
							else if(dwSampleLoops <= 0)
							{
								if((dwSize - 36) != 0)
								{
									fread(m_lpSampler + 36, sizeof(BYTE), dwSize - 36, file);
								}
							}
						}
						else
						{
							break;
						}
					}
					
					// other chunks just skip them
					else
					{
						fread(lpTemp, sizeof(BYTE), dwSize, file);
					}

					// continue to read next chunk
					fread(byId, sizeof(BYTE), 4, file);
					fread(&dwSize, sizeof(DWORD), 1, file);
					dwOffset = ftell(file);
				}
				free(lpTemp);
			}
		}
		fclose(file);
	}

	return TRUE;
}
Esempio n. 13
0
void   Flow::InitVar() {
    InitVar(1.4, 300., 1.e5, 300.);
}
Esempio n. 14
0
int main(int argc, char *argv[])
{
  Planning         *pt_plan=NULL;
  int              user, i;
  char             FileRead[MAX_LINE][MAX_CHAR_LINE];
  char             product;
  char             exec_dir[MAX_PATH_LEN]="";
  
  _interactive_call=1;
  
  if ((pt_plan = malloc (sizeof(Planning)))==NULL)
    {
      printf("Memory Allocation error\n"); exit(1);
    }

  get_exec_directory(exec_dir,argv[0]);
  premia_self_set_global_vars(exec_dir);

  if( argc==2 ){
    ReadInputFile(argv[1],FileRead);
    InputMode(&user);
    WellcomeMsg(user);
    if ((InitErrorMsg()==OK)&&(InitVar()==OK))
      {
        ResetPlanning(pt_plan);
        product=FChooseProduct(FileRead);
        i = 0;
        while (premia_assets[i].name != NULL)
          {
            if (product == premia_assets[i].label)
              {
                premia_treat_input_file(pt_plan, premia_assets[i].models,
                                        premia_assets[i].families, 
                                        premia_assets[i].pricings,
                                        user, FileRead);
                break;
              }
            i++;
          }
        if (premia_assets[i].name == NULL) return FAIL;
      }
                        
  }else{
    InputMode(&user);
    WellcomeMsg(user);
    if ((InitErrorMsg()==OK)&&(InitVar()==OK)){
      do {
        ResetPlanning(pt_plan);
        product = ChooseProduct();
        i = 0;
        while (premia_assets[i].name != NULL)
          {
            if (product == premia_assets[i].label)
              {
                pt_plan->Action = ChooseAction (product);
                premia_interactive_menu(pt_plan, premia_assets[i].models,
                                        premia_assets[i].families, 
                                        premia_assets[i].pricings,user);
                break;
              }
            i++;
          }
      } while (NextSession(pt_plan,pt_plan->Action,user)==OK);
    }
  }
  
  (void)ExitVar();
  free(pt_plan);
  return OK;
}
Esempio n. 15
0
/*初期化処理*/
TextClass::TextClass(){
	InitVar();		//変数初期化
	LoadStory();	//ストーリ読み込み
}