ContainmentResult TestSphereSphere ( Sphere const & A, Sphere const & B ) { // ---------- // do a quick outside test first Vector delta = B.getCenter() - A.getCenter(); real dist2 = delta.magnitudeSquared(); real sumRadius = A.getRadius() + B.getRadius(); real sumRadius2 = sumRadius * sumRadius; if(dist2 > sumRadius2) { return CR_Outside; } else if(dist2 == sumRadius2) //lint !e777 // testing floats for equality { return CR_TouchingOutside; } else { // ---------- // and if that fails do the full test real dist = sqrt(dist2); Range AD( dist - A.getRadius(), dist + A.getRadius() ); Range BD( -B.getRadius(), B.getRadius() ); return Containment1d::TestRangeRange( AD, BD ); } }
int crypto_aead_encrypt( unsigned char *c,unsigned long long *clen, const unsigned char *m,unsigned long long mlen, const unsigned char *ad,unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k ) { string K((const char *)k, (size_t)CRYPTO_KEYBYTES); string N((const char *)npub, (size_t)CRYPTO_NPUBBYTES); stringstream dummy; stringstream AD(string((const char *)ad, adlen)); stringstream plaintext(string((const char *)m, mlen)); stringstream ciphertext; stringstream tag; LakeKeyak instance; instance.StartEngine(K, N, false, dummy, false, false); instance.Wrap(plaintext, ciphertext, AD, tag, false, false); memcpy(c, ciphertext.str().data(), ciphertext.str().size()); *clen = ciphertext.str().size(); memcpy(c+ciphertext.str().size(), tag.str().data(), tag.str().size()); *clen += tag.str().size(); return 0; }
bool change_coor(std::pair<int, int> postcard, std::pair<int, int> envelope) { int hypotenuse_envelope = sqrt(pow(envelope.first, 2) + pow(envelope.second, 2)); if (hypotenuse_envelope - postcard.second) { float h_postcard, w_postcard; std::pair<int, int> A(0, 0); std::pair<int, int> B(0, postcard.second); std::pair<int, int> C(postcard.first, 0); std::pair<int, int> D(postcard.first, postcard.second); for (float angle = 0; angle <= 2*PI;) { std::pair<float, float> AD(rotate(D, angle)); std::pair<float, float> new_A(rotate(A, angle)); AD.first -= new_A.first; AD.second -= new_A.second; std::pair<float, float> BC(rotate(C, angle)); std::pair<float, float> new_B(rotate(B, angle)); BC.first -= new_B.first; BC.second -= new_B.second; h_postcard = std::max(abs(BC.second), abs(AD.second)); w_postcard = std::max(abs(BC.first), abs(AD.first)); if ((h_postcard <= envelope.second)&&(w_postcard <= envelope.first)) return true; angle += 0.001; } } else return false; }
int crypto_aead_decrypt( unsigned char *m,unsigned long long *mlen, unsigned char *nsec, const unsigned char *c,unsigned long long clen, const unsigned char *ad,unsigned long long adlen, const unsigned char *npub, const unsigned char *k ) { if (clen < CRYPTO_ABYTES) return -1; string K((const char *)k, CRYPTO_KEYBYTES); string N((const char *)npub, CRYPTO_NPUBBYTES); stringstream dummy; stringstream AD(string((const char *)ad, adlen)); stringstream plaintext; stringstream ciphertext(string((const char *)c, clen-CRYPTO_ABYTES)); stringstream tag(string((const char *)c+clen-CRYPTO_ABYTES, CRYPTO_ABYTES)); LakeKeyak instance; instance.StartEngine(K, N, false, dummy, true, false); bool result = instance.Wrap(ciphertext, plaintext, AD, tag, true, false); if (result) { memcpy(m, plaintext.str().data(), plaintext.str().size()); *mlen = plaintext.str().size(); return 0; } else return -1; }
void QmitkDiffusionQuantificationView::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->m_StandardGFACheckbox), SIGNAL(clicked()), this, SLOT(GFACheckboxClicked()) ); connect( (QObject*)(m_Controls->m_GFAButton), SIGNAL(clicked()), this, SLOT(GFA()) ); connect( (QObject*)(m_Controls->m_CurvatureButton), SIGNAL(clicked()), this, SLOT(Curvature()) ); connect( (QObject*)(m_Controls->m_FAButton), SIGNAL(clicked()), this, SLOT(FA()) ); connect( (QObject*)(m_Controls->m_RAButton), SIGNAL(clicked()), this, SLOT(RA()) ); connect( (QObject*)(m_Controls->m_ADButton), SIGNAL(clicked()), this, SLOT(AD()) ); connect( (QObject*)(m_Controls->m_RDButton), SIGNAL(clicked()), this, SLOT(RD()) ); connect( (QObject*)(m_Controls->m_MDButton), SIGNAL(clicked()), this, SLOT(MD()) ); connect( (QObject*)(m_Controls->m_ClusteringAnisotropy), SIGNAL(clicked()), this, SLOT(ClusterAnisotropy()) ); } }
void testArithmetic(std::string const & filename) { ::libmaus::autoarray::AutoArray<uint8_t> data = ::libmaus::util::GetFileSize::readFile(filename); unsigned int const alph = 8; for ( uint64_t i = 0; i < data.size(); ++i ) data[i] &= (alph-1); ::libmaus::timing::RealTimeClock rtc; rtc.start(); typedef ::libmaus::bitio::BitWriterVector8 bw_type; std::vector < uint8_t > VV; std::back_insert_iterator< std::vector < uint8_t > > it(VV); bw_type CB(it); unsigned int const loops = 3; for ( uint64_t z = 0; z < loops; ++z ) encodeFileArithmetic(data,alph,CB); typedef ::libmaus::bitio::IteratorBitInputStream< std::vector<uint8_t>::const_iterator, true > br_type; br_type CR(VV.begin(),VV.end()); for ( uint64_t z = 0; z < loops; ++z ) { rtc.start(); ::libmaus::arithmetic::ArithmeticDecoder < br_type > AD (CR); model_type MD(alph); ::libmaus::autoarray::AutoArray<uint8_t> ddata(data.size(),false); for ( uint64_t i = 0; i < data.size(); ++i ) ddata[i] = AD.decodeUpdate(MD); AD.flush(true /* read end marker */); std::cerr << "Decoded in " << rtc.getElapsedSeconds() << " s, " << 1./(rtc.getElapsedSeconds()/data.size()); bool ok = true; for ( uint64_t i = 0; i < data.size(); ++i ) ok = ok && (data[i] == ddata[i]); std::cout << " " << (ok ? "ok" : "failed") << std::endl; } std::cerr << static_cast<double>(loops*data.size()) / VV.size() << std::endl; }
ContainmentResult TestCylinderCylinder ( Cylinder const & A, Cylinder const & B ) { Vector delta = B.getBase() - A.getBase(); delta.y = 0; real dist = delta.magnitude(); Range AD( dist - A.getRadius(), dist + A.getRadius() ); Range BD( -B.getRadius(), B.getRadius() ); ContainmentResult hTest = Containment1d::TestRangeRange( AD, BD ); ContainmentResult vTest = Containment1d::TestRangeRange( A.getRangeY(), B.getRangeY() ); // ---------- return Containment::ComposeAxisTests(hTest,vTest); }
int main() { ArrayDeque<int> AD(5); std::cout << AD << std::endl; AD.insertFront(5); AD.insertBack(3); std::cout << AD << std::endl; AD.insertFront(2); std::cout << AD << std::endl; AD.removeBack(); AD.removeBack(); std::cout << AD << std::endl; try {AD.removeBack();} catch (DequeEmpty& dee) { std::cout << "Caught 1: " << dee.getMessage() << std::endl; } try {AD.removeBack();} catch (DequeEmpty& dee) { std::cout << "Caught 2: " << dee.getMessage() << std::endl; } std::cout << AD << std::endl; int i; try { for (i = 0; i < 10; i++) { AD.insertFront(i); // AD.insertBack(2*i); } } catch (DequeFull& dfe) { std::cout << "Caught " << i << ": " << dfe.getMessage() << std::endl; std::cout << AD << std::endl; } }
void client::clientMain(int commandport, int checktemp, int senderid, int loopNum, std::string test,std::string tempport) { std::mutex* lock = new std::mutex; Sender sndr1("send", loopNum, senderid * 2 + 1, checktemp, tempport, test);// sndr2("send", loopNum, senderid * 2 + 2, checktemp, tempport, test); Receiver* rcvr1 = new Receiver;//create sender and receiver VaultDispatcher* Disp1; Disp1 = new VaultDispatcher("disp"); EchoCommunicator* Echo1; FileCommunicator* File1; Echo1 = new EchoCommunicator("echo"); File1 = new FileCommunicator("file"); Disp1->Register(Echo1); Disp1->Register(File1); Echo1->Dispatcher(Disp1); File1->Dispatcher(Disp1); rcvr1->LOCK(lock);//assign lock to each of the communicator Disp1->LOCK(lock); Echo1->LOCK(lock); File1->LOCK(lock); sndr1.LOCK(lock); std::thread sender1(&Sender::start, &sndr1, "127.0.0.1", 8080); std::thread AD(&VaultDispatcher::ProcessMsg1, Disp1);//open the thread to each of the processMsg function std::thread EC(&EchoCommunicator::ProcessMsg1, Echo1); std::thread FC(&FileCommunicator::ProcessMsg1, File1); rcvr1->DISP(Disp1); rcvr1->start(commandport); AD.join(); EC.join(); FC.join(); sender1.join(); while (Disp1->DisplayQ().size() != 0) { std::string getresult = Disp1->DisplayQ().deQ(); display += '?' + getresult; } }
void Rectangle::Subdivide(float patchSize) { if (mPatches == nullptr) { mPatches = new std::vector< Patch* >(); // Calculate the number of patches along one axis float distance_i = _a.DistanceTo(_b); float dimension_i = distance_i / patchSize; int size_i = int(dimension_i); float remainder_i = dimension_i - size_i; if (remainder_i > 0) { ++size_i; } // Calculate the number of patches along the other axis float distance_j = _a.DistanceTo(_d); float dimension_j = distance_j / patchSize; int size_j = int(dimension_j); float remainder_j = dimension_j - size_j; if (remainder_j > 0) { ++size_j; } // Create a two-dimensional vector to hold points std::vector< std::vector<Point*> > points(size_i + 1, std::vector<Point*>(size_j + 1, (Point*)nullptr)); Vector AB(_b, _a); Vector AD(_d, _a); float len_AB = _b.DistanceTo(_a); float len_AD = _d.DistanceTo(_a); normalize(AB); normalize(AD); Point *p1; // Create the starting point p1 = new Point(_a); // Loop in AD direction for (int j = 0; j <= size_j; ++j) { // add p1 to the list points.at(0).at(j) = p1; Point *p2 = p1; // Loop in AB direction for (int i = 0; i < size_i; ++i) { Point *p3; // Check boundary if (i == size_i - 1) { p3 = new Point(scalarMultiply(AB, len_AB).Translate(*p1)); } else { p3 = new Point(scalarMultiply(AB, patchSize).Translate(*p2)); } // add p3 to the list points.at(i+1).at(j) = p3; // Update p2 p2 = p3; } // Update p1 if (j == size_j - 1) { p1 = new Point(scalarMultiply(AD, len_AD).Translate(_a)); } else { p1 = new Point(scalarMultiply(AD, patchSize).Translate(*p1)); } } // Create the patches // Loop in AD direction for (int j = 0; j < size_j; ++j) { // Loop in AB direction for (int i = 0; i < size_i; ++i) { Point *A = points.at(i).at(j); Point *B = points.at(i+1).at(j); Point *C = points.at(i+1).at(j+1); Point *D = points.at(i).at(j+1); // Create the patch Patch *p = new Patch(A, B, C, D, GetColor(), emission); mPatches->push_back(p); } } } }
void apply_default_hid (HID * d, HID * s) { if (s == 0) s = &hid_nogui; AD (get_export_options); AD (do_export); AD (parse_arguments); AD (invalidate_lr); AD (invalidate_all); AD (set_layer); AD (make_gc); AD (destroy_gc); AD (use_mask); AD (set_color); AD (set_line_cap); AD (set_line_width); AD (set_draw_xor); AD (set_line_cap_angle); AD (draw_line); AD (draw_arc); AD (fill_circle); AD (fill_polygon); AD (fill_pcb_polygon); AD (thindraw_pcb_polygon); AD (calibrate); AD (shift_is_pressed); AD (control_is_pressed); AD (mod1_is_pressed); AD (get_coords); AD (set_crosshair); AD (add_timer); AD (stop_timer); AD (watch_file); AD (unwatch_file); AD (add_block_hook); AD (stop_block_hook); AD (log); AD (logv); AD (confirm_dialog); AD (close_confirm_dialog); AD (report_dialog); AD (prompt_for); AD (fileselect); AD (attribute_dialog); AD (show_item); AD (beep); AD (progress); AD (drc_gui); AD (edit_attributes); }
/** * \brief Missing reds and/or blues are reconstructed on a single row * \param image_h three-row window, horizontal interpolation of row 1 is done * \param image_v three-row window, vertical interpolation of row 1 is done * \param w width of image * \param h height of image. * \param y row number from image which is under construction * \param pos_code position code related to Bayer tiling in use */ static int do_rb_ctr_row(unsigned char *image_h, unsigned char *image_v, int w, int h, int y, int *pos_code) { int x, bayer; int value,value2,div,color; /* * pos_code[0] = red. green lrtb, blue diagonals * pos_code[1] = green. red lr, blue tb * pos_code[2] = green. blue lr, red tb * pos_code[3] = blue. green lrtb, red diagonals * * The Red channel reconstruction is R=G+L(Rs-Gs), in which * G = interpolated & known Green * Rs = known Red * Gs = values of G at the positions of Rs * L()= should be a 2D lowpass filter, now we'll check * them from a 3x3 square * L-functions' convolution matrix is * [1/4 1/2 1/4;1/2 1 1/2; 1/4 1/2 1/4] * * The Blue channel reconstruction uses exactly the same methods. */ for (x = 0; x < w; x++) { bayer = (x&1?0:1) + (y&1?0:2); for (color=0; color < 3; color+=2) { if ((color==RED && bayer == pos_code[3]) || (color==BLUE && bayer == pos_code[0])) { value=value2=div=0; if (x > 0 && y > 0) { value += image_h[AD(x-1,0,w)+color] -image_h[AD(x-1,0,w)+GREEN]; value2+= image_v[AD(x-1,0,w)+color] -image_v[AD(x-1,0,w)+GREEN]; div++; } if (x > 0 && y < h-1) { value += image_h[AD(x-1,2,w)+color] -image_h[AD(x-1,2,w)+GREEN]; value2+= image_v[AD(x-1,2,w)+color] -image_v[AD(x-1,2,w)+GREEN]; div++; } if (x < w-1 && y > 0) { value += image_h[AD(x+1,0,w)+color] -image_h[AD(x+1,0,w)+GREEN]; value2+= image_v[AD(x+1,0,w)+color] -image_v[AD(x+1,0,w)+GREEN]; div++; } if (x < w-1 && y < h-1) { value += image_h[AD(x+1,2,w)+color] -image_h[AD(x+1,2,w)+GREEN]; value2+= image_v[AD(x+1,2,w)+color] -image_v[AD(x+1,2,w)+GREEN]; div++; } image_h[AD(x,1,w)+color]= CLAMP( image_h[AD(x,1,w)+GREEN] +value/div); image_v[AD(x,1,w)+color]= CLAMP(image_v[AD(x,1,w)+GREEN] +value2/div); } else if ((color==RED && bayer == pos_code[2]) || (color==BLUE && bayer == pos_code[1])) { value=value2=div=0; if (y > 0) { value += image_h[AD(x,0,w)+color] -image_h[AD(x,0,w)+GREEN]; value2+= image_v[AD(x,0,w)+color] -image_v[AD(x,0,w)+GREEN]; div++; } if (y < h-1) { value += image_h[AD(x,2,w)+color] -image_h[AD(x,2,w)+GREEN]; value2+= image_v[AD(x,2,w)+color] -image_v[AD(x,2,w)+GREEN]; div++; } image_h[AD(x,1,w)+color]= CLAMP( image_h[AD(x,1,w)+GREEN] +value/div); image_v[AD(x,1,w)+color]= CLAMP( image_v[AD(x,1,w)+GREEN] +value2/div); } else if ((color==RED && bayer == pos_code[1]) || (color==BLUE && bayer == pos_code[2])) { value=value2=div=0; if (x > 0) { value += image_h[AD(x-1,1,w)+color] -image_h[AD(x-1,1,w)+GREEN]; value2+= image_v[AD(x-1,1,w)+color] -image_v[AD(x-1,1,w)+GREEN]; div++; } if (x < w-1) { value += image_h[AD(x+1,1,w)+color] -image_h[AD(x+1,1,w)+GREEN]; value2+= image_v[AD(x+1,1,w)+color] -image_v[AD(x+1,1,w)+GREEN]; div++; } image_h[AD(x,1,w)+color]= CLAMP( image_h[AD(x,1,w)+GREEN] +value/div); image_v[AD(x,1,w)+color]= CLAMP( image_v[AD(x,1,w)+GREEN] +value2/div); } } } return GP_OK; }
static int do_green_ctr_row(unsigned char *image, unsigned char *image_h, unsigned char *image_v, int w, int h, int y, int *pos_code) { int x, bayer; int value,div; /* * The horizontal green estimation on a red-green row is * G(x) = (2*R(x)+2*G(x+1)+2*G(x-1)-R(x-2)-R(x+2))/4 * The estimation on a green-blue row works in the same * way. */ for (x = 0; x < w; x++) { bayer = (x&1?0:1) + (y&1?0:2); /* pos_code[0] = red. green lrtb, blue diagonals */ /* pos_code[3] = blue. green lrtb, red diagonals */ if ( bayer == pos_code[0] || bayer == pos_code[3]) { div=value=0; if (bayer==pos_code[0]) value += 2*image[AD(x,y,w)+RED]; else value += 2*image[AD(x,y,w)+BLUE]; div+=2; if (x < (w-1)) { value += 2*image[AD(x+1,y,w)+GREEN]; div+=2; } if (x < (w-2)) { if (bayer==pos_code[0]) value -= image[AD(x+2,y,w)+RED]; else value -= image[AD(x+2,y,w)+BLUE]; div--; } if (x > 0) { value += 2*image[AD(x-1,y,w)+GREEN]; div+=2; } if (x > 1) { if (bayer==pos_code[0]) value -= image[AD(x-2,y,w)+RED]; else value -= image[AD(x-2,y,w)+BLUE]; div--; } image_h[AD(x,1,w)+GREEN] = CLAMP(value / div); /* The method for vertical estimation is just like * what is done for horizontal estimation, with only * the obvious difference that it is done vertically. */ div=value=0; if (bayer==pos_code[0]) value += 2*image[AD(x,y,w)+RED]; else value += 2*image[AD(x,y,w)+BLUE]; div+=2; if (y < (h-1)) { value += 2*image[AD(x,y+1,w)+GREEN]; div+=2; } if (y < (h-2)) { if (bayer==pos_code[0]) value -= image[AD(x,y+2,w)+RED]; else value -= image[AD(x,y+2,w)+BLUE]; div--; } if (y > 0) { value += 2*image[AD(x,y-1,w)+GREEN]; div+=2; } if (y > 1) { if (bayer==pos_code[0]) value -= image[AD(x,y-2,w)+RED]; else value -= image[AD(x,y-2,w)+BLUE]; div--; } image_v[AD(x,1,w)+GREEN] = CLAMP(value / div); } } return GP_OK; }
Matrix Matrix::operator/(float a) { Matrix AD(3,3); AD.SetMatrix(A[0]/a, A[1]/a, A[2]/a, A[3]/a, A[4]/a, A[5]/a, A[6]/a, A[7]/a, A[8]/a); return AD; }
/** * \brief interpolate one pixel from a bayer 2x2 raster * * For red and blue data, compare the four surrounding values. If three * values are all one side of the mean value, the fourth value is ignored. * This will sharpen boundaries. Treatment of green data looks for vertical and * horizontal edges. Any such which are discovered get special treatment. * Otherwise, the same comparison test is applied which is applied for red * and blue. Standard algorithm is applied without change at edges of the image. */ static int gp_bayer_accrue (unsigned char *image, int w, int h, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int colour) { int x [4] ; int y [4] ; int value [4] ; int above [4] ; int counter ; int sum_of_values; int average ; int i ; x[0] = x0 ; x[1] = x1 ; x[2] = x2 ; x[3] = x3 ; y[0] = y0 ; y[1] = y1 ; y[2] = y2 ; y[3] = y3 ; /* special treatment for green */ counter = sum_of_values = 0 ; if(colour == GREEN) { /* We need to make sure that horizontal or vertical lines * become horizontal and vertical lines even in this * interpolation procedure. Therefore, we determine whether * we might have such a line structure. */ for (i = 0 ; i < 4 ; i++) { if ((x[i] >= 0) && (x[i] < w) && (y[i] >= 0) && (y[i] < h)) { value [i] = image[AD(x[i],y[i],w) + colour] ; counter++; } else { value [i] = -1 ; } } if(counter == 4) { /* It is assumed that x0,y0 and x1,y1 are on a * horizontal line and * x2,y2 and x3,y3 are on a vertical line */ int hdiff ; int vdiff ; hdiff = value [1] - value [0] ; hdiff *= hdiff ; /* Make value positive by squaring */ vdiff = value [3] - value [2] ; vdiff *= vdiff ; /* Make value positive by squaring */ if(hdiff > 2*vdiff) { /* We might have a vertical structure here */ return (value [3] + value [2])/2 ; } if(vdiff > 2*hdiff) { /* we might have a horizontal structure here */ return (value [1] + value [0])/2 ; } /* else we proceed as with blue and red */ } /* if we do not have four points then we proceed as we do for * blue and red */ } /* for blue and red */ counter = sum_of_values = 0 ; for (i = 0 ; i < 4 ; i++) { if ((x[i] >= 0) && (x[i] < w) && (y[i] >= 0) && (y[i] < h)) { value [i] = image[AD(x[i],y[i],w) + colour] ; sum_of_values += value [i] ; counter++ ; } } average = sum_of_values / counter ; if (counter < 4) return average ; /* Less than four surrounding - just take average */ counter = 0 ; for (i = 0 ; i < 4 ; i++) { above[i] = value[i] > average ; if (above[i]) counter++ ; } /* Note: counter == 0 indicates all values the same */ if ((counter == 2) || (counter == 0)) return average ; sum_of_values = 0 ; for (i = 0 ; i < 4 ; i++) { if ((counter == 3) == above[i]) { sum_of_values += value[i] ; } } return sum_of_values / 3 ; }
/** * \brief Interpolate a expanded bayer array into an RGB image. * * \param image the linear RGB array as both input and output * \param w width of the above array * \param h height of the above array * \param tile how the 2x2 bayer array is layed out * * This function interpolates a bayer array which has been pre-expanded * by gp_bayer_expand() to an RGB image. It uses various interpolation * methods, also see gp_bayer_accrue(). * * \return a gphoto error code */ int gp_bayer_interpolate (unsigned char *image, int w, int h, BayerTile tile) { int x, y, bayer; int p0, p1, p2; int value, div ; switch (tile) { default: case BAYER_TILE_RGGB: case BAYER_TILE_RGGB_INTERLACED: p0 = 0; p1 = 1; p2 = 2; break; case BAYER_TILE_GRBG: case BAYER_TILE_GRBG_INTERLACED: p0 = 1; p1 = 0; p2 = 3; break; case BAYER_TILE_BGGR: case BAYER_TILE_BGGR_INTERLACED: p0 = 3; p1 = 2; p2 = 1; break; case BAYER_TILE_GBRG: case BAYER_TILE_GBRG_INTERLACED: p0 = 2; p1 = 3; p2 = 0; break; } for (y = 0; y < h; y++) for (x = 0; x < w; x++) { bayer = (x&1?0:1) + (y&1?0:2); if ( bayer == p0 ) { /* red. green lrtb, blue diagonals */ image[AD(x,y,w)+GREEN] = gp_bayer_accrue(image, w, h, x-1, y, x+1, y, x, y-1, x, y+1, GREEN) ; image[AD(x,y,w)+BLUE] = gp_bayer_accrue(image, w, h, x+1, y+1, x-1, y-1, x-1, y+1, x+1, y-1, BLUE) ; } else if (bayer == p1) { /* green. red lr, blue tb */ div = value = 0; if (x < (w - 1)) { value += image[AD(x+1,y,w)+RED]; div++; } if (x) { value += image[AD(x-1,y,w)+RED]; div++; } image[AD(x,y,w)+RED] = value / div; div = value = 0; if (y < (h - 1)) { value += image[AD(x,y+1,w)+BLUE]; div++; } if (y) { value += image[AD(x,y-1,w)+BLUE]; div++; } image[AD(x,y,w)+BLUE] = value / div; } else if ( bayer == p2 ) { /* green. blue lr, red tb */ div = value = 0; if (x < (w - 1)) { value += image[AD(x+1,y,w)+BLUE]; div++; } if (x) { value += image[AD(x-1,y,w)+BLUE]; div++; } image[AD(x,y,w)+BLUE] = value / div; div = value = 0; if (y < (h - 1)) { value += image[AD(x,y+1,w)+RED]; div++; } if (y) { value += image[AD(x,y-1,w)+RED]; div++; } image[AD(x,y,w)+RED] = value / div; } else { /* blue. green lrtb, red diagonals */ image[AD(x,y,w)+GREEN] = gp_bayer_accrue (image, w, h, x-1, y, x+1, y, x, y-1, x, y+1, GREEN) ; image[AD(x,y,w)+RED] = gp_bayer_accrue (image, w, h, x+1, y+1, x-1, y-1, x-1, y+1, x+1, y-1, RED) ; } } return (GP_OK); }
Matrix Matrix::operator *(float a) { Matrix AD(3,3); AD.SetMatrix(A[0]*a, A[1]*a, A[2]*a, A[3]*a, A[4]*a, A[5]*a, A[6]*a, A[7]*a, A[8]*a); return AD; }
/* Accrue four surrounding values. If three values are one side of the average value, the fourth value is ignored. This will sharpen up boundaries. B.R.Harris 13Nov03*/ int gp_bayer_accrue (unsigned char *image, int w, int h, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int colour) { int x [4] ; int y [4] ; int value [4] ; int above [4] ; int ctr ; // counter int tv ; // total value int average ; int i ; x[0] = x0 ; x[1] = x1 ; x[2] = x2 ; x[3] = x3 ; y[0] = y0 ; y[1] = y1 ; y[2] = y2 ; y[3] = y3 ; // special treatment for green ctr = tv = 0 ; if(colour == GREEN) { // we need to make sure that horizontal or vertical lines become horizontal // and vertical lines even in this interpolation procedure // therefore, we determine whether we might have such a line structure for (i = 0 ; i < 4 ; i++) { if ((x[i] >= 0) && (x[i] < w) && (y[i] >= 0) && (y[i] < h)) { value [i] = image[AD(x[i],y[i],w) + colour] ; ctr++; } else { value [i] = -1 ; } } if(ctr == 4) { // we must assume that x0,y0 and x1,y1 are on the horizontal axis and // x2,y2 and x3,y3 are on the vertical axis int hdiff ; int vdiff ; hdiff = value [1] - value [0] ; hdiff *= hdiff ; // make value positive by squaring it vdiff = value [3] - value [2] ; vdiff *= vdiff ; // make value positive by squaring it // if(hdiff > 2*vdiff) if(hdiff > 2*vdiff) { // we might have a vertical structure here return (value [3] + value [2])/2 ; } // if(vdiff > 2*hdiff) if(vdiff > 2*hdiff) { // we might have a horizontal structure here return (value [1] + value [0])/2 ; } // else we proceed as with blue and red } // if we do not have four points then we proceed as we do for blue and red } // for blue and red as it was before ctr = tv = 0 ; for (i = 0 ; i < 4 ; i++) { if ((x[i] >= 0) && (x[i] < w) && (y[i] >= 0) && (y[i] < h)) { value [i] = image[AD(x[i],y[i],w) + colour] ; tv += value [i] ; ctr++ ; } } average = tv / ctr ; if (ctr < 4) return average ; // Less than four surrounding - just take average ctr = 0 ; for (i = 0 ; i < 4 ; i++) { above[i] = value[i] > average ; if (above[i]) ctr++ ; } // Note: ctr == 0 indicates all values the same if ((ctr == 2) || (ctr == 0)) return average ; tv = 0 ; for (i = 0 ; i < 4 ; i++) { if ((ctr == 3) == above[i]) { tv += value[i] ; } } return tv / 3 ; }
bool FeynHiggsWrapper::SetFeynHiggsPars() { int err; /* FeynHiggs debug flag */ //FHSetDebug(2); //FHSetDebug(3); Mw_FHinput = mySUSY.Mw_tree(); /* Tree-level W-boson mass */ //Mw_FHinput = mySUSY.StandardModel::Mw(); /* SM prediction, which should not be used, since mHl cannot be set before calling FeynHiggs. */ //std::cout << "Mw = " << Mw_FHinput << " used in FeynHiggsWrapper::SetFeynHiggsPars()" << std::endl; /* Set the FeynHiggs SM input parameters */ FHSetSMPara(&err, 1.0/mySUSY.alphaMz(), mySUSY.getAlsMz(), mySUSY.getGF(), mySUSY.getLeptons(StandardModel::ELECTRON).getMass(), mySUSY.getQuarks(QCD::UP).getMass(), mySUSY.getQuarks(QCD::DOWN).getMass(), mySUSY.getLeptons(StandardModel::MU).getMass(), mySUSY.getQuarks(QCD::CHARM).getMass(), mySUSY.getQuarks(QCD::STRANGE).getMass(), mySUSY.getLeptons(StandardModel::TAU).getMass(), mySUSY.getQuarks(QCD::BOTTOM).getMass(), Mw_FHinput, mySUSY.getMz(), mySUSY.getLambda(), mySUSY.getA(), mySUSY.getRhob(), mySUSY.getEtab()); if (err != 0) { #ifdef FHDEBUG std::cout << "FeynHiggsWrapper::SetFeynHiggsPars(): Error has been detected in SetPara.F:" << err << std::endl; #endif return (false); } /* Parameters for FeynHiggs */ double Q_S = mySUSY.Q_SUSY; gslpp::complex muHFH = mySUSY.muH; gslpp::complex M1FH = mySUSY.m1; gslpp::complex M2FH = mySUSY.m2; gslpp::matrix<gslpp::complex> MsQ2 = mySUSY.msQhat2; gslpp::matrix<gslpp::complex> MsU2 = mySUSY.msUhat2; gslpp::matrix<gslpp::complex> MsD2 = mySUSY.msDhat2; gslpp::matrix<gslpp::complex> MsL2 = mySUSY.msLhat2; gslpp::matrix<gslpp::complex> MsE2 = mySUSY.msEhat2; gslpp::matrix<gslpp::complex> KU = mySUSY.TUhat.hconjugate() * mySUSY.v2() / sqrt(2.0); gslpp::matrix<gslpp::complex> KD = mySUSY.TDhat.hconjugate() * mySUSY.v1() / sqrt(2.0); gslpp::matrix<gslpp::complex> KE = mySUSY.TEhat.hconjugate() * mySUSY.v1() / sqrt(2.0); /* MFV trilinear couplings */ gslpp::vector<gslpp::complex> AU(3,0.), AD(3,0.), AE(3,0.); for (int i=0; i<3; i++) { int p = (int)mySUSY.UP + 2*i; AU.assign(i, KU(i,i) / mySUSY.Mq_Q((QCD::quark)p)); p = (int)mySUSY.DOWN + 2*i; AD.assign(i, KD(i,i) / mySUSY.Mq_Q((QCD::quark)p)); p = (int)mySUSY.ELECTRON + 2*i; AE.assign(i, KE(i,i) / mySUSY.Ml_Q((StandardModel::lepton)p)); } /* Check if non-minimal flavor-violating (NMFV) entries exist in the * sfermion mass matrices. See also IniFV() in SetFV.F of FeynHiggs. */ NMFVu = true; NMFVd = true; NMFVe = true;// NMFVnu = true; double TMPu = 0.0, TMPd = 0.0, TMPe = 0.0; //TMPnu = 0.0 for (int i=0; i<3; i++) { for (int j=0; j<3; j++) { if (i < j) { TMPu += MsQ2(i, j).abs2() + MsU2(i, j).abs2(); TMPd += MsQ2(i, j).abs2() + MsD2(i, j).abs2(); //TMPnu += MsL2(i, j).abs2(); /* not used */ TMPe += MsL2(i, j).abs2() + MsE2(i, j).abs2(); } if (i != j) { TMPu += KU(i, j).abs2(); TMPd += KD(i, j).abs2(); TMPe += KE(i, j).abs2(); } } } if (!TMPu) NMFVu = false; if (!TMPe) NMFVd = false; if (!TMPe) NMFVe = false; /* NMFV trilinear couplings. In the case of NMFV, the trilinear couplings * AU, AD and AE for FHSetPara() as well as KU, KD and KE for FHSetNMFV() * and FHSetLFV() have to be rotated. */ gslpp::complex muHphase(1.0, - 2.0*muHFH.arg(), true); if (NMFVu) AU *= muHphase; if (NMFVd) AD *= muHphase; if (NMFVe) AE *= muHphase; KU *= muHphase; KD *= muHphase; KE *= muHphase; /* NMFV parameters for FeynHiggs */ gslpp::matrix<gslpp::complex> deltaQLL(3,3,0.); gslpp::matrix<gslpp::complex> deltaULR(3,3,0.), deltaURL(3,3,0.), deltaURR(3,3,0.); gslpp::matrix<gslpp::complex> deltaDLR(3,3,0.), deltaDRL(3,3,0.), deltaDRR(3,3,0.); gslpp::matrix<gslpp::complex> deltaLLL(3,3,0.); gslpp::matrix<gslpp::complex> deltaELR(3,3,0.), deltaERL(3,3,0.), deltaERR(3,3,0.); for (int i=0; i<3; i++) for (int j=0; j<3; j++) { deltaQLL.assign(i, j, MsQ2(i,j) / sqrt(MsQ2(i,i).real() * MsQ2(j,j).real())); deltaULR.assign(i, j, KU(i,j) / sqrt(MsQ2(i,i).real() * MsU2(j,j).real())); deltaURL.assign(i, j, KU(j,i).conjugate() / sqrt(MsU2(i,i).real() * MsQ2(j,j).real())); deltaURR.assign(i, j, MsU2(i,j) / sqrt(MsU2(i,i).real() * MsU2(j,j).real())); deltaDLR.assign(i, j, KD(i,j) / sqrt(MsQ2(i,i).real() * MsD2(j,j).real())); deltaDRL.assign(i, j, KD(j,i).conjugate() / sqrt(MsD2(i,i).real() * MsQ2(j,j).real())); deltaDRR.assign(i, j, MsD2(i,j) / sqrt(MsD2(i,i).real() * MsD2(j,j).real())); deltaLLL.assign(i, j, MsL2(i,j) / sqrt(MsL2(i,i).real() * MsL2(j,j).real())); deltaELR.assign(i, j, KE(i,j) / sqrt(MsL2(i,i).real() * MsE2(j,j).real())); deltaERL.assign(i, j, KE(j,i).conjugate() / sqrt(MsE2(i,i).real() * MsL2(j,j).real())); deltaERR.assign(i, j, MsE2(i,j) / sqrt(MsE2(i,i).real() * MsE2(j,j).real())); } /* Set the FeynHiggs parameters, where the GUT relation is used for M1=0. */ FHSetPara(&err, mySUSY.mut/mySUSY.quarks[QCD::TOP].getMass(), mySUSY.mtpole, mySUSY.tanb, mySUSY.mHptree, // as now used, "mHptree" is a name for MA0. We shall be using mA instead of mHptree -1, // this is now not used, the mHptree // sqrt(MsL2(2,2).real()), sqrt(MsE2(2,2).real()), sqrt(MsQ2(2,2).real()), sqrt(MsU2(2,2).real()), sqrt(MsD2(2,2).real()), sqrt(MsL2(1,1).real()), sqrt(MsE2(1,1).real()), sqrt(MsQ2(1,1).real()), sqrt(MsU2(1,1).real()), sqrt(MsD2(1,1).real()), sqrt(MsL2(0,0).real()), sqrt(MsE2(0,0).real()), sqrt(MsQ2(0,0).real()), sqrt(MsU2(0,0).real()), sqrt(MsD2(0,0).real()), // ToComplex2(muHFH.real(), muHFH.imag()), // ToComplex2(AE(2).real(), AE(2).imag()), ToComplex2(AU(2).real(), AU(2).imag()), ToComplex2(AD(2).real(), AD(2).imag()), ToComplex2(AE(1).real(), AE(1).imag()), ToComplex2(AU(1).real(), AU(1).imag()), ToComplex2(AD(1).real(), AD(1).imag()), ToComplex2(AE(0).real(), AE(0).imag()), ToComplex2(AU(0).real(), AU(0).imag()), ToComplex2(AD(0).real(), AD(0).imag()), // ToComplex2(M1FH.real(), M1FH.imag()), ToComplex2(M2FH.real(), M2FH.imag()), ToComplex2(mySUSY.m3, 0.), // Q_S, Q_S, Q_S); if (err != 0) { #ifdef FHDEBUG std::cout << "FeynHiggsWrapper::SetFeynHiggsPars(): Error has been detected in SetPara.F:" << err << std::endl; #endif return (false); } /* Set the non-minimal flavor-violating parameters in the squark sector */ FHSetNMFV(&err, // Q_LL ToComplex2(deltaQLL(0,1).real(), deltaQLL(0,1).imag()), ToComplex2(deltaQLL(1,2).real(), deltaQLL(1,2).imag()), ToComplex2(deltaQLL(0,2).real(), deltaQLL(0,2).imag()), // U_LR ToComplex2(deltaULR(0,1).real(), deltaULR(0,1).imag()), ToComplex2(deltaULR(1,2).real(), deltaULR(1,2).imag()), ToComplex2(deltaULR(0,2).real(), deltaULR(0,2).imag()), // U_RL ToComplex2(deltaURL(0,1).real(), deltaURL(0,1).imag()), ToComplex2(deltaURL(1,2).real(), deltaURL(1,2).imag()), ToComplex2(deltaURL(0,2).real(), deltaURL(0,2).imag()), // U_RR ToComplex2(deltaURR(0,1).real(), deltaURR(0,1).imag()), ToComplex2(deltaURR(1,2).real(), deltaURR(1,2).imag()), ToComplex2(deltaURR(0,2).real(), deltaURR(0,2).imag()), // D_LR ToComplex2(deltaDLR(0,1).real(), deltaDLR(0,1).imag()), ToComplex2(deltaDLR(1,2).real(), deltaDLR(1,2).imag()), ToComplex2(deltaDLR(0,2).real(), deltaDLR(0,2).imag()), // D_RL ToComplex2(deltaDRL(0,1).real(), deltaDRL(0,1).imag()), ToComplex2(deltaDRL(1,2).real(), deltaDRL(1,2).imag()), ToComplex2(deltaDRL(0,2).real(), deltaDRL(0,2).imag()), // D_RR ToComplex2(deltaDRR(0,1).real(), deltaDRR(0,1).imag()), ToComplex2(deltaDRR(1,2).real(), deltaDRR(1,2).imag()), ToComplex2(deltaDRR(0,2).real(), deltaDRR(0,2).imag()) ); if (err != 0) { #ifdef FHDEBUG std::cout << "FeynHiggsWrapper::SetFeynHiggsPars(): Error was detected in SetFV.F:" << err << std::endl; #endif return (false); } /* Set the non-minimal flavor-violating parameters in the slepton sector, * which are not used to compute the sneutrino mass spectrum. */ FHSetLFV(&err, // L_LL ToComplex2(deltaLLL(0,1).real(), deltaLLL(0,1).imag()), ToComplex2(deltaLLL(1,2).real(), deltaLLL(1,2).imag()), ToComplex2(deltaLLL(0,2).real(), deltaLLL(0,2).imag()), // E_LR ToComplex2(deltaELR(0,1).real(), deltaELR(0,1).imag()), ToComplex2(deltaELR(1,2).real(), deltaELR(1,2).imag()), ToComplex2(deltaELR(0,2).real(), deltaELR(0,2).imag()), // E_RL ToComplex2(deltaERL(0,1).real(), deltaERL(0,1).imag()), ToComplex2(deltaERL(1,2).real(), deltaERL(1,2).imag()), ToComplex2(deltaERL(0,2).real(), deltaERL(0,2).imag()), // E_RR ToComplex2(deltaERR(0,1).real(), deltaERR(0,1).imag()), ToComplex2(deltaERR(1,2).real(), deltaERR(1,2).imag()), ToComplex2(deltaERR(0,2).real(), deltaERR(0,2).imag()) ); if (err != 0) { #ifdef FHDEBUG std::cout << "FeynHiggsWrapper::SetFeynHiggsPars(): Error was detected in SetFV.F:" << err << std::endl; #endif return (false); } computeHiggsCouplings = true; computeHiggsProd = true; computeConstraints = true; computeFlavour = true; return (true); }