ContinuousMosaicRV::ContinuousMosaicRV(const int n, string name, DAG* dag, const vector<int> boundaries, const vector<double> values) : DAGcomponent(name,dag,"ContinuousMosaicRV"), RandomVariable(), _n(n), _nblocks(boundaries.size()), _block_start(vector<int>(_n)), _previous_block_start(vector<int>(_n)), _block_end(vector<int>(_n)), _previous_block_end(vector<int>(_n)), _value(vector<double>(_n)), _previous_value(vector<double>(_n)), _last_move(NO_CHANGE), _has_changed(_n,true) { if(boundaries.size()!=values.size()) error("ContinuousMosaicRV(): number of boundaries must equal number of values"); if(boundaries[0]!=0) error("ContinuousMosaicRV(): first boundary must be at zero"); // Initialize _block_start int bix = 0, pos; int next_boundary = boundaries[bix]; int block_start = -1; for(pos=0;pos<length();pos++) { if(pos==next_boundary) { block_start = pos; next_boundary = (bix<boundaries.size()-1) ? boundaries[bix+1] : length(); if(next_boundary<=pos) error("ContinuousMosaicRV(): boundaries must be in strict ascending order"); ++bix; } _block_start[pos] = block_start; } if(bix!=nblocks()) error("ContinuousMosaicRV(): boundaries exceed mosaic length"); // Initialize _block_end bix = nblocks()-1; next_boundary = boundaries[bix]; int block_end = length()-1; for(pos=length()-1;pos>=0;pos--) { if(pos<next_boundary) { block_end = pos; next_boundary = (bix>=0) ? boundaries[bix-1] : -1; --bix; } _block_end[pos] = block_end; } // Initialize _value bix = -1; double x; for(pos=0;pos<length();pos++) { if(pos==_block_start[pos]) { ++bix; x = values[bix]; } _value[pos] = x; } }
unsigned V2_minix_blocks(loff_t size, struct super_block *sb) { return nblocks(size, sb); }
unsigned xiafs_blocks(loff_t size, struct super_block *sb) { return nblocks(size, sb); }
//-------------------------------------------------- void f0r_set_param_value(f0r_instance_t instance, f0r_param_t param, int param_index) { tp_inst_t* inst = (tp_inst_t*)instance; f0r_param_double* p = (f0r_param_double*) param; int chg,tmpi; float tmpf; chg=0; switch (param_index) { case 0: //type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 9.9999); if ((tmpi<0)||(tmpi>9.0)) break; if (inst->type != tmpi) chg=1; inst->type = tmpi; break; case 1: //channel tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 7.9999); if ((tmpi<0)||(tmpi>7.0)) break; if (inst->chan != tmpi) chg=1; inst->chan = tmpi; case 2: //amplitude tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->amp != tmpf) chg=1; inst->amp = tmpf; break; case 3: //linear period sweep tmpi = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->linp != tmpi) chg=1; inst->linp = tmpi; break; case 4: //frequency 1 tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->f1 != tmpf) chg=1; inst->f1 = tmpf; break; case 5: //frequency 2 tmpf = map_value_forward(*((double*)p), 0.0, 1.0); if (inst->f2 != tmpf) chg=1; inst->f2 = tmpf; break; case 6: //aspect type tmpf=*((double*)p); if (tmpf>=1.0) tmpi=(int)tmpf; else tmpi = map_value_forward(tmpf, 0.0, 6.9999); if ((tmpi<0)||(tmpi>6.0)) break; if (inst->aspt != tmpi) chg=1; inst->aspt = tmpi; switch (inst->aspt) //pixel aspect ratio { case 0: inst->par=1.000; break; //square pixels case 1: inst->par=1.067; break; //PAL DV case 2: inst->par=1.455; break; //PAL wide case 3: inst->par=0.889; break; //NTSC DV case 4: inst->par=1.212; break; //NTSC wide case 5: inst->par=1.333; break; //HDV case 6: inst->par=inst->mpar; break; //manual } break; case 7: //manual aspect tmpf = map_value_forward_log(*((double*)p), 0.5, 2.0); if (inst->mpar != tmpf) chg=1; inst->mpar = tmpf; if (inst->aspt==6) inst->par=inst->mpar; break; } if (chg==0) return; switch (inst->type) { case 0: //hor freq ver sweep sweep_v(inst->sl, inst->w, inst->h, 0, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 1: //hor freq hor sweep sweep_h(inst->sl, inst->w, inst->h, 0, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 2: //ver freq ver sweep sweep_v(inst->sl, inst->w, inst->h, 1, inst->amp, inst->linp, inst->par, 0.05, 0.7); //ver f ver sw break; case 3: //ver freq hor sweep sweep_h(inst->sl, inst->w, inst->h, 1, inst->amp, inst->linp, inst->par, 0.05, 0.7); break; case 4: // "Siemens star" radials(inst->sl, inst->w, inst->h, inst->amp, inst->par, 60.0); break; case 5: //rings outwards rings(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->linp, 0.05, 0.7); break; case 6: //rings inwards rings(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->linp, 0.7, 0.05); break; case 7: //uniform 2D spatial frequency diags(inst->sl, inst->w, inst->h, inst->amp, inst->par, inst->f1, inst->f2); break; case 8: // "Nyquist blocks" nblocks(inst->sl, inst->w, inst->h, inst->amp); break; case 9: //square bars at integer Nyquist fractions sqbars(inst->sl, inst->w, inst->h, inst->amp); break; default: break; } }
unsigned V1_minix_blocks(loff_t size) { return nblocks(size); }