Example #1
0
double SkyPoint::vREarth(long double jd0)
{
    double sinRA, sinDec, cosRA, cosDec;

    /* u_radial = unitary vector in the direction of the source
    	Vlsr 	= Vhel + Vsun.u_radial
    		= Vgeo + VEarth.u_radial + Vsun.u_radial  =>

    	Vgeo 	= (Vlsr -Vsun.u_radial) - VEarth.u_radial
    		=  Vhel - VEarth.u_radial
    		=  Vhel - (vx, vy, vz).(cos d cos a,cos d sen a,sen d)
    */

    /* We need an auxiliary SkyPoint since we need the
    * source referred to the J2000 equinox and we do not want to ovewrite
    * the current values
    */

    SkyPoint aux( RA0, Dec0 );

    aux.precessFromAnyEpoch(jd0, J2000);

    aux.ra().SinCos( sinRA, cosRA );
    aux.dec().SinCos( sinDec, cosDec );

    /* vEarth is referred to the J2000 equinox, hence we need that
    the source coordinates are also in the same reference system.
    */

    KSNumbers num(jd0);
    return num.vEarth(0) * cosDec * cosRA +
           num.vEarth(1) * cosDec * sinRA +
           num.vEarth(2) * sinDec;
}
/*!
  \param containerFile The path of the container file.
  \return Returns a ResultOfOpening value indicating the result of the operation.
*/
TNxSpooler::ResultOfOpening TNxSpooler::openPathWrittenInside(const QString &containerFile)
{
   QDEBUG_METHOD_NAME;

   QStringList arguments;

   // Read the path inside the file
   QFile container(containerFile);
   container.open(QIODevice::ReadOnly);
   QString path = container.readLine().trimmed();
   container.close();

   // Try to adapt the path to the running system
#ifdef Q_WS_WIN
   path.replace(QRegExp("^smb://"), "\\\\");
   path.replace("/", QDir::separator());
#else
   path.replace(QRegExp("^\\\\\\\\"), "smb://");
   path.replace("\\", QDir::separator());
#endif

   // Note: we'll check later the existence of what "path" refers to

   // Try to activate the NxSpooler window (set the focus to its window) so that the
   // new opened window has the focus. Note: the operating system has to allow that.
   activateWindow();

   qDebug() << TDebug::indentation << "The path that must be opened is: " << path;

   QFileInfo aux(path);

   // Note: we indicate that we found the path inside a container file
   return openPath(aux, containerFile, true);
}
int AuthLogin::doLogin(const ArsCadena &user, const ArsCadena &pass)
{
	ArsCadena		aux("AUTH LOGIN\r\n");
    CBase64			base64;
    BufferSalida	codificado;

	//
	// enviar comando de login
    //
	if (!transmitir(aux.cadena(), aux.longitud()+1, LOGIN_OK_AUTH))
        return ERR_AUTH;

	//
  	// enviar usuario en base64
    //
	codificado = base64.Encode(user.cadena(), user.longitud());

    aux = codificado.c_str();
    aux += "\r\n";
	if (!transmitir(aux.cadena(), aux.longitud()+1, LOGIN_OK_USER))
        return ERR_AUTH_USER;

	//
    // enviar contraseña en base64
    //
	codificado = base64.Encode(pass.cadena(), pass.longitud());

    aux = codificado.c_str();
    aux += "\r\n";
	if (!transmitir(aux.cadena(), aux.longitud()+1, LOGIN_OK_PASSWORD))
        return ERR_AUTH_PASSWORD;

    return ERR_AUTH_OK;
}
Example #4
0
int contida (char a[], char b[]) {
    int i = 0,r = 0;
    for(i=0;a[i] != '\0'; i++){
        if (aux(a[i],b) == 0) return 0;
    }
    return 1;
}
Example #5
0
void merge(std::vector<NeuralNet>& v, int start, int mid, int end, float sum)
{
    std::vector<NeuralNet> aux(end - start + 1);
    int i = start;      // Indice de la parte izquierda
    int j = mid + 1;    // Indice de la parte derecha
    int k = 0;          // Indice del vector aux
    
    // Mientras ninguno de los indices llegue a su fin vamos realizando comparaciones
    while (i <= mid && j <= end)
        if (v[i].getFitness() / sum < v[j].getFitness() / sum)
            aux[k++] = v[i++];
        else
            aux[k++] = v[j++];
    
    // Uno de los dos sub-vectores ya ha sido copiado del todo
    while (i <= mid)
        aux[k++] = v[i++];
    
    while (j <= end)
        aux[k++] = v[j++];
    
    // Copiamos los elementos ordenados de aux al vector original
    for (int n = 0; n != aux.size(); ++n)
        v[start + n] = aux[n];
}
Example #6
0
// Creates one index containing all tokens
// Uses sort-based multiway merge
void InvertedIndex::sorted_index(string temp_name){
	int value, i = 0;
	vector<int> aux(5);
	bool test, final = false;
	priority_queue<vector<int>, vector<vector<int>>, comparator> min_heap;

	if (this->memory_usage){
		memory_dump();
	}

	cout << "Saving";
	cout << " text index\n";
	cout << "Total of files evaluated: " << this->total_docs << endl;
	cout << "Total tokens: " << this->total_size_index << " " << this->total_token << endl;
	cout << "Vocabulary size: " << this->vocabulary.size() << endl;
	cout << "Memory Limit: " << (MEMORY_LIMITE/INDEX_LINE_SIZE) << endl;
	cout << "Total of files: " << this->n_dumps << endl << endl;


	this->vocabulary_init(temp_name);

	while(i < this->n_dumps){
		int n_files;
		fstream out;

		// Testing wether is possible to open all files at once
		if ((this->n_dumps - i) <= (MEMORY_LIMITE/INDEX_LINE_SIZE) && ((this->n_dumps - i) < (MAX_OS_OPEN_FILE - 1000))){
			// If true, needs saving final sorted index
			n_files = this->n_dumps - i;
			out.open(temp_name+INDEX_SORTED_FILE_NAME, ios::out | ios::binary);
			final = true;
		} else {
tablero::tablero(const pair<unsigned int,unsigned int>& par) {

    _tam = par;
    vector<char> aux(par.second,'X');
    for (unsigned int i=0; i < par.first; i++)
        _matriz.push_back(aux);
}
Example #8
0
//el indx dice que zona es, indx = 1...4
Point2f getAreaCenter(RotatedRect& rect, int indx){
	
	Point2f aux(0,0);
	if (abs(rect.angle)<1) {
		aux.x = ((indx == 1 || indx == 3) ? rect.center.x-rect.size.width/4 : rect.center.x+rect.size.width/4);
		aux.y = ((indx == 1 || indx == 2) ? rect.center.y-rect.size.height/4 : rect.center.y+rect.size.height/4);
	}
	else {
		CvPoint2D32f boxPoints[4];
		RotatedRect box2(rect.center,cv::Size(rect.size.width/2,rect.size.height/2),-rect.angle+90);
		cvBoxPoints(CvBox2D(box2), boxPoints);
		if (indx == 1) {
			aux.x = (double)boxPoints[1].x;
			aux.y = (double)boxPoints[1].y;
		}
		else if(indx == 2){
			aux.x = (double)boxPoints[2].x;
			aux.y = (double)boxPoints[2].y;
		}
		else if(indx == 3){
			aux.x = (double)boxPoints[0].x;
			aux.y = (double)boxPoints[0].y;
		}
		else if(indx == 4){
			aux.x = (double)boxPoints[3].x;
			aux.y = (double)boxPoints[3].y;
		}
		else
			CV_Assert(false);
	}
	
	return aux;
}
Example #9
0
//ONLY USED IF USING DESCRIPTORS
SpriteSheetDescription Resources::loadDescription(std::string fileName) {
    std::string filePath = TEXTURETPATH + fileName + TEXTUREDESCRIPTIONEXTENSION;
    SpriteSheetDescription ret;
    // leer el fichero
    std::ifstream file(filePath);
    if (!file.is_open()) {
        std::cout << "Error opening file on resources loadDescription " << filePath << std::endl;
        exit(EXIT_FAILURE);
    }
    std::vector<std::pair<int, std::string> > v;
    int lineNum = 0;
    std::string line;
    while (getline(file,line)) {
        ++lineNum;
        for (int i = 0; i < int(line.size()-1); ++i) {
            if (line[i] == '/' && line[i+1] == '/') {
                line = line.substr(0,i);
                break;
            }
        }
        std::istringstream aux(line);
        std::string s;
        while(aux >> s) 
            v.push_back(std::make_pair(lineNum,s));
    }
    SpriteSheetDescription ssd;
    std::map<std::string, int> positions;
    for (int  i = 0; i < int(v.size()); ++i) {
        lineNum = v[i].first;
        std::string key = v[i].second;
        int descriptorPosition;
        if (positions.find(key) == positions.end()) {
            descriptorPosition = positions.size();
            positions.insert(std::make_pair(key,descriptorPosition));
            ssd.push_back(std::vector<sf::IntRect>());
        }
        else {
            descriptorPosition = positions[key];
        }
        //std::cout << "insertando la key " << key << " en la posicion " << descriptorPosition << std::endl;

        if (i+4 >= int(v.size()) || 
            !isInt(v[i+1].second) || 
            !isInt(v[i+2].second) || 
            !isInt(v[i+3].second) || 
            !isInt(v[i+4].second)) {
            std::cout << "Error in line " << lineNum << ": four integers are needed" << std::endl;
            exit(EXIT_FAILURE);
        }
        sf::IntRect intRect(myStoi(v[i+1].second),
            myStoi(v[i+2].second),
            myStoi(v[i+3].second),
            myStoi(v[i+4].second));
        ssd[descriptorPosition].push_back(intRect);
        i += 4;
    }

    return ssd;
}
Example #10
0
void Rope::update(sf::Time elapsedTime) {
    
    Vector aux(100,0);
    //movingPoint->addScaledVector(aux, elapsedTime.asSeconds());
    
    //vel = vel + acceleration * elapsedTime.asSeconds();
    bb->update(movingPoint->getX(), movingPoint->getY());
}
Example #11
0
String CUtils::RTrim(const String& data)
{
  String  aux(data);
  for (int i = aux.length() - 1; (aux.length() > 0) && !iswgraph(aux.substr(i, 1).operator [](0)); i--)
    aux.erase(i, 1);
  
  return aux;
}
static void		aux(size_t n, unsigned int b, char *ans, int *p)
{
	const char *base = "0123456789abcdef";

	if (n >= b)
		aux(n / b, b, ans, p);
	ans[(*p)++] = base[n % b];
}
Example #13
0
tablero::tablero(const pair<unsigned int,unsigned int>& par){

    _tam = par;
    list<char> aux(_tam.second,'X');
    list<list<char> > aux1(_tam.first, aux);
    _matriz = aux1;

}
Example #14
0
Element::Group <const VolR> Unstructured::getAdjacentRegion(
        const Element::Group<const VolR>& region) const {
    std::vector<Element::Face> outer = getExternalBorder(region);
    std::size_t nOut = outer.size();
    // Removes repeated.
    Math::Matrix::Dynamic<std::size_t> aux(nOut,1);
    for (std::size_t i = 0; i < nOut; i++) {
        aux(i,0) = outer[i].first->getId().toInt();
    }
    aux.sortAndRemoveRepeatedRows_omp();
    // Prepares result.
    Element::Group<ElemR> res;
    for (std::size_t i = 0; i < aux.nRows(); i++) {
        res.add(elems().getId(ElemId(aux(i,0)))->cloneTo<ElemR>());
    }
    return res;
}
Example #15
0
Vector3 Quaternion::operator*(const Vector3& other) const
{
	glm::vec3 aux(other.x, other.y, other.z);

	glm::vec3 ret = _GLMQuat * aux;

	return Vector3(ret.x, ret.y, ret.z);
}
Example #16
0
MaskSequence::MaskSequence(const MaskSequenceFx &other)	// copy constructor
{
	vector<Mask> aux(other._frames.begin(), other._frames.end());
	_frames.swap(aux);
	_size = other._size;


}
Example #17
0
 result_type operator()(Range& rng, diff_t tabsize,
     val_t newline = detail::default_newline<val_t>::value(),
     val_t tab     = detail::default_tab<val_t>::value(),
     val_t space   = detail::default_space<val_t>::value() ) const
 {
     PSTADE_CONCEPT_ASSERT((Forward<Range>));
     return aux(boost::begin(rng), boost::end(rng), tabsize, newline, tab, space);
 }
Example #18
0
SequenceFx<T>& SequenceFx<T>::operator= (const Sequence<T> &other)
{
	vector<ImageFx<T> > aux(other._frames.begin(), other._frames.end());
	_frames.swap(aux);
	_size = other._size;

	return *this;
}
std::complex<double> NoncentralChiSquaredRand::CFImpl(double t) const
{
    std::complex<double> aux(1, -2 * t);
    std::complex<double> y(0, lambda * t);
    y /= aux;
    y -= halfK * std::log(aux);
    return std::exp(y);
}
Example #20
0
tgt::ivec2 Flow2D::flowPosToSlicePos(const tgt::vec2& fp, const tgt::ivec2& sliceSize,
                                        const tgt::ivec2& offset) const
{
    tgt::vec2 aux(fp / static_cast<tgt::vec2>(dimensions_));
    return tgt::ivec2(
        (static_cast<int>(tgt::round(aux.x * sliceSize.x)) + offset.x) % sliceSize.x,
        (static_cast<int>(tgt::round(aux.y * sliceSize.y)) + offset.y) % sliceSize.y);
}
Example #21
0
int main()
{
// Estrutura List
 Route route;
// Ler ponto de um arquivo

 std::ifstream ifs ("points.dat", std::ifstream::in);

 point aux(0,0);

 while (ifs >> aux.real() >> aux.imag()) { 
  route.push_back(aux);
 }

 ifs.close();

// List teste

// Algoritmo
// Step 1: Calcular as poupanças sij=ci0+c0j-cij para i,j=1,...mn i!=j. Criar n rotas de veículos
// (0,i,0) para i=1,...,n. Ordenar as economias num modo não crescente.
 int n=route.size();
 double s[n][n-1];
 point origin=*route.begin();
 Route Aux;
 Subroute Sb; 

 for (Route::iterator i=++route.begin(); i!=route.end(); ++i) {
  Aux.push_back(*i);
  Sb.push_back(Aux);
  for ( Route::iterator j=i; j!=route.end(); ++j) {
   if( i!=j) {
     s[i][j]( std::abs(*i-origin)+std::abs(origin-*j)-std::abs(*i-*j) );
   }
  }
  Aux.clear();
 }

 std::cout << Sb.size() << std::endl;

 s.sort();

 for (std::list<double>::iterator i=s.begin(); i!=s.end(); ++i) 
	std::cout << *i << std::endl;

// Step 2: Iniciar do topo da lista de economias, executando o seguinte. Dada a economia sij,
// determine se há duas rotas, uma contendo arco ou aresta (0,j) e a outra contendo o arco ou aresta
// (i,0), que pode ser mescladas. Se então, combine essas duas rotas deletando (0,j) e (i,0) e
// introduzindo (i,j).

 
 // Mesclar rotas
 for(Subroute::iterator I=Sb.end(); I!=Sb.begin(); --I) {
  
 }

 return 0;
}
void CertCLTest::testSerializar()
{
	ArsCadena	label;
	Tarjeta		*tarjeta;
	AlmacenCertificado *alm;
	Certificado	*cert;

	ArsCadena	encoded;
	ArsCadena	msg;
	bool		pinOK;

	tarjeta = createTarjeta();
	try
	{
		VALIDAR( tarjeta->conectar() );
		alm = tarjeta->abrirAlmacen("");
		VALIDAR(alm != NULL);
		try
		{
			pinOK = tarjeta->establecerPIN(PIN_CORRECTO, msg);
			VALIDAR_CON_MENSAJE(pinOK, msg.cadena());

			cert = alm->loadCertificado(AlmacenCertificado::ClaveBusquedaPrimero, NULL);
			if (cert == NULL && ETIQUETA_CERTIFICADO[0] != '\0')
			{
				label = ETIQUETA_CERTIFICADO;
				cert = alm->loadCertificado(AlmacenCertificado::ClaveBusquedaNombre, &label);
			}

			VALIDAR(cert != NULL);
			try
			{
				ValidarCertificado(cert);

				encoded = cert->serializar();
				VALIDAR(encoded != "");

				ArsCadena aux(CERTIFICADO_ENCODED);

				VALIDAR_IGUALES(aux.longitud(), encoded.longitud());
				VALIDAR_IGUALES(aux.cadena(), encoded.cadena());
				VALIDAR_IGUALES(CERTIFICADO_ENCODED, encoded.cadena());
			}
			__finally
			{
				delete cert;
			}
		}
		__finally
		{
			delete alm;
		}
	}
	__finally
	{
		delete tarjeta;
	}
}
void MainWindow::on_dial_valueChanged(int value)
{

    QVariant aux(value);
    QString command = "set /autopilot/settings/target-speed-kt ";
    command += aux.toString();

    comm->sendData(command);
}
Example #24
0
int main(int argc, char* argv[]) {
  int n;
  for (n=2; n<=TYPE; n++) if (is_prime(n)) {
    primes[nb_primes++] = n;
  }
  printf("%i\n", aux(0, MAXL));

  return 0;
}
Example #25
0
void mystring::subblanc()
{
	int a;
	string aux(1,c);
	while ((a=(int)this->find(' ', a))!=this->npos) {
		this->replace(a, 1, aux);
		a++;
	}
}
Example #26
0
X 
sent(E env) {
	X               sentv = getxx();
	sentv->type = "sent";
	if (prob(0.09)) {
		env->unspec = "";
		sentv->list.x[1] = np(env);
		sentv->list.x[3] = aux(env);
		sentv->list.x[4] = vp(env);
		sentv->list.x[0] = nomq(env);
		sentv->list.x[2] = rel();
		return sentv;
	}
	sentv->list.x[0] = np(env);
	sentv->list.x[1] = aux(env);
	sentv->list.x[2] = vp(env);
	return sentv;
}
Example #27
0
static void		aux(unsigned long long n, unsigned int b, char *ans, int *p)
{
	char		*base;

	base = "0123456789abcdef";
	if (n >= b)
		aux(n / b, b, ans, p);
	ans[(*p)++] = base[n % b];
}
	real_t operator/(REAL dato, real_t& v)
	{
		try
		{
			if(v.mostrar() == 0)
			{
				throw("Error en la división, división entre 0: se devuelve el valor del primer número");
			}
			real_t aux(dato/v.mostrar());
			return aux;	
		}
		catch(const char* msg)
		{
			cerr << msg << endl;
			real_t aux(dato);
			return aux;		
		}
	}
Example #29
0
int aux(int x, int alpha, int beta) {
  if (x == 0) return 1;
  int two_alpha = 1 << alpha;
  if (two_alpha > x) return 0;
  if (cache[x][alpha][beta] != -1)
    return cache[x][alpha][beta];
  int res = aux(x, alpha+1, beta);
  if (res < 2)
    for (int i = 0; i <= beta; i++) {
      int s = two_alpha * pow_int(3, i);
      if (s > x) break;
      res += aux(x - s, alpha + 1, i - 1);
      if (res >= 2) break;
    }
  res = res > 2 ? 2: res;
  cache[x][alpha][beta] = res;
  return res;
}
Example #30
0
int aux(int v[], int ini, int fim, int &max, int &min){
	int l = ini, r = fim;
	int m, esq,dir;

	if (l == r){
		return v[l];
	}

	else if (l < r){
		m = (l+r)/2;
		esq = aux(v,l,m,max,min);
		dir = aux(v,m+1,r,max,min);
		if (esq < dir){
			max = dir;
			min = esq;
		}
	}
}