Example #1
0
double popVariance(vector<double> popData, double mean) {
	double sigmaTerm = 0;
	
	for(vector<double>::iterator it = popData.begin(); it != popData.end(); it++) {
		sigmaTerm += exponent(*it - mean, 2);
	}

	return sigmaTerm / popData.capacity();
}
Example #2
0
size_t
size_below(const vector<T>& v)
{
  size_t res = v.capacity() * sizeof(T);
  for (size_t i = 0; i < v.size(); ++i) {
    res += size_below(v[i]);
  }
  return res;
}
Example #3
0
bool readGzOrZlib(uint8_t *inbuf, size_t size, vector<uint8_t>& data)
{
	// start by resizing vector to entire capacity; we'll shrink back down to the
	//  proper size later
	data.resize(data.capacity());
	if (data.empty())
	{
		data.resize(131072);
		data.resize(data.capacity());  // just in case extra space was allocated
	}
	// initialize zlib stream
	z_stream zstr;
	zstr.next_in = inbuf;
	zstr.avail_in = size;
	zstr.next_out = &(data[0]);
	zstr.avail_out = data.size();
	zstr.zalloc = Z_NULL;
	zstr.zfree = Z_NULL;
	int result = inflateInit2(&zstr, 15 + 32);  // adding 32 to window size means "detect both gzip and zlib"
	if (result != Z_OK)
		return false;
	inflateEnder ie(&zstr);
	// read as much as we can
	result = inflate(&zstr, Z_SYNC_FLUSH);
	while (result != Z_STREAM_END)
	{
		// if we failed for some reason other than not having enough room to read into, abort
		if (result != Z_OK)
			return false;
		// reallocate and read more
		ptrdiff_t diff = zstr.next_out - &(data[0]);
		size_t addedsize = data.size();
		data.resize(data.size() + addedsize);
		data.resize(data.capacity());  // just in case more was allocated
		zstr.next_out = &(data[0]) + diff;
		zstr.avail_out += addedsize;
		result = inflate(&zstr, Z_SYNC_FLUSH);
	}
	// resize buffer back down to end of the actual data
	data.resize(zstr.total_out);
	return true;
}
Example #4
0
		vector(vector const &other)
		{
			this->capacity_ = other.capacity();
			this->size_ = other.size();
			elements = nullptr;

			if(empty()) return;

			elements = new T[this->capacity()];
			ReSTL::copy(other.elements, other.elements + other.size(), elements);
		}
Example #5
0
void NormalAtoms::GetPositions(vector<Vec> &pos, bool ghosts /* = false */) const
{
  DEBUGPRINT;
  assert(active);
  pos.clear();
  if (ghosts || nGhosts == 0)
    {
      assert(positions.size() == nAtoms + nGhosts);
      if (pos.capacity() < nAtoms + nGhosts)
        pos.reserve(nAtoms + nGhosts + (nAtoms + nGhosts)/25);  // 4% extra
      pos.insert(pos.begin(), positions.begin(), positions.end());
    }
  else
    {
      if (pos.capacity() < nAtoms)
        pos.reserve(nAtoms + nAtoms/25);  // 4% extra
      pos.insert(pos.begin(), positions.begin(), positions.begin() + nAtoms);
      assert(pos.size() == nAtoms);
    }
  DEBUGPRINT;
}
Example #6
0
void test(vector<string> &svec, int num)
{
    svec.reserve(1024);
    string s;
    int i;

    for (i = 0; i < num; i++) {
        svec.push_back(s);
    }
    svec.resize(svec.size() + svec.size() / 2);
    cout << num << ": size " << svec.size() << ", capacity " << svec.capacity() << endl;
}
bool xspf::ecrire_fichier(vector<morceau>playlist)
{
fprintf(journal, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n<");
fprintf(journal, "<trackList>");
	for(int n=0; n<playlist.capacity();n++){
	fprintf(journal, "<track>");
	fprintf(journal, "<location>"+playlist[n].getChemin()+"</location>");
	fprintf(journal, "\n</track>\n");
}
fprintf(journal, "</trackList>\n</playlist>");
return true;
}
Example #8
0
int readGzFile(const string& filename, vector<uint8_t>& data)
{
	gzFile gzf = gzopen(filename.c_str(), "rb");
	if (gzf == NULL)
	{
		if (errno == ENOENT)
			return -1;
		return -2;
	}
	gzCloser gc(gzf);
	// start by resizing vector to entire capacity; we'll shrink back down to the
	//  proper size later
	data.resize(data.capacity());
	if (data.empty())
	{
		data.resize(131072);
		data.resize(data.capacity());  // just in case extra space was allocated
	}
	// read as much as we can
	vector<uint8_t>::size_type pos = 0;
	unsigned requestSize = data.size() - pos;  // this is plain old unsigned to match the zlib call
	int bytesRead = gzread(gzf, &data[pos], requestSize);
	if (bytesRead == -1)
		return -2;
	pos += bytesRead;
	while (bytesRead == requestSize)
	{
		// if there's still more, reallocate and read more
		data.resize(data.size() * 2);
		data.resize(data.capacity());  // just in case extra space was allocated
		requestSize = data.size() - pos;
		bytesRead = gzread(gzf, &data[pos], requestSize);
		if (bytesRead == -1)
			return -2;
		pos += bytesRead;
	}
	// resize buffer back down to the end of the actual data
	data.resize(pos);
	return 0;
}
void TrainableProbabilisticSvmClassifier::addTestExamples(vector<Mat>& examples, const vector<Mat>& newExamples, size_t& insertPosition) {
	// add new examples as long as there is space available
	auto example = newExamples.cbegin();
	for (; examples.size() < examples.capacity() && example != newExamples.cend(); ++example)
		examples.push_back(*example);
	// replace the oldest examples by new ones
	for (; example != newExamples.cend(); ++example) {
		examples[insertPosition] = *example;
		++insertPosition;
		if (insertPosition == examples.size())
			insertPosition = 0;
	}
}
Example #10
0
void cudaConspMap(cuda::GpuMat *gBaseFeatureMap, vector<cuda::GpuMat> *gFeaturePyramid, vector<cuda::GpuMat> *gFeatureMapsArray, GpuMat *gConspicuityMap, int numPyrLevels, vector<int> centreVec, vector<int> surroundOffsetVec, int conspMapLevel, Size pyrSizes[], Ptr<Filter> maxFilt, cuda::Stream cuStream)
{
	GpuMat gTemp, gTemp2, gTemp5;

	gConspicuityMap->setTo(Scalar::all(0.0));

	//check lenght of gFeaturePyramids and gFeatureMapsArray and data types, resolution of gBaseFeatureMap and data type, resolution of gConspicuityMap and data type,

	//future improvement make a conspicuity class containing all initialised settings and storing all the data required
	gFeaturePyramid->operator[](0) = *gBaseFeatureMap;
	for (int i = 0; i < numPyrLevels; i++)
	{
		cuda::pyrDown(gFeaturePyramid->operator[](i), gFeaturePyramid->operator[](i + 1), cuStream);
	}

	//the next step computes centre surround differences
	//feature map for arbitrary centre scale q and arbitrary surround scale s is
	//p(q,s) = |p(q) - p(s) linearly interpolated to level q
	//for conspicuity maps instead of taking this centre surround using one centre,
	//it is carried out for a range of centres with a range of surrounds for each centre

	int currCentre, currSurr, ind;
	for (int i = 0; i < centreVec.capacity(); i++)
	{
		currCentre = centreVec[i];
		for (int j = 0; j < surroundOffsetVec.capacity(); j++)
		{
			ind = i*surroundOffsetVec.capacity() + j;
			currSurr = currCentre + surroundOffsetVec[j];
			cuda::resize(gFeaturePyramid->operator[](currSurr), gTemp, pyrSizes[currCentre], 0.0, 0.0, 1, cuStream);
			cuda::absdiff(gFeaturePyramid->operator[](currCentre), gTemp, gFeatureMapsArray->operator[](ind), cuStream);
			cuda::resize(gFeatureMapsArray->operator[](ind), gTemp2, pyrSizes[conspMapLevel], 0.0, 0.0, 1, cuStream);
			normImage(&gTemp2, maxFilt, &gTemp5, pyrSizes[conspMapLevel], cuStream);
			cuda::add(*gConspicuityMap, gTemp5, *gConspicuityMap, noArray(), -1, cuStream);
		}
	}
}
Example #11
0
void NormalAtoms::GetScaledPositions(vector<Vec> &pos, bool ghosts /* = false */)
{
  DEBUGPRINT;
  int n = nAtoms;
  if (ghosts)
    n += nGhosts;
  assert(positions.size() >= n);
  const Vec *inv = GetInverseCell();
  if (pos.capacity() < n)
    pos.reserve(n + n/25);  // Reserve 4% extra.
  pos.resize(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      pos[i][j] = positions[i][0] * inv[0][j]   
                + positions[i][1] * inv[1][j]
                + positions[i][2] * inv[2][j];
  DEBUGPRINT;
}
Example #12
0
	void Init(){
		static bool firstCall = true;
		if (Vertexes == 0 && !firstCall) return; //Vertexes为0时,判断其已经初始化,无需再次初始化
		//清空&初始化~
		firstCall = false;
		if (VertexArray.capacity() == 0){
			VertexArray.reserve(ArrayUNITSIZE * 3);
			TexcoordArray.reserve(ArrayUNITSIZE * 2);
			ColorArray.reserve(ArrayUNITSIZE * 3);
		}

		VertexArray.clear();
		TexcoordArray.clear();
		ColorArray.clear();
		Vertexes = 0;
		Textured = false;
		Colored = false;
	}
Example #13
0
std::string RandomStringGenerator::GetRandomCharFromArray(vector<string> arr, vector<string> items)
{
	string val;
	bool bFlag = false;
	do
	{
		val = arr.at(rand() % arr.capacity());
		
		for(unsigned int i=0; i<items.size(); i++)
		{
			if(items.at(i).find(val) != string::npos)
				bFlag = true;
			else
				bFlag = false;
		}

	} while(bFlag);
	
	return val;
}
Example #14
0
/*
 * El método main es el ejecutable del programa
 */
int main(){
	clock_t inicio, fin; /*declaración de las variables para medir el tiempo 
                         * de ordenamiento*/
	lecturaDeDocumento(); // se imvoca el método lecturaDeDocumento
	inicio = clock(); // se inicia el tiempo de conteo del ordenamiento
	comparar(datos); /*se invoca el método comparar para analizar y 
                         * organizar los datos*/
        fin = clock(); //se termina el tiempo de conteo del ordenamiento
	imprimir(datos); /*se invoca el método imprimir para mostrar los datos 
                         * ordenados*/
	float tiempoTotal = (fin - inicio) / 1000;	
	cout << "El tiempo de ejecucion fue de " << tiempoTotal << " Segundos"
                << endl; /*muestra el tiempo total de ordenamiento restando el 
        tiempo final menos el inicial*/
	cout << datos.capacity()*sizeof(string) << " Bytes" << endl; /*indica la
                                                 * memoria utilizada en el 
                                                 * ordenamiento de los datos en 
                                                 * Bytes*/
	
	return 0;
}
Example #15
0
/**
* @brief function computes the histogram of oriented gradient for input image
* @param Im - input image
* @param descriptors -output desciptors
*/
static void HOG3(IplImage *Im,vector<float>& descriptors)
{


int nwin_x=3; //number of windows in x directions
int nwin_y=3; //number of windows in y directions
int B=9; //number of orientations


int L=Im->height; //image height
int C=Im->width; //image widht

descriptors.resize(nwin_x*nwin_y*B); //allocating memory for descriptors

CvMat angles2;
CvMat magnit2;
CvMat* H = cvCreateMat(nwin_x*nwin_y*B,1, CV_32FC3);
IplImage *Im1=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,3);
cvConvertScale(Im,Im1,1.0,0.0);



int step_x=floor(C/(nwin_x+1));
int step_y=floor(L/(nwin_y+1));
int cont=0;
CvMat *v_angles=0, *v_magnit=0,h1,h2,*v_angles1=0,*v_magnit1=0;

CvMat *hx=cvCreateMat(1,3,CV_32F); hx->data.fl[0]=-1;
hx->data.fl[1]=0; hx->data.fl[2]=1;
CvMat *hy=cvCreateMat(3,1,CV_32F);
hy->data.fl[0]=1;
hy->data.fl[1]=0;
hy->data.fl[2]=-1;


IplImage *grad_xr = cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F, 3);
IplImage *grad_yu = cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F, 3);



//calculating gradient in x and y directions
cvFilter2D(Im1, grad_xr,hx,cvPoint(1,0));
cvFilter2D(Im1, grad_yu,hy,cvPoint(-1,-1));

cvReleaseImage(&Im1);
cvReleaseMat(&hx);
cvReleaseMat(&hy);



IplImage *magnitude=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,3);
IplImage *orientation=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,3);
IplImage *magnitude1=cvCreateImage(cvSize(C,L),IPL_DEPTH_32F,1);
IplImage *orientation1=cvCreateImage(cvSize(C,L),IPL_DEPTH_32F,1);
IplImage *I1=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);
IplImage *I2=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);
IplImage *I3=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);
IplImage *I4=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);
IplImage *I5=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);
IplImage *I6=cvCreateImage(cvGetSize(Im),IPL_DEPTH_32F,1);


//cartesian to polar transformations
cvCartToPolar(grad_xr, grad_yu, magnitude, orientation,0);
cvReleaseImage(&grad_xr);
cvReleaseImage(&grad_yu);

cvSubS(orientation,cvScalar(pi,pi,pi),orientation,0);




cvSplit( magnitude, I4, I5, I6, 0 );


cvSplit( orientation, I1, I2, I3, 0 );

int step = I1->widthStep/sizeof(uchar);


for(int i=0;i<I4->height;i++)
{
   for(int j=0;j<I4->width;j++)
   {


       float *pt1= (float*) (I4->imageData + (i * I4->widthStep));
       float *pt2= (float*) (I5->imageData + (i * I5->widthStep));
       float *pt3= (float*) (I6->imageData + (i * I6->widthStep));
       float max = pt1[j]; /* assume x is the largest */

       if (pt2[j] > max) { /* if y is larger than max, assign y to max */
           ((float *)(I4->imageData + i*I4->widthStep))[j] = ((float *)(I5->imageData + i*I5->widthStep))[j];
           ((float *)(I1->imageData + i*I1->widthStep))[j] =((float *)(I2->imageData + i*I2->widthStep))[j];
       } /* end if */
       //consider only H and S channels.
       if (pt3[j] > max) { /* if z is larger than max, assign z to max */
           ((float *)(I4->imageData + i*I4->widthStep))[j] = ((float *)(I6->imageData + i*I6->widthStep))[j];
           ((float *)(I1->imageData + i*I1->widthStep))[j] =((float *)(I3->imageData + i*I3->widthStep))[j];

       }

       float * pt=((float *)(I1->imageData + i*I1->widthStep));


       if(pt[j]>0)
             {

                 if(pt[j]>pi && (pt[j]-pi <0.001))
                     pt[j]=0;
                 else if(pt[j]<pi && (pt[j]+pi<0.001))
                     pt[j]=0;
                 else
                     pt[j]=pt[j];
                 if(pt[j]>0)
                     pt[j]=-pt[j]+pi;

                 pt[j]=-pt[j];
             }
             else if(pt[j]<0)
             {
                 if(pt[j]>pi && (pt[j]-pi <0.001))
                     pt[j]=0;
                 else if(pt[j]<pi && (pt[j]+pi<0.001))
                     pt[j]=0;
                 else
                     pt[j]=pt[j];
                 if(pt[j]<0)
                     pt[j]=pt[j]+pi;


             }


   }


}
//finding the dominant orientation
cvCopy(I4,magnitude1,0);
cvCopy(I1,orientation1,0);





cvReleaseImage(&orientation);
cvReleaseImage(&magnitude);
cvReleaseImage(&I1);
cvReleaseImage(&I2);
cvReleaseImage(&I3);
cvReleaseImage(&I4);
cvReleaseImage(&I5);
cvReleaseImage(&I6);




int x, y;

int m=0,n=0;


//for each subwindow computing the histogram

for(int n=0;n<nwin_x;n++)
{
   for(int m=0;m<nwin_y;m++)
   {

       cont=cont+1;


       cvGetSubRect(magnitude1,&magnit2,cvRect((m*step_x),(n*step_y),2*step_x,2*step_y));

       v_magnit1=cvCreateMat(magnit2.cols,magnit2.rows,magnit2.type);
       cvT(&magnit2,v_magnit1);
       v_magnit=cvReshape(v_magnit1, &h2,1,magnit2.cols*magnit2.rows);



        cvGetSubRect(orientation1,&angles2,cvRect((m*step_x),(n*step_y),2*step_x,2*step_y));

         v_angles1=cvCreateMat(angles2.cols,angles2.rows,angles2.type);
         cvT(&angles2,v_angles1);
        v_angles=cvReshape(v_angles1, &h1,1,angles2.cols*angles2.rows);

       int K=0;
       if(v_angles->cols>v_angles->rows)
       K=v_angles->cols;
       else
       K=v_angles->rows;
       int bin=0;

       CvMat* H2 = cvCreateMat(B,1, CV_32FC1);
       cvZero(H2);


       float temp_gradient;

       //adding histogram count for each bin
       for(int k=0;k<K;k++)
       {
       float* pt = (float*) ( v_angles->data.ptr + (0 * v_angles->step));
                           float* pt1 = (float*) ( v_magnit->data.ptr + (0 * v_magnit->step));
                           float* pt2 = (float*) ( H2->data.ptr + (0 * H2->step));
       temp_gradient=pt[k];
       if (temp_gradient <= -pi+((2*pi)/B)) {
           bin=0;
           pt2[bin]=pt2[bin]+(pt1[k]);
       }
       else if ( temp_gradient <= -pi+4*pi/B) {
           bin=1;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if (temp_gradient <= -pi+6*pi/B) {
           bin=2;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if ( temp_gradient <= -pi+8*pi/B) {
           bin=3;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if (temp_gradient <= -pi+10*pi/B) {
           bin=4;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if (temp_gradient <= -pi+12*pi/B) {
           bin=5;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if (temp_gradient <= -pi+14*pi/B) {
           bin=6;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else if (temp_gradient <= -pi+16*pi/B) {
           bin=7;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }
       else {
           bin=8;
           pt2[bin]=pt2[bin]+(pt1[k]);

       }

       }
       cvReleaseMat(&v_magnit1);
       cvReleaseMat(&v_angles1);
       cvNormalize(H2, H2, 1, 0, 4);



       for(int y1=0;y1<H2->rows;y1++)
       {
       float* pt2 = (float*) ( H2->data.ptr + (0 * H2->step));
       float* pt3 = (float*) ( H->data.ptr + (0 * H->step));
       pt3[(cont-1)*B+y1]=pt2[y1];

       }


       v_angles=0;
       v_magnit=0;
       cvReleaseMat(&H2);

   }
}

for(int i=0;i<descriptors.capacity();i++)
{

    float* pt2 = (float*) ( H->data.ptr + (0 * H->step));
    descriptors[i]=pt2[i];

}
cvReleaseImage(&magnitude1);
cvReleaseImage(&orientation1);
cvReleaseMat(&H);


}
tResult cSimpleFusion::OnPinEvent( IPin *pSource, tInt nEventCode, tInt nParam1, tInt nParam2, IMediaSample *pMediaSample)
{
    RETURN_IF_POINTER_NULL(pMediaSample);
    RETURN_IF_POINTER_NULL(pSource);

    if (nEventCode == IPinEventSink::PE_MediaSampleReceived)
    {
        tFloat32 signalValue = 0;
        tUInt32 timeStamp = 0;
        m_nLastMSTime = pMediaSample->GetTime();

        if (pMediaSample != NULL && m_pCoderDescSignalInput != NULL)
        {
            // read-out the incoming Media Sample
            cObjectPtr<IMediaCoder> pCoderInput;
            RETURN_IF_FAILED(m_pCoderDescSignalInput->Lock(pMediaSample, &pCoderInput));

            //get values from media sample and sets it on signalValue / timeStamp
            pCoderInput->Get("f32Value", (tVoid*)&signalValue);
            pCoderInput->Get("ui32ArduinoTimestamp", (tVoid*)&timeStamp);
            m_pCoderDescSignalInput->Unlock(pCoderInput);
        }
        else
            RETURN_ERROR(ERR_FAILED);


        // do stuff for the IR-longrange sensor
        if (pSource == &m_ir_long_in)
        {
            //Do not iterate if the input pin is deactivated but connected
            if(stateOfLongeRangeInputPin != 1)
            {
                RETURN_NOERROR;
            }

            //Schwellwerte für ir long range
            if (signalValue < thresholdIRLongRange)
            {
                last_ir_long_input = signalValue;
                sigma_vector.push_back((tFloat32)20.0); // kürzesten Wert ausgeben zw. 20
            }
            // Ausreißer
            else if(abs(int(last_ir_long_input - tUInt32(signalValue))) > 30)
            {
                //Ausreißer  Statistisch auswerten ob es wirklich ein Ausreißer ist
                last_ir_long_input = signalValue;
                last_ir_long_oor = true;
                //sigma_vector.push_back();
                RETURN_NOERROR;
            }
            else
            {
                last_ir_long_input = signalValue;
                // add every iteration the signalValue into the vector
                sigma_vector.push_back(signalValue);
            }
        }

        //Do not iterate if the input pin is deactivated but connected
        else if(pSource == &m_ir_short_in1 && stateOfShortRangeInputPin1 != 1)
        {
            RETURN_NOERROR;
        }
        //Do not iterate if the input pin is deactivated but connected
        else if(pSource == &m_ir_short_in2 && stateOfShortRangeInputPin2 != 1)
        {
            RETURN_NOERROR;
        }
        // do stuff for the IR-shortrange sensor
        else if (pSource == &m_ir_short_in1 || pSource == &m_ir_short_in2)
        {
            // Schwellwert von short range einhalten
            if (signalValue < thresholdIRShortRange)
            {
                last_ir_short_input = signalValue;
                last_ir_short_oor = true;

                sigma_vector.push_back((tFloat32)8.0);// kürzesten Wert ausgeben 8
            }
            // Ausreißer
            else if(abs(int(last_ir_short_input - tUInt32(signalValue))) > 30)
            {
                //Ausreißer...todo: Statistisch auswerten ob es wirklich ein Ausreißer ist
                last_ir_short_input = signalValue;
                last_ir_short_oor = true;

                RETURN_NOERROR;
            }
            else
            {
                last_ir_short_input = signalValue;
                sigma_vector.push_back(signalValue);
            }

        }

        //Do not iterate if the input pin is deactivated but connected
        else if(pSource == &m_us_left_in && stateOfUSLeftInputPin != 1)
        {
            RETURN_NOERROR;
        }
        //Do not iterate if the input pin is deactivated but connected
        else if(pSource == &m_us_right_in && stateOfUSRightInputPin != 1)
        {
            RETURN_NOERROR;
        }
        // do stuff for the Ultrasonic sensors(left||right)
        else if(pSource == &m_us_left_in || pSource == &m_us_right_in)
        {
            //Setion für Schwellwerte für US
            if(signalValue < thresholdUS && pSource == &m_us_left_in )
            {
                last_us_left_input = signalValue;
                sigma_vector.push_back((tFloat32)thresholdUS); // kürzesten Wert ausgeben
                last_us_left_oor = true;
            }
            else if(signalValue < thresholdUS && pSource == &m_us_right_in)
            {
                last_us_right_input = signalValue;
                sigma_vector.push_back((tFloat32)thresholdUS); // kürzesten Wert ausgeben
                last_us_right_oor = true;
            }
            else
            {
                sigma_vector.push_back(signalValue);
            }
        }

        //decrement everytime a signalValue comes in
        sigma_iterations++;

        //send the median value from the sigma_vector to the output
        if(sigma_iterations == lengthOfMedianVector && sigma_vector.capacity() != 0)
        {
            sort(sigma_vector.begin(),sigma_vector.end());

            sigma_Value = sigma_vector.at(median-1);
            //LOG_INFO(cString::Format("%f",sigma_Value));
            sendNewValue(sigma_Value);

            sigma_vector.clear();
            sigma_iterations = 0;
        }
    }
    else
    {
        sendNewValue(0);
    }
    RETURN_NOERROR;
}
void printSizeCapacity(const vector<string>& values){
    cout << "size: " << values.size();
    if(values.size()/10 == 0){cout << ' ';}
    cout << " | capacity: " << values.capacity() << endl;
}
 /** Push element x onto stack. */
 void push(int x) {
     if (list.capacity() <= size) {
         list.resize(list.capacity() * 2);
     }
     list[size++] = x;
 }
Example #19
0
void copy(vector<T> const& src, vector<T>& dst, size_t size)
{
    assert(size <= src.capacity());
    assert(size <= dst.capacity());
    CUDA_CALL(cudaMemcpy(dst.data(), src.data(), size * sizeof(T), cudaMemcpyDeviceToDevice));
}
Example #20
0
void memset(vector<T>& array, int const& value, size_t size)
{
    assert(size <= array.capacity());
    CUDA_CALL(cudaMemset(array.data(), value, size * sizeof(T)));
}
Example #21
0
void copy(vector<T> const& src, host::vector<T>& dst, size_t size, stream& stream)
{
    assert(size <= src.capacity());
    assert(size <= dst.capacity());
    CUDA_CALL(cudaMemcpyAsync(dst.data(), src.data(), size * sizeof(T), cudaMemcpyDeviceToHost, stream.data()));
}
Example #22
0
void listInfo(vector<T> &v)
{
  cout << "Container capacity: " << v.capacity()
       << " size: " << v.size() << endl;
}