int compute_Julia(Input in, int i, int j) { complex_t c = new_complex(in.julia_param1, in.julia_param2); int step = 0; complex_t z = new_complex(in.x_min + j * in.rezolutie, in.y_min + i * in.rezolutie); while(modul(z) < 2 && step < in.max_steps) { z = add(mult(z, z), c); step++; } return step % NUM_COLORS; }
void mzeros1 (header *hd) { header *st=hd,*hd1,*result; int r,c; double *m,xr,xi; hd1=nextof(hd); hd=getvalue(hd); if (error) return; if (hd->type==s_matrix) { make_complex(st); if (error) return; hd=getvalue(st); if (error) return; } hd1=getvalue(hd1); if (error) return; if (hd1->type==s_real) { xr=*realof(hd1); xi=0; } else if (hd1->type==s_complex) { xr=*realof(hd1); xi=*(realof(hd1)+1); } else { output("Need a starting value!\n"); error=300; return; } if (hd->type!=s_cmatrix || dimsof(hd)->r!=1 || dimsof(hd)->c<2) { output("Need a complex polynomial\n"); error=300; return; } getmatrix(hd,&r,&c,&m); result=new_complex(0,0,""); if (error) return; bauhuber(m,c-1,realof(result),0,xr,xi); moveresult(st,result); }
ds::ReflectionData ds::ReflectionData::operator+(const ReflectionData& rhs) { ReflectionData* new_data = new ReflectionData(); //Iterate over all possible miller indices h, k, l in current data for(const_iterator ref=this->begin(); ref!=this->end(); ++ref) { ds::MillerIndex index = (*ref).first; tdx::Complex current_complex = (*ref).second.value(); tdx::Complex new_complex(current_complex.real(), current_complex.imag()); if(rhs.exists(index.h(), index.k(), index.l())) { Complex rhs_complex = rhs.value_at(index.h(), index.k(), index.l()); new_complex = rhs_complex + current_complex; } new_data->set_spot_at(index.h(), index.k(), index.l(), new_complex, weight_at(index.h(), index.k(), index.l()) ); } //Iterate over all possible miller indices h, k, l in rhs data for(const_iterator ref=rhs.begin(); ref!=rhs.end(); ++ref) { //Assign the current Miller Index to the array ds::MillerIndex index = (*ref).first; tdx::Complex current_complex = (*ref).second.value(); if( !(new_data->exists(index.h(), index.k(), index.l())) ) { new_data->set_spot_at(index.h(), index.k(), index.l(), current_complex, (*ref).second.weight() ); } } return *new_data; }
void polytrunc (header *hd) { header *st=hd,*result; double *m; complex *mc; int i; hd=getvalue(hd); if (error) return; if (hd->type==s_matrix && dimsof(hd)->r==1) { m=matrixof(hd); for (i=dimsof(hd)->c-1; i>=0; i--) { if (fabs(m[i])>epsilon) break; } if (i<0) result=new_real(0.0,""); else { result=new_matrix(1,i+1,""); memmove((char *)matrixof(result),(char *)matrixof(hd), (i+1)*sizeof(double)); } } else if (hd->type==s_complex && dimsof(hd)->r==1) { mc=(complex *)matrixof(hd); for (i=dimsof(hd)->c-1; i>=0; i--) { if (fabs(mc[i][0])>epsilon && fabs(mc[i][1])>epsilon) break; } if (i<0) result=new_complex(0.0,0.0,""); else { result=new_cmatrix(1,i+1,""); memmove((char *)matrixof(result),(char *)matrixof(hd), (i+1)*sizeof(complex)); } } else wrong_arg(); moveresult(st,result); }
int compute_Mandelbrot(Input in, int i, int j) { complex_t z = new_zero_complex(); complex_t c = new_complex(in.x_min + j * in.rezolutie, in.y_min + i * in.rezolutie); int step = 0; while(modul(z) < 2 && step < in.max_steps) { z = add(mult(z, z), c); step++; } return step % NUM_COLORS; }