void* mandelbrot(void* par) { params* pars = (params*)par; int y,x,i; double* zn = malloc(sizeof(double)*2); double* c = malloc(sizeof(double)*2); //se implementan auxiliares usados por las funciones para no reservar memoria innecesaria double* auxCuad = malloc(sizeof(double)*2); double* auxSum = malloc(sizeof(double)*2); for (y = pars->Yi; y <= pars->Yf; y++)//hay que ver si no hay que ponerle igual { for (x = 0; x < pars->size; x++) { double z0 = 0;// para efetos del algoritmo creo que este es irrelevante int n = 1;// este calcula las iteraciones necesarias para la cosa double X = pars->a+x*pars->m; double Y = pars->b+y*pars->m; zn[0] = X; zn[1] = Y; c[0] = X; c[1] = Y; while (mod(zn)<2 && n < pars->depth) { zn = sumCR(c,cuad(zn,auxCuad),auxSum); n++; } //printf("M[%d][%d]\n",y,x); pars->M[y*pars->size+x]=log(n);//este tambien hay que ver como se hace con la libreria math } } return NULL; }
void mandelbrot(float* M,long size, double a , double b, double m, int depth){ //el size podria ser int... no se ha que hacer las consideraciones necesarias int y,x,i; double* zn = malloc(sizeof(double)*2); double* c = malloc(sizeof(double)*2); //se implementan auxiliares usados por las funciones para no reservar memoria innecesaria double* auxCuad = malloc(sizeof(double)*2); double* auxSum = malloc(sizeof(double)*2); //aqui hay que reservar la memoria de los auxiliares que ocupan sumCR y cuad for (y = 0; y < size; y++) { for (x = 0; x < size; x++) { double z0 = 0;// para efetos del algoritmo creo que este es irrelevante int n = 1;// este calcula las iteraciones necesarias para la cosa double X = a+y*m; double Y = b+x*m; zn[0] = X; zn[1] = Y; c[0] = X; c[1] = Y; while (mod(zn)<2 && n < depth){ zn = sumCR(c,cuad(zn,auxCuad),auxSum); n++; } //printf("M[%d][%d]\n",y,x); M[y*size+x]=log(n);//este tambien hay que ver como se hace con la libreria math } } //no retorna nada porque como va trabajando en la direccion de la matriz del parametro no necesita retornar la matriz modificada }
void* mandelbrot(void* par){ // //int* Y = (int*)par; int Y=contador++; int y,x,i; float* zn = malloc(sizeof(float)*2); float* c = malloc(sizeof(float)*2); //se implementan auxiliares usados por las funciones para no reservar memoria innecesaria float* auxCuad = malloc(sizeof(float)*2); float* auxSum = malloc(sizeof(float)*2); for (y = Y*FT; y < (Y+1)*FT; y++)//hay que ver si no hay que ponerle igual { for (x = 0; x < gSize; x++) { int n = 1;// este calcula las iteraciones necesarias para la cosa float X = gA+x*gm; float Y = gB+y*gm; zn[0] = X; zn[1] = Y; c[0] = X; c[1] = Y; while (mod(zn)<2 && n < gDepth){ zn = sumCR(c,cuad(zn,auxCuad),auxSum); n++; } //printf("M[%d][%d]\n",y,x); gM[y][x]=log(n);//este tambien hay que ver como se hace con la libreria math } } return NULL; }
void oneRun(char * args) { Input input; Matrix<double> cuad(41, 2); Model *model = new Model(); ModelFactory *modelFactory; PatternMatrix *dataSet; Matrix<double> *theta; Matrix<double> *weight; modelFactory = new SICSGeneralModel(); dataSet = new PatternMatrix(0); theta = new Matrix<double>(1, 41); weight = new Matrix<double>(1, 41); input.importCSV((char *) "Cuads.csv", cuad, 1, 0); input.importCSV(args, *dataSet, 1, 0); model->setModel(modelFactory, ESTIMATION_MODEL); delete modelFactory; model->getItemModel()->setDataset(dataSet); for (int k = 0; k < cuad.nR(); k++) { (*theta)(0, k) = cuad(k, 0); (*weight)(0, k) = cuad(k, 1); } // build parameter set model->getParameterModel()->buildParameterSet(model->getItemModel(), model->getDimensionModel()); // Create estimation EMEstimation em; //Here is where quadratures must be set. //create the quad nodes QuadratureNodes nodes(theta, weight); em.setQuadratureNodes(&nodes); em.setModel(model); em.setInitialValues(Constant::ANDRADE); //Pass the profiler to the estimation object so it can be used to profile each step //Run the estimation em.estimate(); /* * Now we will run the estimation of individual parameter */ //first create the latenTrait objects //LatentTraits * latentTraits; //latentTraits = new LatentTraits(dataSet); //Now create the estimation //LatentTraitEstimation * lte = new LatentTraitEstimation(); //Pass the model //lte->setModel(model); //Pass the latent traits //lte->setLatentTraits(latentTraits); //Pass the quadrature nodes //lte->setQuadratureNodes(&nodes); //Ready to estimate //lte->estimateLatentTraitsEAP(); //lte->estimateLatentTraitsMAP(); //finished //now read the latent traits but we will do this later //lte->getLatentTraits()->print(); //Matrix<double> data(dataSet->countIndividuals(), dataSet->countItems()); //input.importCSV(args, data, 1, 0); //double* itemsf = new double[ data.nC()]; //itemFit(latentTraits->pm, *(latentTraits->traits), data, model->getParameterModel()->getParameterSet(), model -> type,itemsf); //personFit(latentTraits->pm, *(latentTraits->traits), data, model->getParameterModel()->getParameterSet(), model -> type); delete dataSet; delete model; delete theta; delete weight; }
bool cmp(const pto&p1, const pto&p2)const{ int c1 = cuad(p1), c2 = cuad(p2); if(c1==c2) return p1.y*p2.x<p1.x*p2.y; else return c1 < c2; }