Exemple #1
0
void DynConfig::Init()
{
	s_sDataPath     = Filter(Utils::GetStringBetween(NETRIPPER_SETTINGS, "<data_path>", "</data_path>"));
	s_sPlainText    = Filter(Utils::GetStringBetween(NETRIPPER_SETTINGS, "<plaintext>", "</plaintext>"));
	s_sDataLimit    = Filter(Utils::GetStringBetween(NETRIPPER_SETTINGS, "<datalimit>", "</datalimit>"));
	s_sStringFinder = Filter(Utils::GetStringBetween(NETRIPPER_SETTINGS, "<stringfinder>", "</stringfinder>"));
}
Exemple #2
0
bool CglList::KeyPressed(unsigned short k, bool isRepeat)
{
	if (k == SDLK_ESCAPE) {
		if (cancelPlace >= 0) {
			place = cancelPlace;
			Select();
			return true;
		}
	} else if (k == SDLK_UP) {
		UpOne();
		return true;
	} else if (k == SDLK_DOWN) {
		DownOne();
		return true;
	} else if (k == SDLK_PAGEUP) {
		UpPage();
		return true;
	} else if (k == SDLK_PAGEDOWN) {
		DownPage();
		return true;
	} else if (k == SDLK_RETURN) {
		Select();
		return true;
	} else if (k == SDLK_BACKSPACE) {
		query = query.substr(0, query.length() - 1);
		return Filter(true);
	} else if ((k & ~0xFF) != 0) {
		// This prevents isalnum from asserting on msvc debug crt
		// We don't actually need to process the key tho;)
	} else if (isalnum(k)) {
		query += tolower(k);
		return Filter(false);
	}
	return false;
}
Exemple #3
0
ILboolean ILAPIENTRY iluEdgeDetectP()
{
	ILubyte		*HPass, *VPass;
	ILuint		i;
	ILboolean	Palette = IL_FALSE, Converted = IL_FALSE;
	ILenum		Type = 0;

	iluCurImage = ilGetCurImage();
	if (iluCurImage == NULL) {
		ilSetError(ILU_ILLEGAL_OPERATION);
		return IL_FALSE;
	}

	if (iluCurImage->Format == IL_COLOUR_INDEX) {
		Palette = IL_TRUE;
		ilConvertImage(ilGetPalBaseType(iluCurImage->Pal.PalType), IL_UNSIGNED_BYTE);
	}
	else if (iluCurImage->Type > IL_UNSIGNED_BYTE) {
		Converted = IL_TRUE;
		Type = iluCurImage->Type;
		ilConvertImage(iluCurImage->Format, IL_UNSIGNED_BYTE);
	}


	HPass = Filter(iluCurImage, filter_h_prewitt, filter_h_prewitt_scale, filter_h_prewitt_bias);
	VPass = Filter(iluCurImage, filter_v_prewitt, filter_v_prewitt_scale, filter_v_prewitt_bias);
	if (!HPass || !VPass) {
		ifree(HPass);
		ifree(VPass);
		return IL_FALSE;
	}

	// Combine the two passes
	//	Optimization by Matt Denham
	for (i = 0; i < iluCurImage->SizeOfData; i++) {
		if (HPass[i] == 0)
			iluCurImage->Data[i] = VPass[i];
		else if (VPass[i] == 0)
			iluCurImage->Data[i] = HPass[i];
		else
			iluCurImage->Data[i] = (ILubyte)sqrt(HPass[i]*HPass[i]+VPass[i]*VPass[i]);
	}

	/*for (i = 0; i < iluCurImage->SizeOfData; i++) {
		iluCurImage->Data[i] = (ILubyte)sqrt(HPass[i]*HPass[i]+VPass[i]*VPass[i]);
	}*/
	
	ifree(HPass);
	ifree(VPass);

	if (Palette)
		ilConvertImage(IL_COLOUR_INDEX, IL_UNSIGNED_BYTE);
	else if (Converted)
		ilConvertImage(iluCurImage->Format, Type);

	return IL_TRUE;
}
Exemple #4
0
void List::RefreshQuery() {
	if (query != "") {
		int t = topIndex;
		std::string q = query;
		Filter(true);
		query = q;
		Filter(false);
		topIndex = t;
	}
}
void CglList::KeyPress(int k)
{
	if (k == SDLK_BACKSPACE) {
		query = query.substr(0, query.length() - 1);
		Filter(true);
	} else if (isalnum(k)) {
		query += tolower(k);
		Filter(false);
	}
}
Exemple #6
0
void preProcess(IplImage *prv,IplImage *cur,IplImage *nxt,IplImage *wrt)
{    

	// 
	//cvSub(cur,prv,pImagePool[0]);
	//Detect(pImagePool[0],wrt,Robert);
	switch ( whichKernel)
	{
	case 0:
		// diff two img
		cvSub(cur,prv,wrt);
		break;
	case 1:
		Detect(wrt, cur,Robert);
		break;
	case 2:
		Detect(wrt, cur,Prewitt);
		break;
	case 3:
		Detect(wrt, cur,LapLas);
		break;
	case 4:
		histogramNormalize(wrt, cur);
		break;
	case 5:
		histogramNormalize(pImagePool[0], cur);
		Detect(wrt,pImagePool[0],Prewitt);
		break;
	case 6:
		{
			imgDFT(wrt, cur);
		}
		break;
	case 7:
		{
			Detect(wrt, cur,FreiChen);
			break;
		}
	case 8:
		{
			Filter(wrt, cur);
			break;
		}
	case 9:
		{

			transRGB2Gray( pImagePool[0], cur);
			Filter(wrt, pImagePool[0],averageFilter);

		}
	default:
		break;
	}

}
Exemple #7
0
static void Rec(int index)
{
    if (index == 7)
        return;
    Filter();
    Rec(index + 1);
    Number[index] = 100;
    Filter();
    Rec(index + 1);
    Number[index] = 0;
}
Exemple #8
0
void Filters::init() {
	list.clear();

	// Video
	list["noise"] = Filter(tr("add noise"), "noise", "9ah:5ah");
	list["deblock"] = Filter(tr("deblock"), "pp", "vb/hb");
	list["denoise_normal"] = Filter(tr("normal denoise"), "hqdn3d");
	list["denoise_soft"] = Filter(tr("soft denoise"), "hqdn3d", "2:1:2");

	// Audio
	list["volnorm"] = Filter(tr("volume normalization"), "volnorm", "1");
}
/* Function: SetExtSerialPacket ================================================
 * Abstract:
 *  Sets (sends) the contents of an ExtSerialPacket on the comm line.  This
 *  includes the packet's buffer as well as all serial communication overhead
 *  associated with the packet.
 *
 *  EXT_NO_ERROR is returned on success, EXT_ERROR on failure.
 */
PUBLIC boolean_T SetExtSerialPacket(ExtSerialPacket *pkt, ExtSerialPort *portDev)
{
    uint32_T  i;
    uint32_T  newByteCnt   = 0; /* Num bytes after filtering. */
    boolean_T error        = EXT_NO_ERROR;

    char Buffer[sizeof(uint32_T)*2]; /* Local buffer for converting escape chars. */

    /* If not connected, return immediately. */
    if (!portDev->fConnected) return false;

    /* Initialize some fields of the packet. */
    pkt->head[0]      = packet_head;
    pkt->head[1]      = packet_head;
    pkt->tail[0]      = packet_tail;
    pkt->tail[1]      = packet_tail;
    pkt->state        = ESP_NoPacket;
    pkt->cursor       = 0;
    pkt->DataCount    = 0;
    pkt->inQuote      = false;

    /* Send the packet header. */
    error = ExtSerialPortSetData(portDev, pkt->head, HEAD_SIZE);
    if (error != EXT_NO_ERROR) goto EXIT_POINT;

    /* Send the packet type. */
    newByteCnt = Filter(Buffer, &(pkt->PacketType), PACKET_TYPE_SIZE);
    error = ExtSerialPortSetData(portDev, Buffer, newByteCnt);
    if (error != EXT_NO_ERROR) goto EXIT_POINT;

    /* Send the size of the packet buffer. */
    newByteCnt = Num2String(Buffer, pkt->size, true, portDev->isLittleEndian);
    error = ExtSerialPortSetData(portDev, Buffer, newByteCnt);
    if (error != EXT_NO_ERROR) goto EXIT_POINT;

    /* Send the variable-sized packet buffer data. */
    for (i=0; i<pkt->size; i++)
    {
        newByteCnt = Filter(Buffer, &(pkt->Buffer[i]), 1);
        error = ExtSerialPortSetData(portDev, Buffer, newByteCnt);
        if (error != EXT_NO_ERROR) goto EXIT_POINT;
    }

    /* Send the packet tail. */
    error = ExtSerialPortSetData(portDev, pkt->tail, TAIL_SIZE);
    if (error != EXT_NO_ERROR) goto EXIT_POINT;
 
  EXIT_POINT:
    return error;

} /* end SetExtSerialPacket */
Exemple #10
0
void ComClassEventsInAContainer::Init
(
    BCSYM_Container *pContainer
)
{
    // Free the memory.
    m_nra.FreeHeap();

    if (pContainer != NULL)
    {
        BCITER_CHILD bichild(pContainer);
        unsigned cMembers = 0;
        BCSYM_NamedRoot *pRoot;
        BCSYM_NamedRoot **ppRoot;

        while (pRoot = bichild.GetNext())
        {
            if (!Filter(pRoot))
                continue;
            cMembers++;
        }

        IfFalseThrow(cMembers + 1 > cMembers);
        ppRoot = m_ppRoot = m_ppNext = (BCSYM_NamedRoot **)m_nra.Alloc(VBMath::Multiply(
            (cMembers + 1), 
            sizeof(BCSYM_NamedRoot *)));
        m_count = cMembers;

        bichild.Init(pContainer);

        while (pRoot = bichild.GetNext())
        {
            if (!Filter(pRoot))
                continue;

            *ppRoot = pRoot;
            ppRoot++;
        }

        // Sort the list in slot number then file definition order.
        extern int _cdecl SortSymbolsByLocation(const void *arg1, const void *arg2);

        qsort(m_ppNext, ppRoot - m_ppNext, sizeof(BCSYM_NamedRoot *), SortSymbolsByLocation);
    }
    else
    {
        m_count = 0;
        m_ppNext = NULL;
        m_ppRoot = NULL;
    }
}
void CheckDir( GtkWidget * list,char * directory )
{
 struct stat     fs;
 int             i;
 glob_t          gg;

 if ( !fsFilter[0] ) return;

 gtk_widget_hide( list );
 gtk_clist_clear( GTK_CLIST( list ) );

 clist_append_fname(list, ".",  dpixmap, dmask);
 clist_append_fname(list, "..", dpixmap, dmask);

 glob( "*",0,NULL,&gg );
 for(  i=0;(unsigned)i<gg.gl_pathc;i++ )
  {
   stat( gg.gl_pathv[i],&fs );
   if( !S_ISDIR( fs.st_mode ) ) continue;
   clist_append_fname(list, gg.gl_pathv[i], dpixmap, dmask);
  }
 globfree( &gg );

 if ( strchr( fsFilter,',' ) )
  {
   char tmp[8];
   int  i,c,glob_param = 0;
   for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ )
    {
     tmp[c]=fsFilter[i];
     if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) )
      {
       tmp[c]=0; c=-1;
       glob( Filter( tmp ),glob_param,NULL,&gg );
       glob_param=GLOB_APPEND;
      }
    }
  } else glob( Filter( fsFilter ),0,NULL,&gg );

 for(  i=0;(unsigned)i<gg.gl_pathc;i++ )
  {
   stat( gg.gl_pathv[i],&fs );
   if(  S_ISDIR( fs.st_mode ) ) continue;
   clist_append_fname(list, gg.gl_pathv[i], fpixmap, fmask);
  }
 globfree( &gg );

 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 );
 gtk_clist_select_row( GTK_CLIST( list ),0,1 );
 gtk_widget_show( list );
}
Exemple #12
0
void Filterer::Plot(ChannelEvent *event_){

	///The limits of the vertical axis
	static float axisMin, axisMax;

	// Draw the trace

	if(event_->size != x_vals.size()){ // The length of the trace has changed.
		resetGraph_ = true;
	}
	if (resetGraph_) {
		ResetGraph(event_->size);
		axisMax = 0;
		axisMin = 1E9;
	}
	
	// Run the fast filter (trigger) on the trace.
	Filter(event_->yvals, event_->size, fast_filter_y, trig_rise, trig_flat);
	
	// Run the slow filter (energy) on the trace.
	Filter(event_->yvals, event_->size, slow_filter_y, energy_rise, energy_flat);
	
	for (size_t i = 0; i < event_->size ; i++) {
		graph->SetPoint(i, x_vals[i], event_->yvals[i]);
		f_fast->SetPoint(i, x_vals[i], fast_filter_y[i]);
		f_slow->SetPoint(i, x_vals[i], slow_filter_y[i]);
	}

	if (graph->GetYaxis()->GetXmax() > axisMax) axisMax = graph->GetYaxis()->GetXmax(); 
	if (graph->GetYaxis()->GetXmin() < axisMin) axisMin = graph->GetYaxis()->GetXmin(); 
	
	if (f_fast->GetYaxis()->GetXmax() > axisMax) axisMax = f_fast->GetYaxis()->GetXmax(); 
	if (f_fast->GetYaxis()->GetXmin() < axisMin) axisMin = f_fast->GetYaxis()->GetXmin(); 
	
	if (f_slow->GetYaxis()->GetXmax() > axisMax) axisMax = f_slow->GetYaxis()->GetXmax(); 
	if (f_slow->GetYaxis()->GetXmin() < axisMin) axisMin = f_slow->GetYaxis()->GetXmin(); 
	
	graph->GetYaxis()->SetLimits(axisMin, axisMax);
	graph->GetYaxis()->SetRangeUser(axisMin, axisMax);

	graph->Draw("APL");
	f_fast->Draw("LSAME");
	f_slow->Draw("LSAME");

	canvas->Update();

	num_displayed++;

	num_traces++;
}
		bool initializeFilterCallBack(laser_package::update_filter::Request &req, laser_package::update_filter::Response &res)
		{ 
			Eigen::MatrixXd initial_state(5,1);
			
			initial_state << req.initial_x, req.initial_x_velocity, req.initial_y, req.initial_y_velocity, req.initial_turn_rate;
			filter_1 = Filter(initial_state, req.sampling_interval, noise_data[FILTER_1], UM);
			filter_2 = Filter(initial_state, req.sampling_interval, noise_data[FILTER_2], CT);
			updateStateMessage(&filter_1, &state_msg_1, req);
			updateStateMessage(&filter_2, &state_msg_2, req);
			state_pub_1.publish(state_msg_1);
			state_pub_2.publish(state_msg_2);
			ROS_INFO("Filter initialized");
			
		}
Factory::Factory() {
	this->m_filters.append(Filter(
			QString::fromStdString(CurvatureProvider::getTitle()),
			QString::fromStdString(CurvatureProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(GeodesicProvider::getTitle()),
			QString::fromStdString(GeodesicProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(HarmonicProvider::getTitle()),
			QString::fromStdString(HarmonicProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(HeatKernelProvider::getTitle()),
			QString::fromStdString(HeatKernelProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(MidedgeProvider::getTitle()),
			QString::fromStdString(MidedgeProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(PartawareProvider::getTitle()),
			QString::fromStdString(PartawareProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(SamplingProvider::getTitle()),
			QString::fromStdString(SamplingProvider::getName())));
	this->m_filters.append(Filter(
			QString::fromStdString(ThinPlateProvider::getTitle()),
			QString::fromStdString(ThinPlateProvider::getName())));
}
//*****************************************************************************
//
// Function : FMeter tick; called each time the OS tick timer is called
//
// Arguments: none
//
// Result   : none
//
//*****************************************************************************
void FMeterTick (void)
{

	if (FMeterInitialized != 0)
	{
		if (FMeterMeasurementRunning == 1)
		{

			if (FMeterTickCounter == 0)
			{
				// Timer1 & Timer3 start counting now
				TCCR1B = 7; // external pin is the source, rising edge
				TCCR3B = 7;
				EIMSK |= (1<<INT4);

			}
			else
			{
				// do nothing
			}
	
			FMeterTickCounter++;

			if (FMeterTickCounter == (MEASUREMENT_TICKS + 1))
			{
				// Timer1 & Timer3 stop counting now
				TCCR1B = 0; // Timer is stopped
				TCCR3B = 0;	
				EIMSK &= ~(1<<INT4);

				FMeterMeasurementRunning = 0;
				FMeterMeasurementComplete = 1;
				

				//Filter measurement values
				
				FMeterTimerResult1 = Filter(TCNT1, FREQ1);
				FMeterTimerResult3 = Filter(TCNT3, FREQ3);
				FMeterTimerResultS = Filter(SpeedCounter, FREQS);

				DetermineSpeed(FMeterTimerResultS);

				FMeterStartMeasurement();
			}
			
		}
	}
}
void CServerBrowserFilter::CServerFilter::Sort()
{
	// create filtered list
	Filter();

	// sort
	switch(g_Config.m_BrSort)
	{
	case IServerBrowser::SORT_NAME:
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortCompareName));
		break;
	case IServerBrowser::SORT_PING:
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortComparePing));
		break;
	case IServerBrowser::SORT_MAP:
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortCompareMap));
		break;
	case IServerBrowser::SORT_NUMPLAYERS:
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this,
					(m_SortHash&IServerBrowser::FILTER_SPECTATORS) ? &CServerBrowserFilter::CServerFilter::SortCompareNumPlayers : &CServerBrowserFilter::CServerFilter::SortCompareNumClients));
		break;
	case IServerBrowser::SORT_GAMETYPE:
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowserFilter::CServerFilter::SortCompareGametype));
	}

	m_SortHash = GetSortHash();
}
Exemple #17
0
		QList<Filter> ParseToFilters (const QStringList& paths)
		{
			QList<Filter> result;
			for (const auto& filePath : paths)
			{
				QFile file (filePath);
				if (!file.open (QIODevice::ReadOnly))
				{
					qWarning () << Q_FUNC_INFO
						<< "could not open file"
						<< filePath
						<< file.errorString ();
					result << Filter ();
					continue;
				}

				const auto& data = QString::fromUtf8 (file.readAll ());
				auto rawLines = data.split ('\n', QString::SkipEmptyParts);
				if (!rawLines.isEmpty ())
					rawLines.removeAt (0);
				const auto& lines = Util::Map (rawLines, Util::QStringTrimmed {});

				Filter f;
				std::for_each (lines.begin (), lines.end (), LineParser (&f));

				f.SD_.Filename_ = QFileInfo (filePath).fileName ();

				result << f;
			}
			return result;
		}
Exemple #18
0
void InfoPane::ResetText()
{
	try
	{
		file_info_.Clear();

		if (photo_)
		{
			try
			{
				photo_->CompleteInfo(GetImageDataBase(true, true), file_info_);
			}
			catch (...)
			{
				ASSERT(false);
			}
		}

		Filter(bar_.FilterText(), bar_.IsUnknownHidden());

		if (img_preview_)
			InvalidateRect(GetPreviewRect());
	}
	CATCH_ALL
}
Exemple #19
0
void DocDir::SaveDir(const String& package) const
{
	CreateDocDir(package);
	FileOut out(DocFile(package, "dir.h"));
	int q = dir.Find(package);
	if(q >= 0) {
		const ArrayMap<DocKey, Entry>& p = dir[q];
		for(int i = 0; i < p.GetCount(); i++) {
			const Entry& w = p[i];
			if(w.type == NORMAL || w.type == EXTERNAL) {
				const DocKey& k = p.GetKey(i);
				out << "#ifdef INCLUDE_NAMESPACE_" <<
				       Filter(k.nameing, CharFilterNameing) << "\r\n";
				out << "//" << k.item << "\r\n";
				out << "//" << k.nesting << "\r\n";
				out << "//" << k.nameing << "\r\n";
				out << "#include \"doc.dpp/";
				out << w.text;
				out << "\" //";
				if(w.type == EXTERNAL)
					out << "*";
				out << LNGAsText(k.lang) << "\r\n";
				out << "#endif\r\n\r\n";
			}
		}
	}
	SaveLinks(package);
}
Exemple #20
0
LRESULT CFileDiffDlg::OnDiffFinished(WPARAM, LPARAM)
{
	CString sFilterText;
	m_cFilter.GetWindowText(sFilterText);
	m_cFileList.SetRedraw(false);
	Filter(sFilterText);
	if (!m_arFileList.IsEmpty())
	{
		// Highlight first entry in file list
		m_cFileList.SetSelectionMark(0);
		m_cFileList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
	}

	int mincol = 0;
	int maxcol = m_cFileList.GetHeaderCtrl()->GetItemCount() - 1;
	int col;
	for (col = mincol; col <= maxcol; ++col)
	{
		m_cFileList.SetColumnWidth(col, LVSCW_AUTOSIZE_USEHEADER);
	}

	m_cFileList.ClearText();
	if (m_arFileList.IsEmpty())
		m_cFileList.ShowText(CString(MAKEINTRESOURCE(IDS_COMPAREREV_NODIFF)));
	m_cFileList.SetRedraw(true);

	InvalidateRect(NULL);
	RefreshCursor();
	EnableInputControl(true);
	return 0;
}
Exemple #21
0
bool Gdb_MI2::SetBreakpoint(const String& filename, int line, const String& bp)
{
	String file = Filter(host->GetHostPath(NormalizePath(filename)), CharFilterReSlash2);
	
	// gets all breakpoints
	MIValue bps = GetBreakpoints();
	
	// line should start from 1...
	line++;
	
	// check wether we've got already a breakpoint here
	// and remove it
	MIValue brk = pick(bps.FindBreakpoint(file, line));
	if(!brk.IsEmpty())
		if(!MICmd(Format("break-delete %s", brk["number"].Get())))
		{
			Exclamation(t_("Couldn't remove breakpoint"));
			return false;
		}
	
	if(bp.IsEmpty())
		return true;
	else if(bp[0] == 0xe)
		return MICmd(Format("break-insert %s:%d", file, line));
	else
		return MICmd(Format("break-insert -c \"%s\" %s:%d", bp, file, line));
}
int main(int argc, const char *argv[])
{
  const char *name = DEFAULT_NAME;
  char buf[256];
  if (argc>1)
    {
      name = argv[1];
    }
  sprintf(buf, "%s/i:img", name);
  in_img.Register(buf);
  sprintf(buf, "%s/o:img", name);
  out_img.Register(buf);

  sprintf(buf, "%s/i:mix", name);
  in_mix.Register(buf);
  sprintf(buf, "%s/o:box", name);
  out_data.Register(buf);
  
  box_thread.Begin();
  
  while(1)
    {
      in_img.Read();
      YARPImageOf<YarpPixelBGR> in;
      YARPImageOf<YarpPixelBGR> out;
      in.Refer(in_img.Content());
      out_img.Content().SetID(YARP_PIXEL_BGR);
      SatisfySize(in,out_img.Content());
      out.Refer(out_img.Content());
      Filter(in,out);
      out_img.Write();
//      YARPTime::DelayInSeconds(1000000);
    }
  return 0;
}
Exemple #23
0
void LayerConv::Backward(Layer *prev_layer) {
  StartTimer();
  prev_layer->deriv_mat_.resize(prev_layer->batchsize_, prev_layer->length_);
  #if COMP_REGIME != 2
    std::vector< std::vector<Mat> > prev_deriv, filters, deriv;
    InitMaps(prev_layer->deriv_mat_, prev_layer->mapsize_, prev_deriv); 
    InitMaps(weights_.get(), filtersize_, filters);
    InitMaps(deriv_mat_, mapsize_, deriv);
    std::vector<size_t> padding_der(numdim_);
    for (size_t i = 0; i < numdim_; ++i) {
      padding_der[i] = filtersize_[i] - 1 - padding_[i];
    }
    prev_layer->deriv_mat_.assign(0);    
    #if COMP_REGIME == 1
      #pragma omp parallel for num_threads(12) schedule(static,10)
    #endif  
    for (int k = 0; k < batchsize_; ++k) {
      #if COMP_REGIME == 1
      //#pragma omp parallel for
      #endif
      for (size_t i = 0; i < outputmaps_; ++i) {      
        for (size_t j = 0; j < prev_layer->outputmaps_; ++j) {                        
          Mat der_mat(prev_layer->mapsize_);
          Filter(deriv[k][i], filters[i][j], padding_der, true, der_mat);
          prev_deriv[k][j] += der_mat;        
        }      
      }        
    }
  #else // GPU       
    ImgActs(deriv_mat_, weights_.get(), prev_layer->deriv_mat_, 
            prev_layer->mapsize_, filtersize_[0], padding_[0], !unshared_);        
  #endif
  prev_layer->deriv_mat_.Validate();
  MeasureTime("Backwards Conv Layer",1);
}
Exemple #24
0
void DAS(void)
{ 
  int index;
  static int i = 0;
  unsigned short input;
  static unsigned long LastTime;  // time at previous ADC sample  
  unsigned long thisTime;         // time at current ADC sample
  long jitter;                    // time between measured and expected
    if(NumSamples < RUNLENGTH){   // finite time run
	
//	GPIO_B0 ^= 0x01;
      input = ADC_In(1);    
	  thisTime = OS_Time();       // current time, 20 ns
      DASoutput = Filter(input);
      FilterWork++;        // calculation finished
      if(FilterWork>1){    // ignore timing of first interrupt
        jitter = ((OS_TimeDifference(thisTime,LastTime)-PERIOD)*CLOCK_PERIOD)/1000;  // in usec
        if(jitter > MaxJitter){
          MaxJitter = jitter;
        }
        if(jitter < MinJitter){
          MinJitter = jitter;
        }        // jitter should be 0
        index = jitter+JITTERSIZE/2;   // us units
        if(index<0)index = 0;
        if(index>=JitterSize)index = JITTERSIZE-1;
        JitterHistogram[index]++; 
      }
      LastTime = thisTime; 
	  
    }
}
void MultidimensionalFilter::initialize(std::vector<float> initData, bool useButterworth, int dataSize){
	inputDataSize = dataSize;
	filters.resize(dataSize);
	for (int i = 0; i < dataSize; i++){
		filters[i] = Filter(initData[i], useButterworth);
	}
}
/* Function: Num2String ========================================================
 * Abstract:
 *  Translates unsigned long values into strings and returns the size of the
 *  string.
 */
PRIVATE uint32_T Num2String(char *dest,
                            uint32_T value,
                            boolean_T doFilter,
                            boolean_T endianess)
{
    char c[sizeof(uint32_T)];
    unsigned int i;
    unsigned int j;
    numString temp;
    temp.num = value;

    if (!endianess) { /* big endian */
        i = sizeof(uint32_T);
        j = 0;
        while (j<sizeof(uint32_T))
        {
            c[j] = temp.string[i-1];
            j++;
            i--;
        };
        memcpy(temp.string, c, sizeof(uint32_T));
    }

    if (doFilter) {
        return Filter(dest, temp.string, sizeof(uint32_T));
    }
    else {
        memcpy(dest, temp.string, sizeof(uint32_T));
        return sizeof(uint32_T);
    }
} /* end Num2String */
Exemple #27
0
		QList<Filter> ParseToFilters (const QStringList& paths)
		{
			QList<Filter> result;
			for (const auto& filePath : paths)
			{
				QFile file (filePath);
				if (!file.open (QIODevice::ReadOnly))
				{
					qWarning () << Q_FUNC_INFO
						<< "could not open file"
						<< filePath
						<< file.errorString ();
					result << Filter ();
					continue;
				}

				const auto& data = QString::fromUtf8 (file.readAll ());
				QStringList rawLines = data.split ('\n', QString::SkipEmptyParts);
				if (rawLines.size ())
					rawLines.removeAt (0);
				QStringList lines;
				std::transform (rawLines.begin (), rawLines.end (),
						std::back_inserter (lines),
						[] (const QString& t) { return t.trimmed (); });

				Filter f;
				std::for_each (lines.begin (), lines.end (), LineParser (&f));

				f.SD_.Filename_ = QFileInfo (filePath).fileName ();

				result << f;
			}
			return result;
		}
//移动一个棋子严格到(fx,fy)-(jx,jy)线段上,以达到将军或者躲将的目的
void MoveToFuckOrAvoid::Segment::
    F**k(int id, bool red, int fx, int fy, int jx, int jy){
    //red表示当前是走红还是走黑,(fx, fy)表示车,(jx, jy)表示将
    string str = red? "JCMPXSB" : "jcmpxsb";
    for(int i = 0; i < nrow; i++){
        for(int j = 0; j < ncol; j++){
            if(!red && !isBlack(id, i, j)) continue;
            else if(red && !isRed(id, i, j)) continue;
            char c = d[id].At(i, j);
            int dx[5], dy[5], n = 0;
            if(c == str[1]) Che_segment(id, i, j, fx, fy, jx, jy, dx, dy, n);
            else if(c == str[2]) Ma_segment(id, i, j, fx, fy, jx, jy, dx, dy, n);
            else if(c == str[3]) Che_segment(id, i, j, fx, fy, jx, jy, dx, dy, n);//没错
            else if(c == str[4]) Xiang_segment(id, i, j, fx, fy, jx, jy, dx, dy, n);
            else if(c == str[5]) Shi_segment(id, i, j, fx, fy, jx, jy, dx, dy, n);
            else if(c == str[6]) Bin_segment(id, red, i, j, fx, fy, jx, jy, dx, dy, n);
            for(int k = 0; k < n; k++){
                if(d[id].At(dx[k], dy[k]) != '_') continue;
                if(red) Newd(id, fx, fy, i, j, dx[k], dy[k]);
                else Newd(id, -1, -1, i, j, dx[k], dy[k]);
                Filter(red);
            }
        }
    }
}
Exemple #29
0
void CServerBrowser::Sort(bool IgnoreLazy)
{
	int i;

	// create filtered list
	Filter();

	if(!IgnoreLazy && g_Config.m_BrLazySorting && IsRefreshing() && LoadingProgression() < 90)
		return;

	// sort
	if(g_Config.m_BrSort == IServerBrowser::SORT_NAME)
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowser::SortCompareName));
	else if(g_Config.m_BrSort == IServerBrowser::SORT_PING)
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowser::SortComparePing));
	else if(g_Config.m_BrSort == IServerBrowser::SORT_MAP)
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowser::SortCompareMap));
	else if(g_Config.m_BrSort == IServerBrowser::SORT_NUMPLAYERS)
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this,
					g_Config.m_BrFilterSpectators ? &CServerBrowser::SortCompareNumPlayers : &CServerBrowser::SortCompareNumClients));
	else if(g_Config.m_BrSort == IServerBrowser::SORT_GAMETYPE)
		std::stable_sort(m_pSortedServerlist, m_pSortedServerlist+m_NumSortedServers, SortWrap(this, &CServerBrowser::SortCompareGametype));

	// set indexes
	for(i = 0; i < m_NumSortedServers; i++)
		m_ppServerlist[m_pSortedServerlist[i]]->m_Info.m_SortedIndex = i;

	str_copy(m_aFilterGametypeString, g_Config.m_BrFilterGametype, sizeof(m_aFilterGametypeString));
	str_copy(m_aFilterString, g_Config.m_BrFilterString, sizeof(m_aFilterString));
	m_Sorthash = SortHash();
}
Exemple #30
0
String MakeBuild::OutDir(const Index<String>& cfg, const String& package, const VectorMap<String, String>& bm,
                   bool use_target)
{
	Index<String> excl;
	excl.Add(bm.Get("BUILDER", "GCC"));
	excl.Add("MSC");
	LocalHost().AddFlags(excl);
	Vector<String> x;
	bool dbg = cfg.Find("DEBUG_FULL") >= 0 || cfg.Find("DEBUG_MINIMAL") >= 0;
	if(cfg.Find("DEBUG") >= 0) {
		excl.Add("BLITZ");
		if(cfg.Find("BLITZ") < 0)
			x.Add("NOBLITZ");
	}
	else
		if(dbg)
			x.Add("RELEASE");
	if(use_target)
		excl.Add("MAIN");
	for(int i = 0; i < cfg.GetCount(); i++)
		if(excl.Find(cfg[i]) < 0)
			x.Add(cfg[i]);
	Sort(x);
	for(int i = 0; i < x.GetCount(); i++)
		x[i] = InitCaps(x[i]);
	String outdir = GetVar("OUTPUT");
	if(output_per_assembly)
		outdir = AppendFileName(outdir, GetVarsName());
	if(!use_target)
		outdir = AppendFileName(outdir, package);
	outdir = AppendFileName(outdir, GetFileTitle(method) + "." + Join(x, "."));
	outdir = Filter(outdir, CharFilterSlash);
	return outdir;
}